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.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.model.CacheModel;
023    import com.liferay.portal.model.impl.BaseModelImpl;
024    import com.liferay.portal.service.ServiceContext;
025    
026    import com.liferay.portlet.documentlibrary.model.DLContent;
027    import com.liferay.portlet.documentlibrary.model.DLContentDataBlobModel;
028    import com.liferay.portlet.documentlibrary.model.DLContentModel;
029    import com.liferay.portlet.documentlibrary.service.DLContentLocalServiceUtil;
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.Blob;
036    import java.sql.Types;
037    
038    import java.util.HashMap;
039    import java.util.Map;
040    
041    /**
042     * The base model implementation for the DLContent service. Represents a row in the "DLContent" 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.DLContentModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DLContentImpl}.
046     * </p>
047     *
048     * @author Brian Wing Shun Chan
049     * @see DLContentImpl
050     * @see com.liferay.portlet.documentlibrary.model.DLContent
051     * @see com.liferay.portlet.documentlibrary.model.DLContentModel
052     * @generated
053     */
054    public class DLContentModelImpl extends BaseModelImpl<DLContent>
055            implements DLContentModel {
056            /*
057             * NOTE FOR DEVELOPERS:
058             *
059             * Never modify or reference this class directly. All methods that expect a document library content model instance should use the {@link com.liferay.portlet.documentlibrary.model.DLContent} interface instead.
060             */
061            public static final String TABLE_NAME = "DLContent";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "contentId", Types.BIGINT },
064                            { "groupId", Types.BIGINT },
065                            { "companyId", Types.BIGINT },
066                            { "repositoryId", Types.BIGINT },
067                            { "path_", Types.VARCHAR },
068                            { "version", Types.VARCHAR },
069                            { "data_", Types.BLOB },
070                            { "size_", Types.BIGINT }
071                    };
072            public static final String TABLE_SQL_CREATE = "create table DLContent (contentId LONG not null primary key,groupId LONG,companyId LONG,repositoryId LONG,path_ VARCHAR(255) null,version VARCHAR(75) null,data_ BLOB,size_ LONG)";
073            public static final String TABLE_SQL_DROP = "drop table DLContent";
074            public static final String ORDER_BY_JPQL = " ORDER BY dlContent.version DESC";
075            public static final String ORDER_BY_SQL = " ORDER BY DLContent.version DESC";
076            public static final String DATA_SOURCE = "liferayDataSource";
077            public static final String SESSION_FACTORY = "liferaySessionFactory";
078            public static final String TX_MANAGER = "liferayTransactionManager";
079            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080                                    "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLContent"),
081                            true);
082            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
083                                    "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLContent"),
084                            true);
085            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086                                    "value.object.column.bitmask.enabled.com.liferay.portlet.documentlibrary.model.DLContent"),
087                            true);
088            public static long COMPANYID_COLUMN_BITMASK = 1L;
089            public static long PATH_COLUMN_BITMASK = 2L;
090            public static long REPOSITORYID_COLUMN_BITMASK = 4L;
091            public static long VERSION_COLUMN_BITMASK = 8L;
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.DLContent"));
094    
095            public DLContentModelImpl() {
096            }
097    
098            @Override
099            public long getPrimaryKey() {
100                    return _contentId;
101            }
102    
103            @Override
104            public void setPrimaryKey(long primaryKey) {
105                    setContentId(primaryKey);
106            }
107    
108            @Override
109            public Serializable getPrimaryKeyObj() {
110                    return _contentId;
111            }
112    
113            @Override
114            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
115                    setPrimaryKey(((Long)primaryKeyObj).longValue());
116            }
117    
118            @Override
119            public Class<?> getModelClass() {
120                    return DLContent.class;
121            }
122    
123            @Override
124            public String getModelClassName() {
125                    return DLContent.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("contentId", getContentId());
133                    attributes.put("groupId", getGroupId());
134                    attributes.put("companyId", getCompanyId());
135                    attributes.put("repositoryId", getRepositoryId());
136                    attributes.put("path", getPath());
137                    attributes.put("version", getVersion());
138                    attributes.put("data", getData());
139                    attributes.put("size", getSize());
140    
141                    return attributes;
142            }
143    
144            @Override
145            public void setModelAttributes(Map<String, Object> attributes) {
146                    Long contentId = (Long)attributes.get("contentId");
147    
148                    if (contentId != null) {
149                            setContentId(contentId);
150                    }
151    
152                    Long groupId = (Long)attributes.get("groupId");
153    
154                    if (groupId != null) {
155                            setGroupId(groupId);
156                    }
157    
158                    Long companyId = (Long)attributes.get("companyId");
159    
160                    if (companyId != null) {
161                            setCompanyId(companyId);
162                    }
163    
164                    Long repositoryId = (Long)attributes.get("repositoryId");
165    
166                    if (repositoryId != null) {
167                            setRepositoryId(repositoryId);
168                    }
169    
170                    String path = (String)attributes.get("path");
171    
172                    if (path != null) {
173                            setPath(path);
174                    }
175    
176                    String version = (String)attributes.get("version");
177    
178                    if (version != null) {
179                            setVersion(version);
180                    }
181    
182                    Blob data = (Blob)attributes.get("data");
183    
184                    if (data != null) {
185                            setData(data);
186                    }
187    
188                    Long size = (Long)attributes.get("size");
189    
190                    if (size != null) {
191                            setSize(size);
192                    }
193            }
194    
195            @Override
196            public long getContentId() {
197                    return _contentId;
198            }
199    
200            @Override
201            public void setContentId(long contentId) {
202                    _contentId = contentId;
203            }
204    
205            @Override
206            public long getGroupId() {
207                    return _groupId;
208            }
209    
210            @Override
211            public void setGroupId(long groupId) {
212                    _groupId = groupId;
213            }
214    
215            @Override
216            public long getCompanyId() {
217                    return _companyId;
218            }
219    
220            @Override
221            public void setCompanyId(long companyId) {
222                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
223    
224                    if (!_setOriginalCompanyId) {
225                            _setOriginalCompanyId = true;
226    
227                            _originalCompanyId = _companyId;
228                    }
229    
230                    _companyId = companyId;
231            }
232    
233            public long getOriginalCompanyId() {
234                    return _originalCompanyId;
235            }
236    
237            @Override
238            public long getRepositoryId() {
239                    return _repositoryId;
240            }
241    
242            @Override
243            public void setRepositoryId(long repositoryId) {
244                    _columnBitmask |= REPOSITORYID_COLUMN_BITMASK;
245    
246                    if (!_setOriginalRepositoryId) {
247                            _setOriginalRepositoryId = true;
248    
249                            _originalRepositoryId = _repositoryId;
250                    }
251    
252                    _repositoryId = repositoryId;
253            }
254    
255            public long getOriginalRepositoryId() {
256                    return _originalRepositoryId;
257            }
258    
259            @Override
260            public String getPath() {
261                    if (_path == null) {
262                            return StringPool.BLANK;
263                    }
264                    else {
265                            return _path;
266                    }
267            }
268    
269            @Override
270            public void setPath(String path) {
271                    _columnBitmask |= PATH_COLUMN_BITMASK;
272    
273                    if (_originalPath == null) {
274                            _originalPath = _path;
275                    }
276    
277                    _path = path;
278            }
279    
280            public String getOriginalPath() {
281                    return GetterUtil.getString(_originalPath);
282            }
283    
284            @Override
285            public String getVersion() {
286                    if (_version == null) {
287                            return StringPool.BLANK;
288                    }
289                    else {
290                            return _version;
291                    }
292            }
293    
294            @Override
295            public void setVersion(String version) {
296                    _columnBitmask = -1L;
297    
298                    if (_originalVersion == null) {
299                            _originalVersion = _version;
300                    }
301    
302                    _version = version;
303            }
304    
305            public String getOriginalVersion() {
306                    return GetterUtil.getString(_originalVersion);
307            }
308    
309            @Override
310            public Blob getData() {
311                    if (_dataBlobModel == null) {
312                            try {
313                                    _dataBlobModel = DLContentLocalServiceUtil.getDataBlobModel(getPrimaryKey());
314                            }
315                            catch (Exception e) {
316                            }
317                    }
318    
319                    Blob blob = null;
320    
321                    if (_dataBlobModel != null) {
322                            blob = _dataBlobModel.getDataBlob();
323                    }
324    
325                    return blob;
326            }
327    
328            @Override
329            public void setData(Blob data) {
330                    if (_dataBlobModel == null) {
331                            _dataBlobModel = new DLContentDataBlobModel(getPrimaryKey(), data);
332                    }
333                    else {
334                            _dataBlobModel.setDataBlob(data);
335                    }
336            }
337    
338            @Override
339            public long getSize() {
340                    return _size;
341            }
342    
343            @Override
344            public void setSize(long size) {
345                    _size = size;
346            }
347    
348            public long getColumnBitmask() {
349                    return _columnBitmask;
350            }
351    
352            @Override
353            public ExpandoBridge getExpandoBridge() {
354                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
355                            DLContent.class.getName(), getPrimaryKey());
356            }
357    
358            @Override
359            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
360                    ExpandoBridge expandoBridge = getExpandoBridge();
361    
362                    expandoBridge.setAttributes(serviceContext);
363            }
364    
365            @Override
366            public DLContent toEscapedModel() {
367                    if (_escapedModel == null) {
368                            _escapedModel = (DLContent)ProxyUtil.newProxyInstance(_classLoader,
369                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
370                    }
371    
372                    return _escapedModel;
373            }
374    
375            @Override
376            public Object clone() {
377                    DLContentImpl dlContentImpl = new DLContentImpl();
378    
379                    dlContentImpl.setContentId(getContentId());
380                    dlContentImpl.setGroupId(getGroupId());
381                    dlContentImpl.setCompanyId(getCompanyId());
382                    dlContentImpl.setRepositoryId(getRepositoryId());
383                    dlContentImpl.setPath(getPath());
384                    dlContentImpl.setVersion(getVersion());
385                    dlContentImpl.setSize(getSize());
386    
387                    dlContentImpl.resetOriginalValues();
388    
389                    return dlContentImpl;
390            }
391    
392            @Override
393            public int compareTo(DLContent dlContent) {
394                    int value = 0;
395    
396                    value = getVersion().compareTo(dlContent.getVersion());
397    
398                    value = value * -1;
399    
400                    if (value != 0) {
401                            return value;
402                    }
403    
404                    return 0;
405            }
406    
407            @Override
408            public boolean equals(Object obj) {
409                    if (this == obj) {
410                            return true;
411                    }
412    
413                    if (!(obj instanceof DLContent)) {
414                            return false;
415                    }
416    
417                    DLContent dlContent = (DLContent)obj;
418    
419                    long primaryKey = dlContent.getPrimaryKey();
420    
421                    if (getPrimaryKey() == primaryKey) {
422                            return true;
423                    }
424                    else {
425                            return false;
426                    }
427            }
428    
429            @Override
430            public int hashCode() {
431                    return (int)getPrimaryKey();
432            }
433    
434            @Override
435            public void resetOriginalValues() {
436                    DLContentModelImpl dlContentModelImpl = this;
437    
438                    dlContentModelImpl._originalCompanyId = dlContentModelImpl._companyId;
439    
440                    dlContentModelImpl._setOriginalCompanyId = false;
441    
442                    dlContentModelImpl._originalRepositoryId = dlContentModelImpl._repositoryId;
443    
444                    dlContentModelImpl._setOriginalRepositoryId = false;
445    
446                    dlContentModelImpl._originalPath = dlContentModelImpl._path;
447    
448                    dlContentModelImpl._originalVersion = dlContentModelImpl._version;
449    
450                    dlContentModelImpl._dataBlobModel = null;
451    
452                    dlContentModelImpl._columnBitmask = 0;
453            }
454    
455            @Override
456            public CacheModel<DLContent> toCacheModel() {
457                    DLContentCacheModel dlContentCacheModel = new DLContentCacheModel();
458    
459                    dlContentCacheModel.contentId = getContentId();
460    
461                    dlContentCacheModel.groupId = getGroupId();
462    
463                    dlContentCacheModel.companyId = getCompanyId();
464    
465                    dlContentCacheModel.repositoryId = getRepositoryId();
466    
467                    dlContentCacheModel.path = getPath();
468    
469                    String path = dlContentCacheModel.path;
470    
471                    if ((path != null) && (path.length() == 0)) {
472                            dlContentCacheModel.path = null;
473                    }
474    
475                    dlContentCacheModel.version = getVersion();
476    
477                    String version = dlContentCacheModel.version;
478    
479                    if ((version != null) && (version.length() == 0)) {
480                            dlContentCacheModel.version = null;
481                    }
482    
483                    dlContentCacheModel.size = getSize();
484    
485                    return dlContentCacheModel;
486            }
487    
488            @Override
489            public String toString() {
490                    StringBundler sb = new StringBundler(17);
491    
492                    sb.append("{contentId=");
493                    sb.append(getContentId());
494                    sb.append(", groupId=");
495                    sb.append(getGroupId());
496                    sb.append(", companyId=");
497                    sb.append(getCompanyId());
498                    sb.append(", repositoryId=");
499                    sb.append(getRepositoryId());
500                    sb.append(", path=");
501                    sb.append(getPath());
502                    sb.append(", version=");
503                    sb.append(getVersion());
504                    sb.append(", size=");
505                    sb.append(getSize());
506                    sb.append("}");
507    
508                    return sb.toString();
509            }
510    
511            @Override
512            public String toXmlString() {
513                    StringBundler sb = new StringBundler(28);
514    
515                    sb.append("<model><model-name>");
516                    sb.append("com.liferay.portlet.documentlibrary.model.DLContent");
517                    sb.append("</model-name>");
518    
519                    sb.append(
520                            "<column><column-name>contentId</column-name><column-value><![CDATA[");
521                    sb.append(getContentId());
522                    sb.append("]]></column-value></column>");
523                    sb.append(
524                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
525                    sb.append(getGroupId());
526                    sb.append("]]></column-value></column>");
527                    sb.append(
528                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
529                    sb.append(getCompanyId());
530                    sb.append("]]></column-value></column>");
531                    sb.append(
532                            "<column><column-name>repositoryId</column-name><column-value><![CDATA[");
533                    sb.append(getRepositoryId());
534                    sb.append("]]></column-value></column>");
535                    sb.append(
536                            "<column><column-name>path</column-name><column-value><![CDATA[");
537                    sb.append(getPath());
538                    sb.append("]]></column-value></column>");
539                    sb.append(
540                            "<column><column-name>version</column-name><column-value><![CDATA[");
541                    sb.append(getVersion());
542                    sb.append("]]></column-value></column>");
543                    sb.append(
544                            "<column><column-name>size</column-name><column-value><![CDATA[");
545                    sb.append(getSize());
546                    sb.append("]]></column-value></column>");
547    
548                    sb.append("</model>");
549    
550                    return sb.toString();
551            }
552    
553            private static ClassLoader _classLoader = DLContent.class.getClassLoader();
554            private static Class<?>[] _escapedModelInterfaces = new Class[] {
555                            DLContent.class
556                    };
557            private long _contentId;
558            private long _groupId;
559            private long _companyId;
560            private long _originalCompanyId;
561            private boolean _setOriginalCompanyId;
562            private long _repositoryId;
563            private long _originalRepositoryId;
564            private boolean _setOriginalRepositoryId;
565            private String _path;
566            private String _originalPath;
567            private String _version;
568            private String _originalVersion;
569            private DLContentDataBlobModel _dataBlobModel;
570            private long _size;
571            private long _columnBitmask;
572            private DLContent _escapedModel;
573    }