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