1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.documentlibrary.model.impl;
16  
17  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.util.DateUtil;
20  import com.liferay.portal.kernel.util.GetterUtil;
21  import com.liferay.portal.kernel.util.StringBundler;
22  import com.liferay.portal.kernel.util.StringPool;
23  import com.liferay.portal.kernel.workflow.WorkflowConstants;
24  import com.liferay.portal.model.impl.BaseModelImpl;
25  import com.liferay.portal.service.ServiceContext;
26  import com.liferay.portal.util.PortalUtil;
27  
28  import com.liferay.portlet.documentlibrary.model.DLFileVersion;
29  import com.liferay.portlet.documentlibrary.model.DLFileVersionSoap;
30  import com.liferay.portlet.expando.model.ExpandoBridge;
31  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
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="DLFileVersionModelImpl.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 interface is a model that represents the DLFileVersion table in the
53   * database.
54   * </p>
55   *
56   * @author    Brian Wing Shun Chan
57   * @see       DLFileVersionImpl
58   * @see       com.liferay.portlet.documentlibrary.model.DLFileVersion
59   * @see       com.liferay.portlet.documentlibrary.model.DLFileVersionModel
60   * @generated
61   */
62  public class DLFileVersionModelImpl extends BaseModelImpl<DLFileVersion> {
63      public static final String TABLE_NAME = "DLFileVersion";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "fileVersionId", new Integer(Types.BIGINT) },
66              { "groupId", new Integer(Types.BIGINT) },
67              { "companyId", new Integer(Types.BIGINT) },
68              { "userId", new Integer(Types.BIGINT) },
69              { "userName", new Integer(Types.VARCHAR) },
70              { "createDate", new Integer(Types.TIMESTAMP) },
71              { "folderId", new Integer(Types.BIGINT) },
72              { "name", new Integer(Types.VARCHAR) },
73              { "description", new Integer(Types.VARCHAR) },
74              { "version", new Integer(Types.VARCHAR) },
75              { "size_", new Integer(Types.BIGINT) },
76              { "status", new Integer(Types.INTEGER) },
77              { "statusByUserId", new Integer(Types.BIGINT) },
78              { "statusByUserName", new Integer(Types.VARCHAR) },
79              { "statusDate", new Integer(Types.TIMESTAMP) }
80          };
81      public static final String TABLE_SQL_CREATE = "create table DLFileVersion (fileVersionId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,folderId LONG,name VARCHAR(255) null,description STRING null,version VARCHAR(75) null,size_ LONG,status INTEGER,statusByUserId LONG,statusByUserName VARCHAR(75) null,statusDate DATE null)";
82      public static final String TABLE_SQL_DROP = "drop table DLFileVersion";
83      public static final String ORDER_BY_JPQL = " ORDER BY dlFileVersion.folderId DESC, dlFileVersion.name DESC, dlFileVersion.createDate DESC";
84      public static final String ORDER_BY_SQL = " ORDER BY DLFileVersion.folderId DESC, DLFileVersion.name DESC, DLFileVersion.createDate DESC";
85      public static final String DATA_SOURCE = "liferayDataSource";
86      public static final String SESSION_FACTORY = "liferaySessionFactory";
87      public static final String TX_MANAGER = "liferayTransactionManager";
88      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
89                  "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileVersion"),
90              true);
91      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
92                  "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileVersion"),
93              true);
94  
95      public static DLFileVersion toModel(DLFileVersionSoap soapModel) {
96          DLFileVersion model = new DLFileVersionImpl();
97  
98          model.setFileVersionId(soapModel.getFileVersionId());
99          model.setGroupId(soapModel.getGroupId());
100         model.setCompanyId(soapModel.getCompanyId());
101         model.setUserId(soapModel.getUserId());
102         model.setUserName(soapModel.getUserName());
103         model.setCreateDate(soapModel.getCreateDate());
104         model.setFolderId(soapModel.getFolderId());
105         model.setName(soapModel.getName());
106         model.setDescription(soapModel.getDescription());
107         model.setVersion(soapModel.getVersion());
108         model.setSize(soapModel.getSize());
109         model.setStatus(soapModel.getStatus());
110         model.setStatusByUserId(soapModel.getStatusByUserId());
111         model.setStatusByUserName(soapModel.getStatusByUserName());
112         model.setStatusDate(soapModel.getStatusDate());
113 
114         return model;
115     }
116 
117     public static List<DLFileVersion> toModels(DLFileVersionSoap[] soapModels) {
118         List<DLFileVersion> models = new ArrayList<DLFileVersion>(soapModels.length);
119 
120         for (DLFileVersionSoap soapModel : soapModels) {
121             models.add(toModel(soapModel));
122         }
123 
124         return models;
125     }
126 
127     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
128                 "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileVersion"));
129 
130     public DLFileVersionModelImpl() {
131     }
132 
133     public long getPrimaryKey() {
134         return _fileVersionId;
135     }
136 
137     public void setPrimaryKey(long pk) {
138         setFileVersionId(pk);
139     }
140 
141     public Serializable getPrimaryKeyObj() {
142         return new Long(_fileVersionId);
143     }
144 
145     public long getFileVersionId() {
146         return _fileVersionId;
147     }
148 
149     public void setFileVersionId(long fileVersionId) {
150         _fileVersionId = fileVersionId;
151     }
152 
153     public long getGroupId() {
154         return _groupId;
155     }
156 
157     public void setGroupId(long groupId) {
158         _groupId = groupId;
159 
160         if (!_setOriginalGroupId) {
161             _setOriginalGroupId = true;
162 
163             _originalGroupId = groupId;
164         }
165     }
166 
167     public long getOriginalGroupId() {
168         return _originalGroupId;
169     }
170 
171     public long getCompanyId() {
172         return _companyId;
173     }
174 
175     public void setCompanyId(long companyId) {
176         _companyId = companyId;
177     }
178 
179     public long getUserId() {
180         return _userId;
181     }
182 
183     public void setUserId(long userId) {
184         _userId = userId;
185     }
186 
187     public String getUserUuid() throws SystemException {
188         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
189     }
190 
191     public void setUserUuid(String userUuid) {
192         _userUuid = userUuid;
193     }
194 
195     public String getUserName() {
196         if (_userName == null) {
197             return StringPool.BLANK;
198         }
199         else {
200             return _userName;
201         }
202     }
203 
204     public void setUserName(String userName) {
205         _userName = userName;
206     }
207 
208     public Date getCreateDate() {
209         return _createDate;
210     }
211 
212     public void setCreateDate(Date createDate) {
213         _createDate = createDate;
214     }
215 
216     public long getFolderId() {
217         return _folderId;
218     }
219 
220     public void setFolderId(long folderId) {
221         _folderId = folderId;
222 
223         if (!_setOriginalFolderId) {
224             _setOriginalFolderId = true;
225 
226             _originalFolderId = folderId;
227         }
228     }
229 
230     public long getOriginalFolderId() {
231         return _originalFolderId;
232     }
233 
234     public String getName() {
235         if (_name == null) {
236             return StringPool.BLANK;
237         }
238         else {
239             return _name;
240         }
241     }
242 
243     public void setName(String name) {
244         _name = name;
245 
246         if (_originalName == null) {
247             _originalName = name;
248         }
249     }
250 
251     public String getOriginalName() {
252         return GetterUtil.getString(_originalName);
253     }
254 
255     public String getDescription() {
256         if (_description == null) {
257             return StringPool.BLANK;
258         }
259         else {
260             return _description;
261         }
262     }
263 
264     public void setDescription(String description) {
265         _description = description;
266     }
267 
268     public String getVersion() {
269         if (_version == null) {
270             return StringPool.BLANK;
271         }
272         else {
273             return _version;
274         }
275     }
276 
277     public void setVersion(String version) {
278         _version = version;
279 
280         if (_originalVersion == null) {
281             _originalVersion = version;
282         }
283     }
284 
285     public String getOriginalVersion() {
286         return GetterUtil.getString(_originalVersion);
287     }
288 
289     public long getSize() {
290         return _size;
291     }
292 
293     public void setSize(long size) {
294         _size = size;
295     }
296 
297     public int getStatus() {
298         return _status;
299     }
300 
301     public void setStatus(int status) {
302         _status = status;
303     }
304 
305     public long getStatusByUserId() {
306         return _statusByUserId;
307     }
308 
309     public void setStatusByUserId(long statusByUserId) {
310         _statusByUserId = statusByUserId;
311     }
312 
313     public String getStatusByUserUuid() throws SystemException {
314         return PortalUtil.getUserValue(getStatusByUserId(), "uuid",
315             _statusByUserUuid);
316     }
317 
318     public void setStatusByUserUuid(String statusByUserUuid) {
319         _statusByUserUuid = statusByUserUuid;
320     }
321 
322     public String getStatusByUserName() {
323         if (_statusByUserName == null) {
324             return StringPool.BLANK;
325         }
326         else {
327             return _statusByUserName;
328         }
329     }
330 
331     public void setStatusByUserName(String statusByUserName) {
332         _statusByUserName = statusByUserName;
333     }
334 
335     public Date getStatusDate() {
336         return _statusDate;
337     }
338 
339     public void setStatusDate(Date statusDate) {
340         _statusDate = statusDate;
341     }
342 
343     public boolean isApproved() {
344         if (getStatus() == WorkflowConstants.STATUS_APPROVED) {
345             return true;
346         }
347         else {
348             return false;
349         }
350     }
351 
352     public boolean isDraft() {
353         if (getStatus() == WorkflowConstants.STATUS_DRAFT) {
354             return true;
355         }
356         else {
357             return false;
358         }
359     }
360 
361     public boolean isExpired() {
362         if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
363             return true;
364         }
365         else {
366             return false;
367         }
368     }
369 
370     public boolean isPending() {
371         if (getStatus() == WorkflowConstants.STATUS_PENDING) {
372             return true;
373         }
374         else {
375             return false;
376         }
377     }
378 
379     public DLFileVersion toEscapedModel() {
380         if (isEscapedModel()) {
381             return (DLFileVersion)this;
382         }
383         else {
384             return (DLFileVersion)Proxy.newProxyInstance(DLFileVersion.class.getClassLoader(),
385                 new Class[] { DLFileVersion.class },
386                 new AutoEscapeBeanHandler(this));
387         }
388     }
389 
390     public ExpandoBridge getExpandoBridge() {
391         if (_expandoBridge == null) {
392             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
393                     DLFileVersion.class.getName(), getPrimaryKey());
394         }
395 
396         return _expandoBridge;
397     }
398 
399     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
400         getExpandoBridge().setAttributes(serviceContext);
401     }
402 
403     public Object clone() {
404         DLFileVersionImpl clone = new DLFileVersionImpl();
405 
406         clone.setFileVersionId(getFileVersionId());
407         clone.setGroupId(getGroupId());
408         clone.setCompanyId(getCompanyId());
409         clone.setUserId(getUserId());
410         clone.setUserName(getUserName());
411         clone.setCreateDate(getCreateDate());
412         clone.setFolderId(getFolderId());
413         clone.setName(getName());
414         clone.setDescription(getDescription());
415         clone.setVersion(getVersion());
416         clone.setSize(getSize());
417         clone.setStatus(getStatus());
418         clone.setStatusByUserId(getStatusByUserId());
419         clone.setStatusByUserName(getStatusByUserName());
420         clone.setStatusDate(getStatusDate());
421 
422         return clone;
423     }
424 
425     public int compareTo(DLFileVersion dlFileVersion) {
426         int value = 0;
427 
428         if (getFolderId() < dlFileVersion.getFolderId()) {
429             value = -1;
430         }
431         else if (getFolderId() > dlFileVersion.getFolderId()) {
432             value = 1;
433         }
434         else {
435             value = 0;
436         }
437 
438         value = value * -1;
439 
440         if (value != 0) {
441             return value;
442         }
443 
444         value = getName().compareTo(dlFileVersion.getName());
445 
446         value = value * -1;
447 
448         if (value != 0) {
449             return value;
450         }
451 
452         value = DateUtil.compareTo(getCreateDate(),
453                 dlFileVersion.getCreateDate());
454 
455         value = value * -1;
456 
457         if (value != 0) {
458             return value;
459         }
460 
461         return 0;
462     }
463 
464     public boolean equals(Object obj) {
465         if (obj == null) {
466             return false;
467         }
468 
469         DLFileVersion dlFileVersion = null;
470 
471         try {
472             dlFileVersion = (DLFileVersion)obj;
473         }
474         catch (ClassCastException cce) {
475             return false;
476         }
477 
478         long pk = dlFileVersion.getPrimaryKey();
479 
480         if (getPrimaryKey() == pk) {
481             return true;
482         }
483         else {
484             return false;
485         }
486     }
487 
488     public int hashCode() {
489         return (int)getPrimaryKey();
490     }
491 
492     public String toString() {
493         StringBundler sb = new StringBundler(31);
494 
495         sb.append("{fileVersionId=");
496         sb.append(getFileVersionId());
497         sb.append(", groupId=");
498         sb.append(getGroupId());
499         sb.append(", companyId=");
500         sb.append(getCompanyId());
501         sb.append(", userId=");
502         sb.append(getUserId());
503         sb.append(", userName=");
504         sb.append(getUserName());
505         sb.append(", createDate=");
506         sb.append(getCreateDate());
507         sb.append(", folderId=");
508         sb.append(getFolderId());
509         sb.append(", name=");
510         sb.append(getName());
511         sb.append(", description=");
512         sb.append(getDescription());
513         sb.append(", version=");
514         sb.append(getVersion());
515         sb.append(", size=");
516         sb.append(getSize());
517         sb.append(", status=");
518         sb.append(getStatus());
519         sb.append(", statusByUserId=");
520         sb.append(getStatusByUserId());
521         sb.append(", statusByUserName=");
522         sb.append(getStatusByUserName());
523         sb.append(", statusDate=");
524         sb.append(getStatusDate());
525         sb.append("}");
526 
527         return sb.toString();
528     }
529 
530     public String toXmlString() {
531         StringBundler sb = new StringBundler(49);
532 
533         sb.append("<model><model-name>");
534         sb.append("com.liferay.portlet.documentlibrary.model.DLFileVersion");
535         sb.append("</model-name>");
536 
537         sb.append(
538             "<column><column-name>fileVersionId</column-name><column-value><![CDATA[");
539         sb.append(getFileVersionId());
540         sb.append("]]></column-value></column>");
541         sb.append(
542             "<column><column-name>groupId</column-name><column-value><![CDATA[");
543         sb.append(getGroupId());
544         sb.append("]]></column-value></column>");
545         sb.append(
546             "<column><column-name>companyId</column-name><column-value><![CDATA[");
547         sb.append(getCompanyId());
548         sb.append("]]></column-value></column>");
549         sb.append(
550             "<column><column-name>userId</column-name><column-value><![CDATA[");
551         sb.append(getUserId());
552         sb.append("]]></column-value></column>");
553         sb.append(
554             "<column><column-name>userName</column-name><column-value><![CDATA[");
555         sb.append(getUserName());
556         sb.append("]]></column-value></column>");
557         sb.append(
558             "<column><column-name>createDate</column-name><column-value><![CDATA[");
559         sb.append(getCreateDate());
560         sb.append("]]></column-value></column>");
561         sb.append(
562             "<column><column-name>folderId</column-name><column-value><![CDATA[");
563         sb.append(getFolderId());
564         sb.append("]]></column-value></column>");
565         sb.append(
566             "<column><column-name>name</column-name><column-value><![CDATA[");
567         sb.append(getName());
568         sb.append("]]></column-value></column>");
569         sb.append(
570             "<column><column-name>description</column-name><column-value><![CDATA[");
571         sb.append(getDescription());
572         sb.append("]]></column-value></column>");
573         sb.append(
574             "<column><column-name>version</column-name><column-value><![CDATA[");
575         sb.append(getVersion());
576         sb.append("]]></column-value></column>");
577         sb.append(
578             "<column><column-name>size</column-name><column-value><![CDATA[");
579         sb.append(getSize());
580         sb.append("]]></column-value></column>");
581         sb.append(
582             "<column><column-name>status</column-name><column-value><![CDATA[");
583         sb.append(getStatus());
584         sb.append("]]></column-value></column>");
585         sb.append(
586             "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
587         sb.append(getStatusByUserId());
588         sb.append("]]></column-value></column>");
589         sb.append(
590             "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
591         sb.append(getStatusByUserName());
592         sb.append("]]></column-value></column>");
593         sb.append(
594             "<column><column-name>statusDate</column-name><column-value><![CDATA[");
595         sb.append(getStatusDate());
596         sb.append("]]></column-value></column>");
597 
598         sb.append("</model>");
599 
600         return sb.toString();
601     }
602 
603     private long _fileVersionId;
604     private long _groupId;
605     private long _originalGroupId;
606     private boolean _setOriginalGroupId;
607     private long _companyId;
608     private long _userId;
609     private String _userUuid;
610     private String _userName;
611     private Date _createDate;
612     private long _folderId;
613     private long _originalFolderId;
614     private boolean _setOriginalFolderId;
615     private String _name;
616     private String _originalName;
617     private String _description;
618     private String _version;
619     private String _originalVersion;
620     private long _size;
621     private int _status;
622     private long _statusByUserId;
623     private String _statusByUserUuid;
624     private String _statusByUserName;
625     private Date _statusDate;
626     private transient ExpandoBridge _expandoBridge;
627 }