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.DLFileEntryMetadata;
027    import com.liferay.portlet.documentlibrary.model.DLFileEntryMetadataModel;
028    import com.liferay.portlet.expando.model.ExpandoBridge;
029    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
030    
031    import java.io.Serializable;
032    
033    import java.sql.Types;
034    
035    import java.util.HashMap;
036    import java.util.Map;
037    
038    /**
039     * The base model implementation for the DLFileEntryMetadata service. Represents a row in the "DLFileEntryMetadata" database table, with each column mapped to a property of this class.
040     *
041     * <p>
042     * This implementation and its corresponding interface {@link com.liferay.portlet.documentlibrary.model.DLFileEntryMetadataModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DLFileEntryMetadataImpl}.
043     * </p>
044     *
045     * @author Brian Wing Shun Chan
046     * @see DLFileEntryMetadataImpl
047     * @see com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata
048     * @see com.liferay.portlet.documentlibrary.model.DLFileEntryMetadataModel
049     * @generated
050     */
051    public class DLFileEntryMetadataModelImpl extends BaseModelImpl<DLFileEntryMetadata>
052            implements DLFileEntryMetadataModel {
053            /*
054             * NOTE FOR DEVELOPERS:
055             *
056             * Never modify or reference this class directly. All methods that expect a document library file entry metadata model instance should use the {@link com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata} interface instead.
057             */
058            public static final String TABLE_NAME = "DLFileEntryMetadata";
059            public static final Object[][] TABLE_COLUMNS = {
060                            { "uuid_", Types.VARCHAR },
061                            { "fileEntryMetadataId", Types.BIGINT },
062                            { "DDMStorageId", Types.BIGINT },
063                            { "DDMStructureId", Types.BIGINT },
064                            { "fileEntryTypeId", Types.BIGINT },
065                            { "fileEntryId", Types.BIGINT },
066                            { "fileVersionId", Types.BIGINT }
067                    };
068            public static final String TABLE_SQL_CREATE = "create table DLFileEntryMetadata (uuid_ VARCHAR(75) null,fileEntryMetadataId LONG not null primary key,DDMStorageId LONG,DDMStructureId LONG,fileEntryTypeId LONG,fileEntryId LONG,fileVersionId LONG)";
069            public static final String TABLE_SQL_DROP = "drop table DLFileEntryMetadata";
070            public static final String DATA_SOURCE = "liferayDataSource";
071            public static final String SESSION_FACTORY = "liferaySessionFactory";
072            public static final String TX_MANAGER = "liferayTransactionManager";
073            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074                                    "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata"),
075                            true);
076            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata"),
078                            true);
079            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080                                    "value.object.column.bitmask.enabled.com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata"),
081                            true);
082            public static long DDMSTRUCTUREID_COLUMN_BITMASK = 1L;
083            public static long FILEENTRYID_COLUMN_BITMASK = 2L;
084            public static long FILEENTRYTYPEID_COLUMN_BITMASK = 4L;
085            public static long FILEVERSIONID_COLUMN_BITMASK = 8L;
086            public static long UUID_COLUMN_BITMASK = 16L;
087            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
088                                    "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata"));
089    
090            public DLFileEntryMetadataModelImpl() {
091            }
092    
093            public long getPrimaryKey() {
094                    return _fileEntryMetadataId;
095            }
096    
097            public void setPrimaryKey(long primaryKey) {
098                    setFileEntryMetadataId(primaryKey);
099            }
100    
101            public Serializable getPrimaryKeyObj() {
102                    return new Long(_fileEntryMetadataId);
103            }
104    
105            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
106                    setPrimaryKey(((Long)primaryKeyObj).longValue());
107            }
108    
109            public Class<?> getModelClass() {
110                    return DLFileEntryMetadata.class;
111            }
112    
113            public String getModelClassName() {
114                    return DLFileEntryMetadata.class.getName();
115            }
116    
117            @Override
118            public Map<String, Object> getModelAttributes() {
119                    Map<String, Object> attributes = new HashMap<String, Object>();
120    
121                    attributes.put("uuid", getUuid());
122                    attributes.put("fileEntryMetadataId", getFileEntryMetadataId());
123                    attributes.put("DDMStorageId", getDDMStorageId());
124                    attributes.put("DDMStructureId", getDDMStructureId());
125                    attributes.put("fileEntryTypeId", getFileEntryTypeId());
126                    attributes.put("fileEntryId", getFileEntryId());
127                    attributes.put("fileVersionId", getFileVersionId());
128    
129                    return attributes;
130            }
131    
132            @Override
133            public void setModelAttributes(Map<String, Object> attributes) {
134                    String uuid = (String)attributes.get("uuid");
135    
136                    if (uuid != null) {
137                            setUuid(uuid);
138                    }
139    
140                    Long fileEntryMetadataId = (Long)attributes.get("fileEntryMetadataId");
141    
142                    if (fileEntryMetadataId != null) {
143                            setFileEntryMetadataId(fileEntryMetadataId);
144                    }
145    
146                    Long DDMStorageId = (Long)attributes.get("DDMStorageId");
147    
148                    if (DDMStorageId != null) {
149                            setDDMStorageId(DDMStorageId);
150                    }
151    
152                    Long DDMStructureId = (Long)attributes.get("DDMStructureId");
153    
154                    if (DDMStructureId != null) {
155                            setDDMStructureId(DDMStructureId);
156                    }
157    
158                    Long fileEntryTypeId = (Long)attributes.get("fileEntryTypeId");
159    
160                    if (fileEntryTypeId != null) {
161                            setFileEntryTypeId(fileEntryTypeId);
162                    }
163    
164                    Long fileEntryId = (Long)attributes.get("fileEntryId");
165    
166                    if (fileEntryId != null) {
167                            setFileEntryId(fileEntryId);
168                    }
169    
170                    Long fileVersionId = (Long)attributes.get("fileVersionId");
171    
172                    if (fileVersionId != null) {
173                            setFileVersionId(fileVersionId);
174                    }
175            }
176    
177            public String getUuid() {
178                    if (_uuid == null) {
179                            return StringPool.BLANK;
180                    }
181                    else {
182                            return _uuid;
183                    }
184            }
185    
186            public void setUuid(String uuid) {
187                    if (_originalUuid == null) {
188                            _originalUuid = _uuid;
189                    }
190    
191                    _uuid = uuid;
192            }
193    
194            public String getOriginalUuid() {
195                    return GetterUtil.getString(_originalUuid);
196            }
197    
198            public long getFileEntryMetadataId() {
199                    return _fileEntryMetadataId;
200            }
201    
202            public void setFileEntryMetadataId(long fileEntryMetadataId) {
203                    _fileEntryMetadataId = fileEntryMetadataId;
204            }
205    
206            public long getDDMStorageId() {
207                    return _DDMStorageId;
208            }
209    
210            public void setDDMStorageId(long DDMStorageId) {
211                    _DDMStorageId = DDMStorageId;
212            }
213    
214            public long getDDMStructureId() {
215                    return _DDMStructureId;
216            }
217    
218            public void setDDMStructureId(long DDMStructureId) {
219                    _columnBitmask |= DDMSTRUCTUREID_COLUMN_BITMASK;
220    
221                    if (!_setOriginalDDMStructureId) {
222                            _setOriginalDDMStructureId = true;
223    
224                            _originalDDMStructureId = _DDMStructureId;
225                    }
226    
227                    _DDMStructureId = DDMStructureId;
228            }
229    
230            public long getOriginalDDMStructureId() {
231                    return _originalDDMStructureId;
232            }
233    
234            public long getFileEntryTypeId() {
235                    return _fileEntryTypeId;
236            }
237    
238            public void setFileEntryTypeId(long fileEntryTypeId) {
239                    _columnBitmask |= FILEENTRYTYPEID_COLUMN_BITMASK;
240    
241                    if (!_setOriginalFileEntryTypeId) {
242                            _setOriginalFileEntryTypeId = true;
243    
244                            _originalFileEntryTypeId = _fileEntryTypeId;
245                    }
246    
247                    _fileEntryTypeId = fileEntryTypeId;
248            }
249    
250            public long getOriginalFileEntryTypeId() {
251                    return _originalFileEntryTypeId;
252            }
253    
254            public long getFileEntryId() {
255                    return _fileEntryId;
256            }
257    
258            public void setFileEntryId(long fileEntryId) {
259                    _columnBitmask |= FILEENTRYID_COLUMN_BITMASK;
260    
261                    if (!_setOriginalFileEntryId) {
262                            _setOriginalFileEntryId = true;
263    
264                            _originalFileEntryId = _fileEntryId;
265                    }
266    
267                    _fileEntryId = fileEntryId;
268            }
269    
270            public long getOriginalFileEntryId() {
271                    return _originalFileEntryId;
272            }
273    
274            public long getFileVersionId() {
275                    return _fileVersionId;
276            }
277    
278            public void setFileVersionId(long fileVersionId) {
279                    _columnBitmask |= FILEVERSIONID_COLUMN_BITMASK;
280    
281                    if (!_setOriginalFileVersionId) {
282                            _setOriginalFileVersionId = true;
283    
284                            _originalFileVersionId = _fileVersionId;
285                    }
286    
287                    _fileVersionId = fileVersionId;
288            }
289    
290            public long getOriginalFileVersionId() {
291                    return _originalFileVersionId;
292            }
293    
294            public long getColumnBitmask() {
295                    return _columnBitmask;
296            }
297    
298            @Override
299            public ExpandoBridge getExpandoBridge() {
300                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
301                            DLFileEntryMetadata.class.getName(), getPrimaryKey());
302            }
303    
304            @Override
305            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
306                    ExpandoBridge expandoBridge = getExpandoBridge();
307    
308                    expandoBridge.setAttributes(serviceContext);
309            }
310    
311            @Override
312            public DLFileEntryMetadata toEscapedModel() {
313                    if (_escapedModel == null) {
314                            _escapedModel = (DLFileEntryMetadata)ProxyUtil.newProxyInstance(_classLoader,
315                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
316                    }
317    
318                    return _escapedModel;
319            }
320    
321            public DLFileEntryMetadata toUnescapedModel() {
322                    return (DLFileEntryMetadata)this;
323            }
324    
325            @Override
326            public Object clone() {
327                    DLFileEntryMetadataImpl dlFileEntryMetadataImpl = new DLFileEntryMetadataImpl();
328    
329                    dlFileEntryMetadataImpl.setUuid(getUuid());
330                    dlFileEntryMetadataImpl.setFileEntryMetadataId(getFileEntryMetadataId());
331                    dlFileEntryMetadataImpl.setDDMStorageId(getDDMStorageId());
332                    dlFileEntryMetadataImpl.setDDMStructureId(getDDMStructureId());
333                    dlFileEntryMetadataImpl.setFileEntryTypeId(getFileEntryTypeId());
334                    dlFileEntryMetadataImpl.setFileEntryId(getFileEntryId());
335                    dlFileEntryMetadataImpl.setFileVersionId(getFileVersionId());
336    
337                    dlFileEntryMetadataImpl.resetOriginalValues();
338    
339                    return dlFileEntryMetadataImpl;
340            }
341    
342            public int compareTo(DLFileEntryMetadata dlFileEntryMetadata) {
343                    long primaryKey = dlFileEntryMetadata.getPrimaryKey();
344    
345                    if (getPrimaryKey() < primaryKey) {
346                            return -1;
347                    }
348                    else if (getPrimaryKey() > primaryKey) {
349                            return 1;
350                    }
351                    else {
352                            return 0;
353                    }
354            }
355    
356            @Override
357            public boolean equals(Object obj) {
358                    if (this == obj) {
359                            return true;
360                    }
361    
362                    if (!(obj instanceof DLFileEntryMetadata)) {
363                            return false;
364                    }
365    
366                    DLFileEntryMetadata dlFileEntryMetadata = (DLFileEntryMetadata)obj;
367    
368                    long primaryKey = dlFileEntryMetadata.getPrimaryKey();
369    
370                    if (getPrimaryKey() == primaryKey) {
371                            return true;
372                    }
373                    else {
374                            return false;
375                    }
376            }
377    
378            @Override
379            public int hashCode() {
380                    return (int)getPrimaryKey();
381            }
382    
383            @Override
384            public void resetOriginalValues() {
385                    DLFileEntryMetadataModelImpl dlFileEntryMetadataModelImpl = this;
386    
387                    dlFileEntryMetadataModelImpl._originalUuid = dlFileEntryMetadataModelImpl._uuid;
388    
389                    dlFileEntryMetadataModelImpl._originalDDMStructureId = dlFileEntryMetadataModelImpl._DDMStructureId;
390    
391                    dlFileEntryMetadataModelImpl._setOriginalDDMStructureId = false;
392    
393                    dlFileEntryMetadataModelImpl._originalFileEntryTypeId = dlFileEntryMetadataModelImpl._fileEntryTypeId;
394    
395                    dlFileEntryMetadataModelImpl._setOriginalFileEntryTypeId = false;
396    
397                    dlFileEntryMetadataModelImpl._originalFileEntryId = dlFileEntryMetadataModelImpl._fileEntryId;
398    
399                    dlFileEntryMetadataModelImpl._setOriginalFileEntryId = false;
400    
401                    dlFileEntryMetadataModelImpl._originalFileVersionId = dlFileEntryMetadataModelImpl._fileVersionId;
402    
403                    dlFileEntryMetadataModelImpl._setOriginalFileVersionId = false;
404    
405                    dlFileEntryMetadataModelImpl._columnBitmask = 0;
406            }
407    
408            @Override
409            public CacheModel<DLFileEntryMetadata> toCacheModel() {
410                    DLFileEntryMetadataCacheModel dlFileEntryMetadataCacheModel = new DLFileEntryMetadataCacheModel();
411    
412                    dlFileEntryMetadataCacheModel.uuid = getUuid();
413    
414                    String uuid = dlFileEntryMetadataCacheModel.uuid;
415    
416                    if ((uuid != null) && (uuid.length() == 0)) {
417                            dlFileEntryMetadataCacheModel.uuid = null;
418                    }
419    
420                    dlFileEntryMetadataCacheModel.fileEntryMetadataId = getFileEntryMetadataId();
421    
422                    dlFileEntryMetadataCacheModel.DDMStorageId = getDDMStorageId();
423    
424                    dlFileEntryMetadataCacheModel.DDMStructureId = getDDMStructureId();
425    
426                    dlFileEntryMetadataCacheModel.fileEntryTypeId = getFileEntryTypeId();
427    
428                    dlFileEntryMetadataCacheModel.fileEntryId = getFileEntryId();
429    
430                    dlFileEntryMetadataCacheModel.fileVersionId = getFileVersionId();
431    
432                    return dlFileEntryMetadataCacheModel;
433            }
434    
435            @Override
436            public String toString() {
437                    StringBundler sb = new StringBundler(15);
438    
439                    sb.append("{uuid=");
440                    sb.append(getUuid());
441                    sb.append(", fileEntryMetadataId=");
442                    sb.append(getFileEntryMetadataId());
443                    sb.append(", DDMStorageId=");
444                    sb.append(getDDMStorageId());
445                    sb.append(", DDMStructureId=");
446                    sb.append(getDDMStructureId());
447                    sb.append(", fileEntryTypeId=");
448                    sb.append(getFileEntryTypeId());
449                    sb.append(", fileEntryId=");
450                    sb.append(getFileEntryId());
451                    sb.append(", fileVersionId=");
452                    sb.append(getFileVersionId());
453                    sb.append("}");
454    
455                    return sb.toString();
456            }
457    
458            public String toXmlString() {
459                    StringBundler sb = new StringBundler(25);
460    
461                    sb.append("<model><model-name>");
462                    sb.append(
463                            "com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata");
464                    sb.append("</model-name>");
465    
466                    sb.append(
467                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
468                    sb.append(getUuid());
469                    sb.append("]]></column-value></column>");
470                    sb.append(
471                            "<column><column-name>fileEntryMetadataId</column-name><column-value><![CDATA[");
472                    sb.append(getFileEntryMetadataId());
473                    sb.append("]]></column-value></column>");
474                    sb.append(
475                            "<column><column-name>DDMStorageId</column-name><column-value><![CDATA[");
476                    sb.append(getDDMStorageId());
477                    sb.append("]]></column-value></column>");
478                    sb.append(
479                            "<column><column-name>DDMStructureId</column-name><column-value><![CDATA[");
480                    sb.append(getDDMStructureId());
481                    sb.append("]]></column-value></column>");
482                    sb.append(
483                            "<column><column-name>fileEntryTypeId</column-name><column-value><![CDATA[");
484                    sb.append(getFileEntryTypeId());
485                    sb.append("]]></column-value></column>");
486                    sb.append(
487                            "<column><column-name>fileEntryId</column-name><column-value><![CDATA[");
488                    sb.append(getFileEntryId());
489                    sb.append("]]></column-value></column>");
490                    sb.append(
491                            "<column><column-name>fileVersionId</column-name><column-value><![CDATA[");
492                    sb.append(getFileVersionId());
493                    sb.append("]]></column-value></column>");
494    
495                    sb.append("</model>");
496    
497                    return sb.toString();
498            }
499    
500            private static ClassLoader _classLoader = DLFileEntryMetadata.class.getClassLoader();
501            private static Class<?>[] _escapedModelInterfaces = new Class[] {
502                            DLFileEntryMetadata.class
503                    };
504            private String _uuid;
505            private String _originalUuid;
506            private long _fileEntryMetadataId;
507            private long _DDMStorageId;
508            private long _DDMStructureId;
509            private long _originalDDMStructureId;
510            private boolean _setOriginalDDMStructureId;
511            private long _fileEntryTypeId;
512            private long _originalFileEntryTypeId;
513            private boolean _setOriginalFileEntryTypeId;
514            private long _fileEntryId;
515            private long _originalFileEntryId;
516            private boolean _setOriginalFileEntryId;
517            private long _fileVersionId;
518            private long _originalFileVersionId;
519            private boolean _setOriginalFileVersionId;
520            private long _columnBitmask;
521            private DLFileEntryMetadata _escapedModel;
522    }