1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.language.LanguageUtil;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.HtmlUtil;
21  import com.liferay.portal.kernel.util.LocaleUtil;
22  import com.liferay.portal.kernel.util.LocalizationUtil;
23  import com.liferay.portal.kernel.util.StringBundler;
24  import com.liferay.portal.kernel.util.StringPool;
25  import com.liferay.portal.kernel.util.Validator;
26  import com.liferay.portal.model.LayoutSetPrototype;
27  import com.liferay.portal.model.LayoutSetPrototypeSoap;
28  import com.liferay.portal.service.ServiceContext;
29  
30  import com.liferay.portlet.expando.model.ExpandoBridge;
31  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.List;
41  import java.util.Locale;
42  import java.util.Map;
43  
44  /**
45   * <a href="LayoutSetPrototypeModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This interface is a model that represents the LayoutSetPrototype table in the
54   * database.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       LayoutSetPrototypeImpl
59   * @see       com.liferay.portal.model.LayoutSetPrototype
60   * @see       com.liferay.portal.model.LayoutSetPrototypeModel
61   * @generated
62   */
63  public class LayoutSetPrototypeModelImpl extends BaseModelImpl<LayoutSetPrototype> {
64      public static final String TABLE_NAME = "LayoutSetPrototype";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "layoutSetPrototypeId", new Integer(Types.BIGINT) },
67              { "companyId", new Integer(Types.BIGINT) },
68              { "name", new Integer(Types.VARCHAR) },
69              { "description", new Integer(Types.VARCHAR) },
70              { "settings_", new Integer(Types.VARCHAR) },
71              { "active_", new Integer(Types.BOOLEAN) }
72          };
73      public static final String TABLE_SQL_CREATE = "create table LayoutSetPrototype (layoutSetPrototypeId LONG not null primary key,companyId LONG,name STRING null,description STRING null,settings_ STRING null,active_ BOOLEAN)";
74      public static final String TABLE_SQL_DROP = "drop table LayoutSetPrototype";
75      public static final String DATA_SOURCE = "liferayDataSource";
76      public static final String SESSION_FACTORY = "liferaySessionFactory";
77      public static final String TX_MANAGER = "liferayTransactionManager";
78      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79                  "value.object.entity.cache.enabled.com.liferay.portal.model.LayoutSetPrototype"),
80              true);
81      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
82                  "value.object.finder.cache.enabled.com.liferay.portal.model.LayoutSetPrototype"),
83              true);
84  
85      public static LayoutSetPrototype toModel(LayoutSetPrototypeSoap soapModel) {
86          LayoutSetPrototype model = new LayoutSetPrototypeImpl();
87  
88          model.setLayoutSetPrototypeId(soapModel.getLayoutSetPrototypeId());
89          model.setCompanyId(soapModel.getCompanyId());
90          model.setName(soapModel.getName());
91          model.setDescription(soapModel.getDescription());
92          model.setSettings(soapModel.getSettings());
93          model.setActive(soapModel.getActive());
94  
95          return model;
96      }
97  
98      public static List<LayoutSetPrototype> toModels(
99          LayoutSetPrototypeSoap[] soapModels) {
100         List<LayoutSetPrototype> models = new ArrayList<LayoutSetPrototype>(soapModels.length);
101 
102         for (LayoutSetPrototypeSoap soapModel : soapModels) {
103             models.add(toModel(soapModel));
104         }
105 
106         return models;
107     }
108 
109     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
110                 "lock.expiration.time.com.liferay.portal.model.LayoutSetPrototype"));
111 
112     public LayoutSetPrototypeModelImpl() {
113     }
114 
115     public long getPrimaryKey() {
116         return _layoutSetPrototypeId;
117     }
118 
119     public void setPrimaryKey(long pk) {
120         setLayoutSetPrototypeId(pk);
121     }
122 
123     public Serializable getPrimaryKeyObj() {
124         return new Long(_layoutSetPrototypeId);
125     }
126 
127     public long getLayoutSetPrototypeId() {
128         return _layoutSetPrototypeId;
129     }
130 
131     public void setLayoutSetPrototypeId(long layoutSetPrototypeId) {
132         _layoutSetPrototypeId = layoutSetPrototypeId;
133     }
134 
135     public long getCompanyId() {
136         return _companyId;
137     }
138 
139     public void setCompanyId(long companyId) {
140         _companyId = companyId;
141     }
142 
143     public String getName() {
144         if (_name == null) {
145             return StringPool.BLANK;
146         }
147         else {
148             return _name;
149         }
150     }
151 
152     public String getName(Locale locale) {
153         String languageId = LocaleUtil.toLanguageId(locale);
154 
155         return getName(languageId);
156     }
157 
158     public String getName(Locale locale, boolean useDefault) {
159         String languageId = LocaleUtil.toLanguageId(locale);
160 
161         return getName(languageId, useDefault);
162     }
163 
164     public String getName(String languageId) {
165         String value = LocalizationUtil.getLocalization(getName(), languageId);
166 
167         if (isEscapedModel()) {
168             return HtmlUtil.escape(value);
169         }
170         else {
171             return value;
172         }
173     }
174 
175     public String getName(String languageId, boolean useDefault) {
176         String value = LocalizationUtil.getLocalization(getName(), languageId,
177                 useDefault);
178 
179         if (isEscapedModel()) {
180             return HtmlUtil.escape(value);
181         }
182         else {
183             return value;
184         }
185     }
186 
187     public Map<Locale, String> getNameMap() {
188         return LocalizationUtil.getLocalizationMap(getName());
189     }
190 
191     public void setName(String name) {
192         _name = name;
193     }
194 
195     public void setName(Locale locale, String name) {
196         String languageId = LocaleUtil.toLanguageId(locale);
197 
198         if (Validator.isNotNull(name)) {
199             setName(LocalizationUtil.updateLocalization(getName(), "Name",
200                     name, languageId));
201         }
202         else {
203             setName(LocalizationUtil.removeLocalization(getName(), "Name",
204                     languageId));
205         }
206     }
207 
208     public void setNameMap(Map<Locale, String> nameMap) {
209         if (nameMap == null) {
210             return;
211         }
212 
213         Locale[] locales = LanguageUtil.getAvailableLocales();
214 
215         for (Locale locale : locales) {
216             String name = nameMap.get(locale);
217 
218             setName(locale, name);
219         }
220     }
221 
222     public String getDescription() {
223         if (_description == null) {
224             return StringPool.BLANK;
225         }
226         else {
227             return _description;
228         }
229     }
230 
231     public void setDescription(String description) {
232         _description = description;
233     }
234 
235     public String getSettings() {
236         if (_settings == null) {
237             return StringPool.BLANK;
238         }
239         else {
240             return _settings;
241         }
242     }
243 
244     public void setSettings(String settings) {
245         _settings = settings;
246     }
247 
248     public boolean getActive() {
249         return _active;
250     }
251 
252     public boolean isActive() {
253         return _active;
254     }
255 
256     public void setActive(boolean active) {
257         _active = active;
258     }
259 
260     public LayoutSetPrototype toEscapedModel() {
261         if (isEscapedModel()) {
262             return (LayoutSetPrototype)this;
263         }
264         else {
265             return (LayoutSetPrototype)Proxy.newProxyInstance(LayoutSetPrototype.class.getClassLoader(),
266                 new Class[] { LayoutSetPrototype.class },
267                 new AutoEscapeBeanHandler(this));
268         }
269     }
270 
271     public ExpandoBridge getExpandoBridge() {
272         if (_expandoBridge == null) {
273             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
274                     LayoutSetPrototype.class.getName(), getPrimaryKey());
275         }
276 
277         return _expandoBridge;
278     }
279 
280     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
281         getExpandoBridge().setAttributes(serviceContext);
282     }
283 
284     public Object clone() {
285         LayoutSetPrototypeImpl clone = new LayoutSetPrototypeImpl();
286 
287         clone.setLayoutSetPrototypeId(getLayoutSetPrototypeId());
288         clone.setCompanyId(getCompanyId());
289         clone.setName(getName());
290         clone.setDescription(getDescription());
291         clone.setSettings(getSettings());
292         clone.setActive(getActive());
293 
294         return clone;
295     }
296 
297     public int compareTo(LayoutSetPrototype layoutSetPrototype) {
298         long pk = layoutSetPrototype.getPrimaryKey();
299 
300         if (getPrimaryKey() < pk) {
301             return -1;
302         }
303         else if (getPrimaryKey() > pk) {
304             return 1;
305         }
306         else {
307             return 0;
308         }
309     }
310 
311     public boolean equals(Object obj) {
312         if (obj == null) {
313             return false;
314         }
315 
316         LayoutSetPrototype layoutSetPrototype = null;
317 
318         try {
319             layoutSetPrototype = (LayoutSetPrototype)obj;
320         }
321         catch (ClassCastException cce) {
322             return false;
323         }
324 
325         long pk = layoutSetPrototype.getPrimaryKey();
326 
327         if (getPrimaryKey() == pk) {
328             return true;
329         }
330         else {
331             return false;
332         }
333     }
334 
335     public int hashCode() {
336         return (int)getPrimaryKey();
337     }
338 
339     public String toString() {
340         StringBundler sb = new StringBundler(13);
341 
342         sb.append("{layoutSetPrototypeId=");
343         sb.append(getLayoutSetPrototypeId());
344         sb.append(", companyId=");
345         sb.append(getCompanyId());
346         sb.append(", name=");
347         sb.append(getName());
348         sb.append(", description=");
349         sb.append(getDescription());
350         sb.append(", settings=");
351         sb.append(getSettings());
352         sb.append(", active=");
353         sb.append(getActive());
354         sb.append("}");
355 
356         return sb.toString();
357     }
358 
359     public String toXmlString() {
360         StringBundler sb = new StringBundler(22);
361 
362         sb.append("<model><model-name>");
363         sb.append("com.liferay.portal.model.LayoutSetPrototype");
364         sb.append("</model-name>");
365 
366         sb.append(
367             "<column><column-name>layoutSetPrototypeId</column-name><column-value><![CDATA[");
368         sb.append(getLayoutSetPrototypeId());
369         sb.append("]]></column-value></column>");
370         sb.append(
371             "<column><column-name>companyId</column-name><column-value><![CDATA[");
372         sb.append(getCompanyId());
373         sb.append("]]></column-value></column>");
374         sb.append(
375             "<column><column-name>name</column-name><column-value><![CDATA[");
376         sb.append(getName());
377         sb.append("]]></column-value></column>");
378         sb.append(
379             "<column><column-name>description</column-name><column-value><![CDATA[");
380         sb.append(getDescription());
381         sb.append("]]></column-value></column>");
382         sb.append(
383             "<column><column-name>settings</column-name><column-value><![CDATA[");
384         sb.append(getSettings());
385         sb.append("]]></column-value></column>");
386         sb.append(
387             "<column><column-name>active</column-name><column-value><![CDATA[");
388         sb.append(getActive());
389         sb.append("]]></column-value></column>");
390 
391         sb.append("</model>");
392 
393         return sb.toString();
394     }
395 
396     private long _layoutSetPrototypeId;
397     private long _companyId;
398     private String _name;
399     private String _description;
400     private String _settings;
401     private boolean _active;
402     private transient ExpandoBridge _expandoBridge;
403 }