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