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.ReadOnlyBeanHandler;
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.StringBundler;
23  import com.liferay.portal.kernel.util.Validator;
24  import com.liferay.portal.model.LayoutSetPrototype;
25  import com.liferay.portal.model.LayoutSetPrototypeSoap;
26  import com.liferay.portal.service.ServiceContext;
27  
28  import com.liferay.portlet.expando.model.ExpandoBridge;
29  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
30  
31  import com.liferay.util.LocalizationUtil;
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         return GetterUtil.getString(_name);
145     }
146 
147     public String getName(Locale locale) {
148         String languageId = LocaleUtil.toLanguageId(locale);
149 
150         return getName(languageId);
151     }
152 
153     public String getName(Locale locale, boolean useDefault) {
154         String languageId = LocaleUtil.toLanguageId(locale);
155 
156         return getName(languageId, useDefault);
157     }
158 
159     public String getName(String languageId) {
160         String value = LocalizationUtil.getLocalization(getName(), languageId);
161 
162         if (isEscapedModel()) {
163             return HtmlUtil.escape(value);
164         }
165         else {
166             return value;
167         }
168     }
169 
170     public String getName(String languageId, boolean useDefault) {
171         String value = LocalizationUtil.getLocalization(getName(), languageId,
172                 useDefault);
173 
174         if (isEscapedModel()) {
175             return HtmlUtil.escape(value);
176         }
177         else {
178             return value;
179         }
180     }
181 
182     public Map<Locale, String> getNameMap() {
183         return LocalizationUtil.getLocalizationMap(getName());
184     }
185 
186     public void setName(String name) {
187         _name = name;
188     }
189 
190     public void setName(Locale locale, String name) {
191         String languageId = LocaleUtil.toLanguageId(locale);
192 
193         if (Validator.isNotNull(name)) {
194             setName(LocalizationUtil.updateLocalization(getName(), "Name",
195                     name, languageId));
196         }
197         else {
198             setName(LocalizationUtil.removeLocalization(getName(), "Name",
199                     languageId));
200         }
201     }
202 
203     public void setNameMap(Map<Locale, String> nameMap) {
204         if (nameMap == null) {
205             return;
206         }
207 
208         Locale[] locales = LanguageUtil.getAvailableLocales();
209 
210         for (Locale locale : locales) {
211             String name = nameMap.get(locale);
212 
213             setName(locale, name);
214         }
215     }
216 
217     public String getDescription() {
218         return GetterUtil.getString(_description);
219     }
220 
221     public void setDescription(String description) {
222         _description = description;
223     }
224 
225     public String getSettings() {
226         return GetterUtil.getString(_settings);
227     }
228 
229     public void setSettings(String settings) {
230         _settings = settings;
231     }
232 
233     public boolean getActive() {
234         return _active;
235     }
236 
237     public boolean isActive() {
238         return _active;
239     }
240 
241     public void setActive(boolean active) {
242         _active = active;
243     }
244 
245     public LayoutSetPrototype toEscapedModel() {
246         if (isEscapedModel()) {
247             return (LayoutSetPrototype)this;
248         }
249         else {
250             LayoutSetPrototype model = new LayoutSetPrototypeImpl();
251 
252             model.setNew(isNew());
253             model.setEscapedModel(true);
254 
255             model.setLayoutSetPrototypeId(getLayoutSetPrototypeId());
256             model.setCompanyId(getCompanyId());
257             model.setName(getName());
258             model.setDescription(HtmlUtil.escape(getDescription()));
259             model.setSettings(HtmlUtil.escape(getSettings()));
260             model.setActive(getActive());
261 
262             model = (LayoutSetPrototype)Proxy.newProxyInstance(LayoutSetPrototype.class.getClassLoader(),
263                     new Class[] { LayoutSetPrototype.class },
264                     new ReadOnlyBeanHandler(model));
265 
266             return model;
267         }
268     }
269 
270     public ExpandoBridge getExpandoBridge() {
271         if (_expandoBridge == null) {
272             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
273                     LayoutSetPrototype.class.getName(), getPrimaryKey());
274         }
275 
276         return _expandoBridge;
277     }
278 
279     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
280         getExpandoBridge().setAttributes(serviceContext);
281     }
282 
283     public Object clone() {
284         LayoutSetPrototypeImpl clone = new LayoutSetPrototypeImpl();
285 
286         clone.setLayoutSetPrototypeId(getLayoutSetPrototypeId());
287         clone.setCompanyId(getCompanyId());
288         clone.setName(getName());
289         clone.setDescription(getDescription());
290         clone.setSettings(getSettings());
291         clone.setActive(getActive());
292 
293         return clone;
294     }
295 
296     public int compareTo(LayoutSetPrototype layoutSetPrototype) {
297         long pk = layoutSetPrototype.getPrimaryKey();
298 
299         if (getPrimaryKey() < pk) {
300             return -1;
301         }
302         else if (getPrimaryKey() > pk) {
303             return 1;
304         }
305         else {
306             return 0;
307         }
308     }
309 
310     public boolean equals(Object obj) {
311         if (obj == null) {
312             return false;
313         }
314 
315         LayoutSetPrototype layoutSetPrototype = null;
316 
317         try {
318             layoutSetPrototype = (LayoutSetPrototype)obj;
319         }
320         catch (ClassCastException cce) {
321             return false;
322         }
323 
324         long pk = layoutSetPrototype.getPrimaryKey();
325 
326         if (getPrimaryKey() == pk) {
327             return true;
328         }
329         else {
330             return false;
331         }
332     }
333 
334     public int hashCode() {
335         return (int)getPrimaryKey();
336     }
337 
338     public String toString() {
339         StringBundler sb = new StringBundler(13);
340 
341         sb.append("{layoutSetPrototypeId=");
342         sb.append(getLayoutSetPrototypeId());
343         sb.append(", companyId=");
344         sb.append(getCompanyId());
345         sb.append(", name=");
346         sb.append(getName());
347         sb.append(", description=");
348         sb.append(getDescription());
349         sb.append(", settings=");
350         sb.append(getSettings());
351         sb.append(", active=");
352         sb.append(getActive());
353         sb.append("}");
354 
355         return sb.toString();
356     }
357 
358     public String toXmlString() {
359         StringBundler sb = new StringBundler(22);
360 
361         sb.append("<model><model-name>");
362         sb.append("com.liferay.portal.model.LayoutSetPrototype");
363         sb.append("</model-name>");
364 
365         sb.append(
366             "<column><column-name>layoutSetPrototypeId</column-name><column-value><![CDATA[");
367         sb.append(getLayoutSetPrototypeId());
368         sb.append("]]></column-value></column>");
369         sb.append(
370             "<column><column-name>companyId</column-name><column-value><![CDATA[");
371         sb.append(getCompanyId());
372         sb.append("]]></column-value></column>");
373         sb.append(
374             "<column><column-name>name</column-name><column-value><![CDATA[");
375         sb.append(getName());
376         sb.append("]]></column-value></column>");
377         sb.append(
378             "<column><column-name>description</column-name><column-value><![CDATA[");
379         sb.append(getDescription());
380         sb.append("]]></column-value></column>");
381         sb.append(
382             "<column><column-name>settings</column-name><column-value><![CDATA[");
383         sb.append(getSettings());
384         sb.append("]]></column-value></column>");
385         sb.append(
386             "<column><column-name>active</column-name><column-value><![CDATA[");
387         sb.append(getActive());
388         sb.append("]]></column-value></column>");
389 
390         sb.append("</model>");
391 
392         return sb.toString();
393     }
394 
395     private long _layoutSetPrototypeId;
396     private long _companyId;
397     private String _name;
398     private String _description;
399     private String _settings;
400     private boolean _active;
401     private transient ExpandoBridge _expandoBridge;
402 }