001    /**
002     * Copyright (c) 2000-2012 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.json.JSON;
019    import com.liferay.portal.kernel.util.DateUtil;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.ProxyUtil;
022    import com.liferay.portal.kernel.util.StringBundler;
023    import com.liferay.portal.kernel.util.StringPool;
024    import com.liferay.portal.model.CacheModel;
025    import com.liferay.portal.model.impl.BaseModelImpl;
026    import com.liferay.portal.service.ServiceContext;
027    
028    import com.liferay.portlet.documentlibrary.model.DLSync;
029    import com.liferay.portlet.documentlibrary.model.DLSyncModel;
030    import com.liferay.portlet.documentlibrary.model.DLSyncSoap;
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.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.List;
041    
042    /**
043     * The base model implementation for the DLSync service. Represents a row in the "DLSync" database table, with each column mapped to a property of this class.
044     *
045     * <p>
046     * This implementation and its corresponding interface {@link com.liferay.portlet.documentlibrary.model.DLSyncModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DLSyncImpl}.
047     * </p>
048     *
049     * @author Brian Wing Shun Chan
050     * @see DLSyncImpl
051     * @see com.liferay.portlet.documentlibrary.model.DLSync
052     * @see com.liferay.portlet.documentlibrary.model.DLSyncModel
053     * @generated
054     */
055    @JSON(strict = true)
056    public class DLSyncModelImpl extends BaseModelImpl<DLSync>
057            implements DLSyncModel {
058            /*
059             * NOTE FOR DEVELOPERS:
060             *
061             * Never modify or reference this class directly. All methods that expect a d l sync model instance should use the {@link com.liferay.portlet.documentlibrary.model.DLSync} interface instead.
062             */
063            public static final String TABLE_NAME = "DLSync";
064            public static final Object[][] TABLE_COLUMNS = {
065                            { "syncId", Types.BIGINT },
066                            { "companyId", Types.BIGINT },
067                            { "createDate", Types.TIMESTAMP },
068                            { "modifiedDate", Types.TIMESTAMP },
069                            { "fileId", Types.BIGINT },
070                            { "fileUuid", Types.VARCHAR },
071                            { "repositoryId", Types.BIGINT },
072                            { "parentFolderId", Types.BIGINT },
073                            { "name", Types.VARCHAR },
074                            { "description", Types.VARCHAR },
075                            { "event", Types.VARCHAR },
076                            { "type_", Types.VARCHAR },
077                            { "version", Types.VARCHAR }
078                    };
079            public static final String TABLE_SQL_CREATE = "create table DLSync (syncId LONG not null primary key,companyId LONG,createDate DATE null,modifiedDate DATE null,fileId LONG,fileUuid VARCHAR(75) null,repositoryId LONG,parentFolderId LONG,name VARCHAR(255) null,description STRING null,event VARCHAR(75) null,type_ VARCHAR(75) null,version VARCHAR(75) null)";
080            public static final String TABLE_SQL_DROP = "drop table DLSync";
081            public static final String ORDER_BY_JPQL = " ORDER BY dlSync.companyId ASC, dlSync.repositoryId ASC, dlSync.modifiedDate ASC";
082            public static final String ORDER_BY_SQL = " ORDER BY DLSync.companyId ASC, DLSync.repositoryId ASC, DLSync.modifiedDate ASC";
083            public static final String DATA_SOURCE = "liferayDataSource";
084            public static final String SESSION_FACTORY = "liferaySessionFactory";
085            public static final String TX_MANAGER = "liferayTransactionManager";
086            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
087                                    "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLSync"),
088                            true);
089            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
090                                    "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLSync"),
091                            true);
092            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
093                                    "value.object.column.bitmask.enabled.com.liferay.portlet.documentlibrary.model.DLSync"),
094                            true);
095            public static long COMPANYID_COLUMN_BITMASK = 1L;
096            public static long FILEID_COLUMN_BITMASK = 2L;
097            public static long MODIFIEDDATE_COLUMN_BITMASK = 4L;
098            public static long REPOSITORYID_COLUMN_BITMASK = 8L;
099    
100            /**
101             * Converts the soap model instance into a normal model instance.
102             *
103             * @param soapModel the soap model instance to convert
104             * @return the normal model instance
105             */
106            public static DLSync toModel(DLSyncSoap soapModel) {
107                    DLSync model = new DLSyncImpl();
108    
109                    model.setSyncId(soapModel.getSyncId());
110                    model.setCompanyId(soapModel.getCompanyId());
111                    model.setCreateDate(soapModel.getCreateDate());
112                    model.setModifiedDate(soapModel.getModifiedDate());
113                    model.setFileId(soapModel.getFileId());
114                    model.setFileUuid(soapModel.getFileUuid());
115                    model.setRepositoryId(soapModel.getRepositoryId());
116                    model.setParentFolderId(soapModel.getParentFolderId());
117                    model.setName(soapModel.getName());
118                    model.setDescription(soapModel.getDescription());
119                    model.setEvent(soapModel.getEvent());
120                    model.setType(soapModel.getType());
121                    model.setVersion(soapModel.getVersion());
122    
123                    return model;
124            }
125    
126            /**
127             * Converts the soap model instances into normal model instances.
128             *
129             * @param soapModels the soap model instances to convert
130             * @return the normal model instances
131             */
132            public static List<DLSync> toModels(DLSyncSoap[] soapModels) {
133                    List<DLSync> models = new ArrayList<DLSync>(soapModels.length);
134    
135                    for (DLSyncSoap soapModel : soapModels) {
136                            models.add(toModel(soapModel));
137                    }
138    
139                    return models;
140            }
141    
142            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
143                                    "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLSync"));
144    
145            public DLSyncModelImpl() {
146            }
147    
148            public long getPrimaryKey() {
149                    return _syncId;
150            }
151    
152            public void setPrimaryKey(long primaryKey) {
153                    setSyncId(primaryKey);
154            }
155    
156            public Serializable getPrimaryKeyObj() {
157                    return new Long(_syncId);
158            }
159    
160            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
161                    setPrimaryKey(((Long)primaryKeyObj).longValue());
162            }
163    
164            public Class<?> getModelClass() {
165                    return DLSync.class;
166            }
167    
168            public String getModelClassName() {
169                    return DLSync.class.getName();
170            }
171    
172            @JSON
173            public long getSyncId() {
174                    return _syncId;
175            }
176    
177            public void setSyncId(long syncId) {
178                    _syncId = syncId;
179            }
180    
181            @JSON
182            public long getCompanyId() {
183                    return _companyId;
184            }
185    
186            public void setCompanyId(long companyId) {
187                    _columnBitmask = -1L;
188    
189                    if (!_setOriginalCompanyId) {
190                            _setOriginalCompanyId = true;
191    
192                            _originalCompanyId = _companyId;
193                    }
194    
195                    _companyId = companyId;
196            }
197    
198            public long getOriginalCompanyId() {
199                    return _originalCompanyId;
200            }
201    
202            @JSON
203            public Date getCreateDate() {
204                    return _createDate;
205            }
206    
207            public void setCreateDate(Date createDate) {
208                    _createDate = createDate;
209            }
210    
211            @JSON
212            public Date getModifiedDate() {
213                    return _modifiedDate;
214            }
215    
216            public void setModifiedDate(Date modifiedDate) {
217                    _columnBitmask = -1L;
218    
219                    if (_originalModifiedDate == null) {
220                            _originalModifiedDate = _modifiedDate;
221                    }
222    
223                    _modifiedDate = modifiedDate;
224            }
225    
226            public Date getOriginalModifiedDate() {
227                    return _originalModifiedDate;
228            }
229    
230            @JSON
231            public long getFileId() {
232                    return _fileId;
233            }
234    
235            public void setFileId(long fileId) {
236                    _columnBitmask |= FILEID_COLUMN_BITMASK;
237    
238                    if (!_setOriginalFileId) {
239                            _setOriginalFileId = true;
240    
241                            _originalFileId = _fileId;
242                    }
243    
244                    _fileId = fileId;
245            }
246    
247            public long getOriginalFileId() {
248                    return _originalFileId;
249            }
250    
251            @JSON
252            public String getFileUuid() {
253                    if (_fileUuid == null) {
254                            return StringPool.BLANK;
255                    }
256                    else {
257                            return _fileUuid;
258                    }
259            }
260    
261            public void setFileUuid(String fileUuid) {
262                    _fileUuid = fileUuid;
263            }
264    
265            @JSON
266            public long getRepositoryId() {
267                    return _repositoryId;
268            }
269    
270            public void setRepositoryId(long repositoryId) {
271                    _columnBitmask = -1L;
272    
273                    if (!_setOriginalRepositoryId) {
274                            _setOriginalRepositoryId = true;
275    
276                            _originalRepositoryId = _repositoryId;
277                    }
278    
279                    _repositoryId = repositoryId;
280            }
281    
282            public long getOriginalRepositoryId() {
283                    return _originalRepositoryId;
284            }
285    
286            @JSON
287            public long getParentFolderId() {
288                    return _parentFolderId;
289            }
290    
291            public void setParentFolderId(long parentFolderId) {
292                    _parentFolderId = parentFolderId;
293            }
294    
295            @JSON
296            public String getName() {
297                    if (_name == null) {
298                            return StringPool.BLANK;
299                    }
300                    else {
301                            return _name;
302                    }
303            }
304    
305            public void setName(String name) {
306                    _name = name;
307            }
308    
309            @JSON
310            public String getDescription() {
311                    if (_description == null) {
312                            return StringPool.BLANK;
313                    }
314                    else {
315                            return _description;
316                    }
317            }
318    
319            public void setDescription(String description) {
320                    _description = description;
321            }
322    
323            @JSON
324            public String getEvent() {
325                    if (_event == null) {
326                            return StringPool.BLANK;
327                    }
328                    else {
329                            return _event;
330                    }
331            }
332    
333            public void setEvent(String event) {
334                    _event = event;
335            }
336    
337            @JSON
338            public String getType() {
339                    if (_type == null) {
340                            return StringPool.BLANK;
341                    }
342                    else {
343                            return _type;
344                    }
345            }
346    
347            public void setType(String type) {
348                    _type = type;
349            }
350    
351            @JSON
352            public String getVersion() {
353                    if (_version == null) {
354                            return StringPool.BLANK;
355                    }
356                    else {
357                            return _version;
358                    }
359            }
360    
361            public void setVersion(String version) {
362                    _version = version;
363            }
364    
365            public long getColumnBitmask() {
366                    return _columnBitmask;
367            }
368    
369            @Override
370            public DLSync toEscapedModel() {
371                    if (_escapedModelProxy == null) {
372                            _escapedModelProxy = (DLSync)ProxyUtil.newProxyInstance(_classLoader,
373                                            _escapedModelProxyInterfaces,
374                                            new AutoEscapeBeanHandler(this));
375                    }
376    
377                    return _escapedModelProxy;
378            }
379    
380            @Override
381            public ExpandoBridge getExpandoBridge() {
382                    if (_expandoBridge == null) {
383                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
384                                            DLSync.class.getName(), getPrimaryKey());
385                    }
386    
387                    return _expandoBridge;
388            }
389    
390            @Override
391            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
392                    getExpandoBridge().setAttributes(serviceContext);
393            }
394    
395            @Override
396            public Object clone() {
397                    DLSyncImpl dlSyncImpl = new DLSyncImpl();
398    
399                    dlSyncImpl.setSyncId(getSyncId());
400                    dlSyncImpl.setCompanyId(getCompanyId());
401                    dlSyncImpl.setCreateDate(getCreateDate());
402                    dlSyncImpl.setModifiedDate(getModifiedDate());
403                    dlSyncImpl.setFileId(getFileId());
404                    dlSyncImpl.setFileUuid(getFileUuid());
405                    dlSyncImpl.setRepositoryId(getRepositoryId());
406                    dlSyncImpl.setParentFolderId(getParentFolderId());
407                    dlSyncImpl.setName(getName());
408                    dlSyncImpl.setDescription(getDescription());
409                    dlSyncImpl.setEvent(getEvent());
410                    dlSyncImpl.setType(getType());
411                    dlSyncImpl.setVersion(getVersion());
412    
413                    dlSyncImpl.resetOriginalValues();
414    
415                    return dlSyncImpl;
416            }
417    
418            public int compareTo(DLSync dlSync) {
419                    int value = 0;
420    
421                    if (getCompanyId() < dlSync.getCompanyId()) {
422                            value = -1;
423                    }
424                    else if (getCompanyId() > dlSync.getCompanyId()) {
425                            value = 1;
426                    }
427                    else {
428                            value = 0;
429                    }
430    
431                    if (value != 0) {
432                            return value;
433                    }
434    
435                    if (getRepositoryId() < dlSync.getRepositoryId()) {
436                            value = -1;
437                    }
438                    else if (getRepositoryId() > dlSync.getRepositoryId()) {
439                            value = 1;
440                    }
441                    else {
442                            value = 0;
443                    }
444    
445                    if (value != 0) {
446                            return value;
447                    }
448    
449                    value = DateUtil.compareTo(getModifiedDate(), dlSync.getModifiedDate());
450    
451                    if (value != 0) {
452                            return value;
453                    }
454    
455                    return 0;
456            }
457    
458            @Override
459            public boolean equals(Object obj) {
460                    if (obj == null) {
461                            return false;
462                    }
463    
464                    DLSync dlSync = null;
465    
466                    try {
467                            dlSync = (DLSync)obj;
468                    }
469                    catch (ClassCastException cce) {
470                            return false;
471                    }
472    
473                    long primaryKey = dlSync.getPrimaryKey();
474    
475                    if (getPrimaryKey() == primaryKey) {
476                            return true;
477                    }
478                    else {
479                            return false;
480                    }
481            }
482    
483            @Override
484            public int hashCode() {
485                    return (int)getPrimaryKey();
486            }
487    
488            @Override
489            public void resetOriginalValues() {
490                    DLSyncModelImpl dlSyncModelImpl = this;
491    
492                    dlSyncModelImpl._originalCompanyId = dlSyncModelImpl._companyId;
493    
494                    dlSyncModelImpl._setOriginalCompanyId = false;
495    
496                    dlSyncModelImpl._originalModifiedDate = dlSyncModelImpl._modifiedDate;
497    
498                    dlSyncModelImpl._originalFileId = dlSyncModelImpl._fileId;
499    
500                    dlSyncModelImpl._setOriginalFileId = false;
501    
502                    dlSyncModelImpl._originalRepositoryId = dlSyncModelImpl._repositoryId;
503    
504                    dlSyncModelImpl._setOriginalRepositoryId = false;
505    
506                    dlSyncModelImpl._columnBitmask = 0;
507            }
508    
509            @Override
510            public CacheModel<DLSync> toCacheModel() {
511                    DLSyncCacheModel dlSyncCacheModel = new DLSyncCacheModel();
512    
513                    dlSyncCacheModel.syncId = getSyncId();
514    
515                    dlSyncCacheModel.companyId = getCompanyId();
516    
517                    Date createDate = getCreateDate();
518    
519                    if (createDate != null) {
520                            dlSyncCacheModel.createDate = createDate.getTime();
521                    }
522                    else {
523                            dlSyncCacheModel.createDate = Long.MIN_VALUE;
524                    }
525    
526                    Date modifiedDate = getModifiedDate();
527    
528                    if (modifiedDate != null) {
529                            dlSyncCacheModel.modifiedDate = modifiedDate.getTime();
530                    }
531                    else {
532                            dlSyncCacheModel.modifiedDate = Long.MIN_VALUE;
533                    }
534    
535                    dlSyncCacheModel.fileId = getFileId();
536    
537                    dlSyncCacheModel.fileUuid = getFileUuid();
538    
539                    String fileUuid = dlSyncCacheModel.fileUuid;
540    
541                    if ((fileUuid != null) && (fileUuid.length() == 0)) {
542                            dlSyncCacheModel.fileUuid = null;
543                    }
544    
545                    dlSyncCacheModel.repositoryId = getRepositoryId();
546    
547                    dlSyncCacheModel.parentFolderId = getParentFolderId();
548    
549                    dlSyncCacheModel.name = getName();
550    
551                    String name = dlSyncCacheModel.name;
552    
553                    if ((name != null) && (name.length() == 0)) {
554                            dlSyncCacheModel.name = null;
555                    }
556    
557                    dlSyncCacheModel.description = getDescription();
558    
559                    String description = dlSyncCacheModel.description;
560    
561                    if ((description != null) && (description.length() == 0)) {
562                            dlSyncCacheModel.description = null;
563                    }
564    
565                    dlSyncCacheModel.event = getEvent();
566    
567                    String event = dlSyncCacheModel.event;
568    
569                    if ((event != null) && (event.length() == 0)) {
570                            dlSyncCacheModel.event = null;
571                    }
572    
573                    dlSyncCacheModel.type = getType();
574    
575                    String type = dlSyncCacheModel.type;
576    
577                    if ((type != null) && (type.length() == 0)) {
578                            dlSyncCacheModel.type = null;
579                    }
580    
581                    dlSyncCacheModel.version = getVersion();
582    
583                    String version = dlSyncCacheModel.version;
584    
585                    if ((version != null) && (version.length() == 0)) {
586                            dlSyncCacheModel.version = null;
587                    }
588    
589                    return dlSyncCacheModel;
590            }
591    
592            @Override
593            public String toString() {
594                    StringBundler sb = new StringBundler(27);
595    
596                    sb.append("{syncId=");
597                    sb.append(getSyncId());
598                    sb.append(", companyId=");
599                    sb.append(getCompanyId());
600                    sb.append(", createDate=");
601                    sb.append(getCreateDate());
602                    sb.append(", modifiedDate=");
603                    sb.append(getModifiedDate());
604                    sb.append(", fileId=");
605                    sb.append(getFileId());
606                    sb.append(", fileUuid=");
607                    sb.append(getFileUuid());
608                    sb.append(", repositoryId=");
609                    sb.append(getRepositoryId());
610                    sb.append(", parentFolderId=");
611                    sb.append(getParentFolderId());
612                    sb.append(", name=");
613                    sb.append(getName());
614                    sb.append(", description=");
615                    sb.append(getDescription());
616                    sb.append(", event=");
617                    sb.append(getEvent());
618                    sb.append(", type=");
619                    sb.append(getType());
620                    sb.append(", version=");
621                    sb.append(getVersion());
622                    sb.append("}");
623    
624                    return sb.toString();
625            }
626    
627            public String toXmlString() {
628                    StringBundler sb = new StringBundler(43);
629    
630                    sb.append("<model><model-name>");
631                    sb.append("com.liferay.portlet.documentlibrary.model.DLSync");
632                    sb.append("</model-name>");
633    
634                    sb.append(
635                            "<column><column-name>syncId</column-name><column-value><![CDATA[");
636                    sb.append(getSyncId());
637                    sb.append("]]></column-value></column>");
638                    sb.append(
639                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
640                    sb.append(getCompanyId());
641                    sb.append("]]></column-value></column>");
642                    sb.append(
643                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
644                    sb.append(getCreateDate());
645                    sb.append("]]></column-value></column>");
646                    sb.append(
647                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
648                    sb.append(getModifiedDate());
649                    sb.append("]]></column-value></column>");
650                    sb.append(
651                            "<column><column-name>fileId</column-name><column-value><![CDATA[");
652                    sb.append(getFileId());
653                    sb.append("]]></column-value></column>");
654                    sb.append(
655                            "<column><column-name>fileUuid</column-name><column-value><![CDATA[");
656                    sb.append(getFileUuid());
657                    sb.append("]]></column-value></column>");
658                    sb.append(
659                            "<column><column-name>repositoryId</column-name><column-value><![CDATA[");
660                    sb.append(getRepositoryId());
661                    sb.append("]]></column-value></column>");
662                    sb.append(
663                            "<column><column-name>parentFolderId</column-name><column-value><![CDATA[");
664                    sb.append(getParentFolderId());
665                    sb.append("]]></column-value></column>");
666                    sb.append(
667                            "<column><column-name>name</column-name><column-value><![CDATA[");
668                    sb.append(getName());
669                    sb.append("]]></column-value></column>");
670                    sb.append(
671                            "<column><column-name>description</column-name><column-value><![CDATA[");
672                    sb.append(getDescription());
673                    sb.append("]]></column-value></column>");
674                    sb.append(
675                            "<column><column-name>event</column-name><column-value><![CDATA[");
676                    sb.append(getEvent());
677                    sb.append("]]></column-value></column>");
678                    sb.append(
679                            "<column><column-name>type</column-name><column-value><![CDATA[");
680                    sb.append(getType());
681                    sb.append("]]></column-value></column>");
682                    sb.append(
683                            "<column><column-name>version</column-name><column-value><![CDATA[");
684                    sb.append(getVersion());
685                    sb.append("]]></column-value></column>");
686    
687                    sb.append("</model>");
688    
689                    return sb.toString();
690            }
691    
692            private static ClassLoader _classLoader = DLSync.class.getClassLoader();
693            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
694                            DLSync.class
695                    };
696            private long _syncId;
697            private long _companyId;
698            private long _originalCompanyId;
699            private boolean _setOriginalCompanyId;
700            private Date _createDate;
701            private Date _modifiedDate;
702            private Date _originalModifiedDate;
703            private long _fileId;
704            private long _originalFileId;
705            private boolean _setOriginalFileId;
706            private String _fileUuid;
707            private long _repositoryId;
708            private long _originalRepositoryId;
709            private boolean _setOriginalRepositoryId;
710            private long _parentFolderId;
711            private String _name;
712            private String _description;
713            private String _event;
714            private String _type;
715            private String _version;
716            private transient ExpandoBridge _expandoBridge;
717            private long _columnBitmask;
718            private DLSync _escapedModelProxy;
719    }