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.kernel.util.StringPool;
024    import com.liferay.portal.model.CacheModel;
025    import com.liferay.portal.model.impl.BaseModelImpl;
026    import com.liferay.portal.service.ServiceContext;
027    import com.liferay.portal.util.PortalUtil;
028    
029    import com.liferay.portlet.documentlibrary.model.DLFileRank;
030    import com.liferay.portlet.documentlibrary.model.DLFileRankModel;
031    import com.liferay.portlet.expando.model.ExpandoBridge;
032    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
033    
034    import java.io.Serializable;
035    
036    import java.sql.Types;
037    
038    import java.util.Date;
039    import java.util.HashMap;
040    import java.util.Map;
041    
042    /**
043     * 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.
044     *
045     * <p>
046     * 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}.
047     * </p>
048     *
049     * @author Brian Wing Shun Chan
050     * @see DLFileRankImpl
051     * @see com.liferay.portlet.documentlibrary.model.DLFileRank
052     * @see com.liferay.portlet.documentlibrary.model.DLFileRankModel
053     * @generated
054     */
055    public class DLFileRankModelImpl extends BaseModelImpl<DLFileRank>
056            implements DLFileRankModel {
057            /*
058             * NOTE FOR DEVELOPERS:
059             *
060             * 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.
061             */
062            public static final String TABLE_NAME = "DLFileRank";
063            public static final Object[][] TABLE_COLUMNS = {
064                            { "uuid_", Types.VARCHAR },
065                            { "fileRankId", Types.BIGINT },
066                            { "groupId", Types.BIGINT },
067                            { "companyId", Types.BIGINT },
068                            { "userId", Types.BIGINT },
069                            { "userName", Types.VARCHAR },
070                            { "createDate", Types.TIMESTAMP },
071                            { "modifiedDate", Types.TIMESTAMP },
072                            { "fileEntryId", Types.BIGINT },
073                            { "active_", Types.BOOLEAN }
074                    };
075            public static final String TABLE_SQL_CREATE = "create table DLFileRank (uuid_ VARCHAR(75) null,fileRankId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,fileEntryId LONG,active_ BOOLEAN)";
076            public static final String TABLE_SQL_DROP = "drop table DLFileRank";
077            public static final String ORDER_BY_JPQL = " ORDER BY dlFileRank.createDate DESC";
078            public static final String ORDER_BY_SQL = " ORDER BY DLFileRank.createDate DESC";
079            public static final String DATA_SOURCE = "liferayDataSource";
080            public static final String SESSION_FACTORY = "liferaySessionFactory";
081            public static final String TX_MANAGER = "liferayTransactionManager";
082            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
083                                    "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileRank"),
084                            true);
085            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086                                    "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileRank"),
087                            true);
088            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
089                                    "value.object.column.bitmask.enabled.com.liferay.portlet.documentlibrary.model.DLFileRank"),
090                            true);
091            public static long ACTIVE_COLUMN_BITMASK = 1L;
092            public static long COMPANYID_COLUMN_BITMASK = 2L;
093            public static long FILEENTRYID_COLUMN_BITMASK = 4L;
094            public static long GROUPID_COLUMN_BITMASK = 8L;
095            public static long USERID_COLUMN_BITMASK = 16L;
096            public static long UUID_COLUMN_BITMASK = 32L;
097            public static long CREATEDATE_COLUMN_BITMASK = 64L;
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            public long getPrimaryKey() {
105                    return _fileRankId;
106            }
107    
108            public void setPrimaryKey(long primaryKey) {
109                    setFileRankId(primaryKey);
110            }
111    
112            public Serializable getPrimaryKeyObj() {
113                    return _fileRankId;
114            }
115    
116            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
117                    setPrimaryKey(((Long)primaryKeyObj).longValue());
118            }
119    
120            public Class<?> getModelClass() {
121                    return DLFileRank.class;
122            }
123    
124            public String getModelClassName() {
125                    return DLFileRank.class.getName();
126            }
127    
128            @Override
129            public Map<String, Object> getModelAttributes() {
130                    Map<String, Object> attributes = new HashMap<String, Object>();
131    
132                    attributes.put("uuid", getUuid());
133                    attributes.put("fileRankId", getFileRankId());
134                    attributes.put("groupId", getGroupId());
135                    attributes.put("companyId", getCompanyId());
136                    attributes.put("userId", getUserId());
137                    attributes.put("userName", getUserName());
138                    attributes.put("createDate", getCreateDate());
139                    attributes.put("modifiedDate", getModifiedDate());
140                    attributes.put("fileEntryId", getFileEntryId());
141                    attributes.put("active", getActive());
142    
143                    return attributes;
144            }
145    
146            @Override
147            public void setModelAttributes(Map<String, Object> attributes) {
148                    String uuid = (String)attributes.get("uuid");
149    
150                    if (uuid != null) {
151                            setUuid(uuid);
152                    }
153    
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                    String userName = (String)attributes.get("userName");
179    
180                    if (userName != null) {
181                            setUserName(userName);
182                    }
183    
184                    Date createDate = (Date)attributes.get("createDate");
185    
186                    if (createDate != null) {
187                            setCreateDate(createDate);
188                    }
189    
190                    Date modifiedDate = (Date)attributes.get("modifiedDate");
191    
192                    if (modifiedDate != null) {
193                            setModifiedDate(modifiedDate);
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            public String getUuid() {
210                    if (_uuid == null) {
211                            return StringPool.BLANK;
212                    }
213                    else {
214                            return _uuid;
215                    }
216            }
217    
218            public void setUuid(String uuid) {
219                    if (_originalUuid == null) {
220                            _originalUuid = _uuid;
221                    }
222    
223                    _uuid = uuid;
224            }
225    
226            public String getOriginalUuid() {
227                    return GetterUtil.getString(_originalUuid);
228            }
229    
230            public long getFileRankId() {
231                    return _fileRankId;
232            }
233    
234            public void setFileRankId(long fileRankId) {
235                    _fileRankId = fileRankId;
236            }
237    
238            public long getGroupId() {
239                    return _groupId;
240            }
241    
242            public void setGroupId(long groupId) {
243                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
244    
245                    if (!_setOriginalGroupId) {
246                            _setOriginalGroupId = true;
247    
248                            _originalGroupId = _groupId;
249                    }
250    
251                    _groupId = groupId;
252            }
253    
254            public long getOriginalGroupId() {
255                    return _originalGroupId;
256            }
257    
258            public long getCompanyId() {
259                    return _companyId;
260            }
261    
262            public void setCompanyId(long companyId) {
263                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
264    
265                    if (!_setOriginalCompanyId) {
266                            _setOriginalCompanyId = true;
267    
268                            _originalCompanyId = _companyId;
269                    }
270    
271                    _companyId = companyId;
272            }
273    
274            public long getOriginalCompanyId() {
275                    return _originalCompanyId;
276            }
277    
278            public long getUserId() {
279                    return _userId;
280            }
281    
282            public void setUserId(long userId) {
283                    _columnBitmask |= USERID_COLUMN_BITMASK;
284    
285                    if (!_setOriginalUserId) {
286                            _setOriginalUserId = true;
287    
288                            _originalUserId = _userId;
289                    }
290    
291                    _userId = userId;
292            }
293    
294            public String getUserUuid() throws SystemException {
295                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
296            }
297    
298            public void setUserUuid(String userUuid) {
299                    _userUuid = userUuid;
300            }
301    
302            public long getOriginalUserId() {
303                    return _originalUserId;
304            }
305    
306            public String getUserName() {
307                    if (_userName == null) {
308                            return StringPool.BLANK;
309                    }
310                    else {
311                            return _userName;
312                    }
313            }
314    
315            public void setUserName(String userName) {
316                    _userName = userName;
317            }
318    
319            public Date getCreateDate() {
320                    return _createDate;
321            }
322    
323            public void setCreateDate(Date createDate) {
324                    _columnBitmask = -1L;
325    
326                    _createDate = createDate;
327            }
328    
329            public Date getModifiedDate() {
330                    return _modifiedDate;
331            }
332    
333            public void setModifiedDate(Date modifiedDate) {
334                    _modifiedDate = modifiedDate;
335            }
336    
337            public long getFileEntryId() {
338                    return _fileEntryId;
339            }
340    
341            public void setFileEntryId(long fileEntryId) {
342                    _columnBitmask |= FILEENTRYID_COLUMN_BITMASK;
343    
344                    if (!_setOriginalFileEntryId) {
345                            _setOriginalFileEntryId = true;
346    
347                            _originalFileEntryId = _fileEntryId;
348                    }
349    
350                    _fileEntryId = fileEntryId;
351            }
352    
353            public long getOriginalFileEntryId() {
354                    return _originalFileEntryId;
355            }
356    
357            public boolean getActive() {
358                    return _active;
359            }
360    
361            public boolean isActive() {
362                    return _active;
363            }
364    
365            public void setActive(boolean active) {
366                    _columnBitmask |= ACTIVE_COLUMN_BITMASK;
367    
368                    if (!_setOriginalActive) {
369                            _setOriginalActive = true;
370    
371                            _originalActive = _active;
372                    }
373    
374                    _active = active;
375            }
376    
377            public boolean getOriginalActive() {
378                    return _originalActive;
379            }
380    
381            public long getColumnBitmask() {
382                    return _columnBitmask;
383            }
384    
385            @Override
386            public ExpandoBridge getExpandoBridge() {
387                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
388                            DLFileRank.class.getName(), getPrimaryKey());
389            }
390    
391            @Override
392            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
393                    ExpandoBridge expandoBridge = getExpandoBridge();
394    
395                    expandoBridge.setAttributes(serviceContext);
396            }
397    
398            @Override
399            public DLFileRank toEscapedModel() {
400                    if (_escapedModel == null) {
401                            _escapedModel = (DLFileRank)ProxyUtil.newProxyInstance(_classLoader,
402                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
403                    }
404    
405                    return _escapedModel;
406            }
407    
408            @Override
409            public Object clone() {
410                    DLFileRankImpl dlFileRankImpl = new DLFileRankImpl();
411    
412                    dlFileRankImpl.setUuid(getUuid());
413                    dlFileRankImpl.setFileRankId(getFileRankId());
414                    dlFileRankImpl.setGroupId(getGroupId());
415                    dlFileRankImpl.setCompanyId(getCompanyId());
416                    dlFileRankImpl.setUserId(getUserId());
417                    dlFileRankImpl.setUserName(getUserName());
418                    dlFileRankImpl.setCreateDate(getCreateDate());
419                    dlFileRankImpl.setModifiedDate(getModifiedDate());
420                    dlFileRankImpl.setFileEntryId(getFileEntryId());
421                    dlFileRankImpl.setActive(getActive());
422    
423                    dlFileRankImpl.resetOriginalValues();
424    
425                    return dlFileRankImpl;
426            }
427    
428            public int compareTo(DLFileRank dlFileRank) {
429                    int value = 0;
430    
431                    value = DateUtil.compareTo(getCreateDate(), dlFileRank.getCreateDate());
432    
433                    value = value * -1;
434    
435                    if (value != 0) {
436                            return value;
437                    }
438    
439                    return 0;
440            }
441    
442            @Override
443            public boolean equals(Object obj) {
444                    if (obj == null) {
445                            return false;
446                    }
447    
448                    DLFileRank dlFileRank = null;
449    
450                    try {
451                            dlFileRank = (DLFileRank)obj;
452                    }
453                    catch (ClassCastException cce) {
454                            return false;
455                    }
456    
457                    long primaryKey = dlFileRank.getPrimaryKey();
458    
459                    if (getPrimaryKey() == primaryKey) {
460                            return true;
461                    }
462                    else {
463                            return false;
464                    }
465            }
466    
467            @Override
468            public int hashCode() {
469                    return (int)getPrimaryKey();
470            }
471    
472            @Override
473            public void resetOriginalValues() {
474                    DLFileRankModelImpl dlFileRankModelImpl = this;
475    
476                    dlFileRankModelImpl._originalUuid = dlFileRankModelImpl._uuid;
477    
478                    dlFileRankModelImpl._originalGroupId = dlFileRankModelImpl._groupId;
479    
480                    dlFileRankModelImpl._setOriginalGroupId = false;
481    
482                    dlFileRankModelImpl._originalCompanyId = dlFileRankModelImpl._companyId;
483    
484                    dlFileRankModelImpl._setOriginalCompanyId = false;
485    
486                    dlFileRankModelImpl._originalUserId = dlFileRankModelImpl._userId;
487    
488                    dlFileRankModelImpl._setOriginalUserId = false;
489    
490                    dlFileRankModelImpl._originalFileEntryId = dlFileRankModelImpl._fileEntryId;
491    
492                    dlFileRankModelImpl._setOriginalFileEntryId = false;
493    
494                    dlFileRankModelImpl._originalActive = dlFileRankModelImpl._active;
495    
496                    dlFileRankModelImpl._setOriginalActive = false;
497    
498                    dlFileRankModelImpl._columnBitmask = 0;
499            }
500    
501            @Override
502            public CacheModel<DLFileRank> toCacheModel() {
503                    DLFileRankCacheModel dlFileRankCacheModel = new DLFileRankCacheModel();
504    
505                    dlFileRankCacheModel.uuid = getUuid();
506    
507                    String uuid = dlFileRankCacheModel.uuid;
508    
509                    if ((uuid != null) && (uuid.length() == 0)) {
510                            dlFileRankCacheModel.uuid = null;
511                    }
512    
513                    dlFileRankCacheModel.fileRankId = getFileRankId();
514    
515                    dlFileRankCacheModel.groupId = getGroupId();
516    
517                    dlFileRankCacheModel.companyId = getCompanyId();
518    
519                    dlFileRankCacheModel.userId = getUserId();
520    
521                    dlFileRankCacheModel.userName = getUserName();
522    
523                    String userName = dlFileRankCacheModel.userName;
524    
525                    if ((userName != null) && (userName.length() == 0)) {
526                            dlFileRankCacheModel.userName = null;
527                    }
528    
529                    Date createDate = getCreateDate();
530    
531                    if (createDate != null) {
532                            dlFileRankCacheModel.createDate = createDate.getTime();
533                    }
534                    else {
535                            dlFileRankCacheModel.createDate = Long.MIN_VALUE;
536                    }
537    
538                    Date modifiedDate = getModifiedDate();
539    
540                    if (modifiedDate != null) {
541                            dlFileRankCacheModel.modifiedDate = modifiedDate.getTime();
542                    }
543                    else {
544                            dlFileRankCacheModel.modifiedDate = Long.MIN_VALUE;
545                    }
546    
547                    dlFileRankCacheModel.fileEntryId = getFileEntryId();
548    
549                    dlFileRankCacheModel.active = getActive();
550    
551                    return dlFileRankCacheModel;
552            }
553    
554            @Override
555            public String toString() {
556                    StringBundler sb = new StringBundler(21);
557    
558                    sb.append("{uuid=");
559                    sb.append(getUuid());
560                    sb.append(", fileRankId=");
561                    sb.append(getFileRankId());
562                    sb.append(", groupId=");
563                    sb.append(getGroupId());
564                    sb.append(", companyId=");
565                    sb.append(getCompanyId());
566                    sb.append(", userId=");
567                    sb.append(getUserId());
568                    sb.append(", userName=");
569                    sb.append(getUserName());
570                    sb.append(", createDate=");
571                    sb.append(getCreateDate());
572                    sb.append(", modifiedDate=");
573                    sb.append(getModifiedDate());
574                    sb.append(", fileEntryId=");
575                    sb.append(getFileEntryId());
576                    sb.append(", active=");
577                    sb.append(getActive());
578                    sb.append("}");
579    
580                    return sb.toString();
581            }
582    
583            public String toXmlString() {
584                    StringBundler sb = new StringBundler(34);
585    
586                    sb.append("<model><model-name>");
587                    sb.append("com.liferay.portlet.documentlibrary.model.DLFileRank");
588                    sb.append("</model-name>");
589    
590                    sb.append(
591                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
592                    sb.append(getUuid());
593                    sb.append("]]></column-value></column>");
594                    sb.append(
595                            "<column><column-name>fileRankId</column-name><column-value><![CDATA[");
596                    sb.append(getFileRankId());
597                    sb.append("]]></column-value></column>");
598                    sb.append(
599                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
600                    sb.append(getGroupId());
601                    sb.append("]]></column-value></column>");
602                    sb.append(
603                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
604                    sb.append(getCompanyId());
605                    sb.append("]]></column-value></column>");
606                    sb.append(
607                            "<column><column-name>userId</column-name><column-value><![CDATA[");
608                    sb.append(getUserId());
609                    sb.append("]]></column-value></column>");
610                    sb.append(
611                            "<column><column-name>userName</column-name><column-value><![CDATA[");
612                    sb.append(getUserName());
613                    sb.append("]]></column-value></column>");
614                    sb.append(
615                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
616                    sb.append(getCreateDate());
617                    sb.append("]]></column-value></column>");
618                    sb.append(
619                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
620                    sb.append(getModifiedDate());
621                    sb.append("]]></column-value></column>");
622                    sb.append(
623                            "<column><column-name>fileEntryId</column-name><column-value><![CDATA[");
624                    sb.append(getFileEntryId());
625                    sb.append("]]></column-value></column>");
626                    sb.append(
627                            "<column><column-name>active</column-name><column-value><![CDATA[");
628                    sb.append(getActive());
629                    sb.append("]]></column-value></column>");
630    
631                    sb.append("</model>");
632    
633                    return sb.toString();
634            }
635    
636            private static ClassLoader _classLoader = DLFileRank.class.getClassLoader();
637            private static Class<?>[] _escapedModelInterfaces = new Class[] {
638                            DLFileRank.class
639                    };
640            private String _uuid;
641            private String _originalUuid;
642            private long _fileRankId;
643            private long _groupId;
644            private long _originalGroupId;
645            private boolean _setOriginalGroupId;
646            private long _companyId;
647            private long _originalCompanyId;
648            private boolean _setOriginalCompanyId;
649            private long _userId;
650            private String _userUuid;
651            private long _originalUserId;
652            private boolean _setOriginalUserId;
653            private String _userName;
654            private Date _createDate;
655            private Date _modifiedDate;
656            private long _fileEntryId;
657            private long _originalFileEntryId;
658            private boolean _setOriginalFileEntryId;
659            private boolean _active;
660            private boolean _originalActive;
661            private boolean _setOriginalActive;
662            private long _columnBitmask;
663            private DLFileRank _escapedModel;
664    }