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