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  import com.liferay.portlet.expando.model.ExpandoBridge;
33  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
34  
35  import java.io.Serializable;
36  
37  import java.lang.reflect.Proxy;
38  
39  import java.sql.Types;
40  
41  import java.util.ArrayList;
42  import java.util.Date;
43  import java.util.List;
44  
45  /**
46   * <a href="DLFolderModelImpl.java.html"><b><i>View Source</i></b></a>
47   *
48   * <p>
49   * ServiceBuilder generated this class. Modifications in this class will be
50   * overwritten the next time is generated.
51   * </p>
52   *
53   * <p>
54   * This class is a model that represents the <code>DLFolder</code> table
55   * in the database.
56   * </p>
57   *
58   * @author Brian Wing Shun Chan
59   *
60   * @see com.liferay.portlet.documentlibrary.model.DLFolder
61   * @see com.liferay.portlet.documentlibrary.model.DLFolderModel
62   * @see com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl
63   *
64   */
65  public class DLFolderModelImpl extends BaseModelImpl<DLFolder> {
66      public static final String TABLE_NAME = "DLFolder";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "uuid_", new Integer(Types.VARCHAR) },
69              
70  
71              { "folderId", new Integer(Types.BIGINT) },
72              
73  
74              { "groupId", new Integer(Types.BIGINT) },
75              
76  
77              { "companyId", new Integer(Types.BIGINT) },
78              
79  
80              { "userId", new Integer(Types.BIGINT) },
81              
82  
83              { "userName", new Integer(Types.VARCHAR) },
84              
85  
86              { "createDate", new Integer(Types.TIMESTAMP) },
87              
88  
89              { "modifiedDate", new Integer(Types.TIMESTAMP) },
90              
91  
92              { "parentFolderId", new Integer(Types.BIGINT) },
93              
94  
95              { "name", new Integer(Types.VARCHAR) },
96              
97  
98              { "description", new Integer(Types.VARCHAR) },
99              
100 
101             { "lastPostDate", new Integer(Types.TIMESTAMP) }
102         };
103     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)";
104     public static final String TABLE_SQL_DROP = "drop table DLFolder";
105     public static final String DATA_SOURCE = "liferayDataSource";
106     public static final String SESSION_FACTORY = "liferaySessionFactory";
107     public static final String TX_MANAGER = "liferayTransactionManager";
108     public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
109                 "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFolder"),
110             true);
111     public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
112                 "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFolder"),
113             true);
114 
115     public static DLFolder toModel(DLFolderSoap soapModel) {
116         DLFolder model = new DLFolderImpl();
117 
118         model.setUuid(soapModel.getUuid());
119         model.setFolderId(soapModel.getFolderId());
120         model.setGroupId(soapModel.getGroupId());
121         model.setCompanyId(soapModel.getCompanyId());
122         model.setUserId(soapModel.getUserId());
123         model.setUserName(soapModel.getUserName());
124         model.setCreateDate(soapModel.getCreateDate());
125         model.setModifiedDate(soapModel.getModifiedDate());
126         model.setParentFolderId(soapModel.getParentFolderId());
127         model.setName(soapModel.getName());
128         model.setDescription(soapModel.getDescription());
129         model.setLastPostDate(soapModel.getLastPostDate());
130 
131         return model;
132     }
133 
134     public static List<DLFolder> toModels(DLFolderSoap[] soapModels) {
135         List<DLFolder> models = new ArrayList<DLFolder>(soapModels.length);
136 
137         for (DLFolderSoap soapModel : soapModels) {
138             models.add(toModel(soapModel));
139         }
140 
141         return models;
142     }
143 
144     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
145                 "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFolder"));
146 
147     public DLFolderModelImpl() {
148     }
149 
150     public long getPrimaryKey() {
151         return _folderId;
152     }
153 
154     public void setPrimaryKey(long pk) {
155         setFolderId(pk);
156     }
157 
158     public Serializable getPrimaryKeyObj() {
159         return new Long(_folderId);
160     }
161 
162     public String getUuid() {
163         return GetterUtil.getString(_uuid);
164     }
165 
166     public void setUuid(String uuid) {
167         _uuid = uuid;
168 
169         if (_originalUuid == null) {
170             _originalUuid = uuid;
171         }
172     }
173 
174     public String getOriginalUuid() {
175         return GetterUtil.getString(_originalUuid);
176     }
177 
178     public long getFolderId() {
179         return _folderId;
180     }
181 
182     public void setFolderId(long folderId) {
183         _folderId = folderId;
184     }
185 
186     public long getGroupId() {
187         return _groupId;
188     }
189 
190     public void setGroupId(long groupId) {
191         _groupId = groupId;
192 
193         if (!_setOriginalGroupId) {
194             _setOriginalGroupId = true;
195 
196             _originalGroupId = groupId;
197         }
198     }
199 
200     public long getOriginalGroupId() {
201         return _originalGroupId;
202     }
203 
204     public long getCompanyId() {
205         return _companyId;
206     }
207 
208     public void setCompanyId(long companyId) {
209         _companyId = companyId;
210     }
211 
212     public long getUserId() {
213         return _userId;
214     }
215 
216     public void setUserId(long userId) {
217         _userId = userId;
218     }
219 
220     public String getUserName() {
221         return GetterUtil.getString(_userName);
222     }
223 
224     public void setUserName(String userName) {
225         _userName = userName;
226     }
227 
228     public Date getCreateDate() {
229         return _createDate;
230     }
231 
232     public void setCreateDate(Date createDate) {
233         _createDate = createDate;
234     }
235 
236     public Date getModifiedDate() {
237         return _modifiedDate;
238     }
239 
240     public void setModifiedDate(Date modifiedDate) {
241         _modifiedDate = modifiedDate;
242     }
243 
244     public long getParentFolderId() {
245         return _parentFolderId;
246     }
247 
248     public void setParentFolderId(long parentFolderId) {
249         _parentFolderId = parentFolderId;
250 
251         if (!_setOriginalParentFolderId) {
252             _setOriginalParentFolderId = true;
253 
254             _originalParentFolderId = parentFolderId;
255         }
256     }
257 
258     public long getOriginalParentFolderId() {
259         return _originalParentFolderId;
260     }
261 
262     public String getName() {
263         return GetterUtil.getString(_name);
264     }
265 
266     public void setName(String name) {
267         _name = name;
268 
269         if (_originalName == null) {
270             _originalName = name;
271         }
272     }
273 
274     public String getOriginalName() {
275         return GetterUtil.getString(_originalName);
276     }
277 
278     public String getDescription() {
279         return GetterUtil.getString(_description);
280     }
281 
282     public void setDescription(String description) {
283         _description = description;
284     }
285 
286     public Date getLastPostDate() {
287         return _lastPostDate;
288     }
289 
290     public void setLastPostDate(Date lastPostDate) {
291         _lastPostDate = lastPostDate;
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 ExpandoBridge getExpandoBridge() {
326         if (_expandoBridge == null) {
327             _expandoBridge = new ExpandoBridgeImpl(DLFolder.class.getName(),
328                     getPrimaryKey());
329         }
330 
331         return _expandoBridge;
332     }
333 
334     public Object clone() {
335         DLFolderImpl clone = new DLFolderImpl();
336 
337         clone.setUuid(getUuid());
338         clone.setFolderId(getFolderId());
339         clone.setGroupId(getGroupId());
340         clone.setCompanyId(getCompanyId());
341         clone.setUserId(getUserId());
342         clone.setUserName(getUserName());
343         clone.setCreateDate(getCreateDate());
344         clone.setModifiedDate(getModifiedDate());
345         clone.setParentFolderId(getParentFolderId());
346         clone.setName(getName());
347         clone.setDescription(getDescription());
348         clone.setLastPostDate(getLastPostDate());
349 
350         return clone;
351     }
352 
353     public int compareTo(DLFolder dlFolder) {
354         int value = 0;
355 
356         if (getParentFolderId() < dlFolder.getParentFolderId()) {
357             value = -1;
358         }
359         else if (getParentFolderId() > dlFolder.getParentFolderId()) {
360             value = 1;
361         }
362         else {
363             value = 0;
364         }
365 
366         if (value != 0) {
367             return value;
368         }
369 
370         value = getName().toLowerCase()
371                     .compareTo(dlFolder.getName().toLowerCase());
372 
373         if (value != 0) {
374             return value;
375         }
376 
377         return 0;
378     }
379 
380     public boolean equals(Object obj) {
381         if (obj == null) {
382             return false;
383         }
384 
385         DLFolder dlFolder = null;
386 
387         try {
388             dlFolder = (DLFolder)obj;
389         }
390         catch (ClassCastException cce) {
391             return false;
392         }
393 
394         long pk = dlFolder.getPrimaryKey();
395 
396         if (getPrimaryKey() == pk) {
397             return true;
398         }
399         else {
400             return false;
401         }
402     }
403 
404     public int hashCode() {
405         return (int)getPrimaryKey();
406     }
407 
408     public String toString() {
409         StringBuilder sb = new StringBuilder();
410 
411         sb.append("{uuid=");
412         sb.append(getUuid());
413         sb.append(", folderId=");
414         sb.append(getFolderId());
415         sb.append(", groupId=");
416         sb.append(getGroupId());
417         sb.append(", companyId=");
418         sb.append(getCompanyId());
419         sb.append(", userId=");
420         sb.append(getUserId());
421         sb.append(", userName=");
422         sb.append(getUserName());
423         sb.append(", createDate=");
424         sb.append(getCreateDate());
425         sb.append(", modifiedDate=");
426         sb.append(getModifiedDate());
427         sb.append(", parentFolderId=");
428         sb.append(getParentFolderId());
429         sb.append(", name=");
430         sb.append(getName());
431         sb.append(", description=");
432         sb.append(getDescription());
433         sb.append(", lastPostDate=");
434         sb.append(getLastPostDate());
435         sb.append("}");
436 
437         return sb.toString();
438     }
439 
440     public String toXmlString() {
441         StringBuilder sb = new StringBuilder();
442 
443         sb.append("<model><model-name>");
444         sb.append("com.liferay.portlet.documentlibrary.model.DLFolder");
445         sb.append("</model-name>");
446 
447         sb.append(
448             "<column><column-name>uuid</column-name><column-value><![CDATA[");
449         sb.append(getUuid());
450         sb.append("]]></column-value></column>");
451         sb.append(
452             "<column><column-name>folderId</column-name><column-value><![CDATA[");
453         sb.append(getFolderId());
454         sb.append("]]></column-value></column>");
455         sb.append(
456             "<column><column-name>groupId</column-name><column-value><![CDATA[");
457         sb.append(getGroupId());
458         sb.append("]]></column-value></column>");
459         sb.append(
460             "<column><column-name>companyId</column-name><column-value><![CDATA[");
461         sb.append(getCompanyId());
462         sb.append("]]></column-value></column>");
463         sb.append(
464             "<column><column-name>userId</column-name><column-value><![CDATA[");
465         sb.append(getUserId());
466         sb.append("]]></column-value></column>");
467         sb.append(
468             "<column><column-name>userName</column-name><column-value><![CDATA[");
469         sb.append(getUserName());
470         sb.append("]]></column-value></column>");
471         sb.append(
472             "<column><column-name>createDate</column-name><column-value><![CDATA[");
473         sb.append(getCreateDate());
474         sb.append("]]></column-value></column>");
475         sb.append(
476             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
477         sb.append(getModifiedDate());
478         sb.append("]]></column-value></column>");
479         sb.append(
480             "<column><column-name>parentFolderId</column-name><column-value><![CDATA[");
481         sb.append(getParentFolderId());
482         sb.append("]]></column-value></column>");
483         sb.append(
484             "<column><column-name>name</column-name><column-value><![CDATA[");
485         sb.append(getName());
486         sb.append("]]></column-value></column>");
487         sb.append(
488             "<column><column-name>description</column-name><column-value><![CDATA[");
489         sb.append(getDescription());
490         sb.append("]]></column-value></column>");
491         sb.append(
492             "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
493         sb.append(getLastPostDate());
494         sb.append("]]></column-value></column>");
495 
496         sb.append("</model>");
497 
498         return sb.toString();
499     }
500 
501     private String _uuid;
502     private String _originalUuid;
503     private long _folderId;
504     private long _groupId;
505     private long _originalGroupId;
506     private boolean _setOriginalGroupId;
507     private long _companyId;
508     private long _userId;
509     private String _userName;
510     private Date _createDate;
511     private Date _modifiedDate;
512     private long _parentFolderId;
513     private long _originalParentFolderId;
514     private boolean _setOriginalParentFolderId;
515     private String _name;
516     private String _originalName;
517     private String _description;
518     private Date _lastPostDate;
519     private transient ExpandoBridge _expandoBridge;
520 }