001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.documentlibrary.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.json.JSON;
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    import com.liferay.portal.util.PortalUtil;
028    
029    import com.liferay.portlet.documentlibrary.model.DLFileEntryType;
030    import com.liferay.portlet.documentlibrary.model.DLFileEntryTypeModel;
031    import com.liferay.portlet.documentlibrary.model.DLFileEntryTypeSoap;
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.Types;
038    
039    import java.util.ArrayList;
040    import java.util.Date;
041    import java.util.List;
042    
043    /**
044     * The base model implementation for the DLFileEntryType service. Represents a row in the "DLFileEntryType" database table, with each column mapped to a property of this class.
045     *
046     * <p>
047     * This implementation and its corresponding interface {@link com.liferay.portlet.documentlibrary.model.DLFileEntryTypeModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DLFileEntryTypeImpl}.
048     * </p>
049     *
050     * @author Brian Wing Shun Chan
051     * @see DLFileEntryTypeImpl
052     * @see com.liferay.portlet.documentlibrary.model.DLFileEntryType
053     * @see com.liferay.portlet.documentlibrary.model.DLFileEntryTypeModel
054     * @generated
055     */
056    @JSON(strict = true)
057    public class DLFileEntryTypeModelImpl extends BaseModelImpl<DLFileEntryType>
058            implements DLFileEntryTypeModel {
059            /*
060             * NOTE FOR DEVELOPERS:
061             *
062             * Never modify or reference this class directly. All methods that expect a document library file entry type model instance should use the {@link com.liferay.portlet.documentlibrary.model.DLFileEntryType} interface instead.
063             */
064            public static final String TABLE_NAME = "DLFileEntryType";
065            public static final Object[][] TABLE_COLUMNS = {
066                            { "uuid_", Types.VARCHAR },
067                            { "fileEntryTypeId", Types.BIGINT },
068                            { "groupId", Types.BIGINT },
069                            { "companyId", Types.BIGINT },
070                            { "userId", Types.BIGINT },
071                            { "userName", Types.VARCHAR },
072                            { "createDate", Types.TIMESTAMP },
073                            { "modifiedDate", Types.TIMESTAMP },
074                            { "name", Types.VARCHAR },
075                            { "description", Types.VARCHAR }
076                    };
077            public static final String TABLE_SQL_CREATE = "create table DLFileEntryType (uuid_ VARCHAR(75) null,fileEntryTypeId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,name VARCHAR(75) null,description STRING null)";
078            public static final String TABLE_SQL_DROP = "drop table DLFileEntryType";
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.DLFileEntryType"),
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.DLFileEntryType"),
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.DLFileEntryType"),
090                            true);
091            public static long GROUPID_COLUMN_BITMASK = 1L;
092            public static long NAME_COLUMN_BITMASK = 2L;
093            public static long UUID_COLUMN_BITMASK = 4L;
094    
095            /**
096             * Converts the soap model instance into a normal model instance.
097             *
098             * @param soapModel the soap model instance to convert
099             * @return the normal model instance
100             */
101            public static DLFileEntryType toModel(DLFileEntryTypeSoap soapModel) {
102                    DLFileEntryType model = new DLFileEntryTypeImpl();
103    
104                    model.setUuid(soapModel.getUuid());
105                    model.setFileEntryTypeId(soapModel.getFileEntryTypeId());
106                    model.setGroupId(soapModel.getGroupId());
107                    model.setCompanyId(soapModel.getCompanyId());
108                    model.setUserId(soapModel.getUserId());
109                    model.setUserName(soapModel.getUserName());
110                    model.setCreateDate(soapModel.getCreateDate());
111                    model.setModifiedDate(soapModel.getModifiedDate());
112                    model.setName(soapModel.getName());
113                    model.setDescription(soapModel.getDescription());
114    
115                    return model;
116            }
117    
118            /**
119             * Converts the soap model instances into normal model instances.
120             *
121             * @param soapModels the soap model instances to convert
122             * @return the normal model instances
123             */
124            public static List<DLFileEntryType> toModels(
125                    DLFileEntryTypeSoap[] soapModels) {
126                    List<DLFileEntryType> models = new ArrayList<DLFileEntryType>(soapModels.length);
127    
128                    for (DLFileEntryTypeSoap soapModel : soapModels) {
129                            models.add(toModel(soapModel));
130                    }
131    
132                    return models;
133            }
134    
135            public static final String MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME = "DLFileEntryTypes_DLFolders";
136            public static final Object[][] MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_COLUMNS =
137                    {
138                            { "fileEntryTypeId", Types.BIGINT },
139                            { "folderId", Types.BIGINT }
140                    };
141            public static final String MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_SQL_CREATE =
142                    "create table DLFileEntryTypes_DLFolders (fileEntryTypeId LONG not null,folderId LONG not null,primary key (fileEntryTypeId, folderId))";
143            public static final boolean FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
144                                    "value.object.finder.cache.enabled.DLFileEntryTypes_DLFolders"),
145                            true);
146            public static final String MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME =
147                    "DLFileEntryTypes_DDMStructures";
148            public static final Object[][] MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_COLUMNS =
149                    {
150                            { "fileEntryTypeId", Types.BIGINT },
151                            { "structureId", Types.BIGINT }
152                    };
153            public static final String MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_SQL_CREATE =
154                    "create table DLFileEntryTypes_DDMStructures (fileEntryTypeId LONG not null,structureId LONG not null,primary key (fileEntryTypeId, structureId))";
155            public static final boolean FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DDMSTRUCTURES =
156                    GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
157                                    "value.object.finder.cache.enabled.DLFileEntryTypes_DDMStructures"),
158                            true);
159            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
160                                    "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileEntryType"));
161    
162            public DLFileEntryTypeModelImpl() {
163            }
164    
165            public long getPrimaryKey() {
166                    return _fileEntryTypeId;
167            }
168    
169            public void setPrimaryKey(long primaryKey) {
170                    setFileEntryTypeId(primaryKey);
171            }
172    
173            public Serializable getPrimaryKeyObj() {
174                    return new Long(_fileEntryTypeId);
175            }
176    
177            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
178                    setPrimaryKey(((Long)primaryKeyObj).longValue());
179            }
180    
181            public Class<?> getModelClass() {
182                    return DLFileEntryType.class;
183            }
184    
185            public String getModelClassName() {
186                    return DLFileEntryType.class.getName();
187            }
188    
189            @JSON
190            public String getUuid() {
191                    if (_uuid == null) {
192                            return StringPool.BLANK;
193                    }
194                    else {
195                            return _uuid;
196                    }
197            }
198    
199            public void setUuid(String uuid) {
200                    if (_originalUuid == null) {
201                            _originalUuid = _uuid;
202                    }
203    
204                    _uuid = uuid;
205            }
206    
207            public String getOriginalUuid() {
208                    return GetterUtil.getString(_originalUuid);
209            }
210    
211            @JSON
212            public long getFileEntryTypeId() {
213                    return _fileEntryTypeId;
214            }
215    
216            public void setFileEntryTypeId(long fileEntryTypeId) {
217                    _fileEntryTypeId = fileEntryTypeId;
218            }
219    
220            @JSON
221            public long getGroupId() {
222                    return _groupId;
223            }
224    
225            public void setGroupId(long groupId) {
226                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
227    
228                    if (!_setOriginalGroupId) {
229                            _setOriginalGroupId = true;
230    
231                            _originalGroupId = _groupId;
232                    }
233    
234                    _groupId = groupId;
235            }
236    
237            public long getOriginalGroupId() {
238                    return _originalGroupId;
239            }
240    
241            @JSON
242            public long getCompanyId() {
243                    return _companyId;
244            }
245    
246            public void setCompanyId(long companyId) {
247                    _companyId = companyId;
248            }
249    
250            @JSON
251            public long getUserId() {
252                    return _userId;
253            }
254    
255            public void setUserId(long userId) {
256                    _userId = userId;
257            }
258    
259            public String getUserUuid() throws SystemException {
260                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
261            }
262    
263            public void setUserUuid(String userUuid) {
264                    _userUuid = userUuid;
265            }
266    
267            @JSON
268            public String getUserName() {
269                    if (_userName == null) {
270                            return StringPool.BLANK;
271                    }
272                    else {
273                            return _userName;
274                    }
275            }
276    
277            public void setUserName(String userName) {
278                    _userName = userName;
279            }
280    
281            @JSON
282            public Date getCreateDate() {
283                    return _createDate;
284            }
285    
286            public void setCreateDate(Date createDate) {
287                    _createDate = createDate;
288            }
289    
290            @JSON
291            public Date getModifiedDate() {
292                    return _modifiedDate;
293            }
294    
295            public void setModifiedDate(Date modifiedDate) {
296                    _modifiedDate = modifiedDate;
297            }
298    
299            @JSON
300            public String getName() {
301                    if (_name == null) {
302                            return StringPool.BLANK;
303                    }
304                    else {
305                            return _name;
306                    }
307            }
308    
309            public void setName(String name) {
310                    _columnBitmask |= NAME_COLUMN_BITMASK;
311    
312                    if (_originalName == null) {
313                            _originalName = _name;
314                    }
315    
316                    _name = name;
317            }
318    
319            public String getOriginalName() {
320                    return GetterUtil.getString(_originalName);
321            }
322    
323            @JSON
324            public String getDescription() {
325                    if (_description == null) {
326                            return StringPool.BLANK;
327                    }
328                    else {
329                            return _description;
330                    }
331            }
332    
333            public void setDescription(String description) {
334                    _description = description;
335            }
336    
337            public long getColumnBitmask() {
338                    return _columnBitmask;
339            }
340    
341            @Override
342            public DLFileEntryType toEscapedModel() {
343                    if (_escapedModelProxy == null) {
344                            _escapedModelProxy = (DLFileEntryType)ProxyUtil.newProxyInstance(_classLoader,
345                                            _escapedModelProxyInterfaces,
346                                            new AutoEscapeBeanHandler(this));
347                    }
348    
349                    return _escapedModelProxy;
350            }
351    
352            @Override
353            public ExpandoBridge getExpandoBridge() {
354                    if (_expandoBridge == null) {
355                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
356                                            DLFileEntryType.class.getName(), getPrimaryKey());
357                    }
358    
359                    return _expandoBridge;
360            }
361    
362            @Override
363            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
364                    getExpandoBridge().setAttributes(serviceContext);
365            }
366    
367            @Override
368            public Object clone() {
369                    DLFileEntryTypeImpl dlFileEntryTypeImpl = new DLFileEntryTypeImpl();
370    
371                    dlFileEntryTypeImpl.setUuid(getUuid());
372                    dlFileEntryTypeImpl.setFileEntryTypeId(getFileEntryTypeId());
373                    dlFileEntryTypeImpl.setGroupId(getGroupId());
374                    dlFileEntryTypeImpl.setCompanyId(getCompanyId());
375                    dlFileEntryTypeImpl.setUserId(getUserId());
376                    dlFileEntryTypeImpl.setUserName(getUserName());
377                    dlFileEntryTypeImpl.setCreateDate(getCreateDate());
378                    dlFileEntryTypeImpl.setModifiedDate(getModifiedDate());
379                    dlFileEntryTypeImpl.setName(getName());
380                    dlFileEntryTypeImpl.setDescription(getDescription());
381    
382                    dlFileEntryTypeImpl.resetOriginalValues();
383    
384                    return dlFileEntryTypeImpl;
385            }
386    
387            public int compareTo(DLFileEntryType dlFileEntryType) {
388                    long primaryKey = dlFileEntryType.getPrimaryKey();
389    
390                    if (getPrimaryKey() < primaryKey) {
391                            return -1;
392                    }
393                    else if (getPrimaryKey() > primaryKey) {
394                            return 1;
395                    }
396                    else {
397                            return 0;
398                    }
399            }
400    
401            @Override
402            public boolean equals(Object obj) {
403                    if (obj == null) {
404                            return false;
405                    }
406    
407                    DLFileEntryType dlFileEntryType = null;
408    
409                    try {
410                            dlFileEntryType = (DLFileEntryType)obj;
411                    }
412                    catch (ClassCastException cce) {
413                            return false;
414                    }
415    
416                    long primaryKey = dlFileEntryType.getPrimaryKey();
417    
418                    if (getPrimaryKey() == primaryKey) {
419                            return true;
420                    }
421                    else {
422                            return false;
423                    }
424            }
425    
426            @Override
427            public int hashCode() {
428                    return (int)getPrimaryKey();
429            }
430    
431            @Override
432            public void resetOriginalValues() {
433                    DLFileEntryTypeModelImpl dlFileEntryTypeModelImpl = this;
434    
435                    dlFileEntryTypeModelImpl._originalUuid = dlFileEntryTypeModelImpl._uuid;
436    
437                    dlFileEntryTypeModelImpl._originalGroupId = dlFileEntryTypeModelImpl._groupId;
438    
439                    dlFileEntryTypeModelImpl._setOriginalGroupId = false;
440    
441                    dlFileEntryTypeModelImpl._originalName = dlFileEntryTypeModelImpl._name;
442    
443                    dlFileEntryTypeModelImpl._columnBitmask = 0;
444            }
445    
446            @Override
447            public CacheModel<DLFileEntryType> toCacheModel() {
448                    DLFileEntryTypeCacheModel dlFileEntryTypeCacheModel = new DLFileEntryTypeCacheModel();
449    
450                    dlFileEntryTypeCacheModel.uuid = getUuid();
451    
452                    String uuid = dlFileEntryTypeCacheModel.uuid;
453    
454                    if ((uuid != null) && (uuid.length() == 0)) {
455                            dlFileEntryTypeCacheModel.uuid = null;
456                    }
457    
458                    dlFileEntryTypeCacheModel.fileEntryTypeId = getFileEntryTypeId();
459    
460                    dlFileEntryTypeCacheModel.groupId = getGroupId();
461    
462                    dlFileEntryTypeCacheModel.companyId = getCompanyId();
463    
464                    dlFileEntryTypeCacheModel.userId = getUserId();
465    
466                    dlFileEntryTypeCacheModel.userName = getUserName();
467    
468                    String userName = dlFileEntryTypeCacheModel.userName;
469    
470                    if ((userName != null) && (userName.length() == 0)) {
471                            dlFileEntryTypeCacheModel.userName = null;
472                    }
473    
474                    Date createDate = getCreateDate();
475    
476                    if (createDate != null) {
477                            dlFileEntryTypeCacheModel.createDate = createDate.getTime();
478                    }
479                    else {
480                            dlFileEntryTypeCacheModel.createDate = Long.MIN_VALUE;
481                    }
482    
483                    Date modifiedDate = getModifiedDate();
484    
485                    if (modifiedDate != null) {
486                            dlFileEntryTypeCacheModel.modifiedDate = modifiedDate.getTime();
487                    }
488                    else {
489                            dlFileEntryTypeCacheModel.modifiedDate = Long.MIN_VALUE;
490                    }
491    
492                    dlFileEntryTypeCacheModel.name = getName();
493    
494                    String name = dlFileEntryTypeCacheModel.name;
495    
496                    if ((name != null) && (name.length() == 0)) {
497                            dlFileEntryTypeCacheModel.name = null;
498                    }
499    
500                    dlFileEntryTypeCacheModel.description = getDescription();
501    
502                    String description = dlFileEntryTypeCacheModel.description;
503    
504                    if ((description != null) && (description.length() == 0)) {
505                            dlFileEntryTypeCacheModel.description = null;
506                    }
507    
508                    return dlFileEntryTypeCacheModel;
509            }
510    
511            @Override
512            public String toString() {
513                    StringBundler sb = new StringBundler(21);
514    
515                    sb.append("{uuid=");
516                    sb.append(getUuid());
517                    sb.append(", fileEntryTypeId=");
518                    sb.append(getFileEntryTypeId());
519                    sb.append(", groupId=");
520                    sb.append(getGroupId());
521                    sb.append(", companyId=");
522                    sb.append(getCompanyId());
523                    sb.append(", userId=");
524                    sb.append(getUserId());
525                    sb.append(", userName=");
526                    sb.append(getUserName());
527                    sb.append(", createDate=");
528                    sb.append(getCreateDate());
529                    sb.append(", modifiedDate=");
530                    sb.append(getModifiedDate());
531                    sb.append(", name=");
532                    sb.append(getName());
533                    sb.append(", description=");
534                    sb.append(getDescription());
535                    sb.append("}");
536    
537                    return sb.toString();
538            }
539    
540            public String toXmlString() {
541                    StringBundler sb = new StringBundler(34);
542    
543                    sb.append("<model><model-name>");
544                    sb.append("com.liferay.portlet.documentlibrary.model.DLFileEntryType");
545                    sb.append("</model-name>");
546    
547                    sb.append(
548                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
549                    sb.append(getUuid());
550                    sb.append("]]></column-value></column>");
551                    sb.append(
552                            "<column><column-name>fileEntryTypeId</column-name><column-value><![CDATA[");
553                    sb.append(getFileEntryTypeId());
554                    sb.append("]]></column-value></column>");
555                    sb.append(
556                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
557                    sb.append(getGroupId());
558                    sb.append("]]></column-value></column>");
559                    sb.append(
560                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
561                    sb.append(getCompanyId());
562                    sb.append("]]></column-value></column>");
563                    sb.append(
564                            "<column><column-name>userId</column-name><column-value><![CDATA[");
565                    sb.append(getUserId());
566                    sb.append("]]></column-value></column>");
567                    sb.append(
568                            "<column><column-name>userName</column-name><column-value><![CDATA[");
569                    sb.append(getUserName());
570                    sb.append("]]></column-value></column>");
571                    sb.append(
572                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
573                    sb.append(getCreateDate());
574                    sb.append("]]></column-value></column>");
575                    sb.append(
576                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
577                    sb.append(getModifiedDate());
578                    sb.append("]]></column-value></column>");
579                    sb.append(
580                            "<column><column-name>name</column-name><column-value><![CDATA[");
581                    sb.append(getName());
582                    sb.append("]]></column-value></column>");
583                    sb.append(
584                            "<column><column-name>description</column-name><column-value><![CDATA[");
585                    sb.append(getDescription());
586                    sb.append("]]></column-value></column>");
587    
588                    sb.append("</model>");
589    
590                    return sb.toString();
591            }
592    
593            private static ClassLoader _classLoader = DLFileEntryType.class.getClassLoader();
594            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
595                            DLFileEntryType.class
596                    };
597            private String _uuid;
598            private String _originalUuid;
599            private long _fileEntryTypeId;
600            private long _groupId;
601            private long _originalGroupId;
602            private boolean _setOriginalGroupId;
603            private long _companyId;
604            private long _userId;
605            private String _userUuid;
606            private String _userName;
607            private Date _createDate;
608            private Date _modifiedDate;
609            private String _name;
610            private String _originalName;
611            private String _description;
612            private transient ExpandoBridge _expandoBridge;
613            private long _columnBitmask;
614            private DLFileEntryType _escapedModelProxy;
615    }