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.trash.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.ProxyUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.kernel.util.Validator;
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.expando.model.ExpandoBridge;
029    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
030    import com.liferay.portlet.trash.model.TrashVersion;
031    import com.liferay.portlet.trash.model.TrashVersionModel;
032    
033    import java.io.Serializable;
034    
035    import java.sql.Types;
036    
037    import java.util.HashMap;
038    import java.util.Map;
039    
040    /**
041     * The base model implementation for the TrashVersion service. Represents a row in the "TrashVersion" database table, with each column mapped to a property of this class.
042     *
043     * <p>
044     * This implementation and its corresponding interface {@link com.liferay.portlet.trash.model.TrashVersionModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link TrashVersionImpl}.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see TrashVersionImpl
049     * @see com.liferay.portlet.trash.model.TrashVersion
050     * @see com.liferay.portlet.trash.model.TrashVersionModel
051     * @generated
052     */
053    public class TrashVersionModelImpl extends BaseModelImpl<TrashVersion>
054            implements TrashVersionModel {
055            /*
056             * NOTE FOR DEVELOPERS:
057             *
058             * Never modify or reference this class directly. All methods that expect a trash version model instance should use the {@link com.liferay.portlet.trash.model.TrashVersion} interface instead.
059             */
060            public static final String TABLE_NAME = "TrashVersion";
061            public static final Object[][] TABLE_COLUMNS = {
062                            { "versionId", Types.BIGINT },
063                            { "entryId", Types.BIGINT },
064                            { "classNameId", Types.BIGINT },
065                            { "classPK", Types.BIGINT },
066                            { "status", Types.INTEGER }
067                    };
068            public static final String TABLE_SQL_CREATE = "create table TrashVersion (versionId LONG not null primary key,entryId LONG,classNameId LONG,classPK LONG,status INTEGER)";
069            public static final String TABLE_SQL_DROP = "drop table TrashVersion";
070            public static final String ORDER_BY_JPQL = " ORDER BY trashVersion.versionId ASC";
071            public static final String ORDER_BY_SQL = " ORDER BY TrashVersion.versionId ASC";
072            public static final String DATA_SOURCE = "liferayDataSource";
073            public static final String SESSION_FACTORY = "liferaySessionFactory";
074            public static final String TX_MANAGER = "liferayTransactionManager";
075            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076                                    "value.object.entity.cache.enabled.com.liferay.portlet.trash.model.TrashVersion"),
077                            true);
078            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.finder.cache.enabled.com.liferay.portlet.trash.model.TrashVersion"),
080                            true);
081            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082                                    "value.object.column.bitmask.enabled.com.liferay.portlet.trash.model.TrashVersion"),
083                            true);
084            public static long CLASSNAMEID_COLUMN_BITMASK = 1L;
085            public static long CLASSPK_COLUMN_BITMASK = 2L;
086            public static long ENTRYID_COLUMN_BITMASK = 4L;
087            public static long VERSIONID_COLUMN_BITMASK = 8L;
088            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
089                                    "lock.expiration.time.com.liferay.portlet.trash.model.TrashVersion"));
090    
091            public TrashVersionModelImpl() {
092            }
093    
094            public long getPrimaryKey() {
095                    return _versionId;
096            }
097    
098            public void setPrimaryKey(long primaryKey) {
099                    setVersionId(primaryKey);
100            }
101    
102            public Serializable getPrimaryKeyObj() {
103                    return new Long(_versionId);
104            }
105    
106            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
107                    setPrimaryKey(((Long)primaryKeyObj).longValue());
108            }
109    
110            public Class<?> getModelClass() {
111                    return TrashVersion.class;
112            }
113    
114            public String getModelClassName() {
115                    return TrashVersion.class.getName();
116            }
117    
118            @Override
119            public Map<String, Object> getModelAttributes() {
120                    Map<String, Object> attributes = new HashMap<String, Object>();
121    
122                    attributes.put("versionId", getVersionId());
123                    attributes.put("entryId", getEntryId());
124                    attributes.put("classNameId", getClassNameId());
125                    attributes.put("classPK", getClassPK());
126                    attributes.put("status", getStatus());
127    
128                    return attributes;
129            }
130    
131            @Override
132            public void setModelAttributes(Map<String, Object> attributes) {
133                    Long versionId = (Long)attributes.get("versionId");
134    
135                    if (versionId != null) {
136                            setVersionId(versionId);
137                    }
138    
139                    Long entryId = (Long)attributes.get("entryId");
140    
141                    if (entryId != null) {
142                            setEntryId(entryId);
143                    }
144    
145                    Long classNameId = (Long)attributes.get("classNameId");
146    
147                    if (classNameId != null) {
148                            setClassNameId(classNameId);
149                    }
150    
151                    Long classPK = (Long)attributes.get("classPK");
152    
153                    if (classPK != null) {
154                            setClassPK(classPK);
155                    }
156    
157                    Integer status = (Integer)attributes.get("status");
158    
159                    if (status != null) {
160                            setStatus(status);
161                    }
162            }
163    
164            public long getVersionId() {
165                    return _versionId;
166            }
167    
168            public void setVersionId(long versionId) {
169                    _versionId = versionId;
170            }
171    
172            public long getEntryId() {
173                    return _entryId;
174            }
175    
176            public void setEntryId(long entryId) {
177                    _columnBitmask |= ENTRYID_COLUMN_BITMASK;
178    
179                    if (!_setOriginalEntryId) {
180                            _setOriginalEntryId = true;
181    
182                            _originalEntryId = _entryId;
183                    }
184    
185                    _entryId = entryId;
186            }
187    
188            public long getOriginalEntryId() {
189                    return _originalEntryId;
190            }
191    
192            public String getClassName() {
193                    if (getClassNameId() <= 0) {
194                            return StringPool.BLANK;
195                    }
196    
197                    return PortalUtil.getClassName(getClassNameId());
198            }
199    
200            public void setClassName(String className) {
201                    long classNameId = 0;
202    
203                    if (Validator.isNotNull(className)) {
204                            classNameId = PortalUtil.getClassNameId(className);
205                    }
206    
207                    setClassNameId(classNameId);
208            }
209    
210            public long getClassNameId() {
211                    return _classNameId;
212            }
213    
214            public void setClassNameId(long classNameId) {
215                    _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
216    
217                    if (!_setOriginalClassNameId) {
218                            _setOriginalClassNameId = true;
219    
220                            _originalClassNameId = _classNameId;
221                    }
222    
223                    _classNameId = classNameId;
224            }
225    
226            public long getOriginalClassNameId() {
227                    return _originalClassNameId;
228            }
229    
230            public long getClassPK() {
231                    return _classPK;
232            }
233    
234            public void setClassPK(long classPK) {
235                    _columnBitmask |= CLASSPK_COLUMN_BITMASK;
236    
237                    if (!_setOriginalClassPK) {
238                            _setOriginalClassPK = true;
239    
240                            _originalClassPK = _classPK;
241                    }
242    
243                    _classPK = classPK;
244            }
245    
246            public long getOriginalClassPK() {
247                    return _originalClassPK;
248            }
249    
250            public int getStatus() {
251                    return _status;
252            }
253    
254            public void setStatus(int status) {
255                    _status = status;
256            }
257    
258            public long getColumnBitmask() {
259                    return _columnBitmask;
260            }
261    
262            @Override
263            public ExpandoBridge getExpandoBridge() {
264                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
265                            TrashVersion.class.getName(), getPrimaryKey());
266            }
267    
268            @Override
269            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
270                    ExpandoBridge expandoBridge = getExpandoBridge();
271    
272                    expandoBridge.setAttributes(serviceContext);
273            }
274    
275            @Override
276            public TrashVersion toEscapedModel() {
277                    if (_escapedModel == null) {
278                            _escapedModel = (TrashVersion)ProxyUtil.newProxyInstance(_classLoader,
279                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
280                    }
281    
282                    return _escapedModel;
283            }
284    
285            @Override
286            public Object clone() {
287                    TrashVersionImpl trashVersionImpl = new TrashVersionImpl();
288    
289                    trashVersionImpl.setVersionId(getVersionId());
290                    trashVersionImpl.setEntryId(getEntryId());
291                    trashVersionImpl.setClassNameId(getClassNameId());
292                    trashVersionImpl.setClassPK(getClassPK());
293                    trashVersionImpl.setStatus(getStatus());
294    
295                    trashVersionImpl.resetOriginalValues();
296    
297                    return trashVersionImpl;
298            }
299    
300            public int compareTo(TrashVersion trashVersion) {
301                    long primaryKey = trashVersion.getPrimaryKey();
302    
303                    if (getPrimaryKey() < primaryKey) {
304                            return -1;
305                    }
306                    else if (getPrimaryKey() > primaryKey) {
307                            return 1;
308                    }
309                    else {
310                            return 0;
311                    }
312            }
313    
314            @Override
315            public boolean equals(Object obj) {
316                    if (obj == null) {
317                            return false;
318                    }
319    
320                    TrashVersion trashVersion = null;
321    
322                    try {
323                            trashVersion = (TrashVersion)obj;
324                    }
325                    catch (ClassCastException cce) {
326                            return false;
327                    }
328    
329                    long primaryKey = trashVersion.getPrimaryKey();
330    
331                    if (getPrimaryKey() == primaryKey) {
332                            return true;
333                    }
334                    else {
335                            return false;
336                    }
337            }
338    
339            @Override
340            public int hashCode() {
341                    return (int)getPrimaryKey();
342            }
343    
344            @Override
345            public void resetOriginalValues() {
346                    TrashVersionModelImpl trashVersionModelImpl = this;
347    
348                    trashVersionModelImpl._originalEntryId = trashVersionModelImpl._entryId;
349    
350                    trashVersionModelImpl._setOriginalEntryId = false;
351    
352                    trashVersionModelImpl._originalClassNameId = trashVersionModelImpl._classNameId;
353    
354                    trashVersionModelImpl._setOriginalClassNameId = false;
355    
356                    trashVersionModelImpl._originalClassPK = trashVersionModelImpl._classPK;
357    
358                    trashVersionModelImpl._setOriginalClassPK = false;
359    
360                    trashVersionModelImpl._columnBitmask = 0;
361            }
362    
363            @Override
364            public CacheModel<TrashVersion> toCacheModel() {
365                    TrashVersionCacheModel trashVersionCacheModel = new TrashVersionCacheModel();
366    
367                    trashVersionCacheModel.versionId = getVersionId();
368    
369                    trashVersionCacheModel.entryId = getEntryId();
370    
371                    trashVersionCacheModel.classNameId = getClassNameId();
372    
373                    trashVersionCacheModel.classPK = getClassPK();
374    
375                    trashVersionCacheModel.status = getStatus();
376    
377                    return trashVersionCacheModel;
378            }
379    
380            @Override
381            public String toString() {
382                    StringBundler sb = new StringBundler(11);
383    
384                    sb.append("{versionId=");
385                    sb.append(getVersionId());
386                    sb.append(", entryId=");
387                    sb.append(getEntryId());
388                    sb.append(", classNameId=");
389                    sb.append(getClassNameId());
390                    sb.append(", classPK=");
391                    sb.append(getClassPK());
392                    sb.append(", status=");
393                    sb.append(getStatus());
394                    sb.append("}");
395    
396                    return sb.toString();
397            }
398    
399            public String toXmlString() {
400                    StringBundler sb = new StringBundler(19);
401    
402                    sb.append("<model><model-name>");
403                    sb.append("com.liferay.portlet.trash.model.TrashVersion");
404                    sb.append("</model-name>");
405    
406                    sb.append(
407                            "<column><column-name>versionId</column-name><column-value><![CDATA[");
408                    sb.append(getVersionId());
409                    sb.append("]]></column-value></column>");
410                    sb.append(
411                            "<column><column-name>entryId</column-name><column-value><![CDATA[");
412                    sb.append(getEntryId());
413                    sb.append("]]></column-value></column>");
414                    sb.append(
415                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
416                    sb.append(getClassNameId());
417                    sb.append("]]></column-value></column>");
418                    sb.append(
419                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
420                    sb.append(getClassPK());
421                    sb.append("]]></column-value></column>");
422                    sb.append(
423                            "<column><column-name>status</column-name><column-value><![CDATA[");
424                    sb.append(getStatus());
425                    sb.append("]]></column-value></column>");
426    
427                    sb.append("</model>");
428    
429                    return sb.toString();
430            }
431    
432            private static ClassLoader _classLoader = TrashVersion.class.getClassLoader();
433            private static Class<?>[] _escapedModelInterfaces = new Class[] {
434                            TrashVersion.class
435                    };
436            private long _versionId;
437            private long _entryId;
438            private long _originalEntryId;
439            private boolean _setOriginalEntryId;
440            private long _classNameId;
441            private long _originalClassNameId;
442            private boolean _setOriginalClassNameId;
443            private long _classPK;
444            private long _originalClassPK;
445            private boolean _setOriginalClassPK;
446            private int _status;
447            private long _columnBitmask;
448            private TrashVersion _escapedModel;
449    }