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