1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.Layout;
29  import com.liferay.portal.model.LayoutSoap;
30  import com.liferay.portal.util.PropsUtil;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.List;
40  
41  /**
42   * <a href="LayoutModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>Layout</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portal.service.model.Layout
57   * @see com.liferay.portal.service.model.LayoutModel
58   * @see com.liferay.portal.service.model.impl.LayoutImpl
59   *
60   */
61  public class LayoutModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "Layout";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "plid", new Integer(Types.BIGINT) },
65              
66  
67              { "groupId", new Integer(Types.BIGINT) },
68              
69  
70              { "companyId", new Integer(Types.BIGINT) },
71              
72  
73              { "privateLayout", new Integer(Types.BOOLEAN) },
74              
75  
76              { "layoutId", new Integer(Types.BIGINT) },
77              
78  
79              { "parentLayoutId", new Integer(Types.BIGINT) },
80              
81  
82              { "name", new Integer(Types.VARCHAR) },
83              
84  
85              { "title", new Integer(Types.VARCHAR) },
86              
87  
88              { "description", new Integer(Types.VARCHAR) },
89              
90  
91              { "type_", new Integer(Types.VARCHAR) },
92              
93  
94              { "typeSettings", new Integer(Types.CLOB) },
95              
96  
97              { "hidden_", new Integer(Types.BOOLEAN) },
98              
99  
100             { "friendlyURL", new Integer(Types.VARCHAR) },
101             
102 
103             { "iconImage", new Integer(Types.BOOLEAN) },
104             
105 
106             { "iconImageId", new Integer(Types.BIGINT) },
107             
108 
109             { "themeId", new Integer(Types.VARCHAR) },
110             
111 
112             { "colorSchemeId", new Integer(Types.VARCHAR) },
113             
114 
115             { "wapThemeId", new Integer(Types.VARCHAR) },
116             
117 
118             { "wapColorSchemeId", new Integer(Types.VARCHAR) },
119             
120 
121             { "css", new Integer(Types.VARCHAR) },
122             
123 
124             { "priority", new Integer(Types.INTEGER) },
125             
126 
127             { "dlFolderId", new Integer(Types.BIGINT) }
128         };
129     public static final String TABLE_SQL_CREATE = "create table Layout (plid LONG not null primary key,groupId LONG,companyId LONG,privateLayout BOOLEAN,layoutId LONG,parentLayoutId LONG,name STRING null,title STRING null,description STRING null,type_ VARCHAR(75) null,typeSettings TEXT null,hidden_ BOOLEAN,friendlyURL VARCHAR(100) null,iconImage BOOLEAN,iconImageId LONG,themeId VARCHAR(75) null,colorSchemeId VARCHAR(75) null,wapThemeId VARCHAR(75) null,wapColorSchemeId VARCHAR(75) null,css STRING null,priority INTEGER,dlFolderId LONG)";
130     public static final String TABLE_SQL_DROP = "drop table Layout";
131     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
132                 "value.object.finder.cache.enabled.com.liferay.portal.model.Layout"),
133             true);
134 
135     public static Layout toModel(LayoutSoap soapModel) {
136         Layout model = new LayoutImpl();
137 
138         model.setPlid(soapModel.getPlid());
139         model.setGroupId(soapModel.getGroupId());
140         model.setCompanyId(soapModel.getCompanyId());
141         model.setPrivateLayout(soapModel.getPrivateLayout());
142         model.setLayoutId(soapModel.getLayoutId());
143         model.setParentLayoutId(soapModel.getParentLayoutId());
144         model.setName(soapModel.getName());
145         model.setTitle(soapModel.getTitle());
146         model.setDescription(soapModel.getDescription());
147         model.setType(soapModel.getType());
148         model.setTypeSettings(soapModel.getTypeSettings());
149         model.setHidden(soapModel.getHidden());
150         model.setFriendlyURL(soapModel.getFriendlyURL());
151         model.setIconImage(soapModel.getIconImage());
152         model.setIconImageId(soapModel.getIconImageId());
153         model.setThemeId(soapModel.getThemeId());
154         model.setColorSchemeId(soapModel.getColorSchemeId());
155         model.setWapThemeId(soapModel.getWapThemeId());
156         model.setWapColorSchemeId(soapModel.getWapColorSchemeId());
157         model.setCss(soapModel.getCss());
158         model.setPriority(soapModel.getPriority());
159         model.setDlFolderId(soapModel.getDlFolderId());
160 
161         return model;
162     }
163 
164     public static List<Layout> toModels(LayoutSoap[] soapModels) {
165         List<Layout> models = new ArrayList<Layout>(soapModels.length);
166 
167         for (LayoutSoap soapModel : soapModels) {
168             models.add(toModel(soapModel));
169         }
170 
171         return models;
172     }
173 
174     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
175                 "lock.expiration.time.com.liferay.portal.model.Layout"));
176 
177     public LayoutModelImpl() {
178     }
179 
180     public long getPrimaryKey() {
181         return _plid;
182     }
183 
184     public void setPrimaryKey(long pk) {
185         setPlid(pk);
186     }
187 
188     public Serializable getPrimaryKeyObj() {
189         return new Long(_plid);
190     }
191 
192     public long getPlid() {
193         return _plid;
194     }
195 
196     public void setPlid(long plid) {
197         if (plid != _plid) {
198             _plid = plid;
199         }
200     }
201 
202     public long getGroupId() {
203         return _groupId;
204     }
205 
206     public void setGroupId(long groupId) {
207         if (groupId != _groupId) {
208             _groupId = groupId;
209         }
210     }
211 
212     public long getCompanyId() {
213         return _companyId;
214     }
215 
216     public void setCompanyId(long companyId) {
217         if (companyId != _companyId) {
218             _companyId = companyId;
219         }
220     }
221 
222     public boolean getPrivateLayout() {
223         return _privateLayout;
224     }
225 
226     public boolean isPrivateLayout() {
227         return _privateLayout;
228     }
229 
230     public void setPrivateLayout(boolean privateLayout) {
231         if (privateLayout != _privateLayout) {
232             _privateLayout = privateLayout;
233         }
234     }
235 
236     public long getLayoutId() {
237         return _layoutId;
238     }
239 
240     public void setLayoutId(long layoutId) {
241         if (layoutId != _layoutId) {
242             _layoutId = layoutId;
243         }
244     }
245 
246     public long getParentLayoutId() {
247         return _parentLayoutId;
248     }
249 
250     public void setParentLayoutId(long parentLayoutId) {
251         if (parentLayoutId != _parentLayoutId) {
252             _parentLayoutId = parentLayoutId;
253         }
254     }
255 
256     public String getName() {
257         return GetterUtil.getString(_name);
258     }
259 
260     public void setName(String name) {
261         if (((name == null) && (_name != null)) ||
262                 ((name != null) && (_name == null)) ||
263                 ((name != null) && (_name != null) && !name.equals(_name))) {
264             _name = name;
265         }
266     }
267 
268     public String getTitle() {
269         return GetterUtil.getString(_title);
270     }
271 
272     public void setTitle(String title) {
273         if (((title == null) && (_title != null)) ||
274                 ((title != null) && (_title == null)) ||
275                 ((title != null) && (_title != null) && !title.equals(_title))) {
276             _title = title;
277         }
278     }
279 
280     public String getDescription() {
281         return GetterUtil.getString(_description);
282     }
283 
284     public void setDescription(String description) {
285         if (((description == null) && (_description != null)) ||
286                 ((description != null) && (_description == null)) ||
287                 ((description != null) && (_description != null) &&
288                 !description.equals(_description))) {
289             _description = description;
290         }
291     }
292 
293     public String getType() {
294         return GetterUtil.getString(_type);
295     }
296 
297     public void setType(String type) {
298         if (((type == null) && (_type != null)) ||
299                 ((type != null) && (_type == null)) ||
300                 ((type != null) && (_type != null) && !type.equals(_type))) {
301             _type = type;
302         }
303     }
304 
305     public String getTypeSettings() {
306         return GetterUtil.getString(_typeSettings);
307     }
308 
309     public void setTypeSettings(String typeSettings) {
310         if (((typeSettings == null) && (_typeSettings != null)) ||
311                 ((typeSettings != null) && (_typeSettings == null)) ||
312                 ((typeSettings != null) && (_typeSettings != null) &&
313                 !typeSettings.equals(_typeSettings))) {
314             _typeSettings = typeSettings;
315         }
316     }
317 
318     public boolean getHidden() {
319         return _hidden;
320     }
321 
322     public boolean isHidden() {
323         return _hidden;
324     }
325 
326     public void setHidden(boolean hidden) {
327         if (hidden != _hidden) {
328             _hidden = hidden;
329         }
330     }
331 
332     public String getFriendlyURL() {
333         return GetterUtil.getString(_friendlyURL);
334     }
335 
336     public void setFriendlyURL(String friendlyURL) {
337         if (((friendlyURL == null) && (_friendlyURL != null)) ||
338                 ((friendlyURL != null) && (_friendlyURL == null)) ||
339                 ((friendlyURL != null) && (_friendlyURL != null) &&
340                 !friendlyURL.equals(_friendlyURL))) {
341             _friendlyURL = friendlyURL;
342         }
343     }
344 
345     public boolean getIconImage() {
346         return _iconImage;
347     }
348 
349     public boolean isIconImage() {
350         return _iconImage;
351     }
352 
353     public void setIconImage(boolean iconImage) {
354         if (iconImage != _iconImage) {
355             _iconImage = iconImage;
356         }
357     }
358 
359     public long getIconImageId() {
360         return _iconImageId;
361     }
362 
363     public void setIconImageId(long iconImageId) {
364         if (iconImageId != _iconImageId) {
365             _iconImageId = iconImageId;
366         }
367     }
368 
369     public String getThemeId() {
370         return GetterUtil.getString(_themeId);
371     }
372 
373     public void setThemeId(String themeId) {
374         if (((themeId == null) && (_themeId != null)) ||
375                 ((themeId != null) && (_themeId == null)) ||
376                 ((themeId != null) && (_themeId != null) &&
377                 !themeId.equals(_themeId))) {
378             _themeId = themeId;
379         }
380     }
381 
382     public String getColorSchemeId() {
383         return GetterUtil.getString(_colorSchemeId);
384     }
385 
386     public void setColorSchemeId(String colorSchemeId) {
387         if (((colorSchemeId == null) && (_colorSchemeId != null)) ||
388                 ((colorSchemeId != null) && (_colorSchemeId == null)) ||
389                 ((colorSchemeId != null) && (_colorSchemeId != null) &&
390                 !colorSchemeId.equals(_colorSchemeId))) {
391             _colorSchemeId = colorSchemeId;
392         }
393     }
394 
395     public String getWapThemeId() {
396         return GetterUtil.getString(_wapThemeId);
397     }
398 
399     public void setWapThemeId(String wapThemeId) {
400         if (((wapThemeId == null) && (_wapThemeId != null)) ||
401                 ((wapThemeId != null) && (_wapThemeId == null)) ||
402                 ((wapThemeId != null) && (_wapThemeId != null) &&
403                 !wapThemeId.equals(_wapThemeId))) {
404             _wapThemeId = wapThemeId;
405         }
406     }
407 
408     public String getWapColorSchemeId() {
409         return GetterUtil.getString(_wapColorSchemeId);
410     }
411 
412     public void setWapColorSchemeId(String wapColorSchemeId) {
413         if (((wapColorSchemeId == null) && (_wapColorSchemeId != null)) ||
414                 ((wapColorSchemeId != null) && (_wapColorSchemeId == null)) ||
415                 ((wapColorSchemeId != null) && (_wapColorSchemeId != null) &&
416                 !wapColorSchemeId.equals(_wapColorSchemeId))) {
417             _wapColorSchemeId = wapColorSchemeId;
418         }
419     }
420 
421     public String getCss() {
422         return GetterUtil.getString(_css);
423     }
424 
425     public void setCss(String css) {
426         if (((css == null) && (_css != null)) ||
427                 ((css != null) && (_css == null)) ||
428                 ((css != null) && (_css != null) && !css.equals(_css))) {
429             _css = css;
430         }
431     }
432 
433     public int getPriority() {
434         return _priority;
435     }
436 
437     public void setPriority(int priority) {
438         if (priority != _priority) {
439             _priority = priority;
440         }
441     }
442 
443     public long getDlFolderId() {
444         return _dlFolderId;
445     }
446 
447     public void setDlFolderId(long dlFolderId) {
448         if (dlFolderId != _dlFolderId) {
449             _dlFolderId = dlFolderId;
450         }
451     }
452 
453     public Layout toEscapedModel() {
454         if (isEscapedModel()) {
455             return (Layout)this;
456         }
457         else {
458             Layout model = new LayoutImpl();
459 
460             model.setEscapedModel(true);
461 
462             model.setPlid(getPlid());
463             model.setGroupId(getGroupId());
464             model.setCompanyId(getCompanyId());
465             model.setPrivateLayout(getPrivateLayout());
466             model.setLayoutId(getLayoutId());
467             model.setParentLayoutId(getParentLayoutId());
468             model.setName(HtmlUtil.escape(getName()));
469             model.setTitle(HtmlUtil.escape(getTitle()));
470             model.setDescription(HtmlUtil.escape(getDescription()));
471             model.setType(HtmlUtil.escape(getType()));
472             model.setTypeSettings(HtmlUtil.escape(getTypeSettings()));
473             model.setHidden(getHidden());
474             model.setFriendlyURL(HtmlUtil.escape(getFriendlyURL()));
475             model.setIconImage(getIconImage());
476             model.setIconImageId(getIconImageId());
477             model.setThemeId(HtmlUtil.escape(getThemeId()));
478             model.setColorSchemeId(HtmlUtil.escape(getColorSchemeId()));
479             model.setWapThemeId(HtmlUtil.escape(getWapThemeId()));
480             model.setWapColorSchemeId(HtmlUtil.escape(getWapColorSchemeId()));
481             model.setCss(HtmlUtil.escape(getCss()));
482             model.setPriority(getPriority());
483             model.setDlFolderId(getDlFolderId());
484 
485             model = (Layout)Proxy.newProxyInstance(Layout.class.getClassLoader(),
486                     new Class[] { Layout.class }, new ReadOnlyBeanHandler(model));
487 
488             return model;
489         }
490     }
491 
492     public Object clone() {
493         LayoutImpl clone = new LayoutImpl();
494 
495         clone.setPlid(getPlid());
496         clone.setGroupId(getGroupId());
497         clone.setCompanyId(getCompanyId());
498         clone.setPrivateLayout(getPrivateLayout());
499         clone.setLayoutId(getLayoutId());
500         clone.setParentLayoutId(getParentLayoutId());
501         clone.setName(getName());
502         clone.setTitle(getTitle());
503         clone.setDescription(getDescription());
504         clone.setType(getType());
505         clone.setTypeSettings(getTypeSettings());
506         clone.setHidden(getHidden());
507         clone.setFriendlyURL(getFriendlyURL());
508         clone.setIconImage(getIconImage());
509         clone.setIconImageId(getIconImageId());
510         clone.setThemeId(getThemeId());
511         clone.setColorSchemeId(getColorSchemeId());
512         clone.setWapThemeId(getWapThemeId());
513         clone.setWapColorSchemeId(getWapColorSchemeId());
514         clone.setCss(getCss());
515         clone.setPriority(getPriority());
516         clone.setDlFolderId(getDlFolderId());
517 
518         return clone;
519     }
520 
521     public int compareTo(Object obj) {
522         if (obj == null) {
523             return -1;
524         }
525 
526         LayoutImpl layout = (LayoutImpl)obj;
527 
528         int value = 0;
529 
530         if (getParentLayoutId() < layout.getParentLayoutId()) {
531             value = -1;
532         }
533         else if (getParentLayoutId() > layout.getParentLayoutId()) {
534             value = 1;
535         }
536         else {
537             value = 0;
538         }
539 
540         if (value != 0) {
541             return value;
542         }
543 
544         if (getPriority() < layout.getPriority()) {
545             value = -1;
546         }
547         else if (getPriority() > layout.getPriority()) {
548             value = 1;
549         }
550         else {
551             value = 0;
552         }
553 
554         if (value != 0) {
555             return value;
556         }
557 
558         return 0;
559     }
560 
561     public boolean equals(Object obj) {
562         if (obj == null) {
563             return false;
564         }
565 
566         LayoutImpl layout = null;
567 
568         try {
569             layout = (LayoutImpl)obj;
570         }
571         catch (ClassCastException cce) {
572             return false;
573         }
574 
575         long pk = layout.getPrimaryKey();
576 
577         if (getPrimaryKey() == pk) {
578             return true;
579         }
580         else {
581             return false;
582         }
583     }
584 
585     public int hashCode() {
586         return (int)getPrimaryKey();
587     }
588 
589     private long _plid;
590     private long _groupId;
591     private long _companyId;
592     private boolean _privateLayout;
593     private long _layoutId;
594     private long _parentLayoutId;
595     private String _name;
596     private String _title;
597     private String _description;
598     private String _type;
599     private String _typeSettings;
600     private boolean _hidden;
601     private String _friendlyURL;
602     private boolean _iconImage;
603     private long _iconImageId;
604     private String _themeId;
605     private String _colorSchemeId;
606     private String _wapThemeId;
607     private String _wapColorSchemeId;
608     private String _css;
609     private int _priority;
610     private long _dlFolderId;
611 }