1   /**
2    * Copyright (c) 2000-2009 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.portlet.imagegallery.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.impl.BaseModelImpl;
29  
30  import com.liferay.portlet.expando.model.ExpandoBridge;
31  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
32  import com.liferay.portlet.imagegallery.model.IGFolder;
33  import com.liferay.portlet.imagegallery.model.IGFolderSoap;
34  
35  import java.io.Serializable;
36  
37  import java.lang.reflect.Proxy;
38  
39  import java.sql.Types;
40  
41  import java.util.ArrayList;
42  import java.util.Date;
43  import java.util.List;
44  
45  /**
46   * <a href="IGFolderModelImpl.java.html"><b><i>View Source</i></b></a>
47   *
48   * <p>
49   * ServiceBuilder generated this class. Modifications in this class will be
50   * overwritten the next time is generated.
51   * </p>
52   *
53   * <p>
54   * This class is a model that represents the <code>IGFolder</code> table
55   * in the database.
56   * </p>
57   *
58   * @author Brian Wing Shun Chan
59   *
60   * @see com.liferay.portlet.imagegallery.model.IGFolder
61   * @see com.liferay.portlet.imagegallery.model.IGFolderModel
62   * @see com.liferay.portlet.imagegallery.model.impl.IGFolderImpl
63   *
64   */
65  public class IGFolderModelImpl extends BaseModelImpl {
66      public static final String TABLE_NAME = "IGFolder";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "uuid_", new Integer(Types.VARCHAR) },
69              
70  
71              { "folderId", new Integer(Types.BIGINT) },
72              
73  
74              { "groupId", new Integer(Types.BIGINT) },
75              
76  
77              { "companyId", new Integer(Types.BIGINT) },
78              
79  
80              { "userId", new Integer(Types.BIGINT) },
81              
82  
83              { "createDate", new Integer(Types.TIMESTAMP) },
84              
85  
86              { "modifiedDate", new Integer(Types.TIMESTAMP) },
87              
88  
89              { "parentFolderId", new Integer(Types.BIGINT) },
90              
91  
92              { "name", new Integer(Types.VARCHAR) },
93              
94  
95              { "description", new Integer(Types.VARCHAR) }
96          };
97      public static final String TABLE_SQL_CREATE = "create table IGFolder (uuid_ VARCHAR(75) null,folderId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,createDate DATE null,modifiedDate DATE null,parentFolderId LONG,name VARCHAR(75) null,description STRING null)";
98      public static final String TABLE_SQL_DROP = "drop table IGFolder";
99      public static final String DATA_SOURCE = "liferayDataSource";
100     public static final String SESSION_FACTORY = "liferaySessionFactory";
101     public static final String TX_MANAGER = "liferayTransactionManager";
102     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
103                 "value.object.finder.cache.enabled.com.liferay.portlet.imagegallery.model.IGFolder"),
104             true);
105 
106     public static IGFolder toModel(IGFolderSoap soapModel) {
107         IGFolder model = new IGFolderImpl();
108 
109         model.setUuid(soapModel.getUuid());
110         model.setFolderId(soapModel.getFolderId());
111         model.setGroupId(soapModel.getGroupId());
112         model.setCompanyId(soapModel.getCompanyId());
113         model.setUserId(soapModel.getUserId());
114         model.setCreateDate(soapModel.getCreateDate());
115         model.setModifiedDate(soapModel.getModifiedDate());
116         model.setParentFolderId(soapModel.getParentFolderId());
117         model.setName(soapModel.getName());
118         model.setDescription(soapModel.getDescription());
119 
120         return model;
121     }
122 
123     public static List<IGFolder> toModels(IGFolderSoap[] soapModels) {
124         List<IGFolder> models = new ArrayList<IGFolder>(soapModels.length);
125 
126         for (IGFolderSoap soapModel : soapModels) {
127             models.add(toModel(soapModel));
128         }
129 
130         return models;
131     }
132 
133     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
134                 "lock.expiration.time.com.liferay.portlet.imagegallery.model.IGFolder"));
135 
136     public IGFolderModelImpl() {
137     }
138 
139     public long getPrimaryKey() {
140         return _folderId;
141     }
142 
143     public void setPrimaryKey(long pk) {
144         setFolderId(pk);
145     }
146 
147     public Serializable getPrimaryKeyObj() {
148         return new Long(_folderId);
149     }
150 
151     public String getUuid() {
152         return GetterUtil.getString(_uuid);
153     }
154 
155     public void setUuid(String uuid) {
156         if ((uuid != null) && (uuid != _uuid)) {
157             _uuid = uuid;
158         }
159     }
160 
161     public long getFolderId() {
162         return _folderId;
163     }
164 
165     public void setFolderId(long folderId) {
166         if (folderId != _folderId) {
167             _folderId = folderId;
168         }
169     }
170 
171     public long getGroupId() {
172         return _groupId;
173     }
174 
175     public void setGroupId(long groupId) {
176         if (groupId != _groupId) {
177             _groupId = groupId;
178         }
179     }
180 
181     public long getCompanyId() {
182         return _companyId;
183     }
184 
185     public void setCompanyId(long companyId) {
186         if (companyId != _companyId) {
187             _companyId = companyId;
188         }
189     }
190 
191     public long getUserId() {
192         return _userId;
193     }
194 
195     public void setUserId(long userId) {
196         if (userId != _userId) {
197             _userId = userId;
198         }
199     }
200 
201     public Date getCreateDate() {
202         return _createDate;
203     }
204 
205     public void setCreateDate(Date createDate) {
206         if (((createDate == null) && (_createDate != null)) ||
207                 ((createDate != null) && (_createDate == null)) ||
208                 ((createDate != null) && (_createDate != null) &&
209                 !createDate.equals(_createDate))) {
210             _createDate = createDate;
211         }
212     }
213 
214     public Date getModifiedDate() {
215         return _modifiedDate;
216     }
217 
218     public void setModifiedDate(Date modifiedDate) {
219         if (((modifiedDate == null) && (_modifiedDate != null)) ||
220                 ((modifiedDate != null) && (_modifiedDate == null)) ||
221                 ((modifiedDate != null) && (_modifiedDate != null) &&
222                 !modifiedDate.equals(_modifiedDate))) {
223             _modifiedDate = modifiedDate;
224         }
225     }
226 
227     public long getParentFolderId() {
228         return _parentFolderId;
229     }
230 
231     public void setParentFolderId(long parentFolderId) {
232         if (parentFolderId != _parentFolderId) {
233             _parentFolderId = parentFolderId;
234         }
235     }
236 
237     public String getName() {
238         return GetterUtil.getString(_name);
239     }
240 
241     public void setName(String name) {
242         if (((name == null) && (_name != null)) ||
243                 ((name != null) && (_name == null)) ||
244                 ((name != null) && (_name != null) && !name.equals(_name))) {
245             _name = name;
246         }
247     }
248 
249     public String getDescription() {
250         return GetterUtil.getString(_description);
251     }
252 
253     public void setDescription(String description) {
254         if (((description == null) && (_description != null)) ||
255                 ((description != null) && (_description == null)) ||
256                 ((description != null) && (_description != null) &&
257                 !description.equals(_description))) {
258             _description = description;
259         }
260     }
261 
262     public IGFolder toEscapedModel() {
263         if (isEscapedModel()) {
264             return (IGFolder)this;
265         }
266         else {
267             IGFolder model = new IGFolderImpl();
268 
269             model.setNew(isNew());
270             model.setEscapedModel(true);
271 
272             model.setUuid(HtmlUtil.escape(getUuid()));
273             model.setFolderId(getFolderId());
274             model.setGroupId(getGroupId());
275             model.setCompanyId(getCompanyId());
276             model.setUserId(getUserId());
277             model.setCreateDate(getCreateDate());
278             model.setModifiedDate(getModifiedDate());
279             model.setParentFolderId(getParentFolderId());
280             model.setName(HtmlUtil.escape(getName()));
281             model.setDescription(HtmlUtil.escape(getDescription()));
282 
283             model = (IGFolder)Proxy.newProxyInstance(IGFolder.class.getClassLoader(),
284                     new Class[] { IGFolder.class },
285                     new ReadOnlyBeanHandler(model));
286 
287             return model;
288         }
289     }
290 
291     public ExpandoBridge getExpandoBridge() {
292         if (_expandoBridge == null) {
293             _expandoBridge = new ExpandoBridgeImpl(IGFolder.class.getName(),
294                     getPrimaryKey());
295         }
296 
297         return _expandoBridge;
298     }
299 
300     public Object clone() {
301         IGFolderImpl clone = new IGFolderImpl();
302 
303         clone.setUuid(getUuid());
304         clone.setFolderId(getFolderId());
305         clone.setGroupId(getGroupId());
306         clone.setCompanyId(getCompanyId());
307         clone.setUserId(getUserId());
308         clone.setCreateDate(getCreateDate());
309         clone.setModifiedDate(getModifiedDate());
310         clone.setParentFolderId(getParentFolderId());
311         clone.setName(getName());
312         clone.setDescription(getDescription());
313 
314         return clone;
315     }
316 
317     public int compareTo(Object obj) {
318         if (obj == null) {
319             return -1;
320         }
321 
322         IGFolderImpl igFolder = (IGFolderImpl)obj;
323 
324         int value = 0;
325 
326         if (getFolderId() < igFolder.getFolderId()) {
327             value = -1;
328         }
329         else if (getFolderId() > igFolder.getFolderId()) {
330             value = 1;
331         }
332         else {
333             value = 0;
334         }
335 
336         if (value != 0) {
337             return value;
338         }
339 
340         value = getName().toLowerCase()
341                     .compareTo(igFolder.getName().toLowerCase());
342 
343         if (value != 0) {
344             return value;
345         }
346 
347         return 0;
348     }
349 
350     public boolean equals(Object obj) {
351         if (obj == null) {
352             return false;
353         }
354 
355         IGFolderImpl igFolder = null;
356 
357         try {
358             igFolder = (IGFolderImpl)obj;
359         }
360         catch (ClassCastException cce) {
361             return false;
362         }
363 
364         long pk = igFolder.getPrimaryKey();
365 
366         if (getPrimaryKey() == pk) {
367             return true;
368         }
369         else {
370             return false;
371         }
372     }
373 
374     public int hashCode() {
375         return (int)getPrimaryKey();
376     }
377 
378     private String _uuid;
379     private long _folderId;
380     private long _groupId;
381     private long _companyId;
382     private long _userId;
383     private Date _createDate;
384     private Date _modifiedDate;
385     private long _parentFolderId;
386     private String _name;
387     private String _description;
388     private transient ExpandoBridge _expandoBridge;
389 }