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            public long getPrimaryKey() {
099                    return _contentId;
100            }
101    
102            public void setPrimaryKey(long primaryKey) {
103                    setContentId(primaryKey);
104            }
105    
106            public Serializable getPrimaryKeyObj() {
107                    return new Long(_contentId);
108            }
109    
110            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
111                    setPrimaryKey(((Long)primaryKeyObj).longValue());
112            }
113    
114            public Class<?> getModelClass() {
115                    return DLContent.class;
116            }
117    
118            public String getModelClassName() {
119                    return DLContent.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("contentId", getContentId());
127                    attributes.put("groupId", getGroupId());
128                    attributes.put("companyId", getCompanyId());
129                    attributes.put("repositoryId", getRepositoryId());
130                    attributes.put("path", getPath());
131                    attributes.put("version", getVersion());
132                    attributes.put("data", getData());
133                    attributes.put("size", getSize());
134    
135                    return attributes;
136            }
137    
138            @Override
139            public void setModelAttributes(Map<String, Object> attributes) {
140                    Long contentId = (Long)attributes.get("contentId");
141    
142                    if (contentId != null) {
143                            setContentId(contentId);
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 repositoryId = (Long)attributes.get("repositoryId");
159    
160                    if (repositoryId != null) {
161                            setRepositoryId(repositoryId);
162                    }
163    
164                    String path = (String)attributes.get("path");
165    
166                    if (path != null) {
167                            setPath(path);
168                    }
169    
170                    String version = (String)attributes.get("version");
171    
172                    if (version != null) {
173                            setVersion(version);
174                    }
175    
176                    Blob data = (Blob)attributes.get("data");
177    
178                    if (data != null) {
179                            setData(data);
180                    }
181    
182                    Long size = (Long)attributes.get("size");
183    
184                    if (size != null) {
185                            setSize(size);
186                    }
187            }
188    
189            public long getContentId() {
190                    return _contentId;
191            }
192    
193            public void setContentId(long contentId) {
194                    _contentId = contentId;
195            }
196    
197            public long getGroupId() {
198                    return _groupId;
199            }
200    
201            public void setGroupId(long groupId) {
202                    _groupId = groupId;
203            }
204    
205            public long getCompanyId() {
206                    return _companyId;
207            }
208    
209            public void setCompanyId(long companyId) {
210                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
211    
212                    if (!_setOriginalCompanyId) {
213                            _setOriginalCompanyId = true;
214    
215                            _originalCompanyId = _companyId;
216                    }
217    
218                    _companyId = companyId;
219            }
220    
221            public long getOriginalCompanyId() {
222                    return _originalCompanyId;
223            }
224    
225            public long getRepositoryId() {
226                    return _repositoryId;
227            }
228    
229            public void setRepositoryId(long repositoryId) {
230                    _columnBitmask |= REPOSITORYID_COLUMN_BITMASK;
231    
232                    if (!_setOriginalRepositoryId) {
233                            _setOriginalRepositoryId = true;
234    
235                            _originalRepositoryId = _repositoryId;
236                    }
237    
238                    _repositoryId = repositoryId;
239            }
240    
241            public long getOriginalRepositoryId() {
242                    return _originalRepositoryId;
243            }
244    
245            public String getPath() {
246                    if (_path == null) {
247                            return StringPool.BLANK;
248                    }
249                    else {
250                            return _path;
251                    }
252            }
253    
254            public void setPath(String path) {
255                    _columnBitmask |= PATH_COLUMN_BITMASK;
256    
257                    if (_originalPath == null) {
258                            _originalPath = _path;
259                    }
260    
261                    _path = path;
262            }
263    
264            public String getOriginalPath() {
265                    return GetterUtil.getString(_originalPath);
266            }
267    
268            public String getVersion() {
269                    if (_version == null) {
270                            return StringPool.BLANK;
271                    }
272                    else {
273                            return _version;
274                    }
275            }
276    
277            public void setVersion(String version) {
278                    _columnBitmask = -1L;
279    
280                    if (_originalVersion == null) {
281                            _originalVersion = _version;
282                    }
283    
284                    _version = version;
285            }
286    
287            public String getOriginalVersion() {
288                    return GetterUtil.getString(_originalVersion);
289            }
290    
291            public Blob getData() {
292                    if (_dataBlobModel == null) {
293                            try {
294                                    _dataBlobModel = DLContentLocalServiceUtil.getDataBlobModel(getPrimaryKey());
295                            }
296                            catch (Exception e) {
297                            }
298                    }
299    
300                    Blob blob = null;
301    
302                    if (_dataBlobModel != null) {
303                            blob = _dataBlobModel.getDataBlob();
304                    }
305    
306                    return blob;
307            }
308    
309            public void setData(Blob data) {
310                    if (_dataBlobModel == null) {
311                            _dataBlobModel = new DLContentDataBlobModel(getPrimaryKey(), data);
312                    }
313                    else {
314                            _dataBlobModel.setDataBlob(data);
315                    }
316            }
317    
318            public long getSize() {
319                    return _size;
320            }
321    
322            public void setSize(long size) {
323                    _size = size;
324            }
325    
326            public long getColumnBitmask() {
327                    return _columnBitmask;
328            }
329    
330            @Override
331            public ExpandoBridge getExpandoBridge() {
332                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
333                            DLContent.class.getName(), getPrimaryKey());
334            }
335    
336            @Override
337            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
338                    ExpandoBridge expandoBridge = getExpandoBridge();
339    
340                    expandoBridge.setAttributes(serviceContext);
341            }
342    
343            @Override
344            public DLContent toEscapedModel() {
345                    if (_escapedModel == null) {
346                            _escapedModel = (DLContent)ProxyUtil.newProxyInstance(_classLoader,
347                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
348                    }
349    
350                    return _escapedModel;
351            }
352    
353            public DLContent toUnescapedModel() {
354                    return (DLContent)this;
355            }
356    
357            @Override
358            public Object clone() {
359                    DLContentImpl dlContentImpl = new DLContentImpl();
360    
361                    dlContentImpl.setContentId(getContentId());
362                    dlContentImpl.setGroupId(getGroupId());
363                    dlContentImpl.setCompanyId(getCompanyId());
364                    dlContentImpl.setRepositoryId(getRepositoryId());
365                    dlContentImpl.setPath(getPath());
366                    dlContentImpl.setVersion(getVersion());
367                    dlContentImpl.setSize(getSize());
368    
369                    dlContentImpl.resetOriginalValues();
370    
371                    return dlContentImpl;
372            }
373    
374            public int compareTo(DLContent dlContent) {
375                    int value = 0;
376    
377                    value = getVersion().compareTo(dlContent.getVersion());
378    
379                    value = value * -1;
380    
381                    if (value != 0) {
382                            return value;
383                    }
384    
385                    return 0;
386            }
387    
388            @Override
389            public boolean equals(Object obj) {
390                    if (this == obj) {
391                            return true;
392                    }
393    
394                    if (!(obj instanceof DLContent)) {
395                            return false;
396                    }
397    
398                    DLContent dlContent = (DLContent)obj;
399    
400                    long primaryKey = dlContent.getPrimaryKey();
401    
402                    if (getPrimaryKey() == primaryKey) {
403                            return true;
404                    }
405                    else {
406                            return false;
407                    }
408            }
409    
410            @Override
411            public int hashCode() {
412                    return (int)getPrimaryKey();
413            }
414    
415            @Override
416            public void resetOriginalValues() {
417                    DLContentModelImpl dlContentModelImpl = this;
418    
419                    dlContentModelImpl._originalCompanyId = dlContentModelImpl._companyId;
420    
421                    dlContentModelImpl._setOriginalCompanyId = false;
422    
423                    dlContentModelImpl._originalRepositoryId = dlContentModelImpl._repositoryId;
424    
425                    dlContentModelImpl._setOriginalRepositoryId = false;
426    
427                    dlContentModelImpl._originalPath = dlContentModelImpl._path;
428    
429                    dlContentModelImpl._originalVersion = dlContentModelImpl._version;
430    
431                    dlContentModelImpl._dataBlobModel = null;
432    
433                    dlContentModelImpl._columnBitmask = 0;
434            }
435    
436            @Override
437            public CacheModel<DLContent> toCacheModel() {
438                    DLContentCacheModel dlContentCacheModel = new DLContentCacheModel();
439    
440                    dlContentCacheModel.contentId = getContentId();
441    
442                    dlContentCacheModel.groupId = getGroupId();
443    
444                    dlContentCacheModel.companyId = getCompanyId();
445    
446                    dlContentCacheModel.repositoryId = getRepositoryId();
447    
448                    dlContentCacheModel.path = getPath();
449    
450                    String path = dlContentCacheModel.path;
451    
452                    if ((path != null) && (path.length() == 0)) {
453                            dlContentCacheModel.path = null;
454                    }
455    
456                    dlContentCacheModel.version = getVersion();
457    
458                    String version = dlContentCacheModel.version;
459    
460                    if ((version != null) && (version.length() == 0)) {
461                            dlContentCacheModel.version = null;
462                    }
463    
464                    dlContentCacheModel.size = getSize();
465    
466                    return dlContentCacheModel;
467            }
468    
469            @Override
470            public String toString() {
471                    StringBundler sb = new StringBundler(17);
472    
473                    sb.append("{contentId=");
474                    sb.append(getContentId());
475                    sb.append(", groupId=");
476                    sb.append(getGroupId());
477                    sb.append(", companyId=");
478                    sb.append(getCompanyId());
479                    sb.append(", repositoryId=");
480                    sb.append(getRepositoryId());
481                    sb.append(", path=");
482                    sb.append(getPath());
483                    sb.append(", version=");
484                    sb.append(getVersion());
485                    sb.append(", size=");
486                    sb.append(getSize());
487                    sb.append("}");
488    
489                    return sb.toString();
490            }
491    
492            public String toXmlString() {
493                    StringBundler sb = new StringBundler(28);
494    
495                    sb.append("<model><model-name>");
496                    sb.append("com.liferay.portlet.documentlibrary.model.DLContent");
497                    sb.append("</model-name>");
498    
499                    sb.append(
500                            "<column><column-name>contentId</column-name><column-value><![CDATA[");
501                    sb.append(getContentId());
502                    sb.append("]]></column-value></column>");
503                    sb.append(
504                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
505                    sb.append(getGroupId());
506                    sb.append("]]></column-value></column>");
507                    sb.append(
508                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
509                    sb.append(getCompanyId());
510                    sb.append("]]></column-value></column>");
511                    sb.append(
512                            "<column><column-name>repositoryId</column-name><column-value><![CDATA[");
513                    sb.append(getRepositoryId());
514                    sb.append("]]></column-value></column>");
515                    sb.append(
516                            "<column><column-name>path</column-name><column-value><![CDATA[");
517                    sb.append(getPath());
518                    sb.append("]]></column-value></column>");
519                    sb.append(
520                            "<column><column-name>version</column-name><column-value><![CDATA[");
521                    sb.append(getVersion());
522                    sb.append("]]></column-value></column>");
523                    sb.append(
524                            "<column><column-name>size</column-name><column-value><![CDATA[");
525                    sb.append(getSize());
526                    sb.append("]]></column-value></column>");
527    
528                    sb.append("</model>");
529    
530                    return sb.toString();
531            }
532    
533            private static ClassLoader _classLoader = DLContent.class.getClassLoader();
534            private static Class<?>[] _escapedModelInterfaces = new Class[] {
535                            DLContent.class
536                    };
537            private long _contentId;
538            private long _groupId;
539            private long _companyId;
540            private long _originalCompanyId;
541            private boolean _setOriginalCompanyId;
542            private long _repositoryId;
543            private long _originalRepositoryId;
544            private boolean _setOriginalRepositoryId;
545            private String _path;
546            private String _originalPath;
547            private String _version;
548            private String _originalVersion;
549            private DLContentDataBlobModel _dataBlobModel;
550            private long _size;
551            private long _columnBitmask;
552            private DLContent _escapedModel;
553    }