1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.documentlibrary.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.impl.BaseModelImpl;
26  
27  import com.liferay.portlet.documentlibrary.model.DLFolder;
28  import com.liferay.portlet.documentlibrary.model.DLFolderSoap;
29  import com.liferay.portlet.expando.model.ExpandoBridge;
30  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.Date;
40  import java.util.List;
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.model.DLFolder
58   * @see com.liferay.portlet.documentlibrary.model.DLFolderModel
59   * @see com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl
60   *
61   */
62  public class DLFolderModelImpl extends BaseModelImpl<DLFolder> {
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 String DATA_SOURCE = "liferayDataSource";
103     public static final String SESSION_FACTORY = "liferaySessionFactory";
104     public static final String TX_MANAGER = "liferayTransactionManager";
105     public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
106                 "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFolder"),
107             true);
108     public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
109                 "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFolder"),
110             true);
111 
112     public static DLFolder toModel(DLFolderSoap soapModel) {
113         DLFolder model = new DLFolderImpl();
114 
115         model.setUuid(soapModel.getUuid());
116         model.setFolderId(soapModel.getFolderId());
117         model.setGroupId(soapModel.getGroupId());
118         model.setCompanyId(soapModel.getCompanyId());
119         model.setUserId(soapModel.getUserId());
120         model.setUserName(soapModel.getUserName());
121         model.setCreateDate(soapModel.getCreateDate());
122         model.setModifiedDate(soapModel.getModifiedDate());
123         model.setParentFolderId(soapModel.getParentFolderId());
124         model.setName(soapModel.getName());
125         model.setDescription(soapModel.getDescription());
126         model.setLastPostDate(soapModel.getLastPostDate());
127 
128         return model;
129     }
130 
131     public static List<DLFolder> toModels(DLFolderSoap[] soapModels) {
132         List<DLFolder> models = new ArrayList<DLFolder>(soapModels.length);
133 
134         for (DLFolderSoap soapModel : soapModels) {
135             models.add(toModel(soapModel));
136         }
137 
138         return models;
139     }
140 
141     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
142                 "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFolder"));
143 
144     public DLFolderModelImpl() {
145     }
146 
147     public long getPrimaryKey() {
148         return _folderId;
149     }
150 
151     public void setPrimaryKey(long pk) {
152         setFolderId(pk);
153     }
154 
155     public Serializable getPrimaryKeyObj() {
156         return new Long(_folderId);
157     }
158 
159     public String getUuid() {
160         return GetterUtil.getString(_uuid);
161     }
162 
163     public void setUuid(String uuid) {
164         _uuid = uuid;
165 
166         if (_originalUuid == null) {
167             _originalUuid = uuid;
168         }
169     }
170 
171     public String getOriginalUuid() {
172         return GetterUtil.getString(_originalUuid);
173     }
174 
175     public long getFolderId() {
176         return _folderId;
177     }
178 
179     public void setFolderId(long folderId) {
180         _folderId = folderId;
181     }
182 
183     public long getGroupId() {
184         return _groupId;
185     }
186 
187     public void setGroupId(long groupId) {
188         _groupId = groupId;
189 
190         if (!_setOriginalGroupId) {
191             _setOriginalGroupId = true;
192 
193             _originalGroupId = groupId;
194         }
195     }
196 
197     public long getOriginalGroupId() {
198         return _originalGroupId;
199     }
200 
201     public long getCompanyId() {
202         return _companyId;
203     }
204 
205     public void setCompanyId(long companyId) {
206         _companyId = companyId;
207     }
208 
209     public long getUserId() {
210         return _userId;
211     }
212 
213     public void setUserId(long userId) {
214         _userId = userId;
215     }
216 
217     public String getUserName() {
218         return GetterUtil.getString(_userName);
219     }
220 
221     public void setUserName(String userName) {
222         _userName = userName;
223     }
224 
225     public Date getCreateDate() {
226         return _createDate;
227     }
228 
229     public void setCreateDate(Date createDate) {
230         _createDate = createDate;
231     }
232 
233     public Date getModifiedDate() {
234         return _modifiedDate;
235     }
236 
237     public void setModifiedDate(Date modifiedDate) {
238         _modifiedDate = modifiedDate;
239     }
240 
241     public long getParentFolderId() {
242         return _parentFolderId;
243     }
244 
245     public void setParentFolderId(long parentFolderId) {
246         _parentFolderId = parentFolderId;
247 
248         if (!_setOriginalParentFolderId) {
249             _setOriginalParentFolderId = true;
250 
251             _originalParentFolderId = parentFolderId;
252         }
253     }
254 
255     public long getOriginalParentFolderId() {
256         return _originalParentFolderId;
257     }
258 
259     public String getName() {
260         return GetterUtil.getString(_name);
261     }
262 
263     public void setName(String name) {
264         _name = name;
265 
266         if (_originalName == null) {
267             _originalName = name;
268         }
269     }
270 
271     public String getOriginalName() {
272         return GetterUtil.getString(_originalName);
273     }
274 
275     public String getDescription() {
276         return GetterUtil.getString(_description);
277     }
278 
279     public void setDescription(String description) {
280         _description = description;
281     }
282 
283     public Date getLastPostDate() {
284         return _lastPostDate;
285     }
286 
287     public void setLastPostDate(Date lastPostDate) {
288         _lastPostDate = lastPostDate;
289     }
290 
291     public DLFolder toEscapedModel() {
292         if (isEscapedModel()) {
293             return (DLFolder)this;
294         }
295         else {
296             DLFolder model = new DLFolderImpl();
297 
298             model.setNew(isNew());
299             model.setEscapedModel(true);
300 
301             model.setUuid(HtmlUtil.escape(getUuid()));
302             model.setFolderId(getFolderId());
303             model.setGroupId(getGroupId());
304             model.setCompanyId(getCompanyId());
305             model.setUserId(getUserId());
306             model.setUserName(HtmlUtil.escape(getUserName()));
307             model.setCreateDate(getCreateDate());
308             model.setModifiedDate(getModifiedDate());
309             model.setParentFolderId(getParentFolderId());
310             model.setName(HtmlUtil.escape(getName()));
311             model.setDescription(HtmlUtil.escape(getDescription()));
312             model.setLastPostDate(getLastPostDate());
313 
314             model = (DLFolder)Proxy.newProxyInstance(DLFolder.class.getClassLoader(),
315                     new Class[] { DLFolder.class },
316                     new ReadOnlyBeanHandler(model));
317 
318             return model;
319         }
320     }
321 
322     public ExpandoBridge getExpandoBridge() {
323         if (_expandoBridge == null) {
324             _expandoBridge = new ExpandoBridgeImpl(DLFolder.class.getName(),
325                     getPrimaryKey());
326         }
327 
328         return _expandoBridge;
329     }
330 
331     public Object clone() {
332         DLFolderImpl clone = new DLFolderImpl();
333 
334         clone.setUuid(getUuid());
335         clone.setFolderId(getFolderId());
336         clone.setGroupId(getGroupId());
337         clone.setCompanyId(getCompanyId());
338         clone.setUserId(getUserId());
339         clone.setUserName(getUserName());
340         clone.setCreateDate(getCreateDate());
341         clone.setModifiedDate(getModifiedDate());
342         clone.setParentFolderId(getParentFolderId());
343         clone.setName(getName());
344         clone.setDescription(getDescription());
345         clone.setLastPostDate(getLastPostDate());
346 
347         return clone;
348     }
349 
350     public int compareTo(DLFolder dlFolder) {
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         DLFolder dlFolder = null;
383 
384         try {
385             dlFolder = (DLFolder)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     public String toString() {
406         StringBuilder sb = new StringBuilder();
407 
408         sb.append("{uuid=");
409         sb.append(getUuid());
410         sb.append(", folderId=");
411         sb.append(getFolderId());
412         sb.append(", groupId=");
413         sb.append(getGroupId());
414         sb.append(", companyId=");
415         sb.append(getCompanyId());
416         sb.append(", userId=");
417         sb.append(getUserId());
418         sb.append(", userName=");
419         sb.append(getUserName());
420         sb.append(", createDate=");
421         sb.append(getCreateDate());
422         sb.append(", modifiedDate=");
423         sb.append(getModifiedDate());
424         sb.append(", parentFolderId=");
425         sb.append(getParentFolderId());
426         sb.append(", name=");
427         sb.append(getName());
428         sb.append(", description=");
429         sb.append(getDescription());
430         sb.append(", lastPostDate=");
431         sb.append(getLastPostDate());
432         sb.append("}");
433 
434         return sb.toString();
435     }
436 
437     public String toXmlString() {
438         StringBuilder sb = new StringBuilder();
439 
440         sb.append("<model><model-name>");
441         sb.append("com.liferay.portlet.documentlibrary.model.DLFolder");
442         sb.append("</model-name>");
443 
444         sb.append(
445             "<column><column-name>uuid</column-name><column-value><![CDATA[");
446         sb.append(getUuid());
447         sb.append("]]></column-value></column>");
448         sb.append(
449             "<column><column-name>folderId</column-name><column-value><![CDATA[");
450         sb.append(getFolderId());
451         sb.append("]]></column-value></column>");
452         sb.append(
453             "<column><column-name>groupId</column-name><column-value><![CDATA[");
454         sb.append(getGroupId());
455         sb.append("]]></column-value></column>");
456         sb.append(
457             "<column><column-name>companyId</column-name><column-value><![CDATA[");
458         sb.append(getCompanyId());
459         sb.append("]]></column-value></column>");
460         sb.append(
461             "<column><column-name>userId</column-name><column-value><![CDATA[");
462         sb.append(getUserId());
463         sb.append("]]></column-value></column>");
464         sb.append(
465             "<column><column-name>userName</column-name><column-value><![CDATA[");
466         sb.append(getUserName());
467         sb.append("]]></column-value></column>");
468         sb.append(
469             "<column><column-name>createDate</column-name><column-value><![CDATA[");
470         sb.append(getCreateDate());
471         sb.append("]]></column-value></column>");
472         sb.append(
473             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
474         sb.append(getModifiedDate());
475         sb.append("]]></column-value></column>");
476         sb.append(
477             "<column><column-name>parentFolderId</column-name><column-value><![CDATA[");
478         sb.append(getParentFolderId());
479         sb.append("]]></column-value></column>");
480         sb.append(
481             "<column><column-name>name</column-name><column-value><![CDATA[");
482         sb.append(getName());
483         sb.append("]]></column-value></column>");
484         sb.append(
485             "<column><column-name>description</column-name><column-value><![CDATA[");
486         sb.append(getDescription());
487         sb.append("]]></column-value></column>");
488         sb.append(
489             "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
490         sb.append(getLastPostDate());
491         sb.append("]]></column-value></column>");
492 
493         sb.append("</model>");
494 
495         return sb.toString();
496     }
497 
498     private String _uuid;
499     private String _originalUuid;
500     private long _folderId;
501     private long _groupId;
502     private long _originalGroupId;
503     private boolean _setOriginalGroupId;
504     private long _companyId;
505     private long _userId;
506     private String _userName;
507     private Date _createDate;
508     private Date _modifiedDate;
509     private long _parentFolderId;
510     private long _originalParentFolderId;
511     private boolean _setOriginalParentFolderId;
512     private String _name;
513     private String _originalName;
514     private String _description;
515     private Date _lastPostDate;
516     private transient ExpandoBridge _expandoBridge;
517 }