001    /**
002     * Copyright (c) 2000-present 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 aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
020    import com.liferay.portal.kernel.exception.PortalException;
021    import com.liferay.portal.kernel.util.DateUtil;
022    import com.liferay.portal.kernel.util.GetterUtil;
023    import com.liferay.portal.kernel.util.ProxyUtil;
024    import com.liferay.portal.kernel.util.StringBundler;
025    import com.liferay.portal.kernel.util.StringPool;
026    import com.liferay.portal.model.CacheModel;
027    import com.liferay.portal.model.User;
028    import com.liferay.portal.model.impl.BaseModelImpl;
029    import com.liferay.portal.service.ServiceContext;
030    import com.liferay.portal.service.UserLocalServiceUtil;
031    
032    import com.liferay.portlet.documentlibrary.model.DLFileRank;
033    import com.liferay.portlet.documentlibrary.model.DLFileRankModel;
034    import com.liferay.portlet.expando.model.ExpandoBridge;
035    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
036    
037    import java.io.Serializable;
038    
039    import java.sql.Types;
040    
041    import java.util.Date;
042    import java.util.HashMap;
043    import java.util.Map;
044    
045    /**
046     * The base model implementation for the DLFileRank service. Represents a row in the "DLFileRank" database table, with each column mapped to a property of this class.
047     *
048     * <p>
049     * This implementation and its corresponding interface {@link com.liferay.portlet.documentlibrary.model.DLFileRankModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DLFileRankImpl}.
050     * </p>
051     *
052     * @author Brian Wing Shun Chan
053     * @see DLFileRankImpl
054     * @see com.liferay.portlet.documentlibrary.model.DLFileRank
055     * @see com.liferay.portlet.documentlibrary.model.DLFileRankModel
056     * @generated
057     */
058    @ProviderType
059    public class DLFileRankModelImpl extends BaseModelImpl<DLFileRank>
060            implements DLFileRankModel {
061            /*
062             * NOTE FOR DEVELOPERS:
063             *
064             * Never modify or reference this class directly. All methods that expect a document library file rank model instance should use the {@link com.liferay.portlet.documentlibrary.model.DLFileRank} interface instead.
065             */
066            public static final String TABLE_NAME = "DLFileRank";
067            public static final Object[][] TABLE_COLUMNS = {
068                            { "fileRankId", Types.BIGINT },
069                            { "groupId", Types.BIGINT },
070                            { "companyId", Types.BIGINT },
071                            { "userId", Types.BIGINT },
072                            { "createDate", Types.TIMESTAMP },
073                            { "fileEntryId", Types.BIGINT },
074                            { "active_", Types.BOOLEAN }
075                    };
076            public static final String TABLE_SQL_CREATE = "create table DLFileRank (fileRankId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,createDate DATE null,fileEntryId LONG,active_ BOOLEAN)";
077            public static final String TABLE_SQL_DROP = "drop table DLFileRank";
078            public static final String ORDER_BY_JPQL = " ORDER BY dlFileRank.createDate DESC";
079            public static final String ORDER_BY_SQL = " ORDER BY DLFileRank.createDate DESC";
080            public static final String DATA_SOURCE = "liferayDataSource";
081            public static final String SESSION_FACTORY = "liferaySessionFactory";
082            public static final String TX_MANAGER = "liferayTransactionManager";
083            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084                                    "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileRank"),
085                            true);
086            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
087                                    "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileRank"),
088                            true);
089            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
090                                    "value.object.column.bitmask.enabled.com.liferay.portlet.documentlibrary.model.DLFileRank"),
091                            true);
092            public static final long ACTIVE_COLUMN_BITMASK = 1L;
093            public static final long COMPANYID_COLUMN_BITMASK = 2L;
094            public static final long FILEENTRYID_COLUMN_BITMASK = 4L;
095            public static final long GROUPID_COLUMN_BITMASK = 8L;
096            public static final long USERID_COLUMN_BITMASK = 16L;
097            public static final long CREATEDATE_COLUMN_BITMASK = 32L;
098            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
099                                    "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileRank"));
100    
101            public DLFileRankModelImpl() {
102            }
103    
104            @Override
105            public long getPrimaryKey() {
106                    return _fileRankId;
107            }
108    
109            @Override
110            public void setPrimaryKey(long primaryKey) {
111                    setFileRankId(primaryKey);
112            }
113    
114            @Override
115            public Serializable getPrimaryKeyObj() {
116                    return _fileRankId;
117            }
118    
119            @Override
120            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
121                    setPrimaryKey(((Long)primaryKeyObj).longValue());
122            }
123    
124            @Override
125            public Class<?> getModelClass() {
126                    return DLFileRank.class;
127            }
128    
129            @Override
130            public String getModelClassName() {
131                    return DLFileRank.class.getName();
132            }
133    
134            @Override
135            public Map<String, Object> getModelAttributes() {
136                    Map<String, Object> attributes = new HashMap<String, Object>();
137    
138                    attributes.put("fileRankId", getFileRankId());
139                    attributes.put("groupId", getGroupId());
140                    attributes.put("companyId", getCompanyId());
141                    attributes.put("userId", getUserId());
142                    attributes.put("createDate", getCreateDate());
143                    attributes.put("fileEntryId", getFileEntryId());
144                    attributes.put("active", getActive());
145    
146                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
147                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
148    
149                    return attributes;
150            }
151    
152            @Override
153            public void setModelAttributes(Map<String, Object> attributes) {
154                    Long fileRankId = (Long)attributes.get("fileRankId");
155    
156                    if (fileRankId != null) {
157                            setFileRankId(fileRankId);
158                    }
159    
160                    Long groupId = (Long)attributes.get("groupId");
161    
162                    if (groupId != null) {
163                            setGroupId(groupId);
164                    }
165    
166                    Long companyId = (Long)attributes.get("companyId");
167    
168                    if (companyId != null) {
169                            setCompanyId(companyId);
170                    }
171    
172                    Long userId = (Long)attributes.get("userId");
173    
174                    if (userId != null) {
175                            setUserId(userId);
176                    }
177    
178                    Date createDate = (Date)attributes.get("createDate");
179    
180                    if (createDate != null) {
181                            setCreateDate(createDate);
182                    }
183    
184                    Long fileEntryId = (Long)attributes.get("fileEntryId");
185    
186                    if (fileEntryId != null) {
187                            setFileEntryId(fileEntryId);
188                    }
189    
190                    Boolean active = (Boolean)attributes.get("active");
191    
192                    if (active != null) {
193                            setActive(active);
194                    }
195            }
196    
197            @Override
198            public long getFileRankId() {
199                    return _fileRankId;
200            }
201    
202            @Override
203            public void setFileRankId(long fileRankId) {
204                    _fileRankId = fileRankId;
205            }
206    
207            @Override
208            public long getGroupId() {
209                    return _groupId;
210            }
211    
212            @Override
213            public void setGroupId(long groupId) {
214                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
215    
216                    if (!_setOriginalGroupId) {
217                            _setOriginalGroupId = true;
218    
219                            _originalGroupId = _groupId;
220                    }
221    
222                    _groupId = groupId;
223            }
224    
225            public long getOriginalGroupId() {
226                    return _originalGroupId;
227            }
228    
229            @Override
230            public long getCompanyId() {
231                    return _companyId;
232            }
233    
234            @Override
235            public void setCompanyId(long companyId) {
236                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
237    
238                    if (!_setOriginalCompanyId) {
239                            _setOriginalCompanyId = true;
240    
241                            _originalCompanyId = _companyId;
242                    }
243    
244                    _companyId = companyId;
245            }
246    
247            public long getOriginalCompanyId() {
248                    return _originalCompanyId;
249            }
250    
251            @Override
252            public long getUserId() {
253                    return _userId;
254            }
255    
256            @Override
257            public void setUserId(long userId) {
258                    _columnBitmask |= USERID_COLUMN_BITMASK;
259    
260                    if (!_setOriginalUserId) {
261                            _setOriginalUserId = true;
262    
263                            _originalUserId = _userId;
264                    }
265    
266                    _userId = userId;
267            }
268    
269            @Override
270            public String getUserUuid() {
271                    try {
272                            User user = UserLocalServiceUtil.getUserById(getUserId());
273    
274                            return user.getUuid();
275                    }
276                    catch (PortalException pe) {
277                            return StringPool.BLANK;
278                    }
279            }
280    
281            @Override
282            public void setUserUuid(String userUuid) {
283            }
284    
285            public long getOriginalUserId() {
286                    return _originalUserId;
287            }
288    
289            @Override
290            public Date getCreateDate() {
291                    return _createDate;
292            }
293    
294            @Override
295            public void setCreateDate(Date createDate) {
296                    _columnBitmask = -1L;
297    
298                    _createDate = createDate;
299            }
300    
301            @Override
302            public long getFileEntryId() {
303                    return _fileEntryId;
304            }
305    
306            @Override
307            public void setFileEntryId(long fileEntryId) {
308                    _columnBitmask |= FILEENTRYID_COLUMN_BITMASK;
309    
310                    if (!_setOriginalFileEntryId) {
311                            _setOriginalFileEntryId = true;
312    
313                            _originalFileEntryId = _fileEntryId;
314                    }
315    
316                    _fileEntryId = fileEntryId;
317            }
318    
319            public long getOriginalFileEntryId() {
320                    return _originalFileEntryId;
321            }
322    
323            @Override
324            public boolean getActive() {
325                    return _active;
326            }
327    
328            @Override
329            public boolean isActive() {
330                    return _active;
331            }
332    
333            @Override
334            public void setActive(boolean active) {
335                    _columnBitmask |= ACTIVE_COLUMN_BITMASK;
336    
337                    if (!_setOriginalActive) {
338                            _setOriginalActive = true;
339    
340                            _originalActive = _active;
341                    }
342    
343                    _active = active;
344            }
345    
346            public boolean getOriginalActive() {
347                    return _originalActive;
348            }
349    
350            public long getColumnBitmask() {
351                    return _columnBitmask;
352            }
353    
354            @Override
355            public ExpandoBridge getExpandoBridge() {
356                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
357                            DLFileRank.class.getName(), getPrimaryKey());
358            }
359    
360            @Override
361            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
362                    ExpandoBridge expandoBridge = getExpandoBridge();
363    
364                    expandoBridge.setAttributes(serviceContext);
365            }
366    
367            @Override
368            public DLFileRank toEscapedModel() {
369                    if (_escapedModel == null) {
370                            _escapedModel = (DLFileRank)ProxyUtil.newProxyInstance(_classLoader,
371                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
372                    }
373    
374                    return _escapedModel;
375            }
376    
377            @Override
378            public Object clone() {
379                    DLFileRankImpl dlFileRankImpl = new DLFileRankImpl();
380    
381                    dlFileRankImpl.setFileRankId(getFileRankId());
382                    dlFileRankImpl.setGroupId(getGroupId());
383                    dlFileRankImpl.setCompanyId(getCompanyId());
384                    dlFileRankImpl.setUserId(getUserId());
385                    dlFileRankImpl.setCreateDate(getCreateDate());
386                    dlFileRankImpl.setFileEntryId(getFileEntryId());
387                    dlFileRankImpl.setActive(getActive());
388    
389                    dlFileRankImpl.resetOriginalValues();
390    
391                    return dlFileRankImpl;
392            }
393    
394            @Override
395            public int compareTo(DLFileRank dlFileRank) {
396                    int value = 0;
397    
398                    value = DateUtil.compareTo(getCreateDate(), dlFileRank.getCreateDate());
399    
400                    value = value * -1;
401    
402                    if (value != 0) {
403                            return value;
404                    }
405    
406                    return 0;
407            }
408    
409            @Override
410            public boolean equals(Object obj) {
411                    if (this == obj) {
412                            return true;
413                    }
414    
415                    if (!(obj instanceof DLFileRank)) {
416                            return false;
417                    }
418    
419                    DLFileRank dlFileRank = (DLFileRank)obj;
420    
421                    long primaryKey = dlFileRank.getPrimaryKey();
422    
423                    if (getPrimaryKey() == primaryKey) {
424                            return true;
425                    }
426                    else {
427                            return false;
428                    }
429            }
430    
431            @Override
432            public int hashCode() {
433                    return (int)getPrimaryKey();
434            }
435    
436            @Override
437            public boolean isEntityCacheEnabled() {
438                    return ENTITY_CACHE_ENABLED;
439            }
440    
441            @Override
442            public boolean isFinderCacheEnabled() {
443                    return FINDER_CACHE_ENABLED;
444            }
445    
446            @Override
447            public void resetOriginalValues() {
448                    DLFileRankModelImpl dlFileRankModelImpl = this;
449    
450                    dlFileRankModelImpl._originalGroupId = dlFileRankModelImpl._groupId;
451    
452                    dlFileRankModelImpl._setOriginalGroupId = false;
453    
454                    dlFileRankModelImpl._originalCompanyId = dlFileRankModelImpl._companyId;
455    
456                    dlFileRankModelImpl._setOriginalCompanyId = false;
457    
458                    dlFileRankModelImpl._originalUserId = dlFileRankModelImpl._userId;
459    
460                    dlFileRankModelImpl._setOriginalUserId = false;
461    
462                    dlFileRankModelImpl._originalFileEntryId = dlFileRankModelImpl._fileEntryId;
463    
464                    dlFileRankModelImpl._setOriginalFileEntryId = false;
465    
466                    dlFileRankModelImpl._originalActive = dlFileRankModelImpl._active;
467    
468                    dlFileRankModelImpl._setOriginalActive = false;
469    
470                    dlFileRankModelImpl._columnBitmask = 0;
471            }
472    
473            @Override
474            public CacheModel<DLFileRank> toCacheModel() {
475                    DLFileRankCacheModel dlFileRankCacheModel = new DLFileRankCacheModel();
476    
477                    dlFileRankCacheModel.fileRankId = getFileRankId();
478    
479                    dlFileRankCacheModel.groupId = getGroupId();
480    
481                    dlFileRankCacheModel.companyId = getCompanyId();
482    
483                    dlFileRankCacheModel.userId = getUserId();
484    
485                    Date createDate = getCreateDate();
486    
487                    if (createDate != null) {
488                            dlFileRankCacheModel.createDate = createDate.getTime();
489                    }
490                    else {
491                            dlFileRankCacheModel.createDate = Long.MIN_VALUE;
492                    }
493    
494                    dlFileRankCacheModel.fileEntryId = getFileEntryId();
495    
496                    dlFileRankCacheModel.active = getActive();
497    
498                    return dlFileRankCacheModel;
499            }
500    
501            @Override
502            public String toString() {
503                    StringBundler sb = new StringBundler(15);
504    
505                    sb.append("{fileRankId=");
506                    sb.append(getFileRankId());
507                    sb.append(", groupId=");
508                    sb.append(getGroupId());
509                    sb.append(", companyId=");
510                    sb.append(getCompanyId());
511                    sb.append(", userId=");
512                    sb.append(getUserId());
513                    sb.append(", createDate=");
514                    sb.append(getCreateDate());
515                    sb.append(", fileEntryId=");
516                    sb.append(getFileEntryId());
517                    sb.append(", active=");
518                    sb.append(getActive());
519                    sb.append("}");
520    
521                    return sb.toString();
522            }
523    
524            @Override
525            public String toXmlString() {
526                    StringBundler sb = new StringBundler(25);
527    
528                    sb.append("<model><model-name>");
529                    sb.append("com.liferay.portlet.documentlibrary.model.DLFileRank");
530                    sb.append("</model-name>");
531    
532                    sb.append(
533                            "<column><column-name>fileRankId</column-name><column-value><![CDATA[");
534                    sb.append(getFileRankId());
535                    sb.append("]]></column-value></column>");
536                    sb.append(
537                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
538                    sb.append(getGroupId());
539                    sb.append("]]></column-value></column>");
540                    sb.append(
541                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
542                    sb.append(getCompanyId());
543                    sb.append("]]></column-value></column>");
544                    sb.append(
545                            "<column><column-name>userId</column-name><column-value><![CDATA[");
546                    sb.append(getUserId());
547                    sb.append("]]></column-value></column>");
548                    sb.append(
549                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
550                    sb.append(getCreateDate());
551                    sb.append("]]></column-value></column>");
552                    sb.append(
553                            "<column><column-name>fileEntryId</column-name><column-value><![CDATA[");
554                    sb.append(getFileEntryId());
555                    sb.append("]]></column-value></column>");
556                    sb.append(
557                            "<column><column-name>active</column-name><column-value><![CDATA[");
558                    sb.append(getActive());
559                    sb.append("]]></column-value></column>");
560    
561                    sb.append("</model>");
562    
563                    return sb.toString();
564            }
565    
566            private static final ClassLoader _classLoader = DLFileRank.class.getClassLoader();
567            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
568                            DLFileRank.class
569                    };
570            private long _fileRankId;
571            private long _groupId;
572            private long _originalGroupId;
573            private boolean _setOriginalGroupId;
574            private long _companyId;
575            private long _originalCompanyId;
576            private boolean _setOriginalCompanyId;
577            private long _userId;
578            private long _originalUserId;
579            private boolean _setOriginalUserId;
580            private Date _createDate;
581            private long _fileEntryId;
582            private long _originalFileEntryId;
583            private boolean _setOriginalFileEntryId;
584            private boolean _active;
585            private boolean _originalActive;
586            private boolean _setOriginalActive;
587            private long _columnBitmask;
588            private DLFileRank _escapedModel;
589    }