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 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            public long getPrimaryKey() {
100                    return _fileRankId;
101            }
102    
103            public void setPrimaryKey(long primaryKey) {
104                    setFileRankId(primaryKey);
105            }
106    
107            public Serializable getPrimaryKeyObj() {
108                    return new Long(_fileRankId);
109            }
110    
111            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
112                    setPrimaryKey(((Long)primaryKeyObj).longValue());
113            }
114    
115            public Class<?> getModelClass() {
116                    return DLFileRank.class;
117            }
118    
119            public String getModelClassName() {
120                    return DLFileRank.class.getName();
121            }
122    
123            @Override
124            public Map<String, Object> getModelAttributes() {
125                    Map<String, Object> attributes = new HashMap<String, Object>();
126    
127                    attributes.put("fileRankId", getFileRankId());
128                    attributes.put("groupId", getGroupId());
129                    attributes.put("companyId", getCompanyId());
130                    attributes.put("userId", getUserId());
131                    attributes.put("createDate", getCreateDate());
132                    attributes.put("fileEntryId", getFileEntryId());
133                    attributes.put("active", getActive());
134    
135                    return attributes;
136            }
137    
138            @Override
139            public void setModelAttributes(Map<String, Object> attributes) {
140                    Long fileRankId = (Long)attributes.get("fileRankId");
141    
142                    if (fileRankId != null) {
143                            setFileRankId(fileRankId);
144                    }
145    
146                    Long groupId = (Long)attributes.get("groupId");
147    
148                    if (groupId != null) {
149                            setGroupId(groupId);
150                    }
151    
152                    Long companyId = (Long)attributes.get("companyId");
153    
154                    if (companyId != null) {
155                            setCompanyId(companyId);
156                    }
157    
158                    Long userId = (Long)attributes.get("userId");
159    
160                    if (userId != null) {
161                            setUserId(userId);
162                    }
163    
164                    Date createDate = (Date)attributes.get("createDate");
165    
166                    if (createDate != null) {
167                            setCreateDate(createDate);
168                    }
169    
170                    Long fileEntryId = (Long)attributes.get("fileEntryId");
171    
172                    if (fileEntryId != null) {
173                            setFileEntryId(fileEntryId);
174                    }
175    
176                    Boolean active = (Boolean)attributes.get("active");
177    
178                    if (active != null) {
179                            setActive(active);
180                    }
181            }
182    
183            public long getFileRankId() {
184                    return _fileRankId;
185            }
186    
187            public void setFileRankId(long fileRankId) {
188                    _fileRankId = fileRankId;
189            }
190    
191            public long getGroupId() {
192                    return _groupId;
193            }
194    
195            public void setGroupId(long groupId) {
196                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
197    
198                    if (!_setOriginalGroupId) {
199                            _setOriginalGroupId = true;
200    
201                            _originalGroupId = _groupId;
202                    }
203    
204                    _groupId = groupId;
205            }
206    
207            public long getOriginalGroupId() {
208                    return _originalGroupId;
209            }
210    
211            public long getCompanyId() {
212                    return _companyId;
213            }
214    
215            public void setCompanyId(long companyId) {
216                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
217    
218                    if (!_setOriginalCompanyId) {
219                            _setOriginalCompanyId = true;
220    
221                            _originalCompanyId = _companyId;
222                    }
223    
224                    _companyId = companyId;
225            }
226    
227            public long getOriginalCompanyId() {
228                    return _originalCompanyId;
229            }
230    
231            public long getUserId() {
232                    return _userId;
233            }
234    
235            public void setUserId(long userId) {
236                    _columnBitmask |= USERID_COLUMN_BITMASK;
237    
238                    if (!_setOriginalUserId) {
239                            _setOriginalUserId = true;
240    
241                            _originalUserId = _userId;
242                    }
243    
244                    _userId = userId;
245            }
246    
247            public String getUserUuid() throws SystemException {
248                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
249            }
250    
251            public void setUserUuid(String userUuid) {
252                    _userUuid = userUuid;
253            }
254    
255            public long getOriginalUserId() {
256                    return _originalUserId;
257            }
258    
259            public Date getCreateDate() {
260                    return _createDate;
261            }
262    
263            public void setCreateDate(Date createDate) {
264                    _columnBitmask = -1L;
265    
266                    _createDate = createDate;
267            }
268    
269            public long getFileEntryId() {
270                    return _fileEntryId;
271            }
272    
273            public void setFileEntryId(long fileEntryId) {
274                    _columnBitmask |= FILEENTRYID_COLUMN_BITMASK;
275    
276                    if (!_setOriginalFileEntryId) {
277                            _setOriginalFileEntryId = true;
278    
279                            _originalFileEntryId = _fileEntryId;
280                    }
281    
282                    _fileEntryId = fileEntryId;
283            }
284    
285            public long getOriginalFileEntryId() {
286                    return _originalFileEntryId;
287            }
288    
289            public boolean getActive() {
290                    return _active;
291            }
292    
293            public boolean isActive() {
294                    return _active;
295            }
296    
297            public void setActive(boolean active) {
298                    _columnBitmask |= ACTIVE_COLUMN_BITMASK;
299    
300                    if (!_setOriginalActive) {
301                            _setOriginalActive = true;
302    
303                            _originalActive = _active;
304                    }
305    
306                    _active = active;
307            }
308    
309            public boolean getOriginalActive() {
310                    return _originalActive;
311            }
312    
313            public long getColumnBitmask() {
314                    return _columnBitmask;
315            }
316    
317            @Override
318            public ExpandoBridge getExpandoBridge() {
319                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
320                            DLFileRank.class.getName(), getPrimaryKey());
321            }
322    
323            @Override
324            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
325                    ExpandoBridge expandoBridge = getExpandoBridge();
326    
327                    expandoBridge.setAttributes(serviceContext);
328            }
329    
330            @Override
331            public DLFileRank toEscapedModel() {
332                    if (_escapedModel == null) {
333                            _escapedModel = (DLFileRank)ProxyUtil.newProxyInstance(_classLoader,
334                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
335                    }
336    
337                    return _escapedModel;
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<?>[] _escapedModelInterfaces = 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 _escapedModel;
544    }