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