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