1   /**
2    * Copyright (c) 2000-2009 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<DLFolder> {
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 ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
107                 "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFolder"),
108             true);
109     public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
110                 "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFolder"),
111             true);
112 
113     public static DLFolder toModel(DLFolderSoap soapModel) {
114         DLFolder model = new DLFolderImpl();
115 
116         model.setUuid(soapModel.getUuid());
117         model.setFolderId(soapModel.getFolderId());
118         model.setGroupId(soapModel.getGroupId());
119         model.setCompanyId(soapModel.getCompanyId());
120         model.setUserId(soapModel.getUserId());
121         model.setUserName(soapModel.getUserName());
122         model.setCreateDate(soapModel.getCreateDate());
123         model.setModifiedDate(soapModel.getModifiedDate());
124         model.setParentFolderId(soapModel.getParentFolderId());
125         model.setName(soapModel.getName());
126         model.setDescription(soapModel.getDescription());
127         model.setLastPostDate(soapModel.getLastPostDate());
128 
129         return model;
130     }
131 
132     public static List<DLFolder> toModels(DLFolderSoap[] soapModels) {
133         List<DLFolder> models = new ArrayList<DLFolder>(soapModels.length);
134 
135         for (DLFolderSoap soapModel : soapModels) {
136             models.add(toModel(soapModel));
137         }
138 
139         return models;
140     }
141 
142     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
143                 "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFolder"));
144 
145     public DLFolderModelImpl() {
146     }
147 
148     public long getPrimaryKey() {
149         return _folderId;
150     }
151 
152     public void setPrimaryKey(long pk) {
153         setFolderId(pk);
154     }
155 
156     public Serializable getPrimaryKeyObj() {
157         return new Long(_folderId);
158     }
159 
160     public String getUuid() {
161         return GetterUtil.getString(_uuid);
162     }
163 
164     public void setUuid(String uuid) {
165         _uuid = uuid;
166 
167         if (_originalUuid == null) {
168             _originalUuid = uuid;
169         }
170     }
171 
172     public String getOriginalUuid() {
173         return GetterUtil.getString(_originalUuid);
174     }
175 
176     public long getFolderId() {
177         return _folderId;
178     }
179 
180     public void setFolderId(long folderId) {
181         _folderId = folderId;
182     }
183 
184     public long getGroupId() {
185         return _groupId;
186     }
187 
188     public void setGroupId(long groupId) {
189         _groupId = groupId;
190 
191         if (!_setOriginalGroupId) {
192             _setOriginalGroupId = true;
193 
194             _originalGroupId = groupId;
195         }
196     }
197 
198     public long getOriginalGroupId() {
199         return _originalGroupId;
200     }
201 
202     public long getCompanyId() {
203         return _companyId;
204     }
205 
206     public void setCompanyId(long companyId) {
207         _companyId = companyId;
208     }
209 
210     public long getUserId() {
211         return _userId;
212     }
213 
214     public void setUserId(long userId) {
215         _userId = userId;
216     }
217 
218     public String getUserName() {
219         return GetterUtil.getString(_userName);
220     }
221 
222     public void setUserName(String userName) {
223         _userName = userName;
224     }
225 
226     public Date getCreateDate() {
227         return _createDate;
228     }
229 
230     public void setCreateDate(Date createDate) {
231         _createDate = createDate;
232     }
233 
234     public Date getModifiedDate() {
235         return _modifiedDate;
236     }
237 
238     public void setModifiedDate(Date modifiedDate) {
239         _modifiedDate = modifiedDate;
240     }
241 
242     public long getParentFolderId() {
243         return _parentFolderId;
244     }
245 
246     public void setParentFolderId(long parentFolderId) {
247         _parentFolderId = parentFolderId;
248 
249         if (!_setOriginalParentFolderId) {
250             _setOriginalParentFolderId = true;
251 
252             _originalParentFolderId = parentFolderId;
253         }
254     }
255 
256     public long getOriginalParentFolderId() {
257         return _originalParentFolderId;
258     }
259 
260     public String getName() {
261         return GetterUtil.getString(_name);
262     }
263 
264     public void setName(String name) {
265         _name = name;
266 
267         if (_originalName == null) {
268             _originalName = name;
269         }
270     }
271 
272     public String getOriginalName() {
273         return GetterUtil.getString(_originalName);
274     }
275 
276     public String getDescription() {
277         return GetterUtil.getString(_description);
278     }
279 
280     public void setDescription(String description) {
281         _description = description;
282     }
283 
284     public Date getLastPostDate() {
285         return _lastPostDate;
286     }
287 
288     public void setLastPostDate(Date lastPostDate) {
289         _lastPostDate = lastPostDate;
290     }
291 
292     public DLFolder toEscapedModel() {
293         if (isEscapedModel()) {
294             return (DLFolder)this;
295         }
296         else {
297             DLFolder model = new DLFolderImpl();
298 
299             model.setNew(isNew());
300             model.setEscapedModel(true);
301 
302             model.setUuid(HtmlUtil.escape(getUuid()));
303             model.setFolderId(getFolderId());
304             model.setGroupId(getGroupId());
305             model.setCompanyId(getCompanyId());
306             model.setUserId(getUserId());
307             model.setUserName(HtmlUtil.escape(getUserName()));
308             model.setCreateDate(getCreateDate());
309             model.setModifiedDate(getModifiedDate());
310             model.setParentFolderId(getParentFolderId());
311             model.setName(HtmlUtil.escape(getName()));
312             model.setDescription(HtmlUtil.escape(getDescription()));
313             model.setLastPostDate(getLastPostDate());
314 
315             model = (DLFolder)Proxy.newProxyInstance(DLFolder.class.getClassLoader(),
316                     new Class[] { DLFolder.class },
317                     new ReadOnlyBeanHandler(model));
318 
319             return model;
320         }
321     }
322 
323     public Object clone() {
324         DLFolderImpl clone = new DLFolderImpl();
325 
326         clone.setUuid(getUuid());
327         clone.setFolderId(getFolderId());
328         clone.setGroupId(getGroupId());
329         clone.setCompanyId(getCompanyId());
330         clone.setUserId(getUserId());
331         clone.setUserName(getUserName());
332         clone.setCreateDate(getCreateDate());
333         clone.setModifiedDate(getModifiedDate());
334         clone.setParentFolderId(getParentFolderId());
335         clone.setName(getName());
336         clone.setDescription(getDescription());
337         clone.setLastPostDate(getLastPostDate());
338 
339         return clone;
340     }
341 
342     public int compareTo(DLFolder dlFolder) {
343         int value = 0;
344 
345         if (getParentFolderId() < dlFolder.getParentFolderId()) {
346             value = -1;
347         }
348         else if (getParentFolderId() > dlFolder.getParentFolderId()) {
349             value = 1;
350         }
351         else {
352             value = 0;
353         }
354 
355         if (value != 0) {
356             return value;
357         }
358 
359         value = getName().toLowerCase()
360                     .compareTo(dlFolder.getName().toLowerCase());
361 
362         if (value != 0) {
363             return value;
364         }
365 
366         return 0;
367     }
368 
369     public boolean equals(Object obj) {
370         if (obj == null) {
371             return false;
372         }
373 
374         DLFolder dlFolder = null;
375 
376         try {
377             dlFolder = (DLFolder)obj;
378         }
379         catch (ClassCastException cce) {
380             return false;
381         }
382 
383         long pk = dlFolder.getPrimaryKey();
384 
385         if (getPrimaryKey() == pk) {
386             return true;
387         }
388         else {
389             return false;
390         }
391     }
392 
393     public int hashCode() {
394         return (int)getPrimaryKey();
395     }
396 
397     public String toString() {
398         StringBuilder sb = new StringBuilder();
399 
400         sb.append("{uuid=");
401         sb.append(getUuid());
402         sb.append(", folderId=");
403         sb.append(getFolderId());
404         sb.append(", groupId=");
405         sb.append(getGroupId());
406         sb.append(", companyId=");
407         sb.append(getCompanyId());
408         sb.append(", userId=");
409         sb.append(getUserId());
410         sb.append(", userName=");
411         sb.append(getUserName());
412         sb.append(", createDate=");
413         sb.append(getCreateDate());
414         sb.append(", modifiedDate=");
415         sb.append(getModifiedDate());
416         sb.append(", parentFolderId=");
417         sb.append(getParentFolderId());
418         sb.append(", name=");
419         sb.append(getName());
420         sb.append(", description=");
421         sb.append(getDescription());
422         sb.append(", lastPostDate=");
423         sb.append(getLastPostDate());
424         sb.append("}");
425 
426         return sb.toString();
427     }
428 
429     public String toXmlString() {
430         StringBuilder sb = new StringBuilder();
431 
432         sb.append("<model><model-name>");
433         sb.append("com.liferay.portlet.documentlibrary.model.DLFolder");
434         sb.append("</model-name>");
435 
436         sb.append(
437             "<column><column-name>uuid</column-name><column-value><![CDATA[");
438         sb.append(getUuid());
439         sb.append("]]></column-value></column>");
440         sb.append(
441             "<column><column-name>folderId</column-name><column-value><![CDATA[");
442         sb.append(getFolderId());
443         sb.append("]]></column-value></column>");
444         sb.append(
445             "<column><column-name>groupId</column-name><column-value><![CDATA[");
446         sb.append(getGroupId());
447         sb.append("]]></column-value></column>");
448         sb.append(
449             "<column><column-name>companyId</column-name><column-value><![CDATA[");
450         sb.append(getCompanyId());
451         sb.append("]]></column-value></column>");
452         sb.append(
453             "<column><column-name>userId</column-name><column-value><![CDATA[");
454         sb.append(getUserId());
455         sb.append("]]></column-value></column>");
456         sb.append(
457             "<column><column-name>userName</column-name><column-value><![CDATA[");
458         sb.append(getUserName());
459         sb.append("]]></column-value></column>");
460         sb.append(
461             "<column><column-name>createDate</column-name><column-value><![CDATA[");
462         sb.append(getCreateDate());
463         sb.append("]]></column-value></column>");
464         sb.append(
465             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
466         sb.append(getModifiedDate());
467         sb.append("]]></column-value></column>");
468         sb.append(
469             "<column><column-name>parentFolderId</column-name><column-value><![CDATA[");
470         sb.append(getParentFolderId());
471         sb.append("]]></column-value></column>");
472         sb.append(
473             "<column><column-name>name</column-name><column-value><![CDATA[");
474         sb.append(getName());
475         sb.append("]]></column-value></column>");
476         sb.append(
477             "<column><column-name>description</column-name><column-value><![CDATA[");
478         sb.append(getDescription());
479         sb.append("]]></column-value></column>");
480         sb.append(
481             "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
482         sb.append(getLastPostDate());
483         sb.append("]]></column-value></column>");
484 
485         sb.append("</model>");
486 
487         return sb.toString();
488     }
489 
490     private String _uuid;
491     private String _originalUuid;
492     private long _folderId;
493     private long _groupId;
494     private long _originalGroupId;
495     private boolean _setOriginalGroupId;
496     private long _companyId;
497     private long _userId;
498     private String _userName;
499     private Date _createDate;
500     private Date _modifiedDate;
501     private long _parentFolderId;
502     private long _originalParentFolderId;
503     private boolean _setOriginalParentFolderId;
504     private String _name;
505     private String _originalName;
506     private String _description;
507     private Date _lastPostDate;
508 }