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.service.model.IGFolder
59   * @see com.liferay.portlet.imagegallery.service.model.IGFolderModel
60   * @see com.liferay.portlet.imagegallery.service.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.setEscapedModel(true);
268 
269             model.setUuid(HtmlUtil.escape(getUuid()));
270             model.setFolderId(getFolderId());
271             model.setGroupId(getGroupId());
272             model.setCompanyId(getCompanyId());
273             model.setUserId(getUserId());
274             model.setCreateDate(getCreateDate());
275             model.setModifiedDate(getModifiedDate());
276             model.setParentFolderId(getParentFolderId());
277             model.setName(HtmlUtil.escape(getName()));
278             model.setDescription(HtmlUtil.escape(getDescription()));
279 
280             model = (IGFolder)Proxy.newProxyInstance(IGFolder.class.getClassLoader(),
281                     new Class[] { IGFolder.class },
282                     new ReadOnlyBeanHandler(model));
283 
284             return model;
285         }
286     }
287 
288     public Object clone() {
289         IGFolderImpl clone = new IGFolderImpl();
290 
291         clone.setUuid(getUuid());
292         clone.setFolderId(getFolderId());
293         clone.setGroupId(getGroupId());
294         clone.setCompanyId(getCompanyId());
295         clone.setUserId(getUserId());
296         clone.setCreateDate(getCreateDate());
297         clone.setModifiedDate(getModifiedDate());
298         clone.setParentFolderId(getParentFolderId());
299         clone.setName(getName());
300         clone.setDescription(getDescription());
301 
302         return clone;
303     }
304 
305     public int compareTo(Object obj) {
306         if (obj == null) {
307             return -1;
308         }
309 
310         IGFolderImpl igFolder = (IGFolderImpl)obj;
311 
312         int value = 0;
313 
314         if (getFolderId() < igFolder.getFolderId()) {
315             value = -1;
316         }
317         else if (getFolderId() > igFolder.getFolderId()) {
318             value = 1;
319         }
320         else {
321             value = 0;
322         }
323 
324         if (value != 0) {
325             return value;
326         }
327 
328         value = getName().toLowerCase()
329                     .compareTo(igFolder.getName().toLowerCase());
330 
331         if (value != 0) {
332             return value;
333         }
334 
335         return 0;
336     }
337 
338     public boolean equals(Object obj) {
339         if (obj == null) {
340             return false;
341         }
342 
343         IGFolderImpl igFolder = null;
344 
345         try {
346             igFolder = (IGFolderImpl)obj;
347         }
348         catch (ClassCastException cce) {
349             return false;
350         }
351 
352         long pk = igFolder.getPrimaryKey();
353 
354         if (getPrimaryKey() == pk) {
355             return true;
356         }
357         else {
358             return false;
359         }
360     }
361 
362     public int hashCode() {
363         return (int)getPrimaryKey();
364     }
365 
366     private String _uuid;
367     private long _folderId;
368     private long _groupId;
369     private long _companyId;
370     private long _userId;
371     private Date _createDate;
372     private Date _modifiedDate;
373     private long _parentFolderId;
374     private String _name;
375     private String _description;
376 }