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