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.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.kernel.util.HtmlUtil;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.util.PortalUtil;
31  
32  import com.liferay.portlet.documentlibrary.model.DLFolder;
33  import com.liferay.portlet.documentlibrary.model.DLFolderSoap;
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 getUserUuid() throws SystemException {
221         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
222     }
223 
224     public void setUserUuid(String userUuid) {
225         _userUuid = userUuid;
226     }
227 
228     public String getUserName() {
229         return GetterUtil.getString(_userName);
230     }
231 
232     public void setUserName(String userName) {
233         _userName = userName;
234     }
235 
236     public Date getCreateDate() {
237         return _createDate;
238     }
239 
240     public void setCreateDate(Date createDate) {
241         _createDate = createDate;
242     }
243 
244     public Date getModifiedDate() {
245         return _modifiedDate;
246     }
247 
248     public void setModifiedDate(Date modifiedDate) {
249         _modifiedDate = modifiedDate;
250     }
251 
252     public long getParentFolderId() {
253         return _parentFolderId;
254     }
255 
256     public void setParentFolderId(long parentFolderId) {
257         _parentFolderId = parentFolderId;
258 
259         if (!_setOriginalParentFolderId) {
260             _setOriginalParentFolderId = true;
261 
262             _originalParentFolderId = parentFolderId;
263         }
264     }
265 
266     public long getOriginalParentFolderId() {
267         return _originalParentFolderId;
268     }
269 
270     public String getName() {
271         return GetterUtil.getString(_name);
272     }
273 
274     public void setName(String name) {
275         _name = name;
276 
277         if (_originalName == null) {
278             _originalName = name;
279         }
280     }
281 
282     public String getOriginalName() {
283         return GetterUtil.getString(_originalName);
284     }
285 
286     public String getDescription() {
287         return GetterUtil.getString(_description);
288     }
289 
290     public void setDescription(String description) {
291         _description = description;
292     }
293 
294     public Date getLastPostDate() {
295         return _lastPostDate;
296     }
297 
298     public void setLastPostDate(Date lastPostDate) {
299         _lastPostDate = lastPostDate;
300     }
301 
302     public DLFolder toEscapedModel() {
303         if (isEscapedModel()) {
304             return (DLFolder)this;
305         }
306         else {
307             DLFolder model = new DLFolderImpl();
308 
309             model.setNew(isNew());
310             model.setEscapedModel(true);
311 
312             model.setUuid(HtmlUtil.escape(getUuid()));
313             model.setFolderId(getFolderId());
314             model.setGroupId(getGroupId());
315             model.setCompanyId(getCompanyId());
316             model.setUserId(getUserId());
317             model.setUserName(HtmlUtil.escape(getUserName()));
318             model.setCreateDate(getCreateDate());
319             model.setModifiedDate(getModifiedDate());
320             model.setParentFolderId(getParentFolderId());
321             model.setName(HtmlUtil.escape(getName()));
322             model.setDescription(HtmlUtil.escape(getDescription()));
323             model.setLastPostDate(getLastPostDate());
324 
325             model = (DLFolder)Proxy.newProxyInstance(DLFolder.class.getClassLoader(),
326                     new Class[] { DLFolder.class },
327                     new ReadOnlyBeanHandler(model));
328 
329             return model;
330         }
331     }
332 
333     public Object clone() {
334         DLFolderImpl clone = new DLFolderImpl();
335 
336         clone.setUuid(getUuid());
337         clone.setFolderId(getFolderId());
338         clone.setGroupId(getGroupId());
339         clone.setCompanyId(getCompanyId());
340         clone.setUserId(getUserId());
341         clone.setUserName(getUserName());
342         clone.setCreateDate(getCreateDate());
343         clone.setModifiedDate(getModifiedDate());
344         clone.setParentFolderId(getParentFolderId());
345         clone.setName(getName());
346         clone.setDescription(getDescription());
347         clone.setLastPostDate(getLastPostDate());
348 
349         return clone;
350     }
351 
352     public int compareTo(DLFolder dlFolder) {
353         int value = 0;
354 
355         if (getParentFolderId() < dlFolder.getParentFolderId()) {
356             value = -1;
357         }
358         else if (getParentFolderId() > dlFolder.getParentFolderId()) {
359             value = 1;
360         }
361         else {
362             value = 0;
363         }
364 
365         if (value != 0) {
366             return value;
367         }
368 
369         value = getName().toLowerCase()
370                     .compareTo(dlFolder.getName().toLowerCase());
371 
372         if (value != 0) {
373             return value;
374         }
375 
376         return 0;
377     }
378 
379     public boolean equals(Object obj) {
380         if (obj == null) {
381             return false;
382         }
383 
384         DLFolder dlFolder = null;
385 
386         try {
387             dlFolder = (DLFolder)obj;
388         }
389         catch (ClassCastException cce) {
390             return false;
391         }
392 
393         long pk = dlFolder.getPrimaryKey();
394 
395         if (getPrimaryKey() == pk) {
396             return true;
397         }
398         else {
399             return false;
400         }
401     }
402 
403     public int hashCode() {
404         return (int)getPrimaryKey();
405     }
406 
407     public String toString() {
408         StringBuilder sb = new StringBuilder();
409 
410         sb.append("{uuid=");
411         sb.append(getUuid());
412         sb.append(", folderId=");
413         sb.append(getFolderId());
414         sb.append(", groupId=");
415         sb.append(getGroupId());
416         sb.append(", companyId=");
417         sb.append(getCompanyId());
418         sb.append(", userId=");
419         sb.append(getUserId());
420         sb.append(", userName=");
421         sb.append(getUserName());
422         sb.append(", createDate=");
423         sb.append(getCreateDate());
424         sb.append(", modifiedDate=");
425         sb.append(getModifiedDate());
426         sb.append(", parentFolderId=");
427         sb.append(getParentFolderId());
428         sb.append(", name=");
429         sb.append(getName());
430         sb.append(", description=");
431         sb.append(getDescription());
432         sb.append(", lastPostDate=");
433         sb.append(getLastPostDate());
434         sb.append("}");
435 
436         return sb.toString();
437     }
438 
439     public String toXmlString() {
440         StringBuilder sb = new StringBuilder();
441 
442         sb.append("<model><model-name>");
443         sb.append("com.liferay.portlet.documentlibrary.model.DLFolder");
444         sb.append("</model-name>");
445 
446         sb.append(
447             "<column><column-name>uuid</column-name><column-value><![CDATA[");
448         sb.append(getUuid());
449         sb.append("]]></column-value></column>");
450         sb.append(
451             "<column><column-name>folderId</column-name><column-value><![CDATA[");
452         sb.append(getFolderId());
453         sb.append("]]></column-value></column>");
454         sb.append(
455             "<column><column-name>groupId</column-name><column-value><![CDATA[");
456         sb.append(getGroupId());
457         sb.append("]]></column-value></column>");
458         sb.append(
459             "<column><column-name>companyId</column-name><column-value><![CDATA[");
460         sb.append(getCompanyId());
461         sb.append("]]></column-value></column>");
462         sb.append(
463             "<column><column-name>userId</column-name><column-value><![CDATA[");
464         sb.append(getUserId());
465         sb.append("]]></column-value></column>");
466         sb.append(
467             "<column><column-name>userName</column-name><column-value><![CDATA[");
468         sb.append(getUserName());
469         sb.append("]]></column-value></column>");
470         sb.append(
471             "<column><column-name>createDate</column-name><column-value><![CDATA[");
472         sb.append(getCreateDate());
473         sb.append("]]></column-value></column>");
474         sb.append(
475             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
476         sb.append(getModifiedDate());
477         sb.append("]]></column-value></column>");
478         sb.append(
479             "<column><column-name>parentFolderId</column-name><column-value><![CDATA[");
480         sb.append(getParentFolderId());
481         sb.append("]]></column-value></column>");
482         sb.append(
483             "<column><column-name>name</column-name><column-value><![CDATA[");
484         sb.append(getName());
485         sb.append("]]></column-value></column>");
486         sb.append(
487             "<column><column-name>description</column-name><column-value><![CDATA[");
488         sb.append(getDescription());
489         sb.append("]]></column-value></column>");
490         sb.append(
491             "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
492         sb.append(getLastPostDate());
493         sb.append("]]></column-value></column>");
494 
495         sb.append("</model>");
496 
497         return sb.toString();
498     }
499 
500     private String _uuid;
501     private String _originalUuid;
502     private long _folderId;
503     private long _groupId;
504     private long _originalGroupId;
505     private boolean _setOriginalGroupId;
506     private long _companyId;
507     private long _userId;
508     private String _userUuid;
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 }