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