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