001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.documentlibrary.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.DateUtil;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
022    import com.liferay.portal.kernel.util.StringPool;
023    import com.liferay.portal.kernel.workflow.WorkflowConstants;
024    import com.liferay.portal.model.impl.BaseModelImpl;
025    import com.liferay.portal.service.ServiceContext;
026    import com.liferay.portal.util.PortalUtil;
027    
028    import com.liferay.portlet.documentlibrary.model.DLFileVersion;
029    import com.liferay.portlet.documentlibrary.model.DLFileVersionModel;
030    import com.liferay.portlet.documentlibrary.model.DLFileVersionSoap;
031    import com.liferay.portlet.expando.model.ExpandoBridge;
032    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
033    
034    import java.io.Serializable;
035    
036    import java.lang.reflect.Proxy;
037    
038    import java.sql.Types;
039    
040    import java.util.ArrayList;
041    import java.util.Date;
042    import java.util.List;
043    
044    /**
045     * The base model implementation for the DLFileVersion service. Represents a row in the "DLFileVersion" database table, with each column mapped to a property of this class.
046     *
047     * <p>
048     * This implementation and its corresponding interface {@link com.liferay.portlet.documentlibrary.model.DLFileVersionModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DLFileVersionImpl}.
049     * </p>
050     *
051     * <p>
052     * Never modify or reference this class directly. All methods that expect a d l file version model instance should use the {@link com.liferay.portlet.documentlibrary.model.DLFileVersion} interface instead.
053     * </p>
054     *
055     * @author Brian Wing Shun Chan
056     * @see DLFileVersionImpl
057     * @see com.liferay.portlet.documentlibrary.model.DLFileVersion
058     * @see com.liferay.portlet.documentlibrary.model.DLFileVersionModel
059     * @generated
060     */
061    public class DLFileVersionModelImpl extends BaseModelImpl<DLFileVersion>
062            implements DLFileVersionModel {
063            public static final String TABLE_NAME = "DLFileVersion";
064            public static final Object[][] TABLE_COLUMNS = {
065                            { "fileVersionId", new Integer(Types.BIGINT) },
066                            { "groupId", new Integer(Types.BIGINT) },
067                            { "companyId", new Integer(Types.BIGINT) },
068                            { "userId", new Integer(Types.BIGINT) },
069                            { "userName", new Integer(Types.VARCHAR) },
070                            { "createDate", new Integer(Types.TIMESTAMP) },
071                            { "folderId", new Integer(Types.BIGINT) },
072                            { "name", new Integer(Types.VARCHAR) },
073                            { "extension", new Integer(Types.VARCHAR) },
074                            { "title", new Integer(Types.VARCHAR) },
075                            { "description", new Integer(Types.VARCHAR) },
076                            { "changeLog", new Integer(Types.VARCHAR) },
077                            { "extraSettings", new Integer(Types.VARCHAR) },
078                            { "version", new Integer(Types.VARCHAR) },
079                            { "size_", new Integer(Types.BIGINT) },
080                            { "status", new Integer(Types.INTEGER) },
081                            { "statusByUserId", new Integer(Types.BIGINT) },
082                            { "statusByUserName", new Integer(Types.VARCHAR) },
083                            { "statusDate", new Integer(Types.TIMESTAMP) }
084                    };
085            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,extension VARCHAR(75) null,title VARCHAR(75) null,description STRING null,changeLog VARCHAR(75) null,extraSettings VARCHAR(75) null,version VARCHAR(75) null,size_ LONG,status INTEGER,statusByUserId LONG,statusByUserName VARCHAR(75) null,statusDate DATE null)";
086            public static final String TABLE_SQL_DROP = "drop table DLFileVersion";
087            public static final String ORDER_BY_JPQL = " ORDER BY dlFileVersion.folderId DESC, dlFileVersion.name DESC, dlFileVersion.createDate DESC";
088            public static final String ORDER_BY_SQL = " ORDER BY DLFileVersion.folderId DESC, DLFileVersion.name DESC, DLFileVersion.createDate DESC";
089            public static final String DATA_SOURCE = "liferayDataSource";
090            public static final String SESSION_FACTORY = "liferaySessionFactory";
091            public static final String TX_MANAGER = "liferayTransactionManager";
092            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
093                                    "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileVersion"),
094                            true);
095            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
096                                    "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileVersion"),
097                            true);
098    
099            /**
100             * Converts the soap model instance into a normal model instance.
101             *
102             * @param soapModel the soap model instance to convert
103             * @return the normal model instance
104             */
105            public static DLFileVersion toModel(DLFileVersionSoap soapModel) {
106                    DLFileVersion model = new DLFileVersionImpl();
107    
108                    model.setFileVersionId(soapModel.getFileVersionId());
109                    model.setGroupId(soapModel.getGroupId());
110                    model.setCompanyId(soapModel.getCompanyId());
111                    model.setUserId(soapModel.getUserId());
112                    model.setUserName(soapModel.getUserName());
113                    model.setCreateDate(soapModel.getCreateDate());
114                    model.setFolderId(soapModel.getFolderId());
115                    model.setName(soapModel.getName());
116                    model.setExtension(soapModel.getExtension());
117                    model.setTitle(soapModel.getTitle());
118                    model.setDescription(soapModel.getDescription());
119                    model.setChangeLog(soapModel.getChangeLog());
120                    model.setExtraSettings(soapModel.getExtraSettings());
121                    model.setVersion(soapModel.getVersion());
122                    model.setSize(soapModel.getSize());
123                    model.setStatus(soapModel.getStatus());
124                    model.setStatusByUserId(soapModel.getStatusByUserId());
125                    model.setStatusByUserName(soapModel.getStatusByUserName());
126                    model.setStatusDate(soapModel.getStatusDate());
127    
128                    return model;
129            }
130    
131            /**
132             * Converts the soap model instances into normal model instances.
133             *
134             * @param soapModels the soap model instances to convert
135             * @return the normal model instances
136             */
137            public static List<DLFileVersion> toModels(DLFileVersionSoap[] soapModels) {
138                    List<DLFileVersion> models = new ArrayList<DLFileVersion>(soapModels.length);
139    
140                    for (DLFileVersionSoap soapModel : soapModels) {
141                            models.add(toModel(soapModel));
142                    }
143    
144                    return models;
145            }
146    
147            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
148                                    "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileVersion"));
149    
150            public DLFileVersionModelImpl() {
151            }
152    
153            public long getPrimaryKey() {
154                    return _fileVersionId;
155            }
156    
157            public void setPrimaryKey(long pk) {
158                    setFileVersionId(pk);
159            }
160    
161            public Serializable getPrimaryKeyObj() {
162                    return new Long(_fileVersionId);
163            }
164    
165            public long getFileVersionId() {
166                    return _fileVersionId;
167            }
168    
169            public void setFileVersionId(long fileVersionId) {
170                    _fileVersionId = fileVersionId;
171            }
172    
173            public long getGroupId() {
174                    return _groupId;
175            }
176    
177            public void setGroupId(long groupId) {
178                    _groupId = groupId;
179    
180                    if (!_setOriginalGroupId) {
181                            _setOriginalGroupId = true;
182    
183                            _originalGroupId = groupId;
184                    }
185            }
186    
187            public long getOriginalGroupId() {
188                    return _originalGroupId;
189            }
190    
191            public long getCompanyId() {
192                    return _companyId;
193            }
194    
195            public void setCompanyId(long companyId) {
196                    _companyId = companyId;
197            }
198    
199            public long getUserId() {
200                    return _userId;
201            }
202    
203            public void setUserId(long userId) {
204                    _userId = userId;
205            }
206    
207            public String getUserUuid() throws SystemException {
208                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
209            }
210    
211            public void setUserUuid(String userUuid) {
212                    _userUuid = userUuid;
213            }
214    
215            public String getUserName() {
216                    if (_userName == null) {
217                            return StringPool.BLANK;
218                    }
219                    else {
220                            return _userName;
221                    }
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 long getFolderId() {
237                    return _folderId;
238            }
239    
240            public void setFolderId(long folderId) {
241                    _folderId = folderId;
242    
243                    if (!_setOriginalFolderId) {
244                            _setOriginalFolderId = true;
245    
246                            _originalFolderId = folderId;
247                    }
248            }
249    
250            public long getOriginalFolderId() {
251                    return _originalFolderId;
252            }
253    
254            public String getName() {
255                    if (_name == null) {
256                            return StringPool.BLANK;
257                    }
258                    else {
259                            return _name;
260                    }
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 getExtension() {
276                    if (_extension == null) {
277                            return StringPool.BLANK;
278                    }
279                    else {
280                            return _extension;
281                    }
282            }
283    
284            public void setExtension(String extension) {
285                    _extension = extension;
286            }
287    
288            public String getTitle() {
289                    if (_title == null) {
290                            return StringPool.BLANK;
291                    }
292                    else {
293                            return _title;
294                    }
295            }
296    
297            public void setTitle(String title) {
298                    _title = title;
299            }
300    
301            public String getDescription() {
302                    if (_description == null) {
303                            return StringPool.BLANK;
304                    }
305                    else {
306                            return _description;
307                    }
308            }
309    
310            public void setDescription(String description) {
311                    _description = description;
312            }
313    
314            public String getChangeLog() {
315                    if (_changeLog == null) {
316                            return StringPool.BLANK;
317                    }
318                    else {
319                            return _changeLog;
320                    }
321            }
322    
323            public void setChangeLog(String changeLog) {
324                    _changeLog = changeLog;
325            }
326    
327            public String getExtraSettings() {
328                    if (_extraSettings == null) {
329                            return StringPool.BLANK;
330                    }
331                    else {
332                            return _extraSettings;
333                    }
334            }
335    
336            public void setExtraSettings(String extraSettings) {
337                    _extraSettings = extraSettings;
338            }
339    
340            public String getVersion() {
341                    if (_version == null) {
342                            return StringPool.BLANK;
343                    }
344                    else {
345                            return _version;
346                    }
347            }
348    
349            public void setVersion(String version) {
350                    _version = version;
351    
352                    if (_originalVersion == null) {
353                            _originalVersion = version;
354                    }
355            }
356    
357            public String getOriginalVersion() {
358                    return GetterUtil.getString(_originalVersion);
359            }
360    
361            public long getSize() {
362                    return _size;
363            }
364    
365            public void setSize(long size) {
366                    _size = size;
367            }
368    
369            public int getStatus() {
370                    return _status;
371            }
372    
373            public void setStatus(int status) {
374                    _status = status;
375            }
376    
377            public long getStatusByUserId() {
378                    return _statusByUserId;
379            }
380    
381            public void setStatusByUserId(long statusByUserId) {
382                    _statusByUserId = statusByUserId;
383            }
384    
385            public String getStatusByUserUuid() throws SystemException {
386                    return PortalUtil.getUserValue(getStatusByUserId(), "uuid",
387                            _statusByUserUuid);
388            }
389    
390            public void setStatusByUserUuid(String statusByUserUuid) {
391                    _statusByUserUuid = statusByUserUuid;
392            }
393    
394            public String getStatusByUserName() {
395                    if (_statusByUserName == null) {
396                            return StringPool.BLANK;
397                    }
398                    else {
399                            return _statusByUserName;
400                    }
401            }
402    
403            public void setStatusByUserName(String statusByUserName) {
404                    _statusByUserName = statusByUserName;
405            }
406    
407            public Date getStatusDate() {
408                    return _statusDate;
409            }
410    
411            public void setStatusDate(Date statusDate) {
412                    _statusDate = statusDate;
413            }
414    
415            public boolean isApproved() {
416                    if (getStatus() == WorkflowConstants.STATUS_APPROVED) {
417                            return true;
418                    }
419                    else {
420                            return false;
421                    }
422            }
423    
424            public boolean isDraft() {
425                    if (getStatus() == WorkflowConstants.STATUS_DRAFT) {
426                            return true;
427                    }
428                    else {
429                            return false;
430                    }
431            }
432    
433            public boolean isExpired() {
434                    if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
435                            return true;
436                    }
437                    else {
438                            return false;
439                    }
440            }
441    
442            public boolean isPending() {
443                    if (getStatus() == WorkflowConstants.STATUS_PENDING) {
444                            return true;
445                    }
446                    else {
447                            return false;
448                    }
449            }
450    
451            public DLFileVersion toEscapedModel() {
452                    if (isEscapedModel()) {
453                            return (DLFileVersion)this;
454                    }
455                    else {
456                            return (DLFileVersion)Proxy.newProxyInstance(DLFileVersion.class.getClassLoader(),
457                                    new Class[] { DLFileVersion.class },
458                                    new AutoEscapeBeanHandler(this));
459                    }
460            }
461    
462            public ExpandoBridge getExpandoBridge() {
463                    if (_expandoBridge == null) {
464                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
465                                            DLFileVersion.class.getName(), getPrimaryKey());
466                    }
467    
468                    return _expandoBridge;
469            }
470    
471            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
472                    getExpandoBridge().setAttributes(serviceContext);
473            }
474    
475            public Object clone() {
476                    DLFileVersionImpl clone = new DLFileVersionImpl();
477    
478                    clone.setFileVersionId(getFileVersionId());
479                    clone.setGroupId(getGroupId());
480                    clone.setCompanyId(getCompanyId());
481                    clone.setUserId(getUserId());
482                    clone.setUserName(getUserName());
483                    clone.setCreateDate(getCreateDate());
484                    clone.setFolderId(getFolderId());
485                    clone.setName(getName());
486                    clone.setExtension(getExtension());
487                    clone.setTitle(getTitle());
488                    clone.setDescription(getDescription());
489                    clone.setChangeLog(getChangeLog());
490                    clone.setExtraSettings(getExtraSettings());
491                    clone.setVersion(getVersion());
492                    clone.setSize(getSize());
493                    clone.setStatus(getStatus());
494                    clone.setStatusByUserId(getStatusByUserId());
495                    clone.setStatusByUserName(getStatusByUserName());
496                    clone.setStatusDate(getStatusDate());
497    
498                    return clone;
499            }
500    
501            public int compareTo(DLFileVersion dlFileVersion) {
502                    int value = 0;
503    
504                    if (getFolderId() < dlFileVersion.getFolderId()) {
505                            value = -1;
506                    }
507                    else if (getFolderId() > dlFileVersion.getFolderId()) {
508                            value = 1;
509                    }
510                    else {
511                            value = 0;
512                    }
513    
514                    value = value * -1;
515    
516                    if (value != 0) {
517                            return value;
518                    }
519    
520                    value = getName().compareTo(dlFileVersion.getName());
521    
522                    value = value * -1;
523    
524                    if (value != 0) {
525                            return value;
526                    }
527    
528                    value = DateUtil.compareTo(getCreateDate(),
529                                    dlFileVersion.getCreateDate());
530    
531                    value = value * -1;
532    
533                    if (value != 0) {
534                            return value;
535                    }
536    
537                    return 0;
538            }
539    
540            public boolean equals(Object obj) {
541                    if (obj == null) {
542                            return false;
543                    }
544    
545                    DLFileVersion dlFileVersion = null;
546    
547                    try {
548                            dlFileVersion = (DLFileVersion)obj;
549                    }
550                    catch (ClassCastException cce) {
551                            return false;
552                    }
553    
554                    long pk = dlFileVersion.getPrimaryKey();
555    
556                    if (getPrimaryKey() == pk) {
557                            return true;
558                    }
559                    else {
560                            return false;
561                    }
562            }
563    
564            public int hashCode() {
565                    return (int)getPrimaryKey();
566            }
567    
568            public String toString() {
569                    StringBundler sb = new StringBundler(39);
570    
571                    sb.append("{fileVersionId=");
572                    sb.append(getFileVersionId());
573                    sb.append(", groupId=");
574                    sb.append(getGroupId());
575                    sb.append(", companyId=");
576                    sb.append(getCompanyId());
577                    sb.append(", userId=");
578                    sb.append(getUserId());
579                    sb.append(", userName=");
580                    sb.append(getUserName());
581                    sb.append(", createDate=");
582                    sb.append(getCreateDate());
583                    sb.append(", folderId=");
584                    sb.append(getFolderId());
585                    sb.append(", name=");
586                    sb.append(getName());
587                    sb.append(", extension=");
588                    sb.append(getExtension());
589                    sb.append(", title=");
590                    sb.append(getTitle());
591                    sb.append(", description=");
592                    sb.append(getDescription());
593                    sb.append(", changeLog=");
594                    sb.append(getChangeLog());
595                    sb.append(", extraSettings=");
596                    sb.append(getExtraSettings());
597                    sb.append(", version=");
598                    sb.append(getVersion());
599                    sb.append(", size=");
600                    sb.append(getSize());
601                    sb.append(", status=");
602                    sb.append(getStatus());
603                    sb.append(", statusByUserId=");
604                    sb.append(getStatusByUserId());
605                    sb.append(", statusByUserName=");
606                    sb.append(getStatusByUserName());
607                    sb.append(", statusDate=");
608                    sb.append(getStatusDate());
609                    sb.append("}");
610    
611                    return sb.toString();
612            }
613    
614            public String toXmlString() {
615                    StringBundler sb = new StringBundler(61);
616    
617                    sb.append("<model><model-name>");
618                    sb.append("com.liferay.portlet.documentlibrary.model.DLFileVersion");
619                    sb.append("</model-name>");
620    
621                    sb.append(
622                            "<column><column-name>fileVersionId</column-name><column-value><![CDATA[");
623                    sb.append(getFileVersionId());
624                    sb.append("]]></column-value></column>");
625                    sb.append(
626                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
627                    sb.append(getGroupId());
628                    sb.append("]]></column-value></column>");
629                    sb.append(
630                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
631                    sb.append(getCompanyId());
632                    sb.append("]]></column-value></column>");
633                    sb.append(
634                            "<column><column-name>userId</column-name><column-value><![CDATA[");
635                    sb.append(getUserId());
636                    sb.append("]]></column-value></column>");
637                    sb.append(
638                            "<column><column-name>userName</column-name><column-value><![CDATA[");
639                    sb.append(getUserName());
640                    sb.append("]]></column-value></column>");
641                    sb.append(
642                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
643                    sb.append(getCreateDate());
644                    sb.append("]]></column-value></column>");
645                    sb.append(
646                            "<column><column-name>folderId</column-name><column-value><![CDATA[");
647                    sb.append(getFolderId());
648                    sb.append("]]></column-value></column>");
649                    sb.append(
650                            "<column><column-name>name</column-name><column-value><![CDATA[");
651                    sb.append(getName());
652                    sb.append("]]></column-value></column>");
653                    sb.append(
654                            "<column><column-name>extension</column-name><column-value><![CDATA[");
655                    sb.append(getExtension());
656                    sb.append("]]></column-value></column>");
657                    sb.append(
658                            "<column><column-name>title</column-name><column-value><![CDATA[");
659                    sb.append(getTitle());
660                    sb.append("]]></column-value></column>");
661                    sb.append(
662                            "<column><column-name>description</column-name><column-value><![CDATA[");
663                    sb.append(getDescription());
664                    sb.append("]]></column-value></column>");
665                    sb.append(
666                            "<column><column-name>changeLog</column-name><column-value><![CDATA[");
667                    sb.append(getChangeLog());
668                    sb.append("]]></column-value></column>");
669                    sb.append(
670                            "<column><column-name>extraSettings</column-name><column-value><![CDATA[");
671                    sb.append(getExtraSettings());
672                    sb.append("]]></column-value></column>");
673                    sb.append(
674                            "<column><column-name>version</column-name><column-value><![CDATA[");
675                    sb.append(getVersion());
676                    sb.append("]]></column-value></column>");
677                    sb.append(
678                            "<column><column-name>size</column-name><column-value><![CDATA[");
679                    sb.append(getSize());
680                    sb.append("]]></column-value></column>");
681                    sb.append(
682                            "<column><column-name>status</column-name><column-value><![CDATA[");
683                    sb.append(getStatus());
684                    sb.append("]]></column-value></column>");
685                    sb.append(
686                            "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
687                    sb.append(getStatusByUserId());
688                    sb.append("]]></column-value></column>");
689                    sb.append(
690                            "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
691                    sb.append(getStatusByUserName());
692                    sb.append("]]></column-value></column>");
693                    sb.append(
694                            "<column><column-name>statusDate</column-name><column-value><![CDATA[");
695                    sb.append(getStatusDate());
696                    sb.append("]]></column-value></column>");
697    
698                    sb.append("</model>");
699    
700                    return sb.toString();
701            }
702    
703            private long _fileVersionId;
704            private long _groupId;
705            private long _originalGroupId;
706            private boolean _setOriginalGroupId;
707            private long _companyId;
708            private long _userId;
709            private String _userUuid;
710            private String _userName;
711            private Date _createDate;
712            private long _folderId;
713            private long _originalFolderId;
714            private boolean _setOriginalFolderId;
715            private String _name;
716            private String _originalName;
717            private String _extension;
718            private String _title;
719            private String _description;
720            private String _changeLog;
721            private String _extraSettings;
722            private String _version;
723            private String _originalVersion;
724            private long _size;
725            private int _status;
726            private long _statusByUserId;
727            private String _statusByUserUuid;
728            private String _statusByUserName;
729            private Date _statusDate;
730            private transient ExpandoBridge _expandoBridge;
731    }