001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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                            { "repositoryId", Types.BIGINT },
071                            { "parentFolderId", Types.BIGINT },
072                            { "event", Types.VARCHAR },
073                            { "type_", Types.VARCHAR }
074                    };
075            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,repositoryId LONG,parentFolderId LONG,event VARCHAR(75) null,type_ VARCHAR(75) null)";
076            public static final String TABLE_SQL_DROP = "drop table DLSync";
077            public static final String ORDER_BY_JPQL = " ORDER BY dlSync.companyId ASC, dlSync.repositoryId ASC, dlSync.modifiedDate ASC";
078            public static final String ORDER_BY_SQL = " ORDER BY DLSync.companyId ASC, DLSync.repositoryId ASC, DLSync.modifiedDate ASC";
079            public static final String DATA_SOURCE = "liferayDataSource";
080            public static final String SESSION_FACTORY = "liferaySessionFactory";
081            public static final String TX_MANAGER = "liferayTransactionManager";
082            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
083                                    "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLSync"),
084                            true);
085            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086                                    "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLSync"),
087                            true);
088            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
089                                    "value.object.column.bitmask.enabled.com.liferay.portlet.documentlibrary.model.DLSync"),
090                            true);
091            public static long COMPANYID_COLUMN_BITMASK = 1L;
092            public static long FILEID_COLUMN_BITMASK = 2L;
093            public static long MODIFIEDDATE_COLUMN_BITMASK = 4L;
094            public static long REPOSITORYID_COLUMN_BITMASK = 8L;
095    
096            /**
097             * Converts the soap model instance into a normal model instance.
098             *
099             * @param soapModel the soap model instance to convert
100             * @return the normal model instance
101             */
102            public static DLSync toModel(DLSyncSoap soapModel) {
103                    DLSync model = new DLSyncImpl();
104    
105                    model.setSyncId(soapModel.getSyncId());
106                    model.setCompanyId(soapModel.getCompanyId());
107                    model.setCreateDate(soapModel.getCreateDate());
108                    model.setModifiedDate(soapModel.getModifiedDate());
109                    model.setFileId(soapModel.getFileId());
110                    model.setRepositoryId(soapModel.getRepositoryId());
111                    model.setParentFolderId(soapModel.getParentFolderId());
112                    model.setEvent(soapModel.getEvent());
113                    model.setType(soapModel.getType());
114    
115                    return model;
116            }
117    
118            /**
119             * Converts the soap model instances into normal model instances.
120             *
121             * @param soapModels the soap model instances to convert
122             * @return the normal model instances
123             */
124            public static List<DLSync> toModels(DLSyncSoap[] soapModels) {
125                    List<DLSync> models = new ArrayList<DLSync>(soapModels.length);
126    
127                    for (DLSyncSoap soapModel : soapModels) {
128                            models.add(toModel(soapModel));
129                    }
130    
131                    return models;
132            }
133    
134            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
135                                    "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLSync"));
136    
137            public DLSyncModelImpl() {
138            }
139    
140            public long getPrimaryKey() {
141                    return _syncId;
142            }
143    
144            public void setPrimaryKey(long primaryKey) {
145                    setSyncId(primaryKey);
146            }
147    
148            public Serializable getPrimaryKeyObj() {
149                    return new Long(_syncId);
150            }
151    
152            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
153                    setPrimaryKey(((Long)primaryKeyObj).longValue());
154            }
155    
156            public Class<?> getModelClass() {
157                    return DLSync.class;
158            }
159    
160            public String getModelClassName() {
161                    return DLSync.class.getName();
162            }
163    
164            @JSON
165            public long getSyncId() {
166                    return _syncId;
167            }
168    
169            public void setSyncId(long syncId) {
170                    _syncId = syncId;
171            }
172    
173            @JSON
174            public long getCompanyId() {
175                    return _companyId;
176            }
177    
178            public void setCompanyId(long companyId) {
179                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
180    
181                    if (!_setOriginalCompanyId) {
182                            _setOriginalCompanyId = true;
183    
184                            _originalCompanyId = _companyId;
185                    }
186    
187                    _companyId = companyId;
188            }
189    
190            public long getOriginalCompanyId() {
191                    return _originalCompanyId;
192            }
193    
194            @JSON
195            public Date getCreateDate() {
196                    return _createDate;
197            }
198    
199            public void setCreateDate(Date createDate) {
200                    _createDate = createDate;
201            }
202    
203            @JSON
204            public Date getModifiedDate() {
205                    return _modifiedDate;
206            }
207    
208            public void setModifiedDate(Date modifiedDate) {
209                    _columnBitmask |= MODIFIEDDATE_COLUMN_BITMASK;
210    
211                    if (_originalModifiedDate == null) {
212                            _originalModifiedDate = _modifiedDate;
213                    }
214    
215                    _modifiedDate = modifiedDate;
216            }
217    
218            public Date getOriginalModifiedDate() {
219                    return _originalModifiedDate;
220            }
221    
222            @JSON
223            public long getFileId() {
224                    return _fileId;
225            }
226    
227            public void setFileId(long fileId) {
228                    _columnBitmask |= FILEID_COLUMN_BITMASK;
229    
230                    if (!_setOriginalFileId) {
231                            _setOriginalFileId = true;
232    
233                            _originalFileId = _fileId;
234                    }
235    
236                    _fileId = fileId;
237            }
238    
239            public long getOriginalFileId() {
240                    return _originalFileId;
241            }
242    
243            @JSON
244            public long getRepositoryId() {
245                    return _repositoryId;
246            }
247    
248            public void setRepositoryId(long repositoryId) {
249                    _columnBitmask |= REPOSITORYID_COLUMN_BITMASK;
250    
251                    if (!_setOriginalRepositoryId) {
252                            _setOriginalRepositoryId = true;
253    
254                            _originalRepositoryId = _repositoryId;
255                    }
256    
257                    _repositoryId = repositoryId;
258            }
259    
260            public long getOriginalRepositoryId() {
261                    return _originalRepositoryId;
262            }
263    
264            @JSON
265            public long getParentFolderId() {
266                    return _parentFolderId;
267            }
268    
269            public void setParentFolderId(long parentFolderId) {
270                    _parentFolderId = parentFolderId;
271            }
272    
273            @JSON
274            public String getEvent() {
275                    if (_event == null) {
276                            return StringPool.BLANK;
277                    }
278                    else {
279                            return _event;
280                    }
281            }
282    
283            public void setEvent(String event) {
284                    _event = event;
285            }
286    
287            @JSON
288            public String getType() {
289                    if (_type == null) {
290                            return StringPool.BLANK;
291                    }
292                    else {
293                            return _type;
294                    }
295            }
296    
297            public void setType(String type) {
298                    _type = type;
299            }
300    
301            public long getColumnBitmask() {
302                    return _columnBitmask;
303            }
304    
305            @Override
306            public DLSync toEscapedModel() {
307                    if (_escapedModelProxy == null) {
308                            _escapedModelProxy = (DLSync)ProxyUtil.newProxyInstance(_classLoader,
309                                            _escapedModelProxyInterfaces,
310                                            new AutoEscapeBeanHandler(this));
311                    }
312    
313                    return _escapedModelProxy;
314            }
315    
316            @Override
317            public ExpandoBridge getExpandoBridge() {
318                    if (_expandoBridge == null) {
319                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
320                                            DLSync.class.getName(), getPrimaryKey());
321                    }
322    
323                    return _expandoBridge;
324            }
325    
326            @Override
327            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
328                    getExpandoBridge().setAttributes(serviceContext);
329            }
330    
331            @Override
332            public Object clone() {
333                    DLSyncImpl dlSyncImpl = new DLSyncImpl();
334    
335                    dlSyncImpl.setSyncId(getSyncId());
336                    dlSyncImpl.setCompanyId(getCompanyId());
337                    dlSyncImpl.setCreateDate(getCreateDate());
338                    dlSyncImpl.setModifiedDate(getModifiedDate());
339                    dlSyncImpl.setFileId(getFileId());
340                    dlSyncImpl.setRepositoryId(getRepositoryId());
341                    dlSyncImpl.setParentFolderId(getParentFolderId());
342                    dlSyncImpl.setEvent(getEvent());
343                    dlSyncImpl.setType(getType());
344    
345                    dlSyncImpl.resetOriginalValues();
346    
347                    return dlSyncImpl;
348            }
349    
350            public int compareTo(DLSync dlSync) {
351                    int value = 0;
352    
353                    if (getCompanyId() < dlSync.getCompanyId()) {
354                            value = -1;
355                    }
356                    else if (getCompanyId() > dlSync.getCompanyId()) {
357                            value = 1;
358                    }
359                    else {
360                            value = 0;
361                    }
362    
363                    if (value != 0) {
364                            return value;
365                    }
366    
367                    if (getRepositoryId() < dlSync.getRepositoryId()) {
368                            value = -1;
369                    }
370                    else if (getRepositoryId() > dlSync.getRepositoryId()) {
371                            value = 1;
372                    }
373                    else {
374                            value = 0;
375                    }
376    
377                    if (value != 0) {
378                            return value;
379                    }
380    
381                    value = DateUtil.compareTo(getModifiedDate(), dlSync.getModifiedDate());
382    
383                    if (value != 0) {
384                            return value;
385                    }
386    
387                    return 0;
388            }
389    
390            @Override
391            public boolean equals(Object obj) {
392                    if (obj == null) {
393                            return false;
394                    }
395    
396                    DLSync dlSync = null;
397    
398                    try {
399                            dlSync = (DLSync)obj;
400                    }
401                    catch (ClassCastException cce) {
402                            return false;
403                    }
404    
405                    long primaryKey = dlSync.getPrimaryKey();
406    
407                    if (getPrimaryKey() == primaryKey) {
408                            return true;
409                    }
410                    else {
411                            return false;
412                    }
413            }
414    
415            @Override
416            public int hashCode() {
417                    return (int)getPrimaryKey();
418            }
419    
420            @Override
421            public void resetOriginalValues() {
422                    DLSyncModelImpl dlSyncModelImpl = this;
423    
424                    dlSyncModelImpl._originalCompanyId = dlSyncModelImpl._companyId;
425    
426                    dlSyncModelImpl._setOriginalCompanyId = false;
427    
428                    dlSyncModelImpl._originalModifiedDate = dlSyncModelImpl._modifiedDate;
429    
430                    dlSyncModelImpl._originalFileId = dlSyncModelImpl._fileId;
431    
432                    dlSyncModelImpl._setOriginalFileId = false;
433    
434                    dlSyncModelImpl._originalRepositoryId = dlSyncModelImpl._repositoryId;
435    
436                    dlSyncModelImpl._setOriginalRepositoryId = false;
437    
438                    dlSyncModelImpl._columnBitmask = 0;
439            }
440    
441            @Override
442            public CacheModel<DLSync> toCacheModel() {
443                    DLSyncCacheModel dlSyncCacheModel = new DLSyncCacheModel();
444    
445                    dlSyncCacheModel.syncId = getSyncId();
446    
447                    dlSyncCacheModel.companyId = getCompanyId();
448    
449                    Date createDate = getCreateDate();
450    
451                    if (createDate != null) {
452                            dlSyncCacheModel.createDate = createDate.getTime();
453                    }
454                    else {
455                            dlSyncCacheModel.createDate = Long.MIN_VALUE;
456                    }
457    
458                    Date modifiedDate = getModifiedDate();
459    
460                    if (modifiedDate != null) {
461                            dlSyncCacheModel.modifiedDate = modifiedDate.getTime();
462                    }
463                    else {
464                            dlSyncCacheModel.modifiedDate = Long.MIN_VALUE;
465                    }
466    
467                    dlSyncCacheModel.fileId = getFileId();
468    
469                    dlSyncCacheModel.repositoryId = getRepositoryId();
470    
471                    dlSyncCacheModel.parentFolderId = getParentFolderId();
472    
473                    dlSyncCacheModel.event = getEvent();
474    
475                    String event = dlSyncCacheModel.event;
476    
477                    if ((event != null) && (event.length() == 0)) {
478                            dlSyncCacheModel.event = null;
479                    }
480    
481                    dlSyncCacheModel.type = getType();
482    
483                    String type = dlSyncCacheModel.type;
484    
485                    if ((type != null) && (type.length() == 0)) {
486                            dlSyncCacheModel.type = null;
487                    }
488    
489                    return dlSyncCacheModel;
490            }
491    
492            @Override
493            public String toString() {
494                    StringBundler sb = new StringBundler(19);
495    
496                    sb.append("{syncId=");
497                    sb.append(getSyncId());
498                    sb.append(", companyId=");
499                    sb.append(getCompanyId());
500                    sb.append(", createDate=");
501                    sb.append(getCreateDate());
502                    sb.append(", modifiedDate=");
503                    sb.append(getModifiedDate());
504                    sb.append(", fileId=");
505                    sb.append(getFileId());
506                    sb.append(", repositoryId=");
507                    sb.append(getRepositoryId());
508                    sb.append(", parentFolderId=");
509                    sb.append(getParentFolderId());
510                    sb.append(", event=");
511                    sb.append(getEvent());
512                    sb.append(", type=");
513                    sb.append(getType());
514                    sb.append("}");
515    
516                    return sb.toString();
517            }
518    
519            public String toXmlString() {
520                    StringBundler sb = new StringBundler(31);
521    
522                    sb.append("<model><model-name>");
523                    sb.append("com.liferay.portlet.documentlibrary.model.DLSync");
524                    sb.append("</model-name>");
525    
526                    sb.append(
527                            "<column><column-name>syncId</column-name><column-value><![CDATA[");
528                    sb.append(getSyncId());
529                    sb.append("]]></column-value></column>");
530                    sb.append(
531                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
532                    sb.append(getCompanyId());
533                    sb.append("]]></column-value></column>");
534                    sb.append(
535                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
536                    sb.append(getCreateDate());
537                    sb.append("]]></column-value></column>");
538                    sb.append(
539                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
540                    sb.append(getModifiedDate());
541                    sb.append("]]></column-value></column>");
542                    sb.append(
543                            "<column><column-name>fileId</column-name><column-value><![CDATA[");
544                    sb.append(getFileId());
545                    sb.append("]]></column-value></column>");
546                    sb.append(
547                            "<column><column-name>repositoryId</column-name><column-value><![CDATA[");
548                    sb.append(getRepositoryId());
549                    sb.append("]]></column-value></column>");
550                    sb.append(
551                            "<column><column-name>parentFolderId</column-name><column-value><![CDATA[");
552                    sb.append(getParentFolderId());
553                    sb.append("]]></column-value></column>");
554                    sb.append(
555                            "<column><column-name>event</column-name><column-value><![CDATA[");
556                    sb.append(getEvent());
557                    sb.append("]]></column-value></column>");
558                    sb.append(
559                            "<column><column-name>type</column-name><column-value><![CDATA[");
560                    sb.append(getType());
561                    sb.append("]]></column-value></column>");
562    
563                    sb.append("</model>");
564    
565                    return sb.toString();
566            }
567    
568            private static ClassLoader _classLoader = DLSync.class.getClassLoader();
569            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
570                            DLSync.class
571                    };
572            private long _syncId;
573            private long _companyId;
574            private long _originalCompanyId;
575            private boolean _setOriginalCompanyId;
576            private Date _createDate;
577            private Date _modifiedDate;
578            private Date _originalModifiedDate;
579            private long _fileId;
580            private long _originalFileId;
581            private boolean _setOriginalFileId;
582            private long _repositoryId;
583            private long _originalRepositoryId;
584            private boolean _setOriginalRepositoryId;
585            private long _parentFolderId;
586            private String _event;
587            private String _type;
588            private transient ExpandoBridge _expandoBridge;
589            private long _columnBitmask;
590            private DLSync _escapedModelProxy;
591    }