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.asset.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
020    import com.liferay.portal.kernel.exception.PortalException;
021    import com.liferay.portal.kernel.json.JSON;
022    import com.liferay.portal.kernel.util.GetterUtil;
023    import com.liferay.portal.kernel.util.ProxyUtil;
024    import com.liferay.portal.kernel.util.StringBundler;
025    import com.liferay.portal.kernel.util.StringPool;
026    import com.liferay.portal.model.CacheModel;
027    import com.liferay.portal.model.User;
028    import com.liferay.portal.model.impl.BaseModelImpl;
029    import com.liferay.portal.service.ServiceContext;
030    import com.liferay.portal.service.UserLocalServiceUtil;
031    
032    import com.liferay.portlet.asset.model.AssetCategoryProperty;
033    import com.liferay.portlet.asset.model.AssetCategoryPropertyModel;
034    import com.liferay.portlet.asset.model.AssetCategoryPropertySoap;
035    import com.liferay.portlet.expando.model.ExpandoBridge;
036    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
037    
038    import java.io.Serializable;
039    
040    import java.sql.Types;
041    
042    import java.util.ArrayList;
043    import java.util.Date;
044    import java.util.HashMap;
045    import java.util.List;
046    import java.util.Map;
047    
048    /**
049     * The base model implementation for the AssetCategoryProperty service. Represents a row in the "AssetCategoryProperty" database table, with each column mapped to a property of this class.
050     *
051     * <p>
052     * This implementation and its corresponding interface {@link AssetCategoryPropertyModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AssetCategoryPropertyImpl}.
053     * </p>
054     *
055     * @author Brian Wing Shun Chan
056     * @see AssetCategoryPropertyImpl
057     * @see AssetCategoryProperty
058     * @see AssetCategoryPropertyModel
059     * @generated
060     */
061    @JSON(strict = true)
062    @ProviderType
063    public class AssetCategoryPropertyModelImpl extends BaseModelImpl<AssetCategoryProperty>
064            implements AssetCategoryPropertyModel {
065            /*
066             * NOTE FOR DEVELOPERS:
067             *
068             * Never modify or reference this class directly. All methods that expect a asset category property model instance should use the {@link AssetCategoryProperty} interface instead.
069             */
070            public static final String TABLE_NAME = "AssetCategoryProperty";
071            public static final Object[][] TABLE_COLUMNS = {
072                            { "categoryPropertyId", Types.BIGINT },
073                            { "companyId", Types.BIGINT },
074                            { "userId", Types.BIGINT },
075                            { "userName", Types.VARCHAR },
076                            { "createDate", Types.TIMESTAMP },
077                            { "modifiedDate", Types.TIMESTAMP },
078                            { "categoryId", Types.BIGINT },
079                            { "key_", Types.VARCHAR },
080                            { "value", Types.VARCHAR }
081                    };
082            public static final Map<String, Integer> TABLE_COLUMNS_MAP = new HashMap<String, Integer>();
083    
084            static {
085                    TABLE_COLUMNS_MAP.put("categoryPropertyId", Types.BIGINT);
086                    TABLE_COLUMNS_MAP.put("companyId", Types.BIGINT);
087                    TABLE_COLUMNS_MAP.put("userId", Types.BIGINT);
088                    TABLE_COLUMNS_MAP.put("userName", Types.VARCHAR);
089                    TABLE_COLUMNS_MAP.put("createDate", Types.TIMESTAMP);
090                    TABLE_COLUMNS_MAP.put("modifiedDate", Types.TIMESTAMP);
091                    TABLE_COLUMNS_MAP.put("categoryId", Types.BIGINT);
092                    TABLE_COLUMNS_MAP.put("key_", Types.VARCHAR);
093                    TABLE_COLUMNS_MAP.put("value", Types.VARCHAR);
094            }
095    
096            public static final String TABLE_SQL_CREATE = "create table AssetCategoryProperty (categoryPropertyId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,categoryId LONG,key_ VARCHAR(75) null,value VARCHAR(75) null)";
097            public static final String TABLE_SQL_DROP = "drop table AssetCategoryProperty";
098            public static final String ORDER_BY_JPQL = " ORDER BY assetCategoryProperty.key ASC";
099            public static final String ORDER_BY_SQL = " ORDER BY AssetCategoryProperty.key_ ASC";
100            public static final String DATA_SOURCE = "liferayDataSource";
101            public static final String SESSION_FACTORY = "liferaySessionFactory";
102            public static final String TX_MANAGER = "liferayTransactionManager";
103            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
104                                    "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetCategoryProperty"),
105                            true);
106            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
107                                    "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetCategoryProperty"),
108                            true);
109            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
110                                    "value.object.column.bitmask.enabled.com.liferay.portlet.asset.model.AssetCategoryProperty"),
111                            true);
112            public static final long CATEGORYID_COLUMN_BITMASK = 1L;
113            public static final long COMPANYID_COLUMN_BITMASK = 2L;
114            public static final long KEY_COLUMN_BITMASK = 4L;
115    
116            /**
117             * Converts the soap model instance into a normal model instance.
118             *
119             * @param soapModel the soap model instance to convert
120             * @return the normal model instance
121             */
122            public static AssetCategoryProperty toModel(
123                    AssetCategoryPropertySoap soapModel) {
124                    if (soapModel == null) {
125                            return null;
126                    }
127    
128                    AssetCategoryProperty model = new AssetCategoryPropertyImpl();
129    
130                    model.setCategoryPropertyId(soapModel.getCategoryPropertyId());
131                    model.setCompanyId(soapModel.getCompanyId());
132                    model.setUserId(soapModel.getUserId());
133                    model.setUserName(soapModel.getUserName());
134                    model.setCreateDate(soapModel.getCreateDate());
135                    model.setModifiedDate(soapModel.getModifiedDate());
136                    model.setCategoryId(soapModel.getCategoryId());
137                    model.setKey(soapModel.getKey());
138                    model.setValue(soapModel.getValue());
139    
140                    return model;
141            }
142    
143            /**
144             * Converts the soap model instances into normal model instances.
145             *
146             * @param soapModels the soap model instances to convert
147             * @return the normal model instances
148             */
149            public static List<AssetCategoryProperty> toModels(
150                    AssetCategoryPropertySoap[] soapModels) {
151                    if (soapModels == null) {
152                            return null;
153                    }
154    
155                    List<AssetCategoryProperty> models = new ArrayList<AssetCategoryProperty>(soapModels.length);
156    
157                    for (AssetCategoryPropertySoap soapModel : soapModels) {
158                            models.add(toModel(soapModel));
159                    }
160    
161                    return models;
162            }
163    
164            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
165                                    "lock.expiration.time.com.liferay.portlet.asset.model.AssetCategoryProperty"));
166    
167            public AssetCategoryPropertyModelImpl() {
168            }
169    
170            @Override
171            public long getPrimaryKey() {
172                    return _categoryPropertyId;
173            }
174    
175            @Override
176            public void setPrimaryKey(long primaryKey) {
177                    setCategoryPropertyId(primaryKey);
178            }
179    
180            @Override
181            public Serializable getPrimaryKeyObj() {
182                    return _categoryPropertyId;
183            }
184    
185            @Override
186            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
187                    setPrimaryKey(((Long)primaryKeyObj).longValue());
188            }
189    
190            @Override
191            public Class<?> getModelClass() {
192                    return AssetCategoryProperty.class;
193            }
194    
195            @Override
196            public String getModelClassName() {
197                    return AssetCategoryProperty.class.getName();
198            }
199    
200            @Override
201            public Map<String, Object> getModelAttributes() {
202                    Map<String, Object> attributes = new HashMap<String, Object>();
203    
204                    attributes.put("categoryPropertyId", getCategoryPropertyId());
205                    attributes.put("companyId", getCompanyId());
206                    attributes.put("userId", getUserId());
207                    attributes.put("userName", getUserName());
208                    attributes.put("createDate", getCreateDate());
209                    attributes.put("modifiedDate", getModifiedDate());
210                    attributes.put("categoryId", getCategoryId());
211                    attributes.put("key", getKey());
212                    attributes.put("value", getValue());
213    
214                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
215                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
216    
217                    return attributes;
218            }
219    
220            @Override
221            public void setModelAttributes(Map<String, Object> attributes) {
222                    Long categoryPropertyId = (Long)attributes.get("categoryPropertyId");
223    
224                    if (categoryPropertyId != null) {
225                            setCategoryPropertyId(categoryPropertyId);
226                    }
227    
228                    Long companyId = (Long)attributes.get("companyId");
229    
230                    if (companyId != null) {
231                            setCompanyId(companyId);
232                    }
233    
234                    Long userId = (Long)attributes.get("userId");
235    
236                    if (userId != null) {
237                            setUserId(userId);
238                    }
239    
240                    String userName = (String)attributes.get("userName");
241    
242                    if (userName != null) {
243                            setUserName(userName);
244                    }
245    
246                    Date createDate = (Date)attributes.get("createDate");
247    
248                    if (createDate != null) {
249                            setCreateDate(createDate);
250                    }
251    
252                    Date modifiedDate = (Date)attributes.get("modifiedDate");
253    
254                    if (modifiedDate != null) {
255                            setModifiedDate(modifiedDate);
256                    }
257    
258                    Long categoryId = (Long)attributes.get("categoryId");
259    
260                    if (categoryId != null) {
261                            setCategoryId(categoryId);
262                    }
263    
264                    String key = (String)attributes.get("key");
265    
266                    if (key != null) {
267                            setKey(key);
268                    }
269    
270                    String value = (String)attributes.get("value");
271    
272                    if (value != null) {
273                            setValue(value);
274                    }
275            }
276    
277            @JSON
278            @Override
279            public long getCategoryPropertyId() {
280                    return _categoryPropertyId;
281            }
282    
283            @Override
284            public void setCategoryPropertyId(long categoryPropertyId) {
285                    _categoryPropertyId = categoryPropertyId;
286            }
287    
288            @JSON
289            @Override
290            public long getCompanyId() {
291                    return _companyId;
292            }
293    
294            @Override
295            public void setCompanyId(long companyId) {
296                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
297    
298                    if (!_setOriginalCompanyId) {
299                            _setOriginalCompanyId = true;
300    
301                            _originalCompanyId = _companyId;
302                    }
303    
304                    _companyId = companyId;
305            }
306    
307            public long getOriginalCompanyId() {
308                    return _originalCompanyId;
309            }
310    
311            @JSON
312            @Override
313            public long getUserId() {
314                    return _userId;
315            }
316    
317            @Override
318            public void setUserId(long userId) {
319                    _userId = userId;
320            }
321    
322            @Override
323            public String getUserUuid() {
324                    try {
325                            User user = UserLocalServiceUtil.getUserById(getUserId());
326    
327                            return user.getUuid();
328                    }
329                    catch (PortalException pe) {
330                            return StringPool.BLANK;
331                    }
332            }
333    
334            @Override
335            public void setUserUuid(String userUuid) {
336            }
337    
338            @JSON
339            @Override
340            public String getUserName() {
341                    if (_userName == null) {
342                            return StringPool.BLANK;
343                    }
344                    else {
345                            return _userName;
346                    }
347            }
348    
349            @Override
350            public void setUserName(String userName) {
351                    _userName = userName;
352            }
353    
354            @JSON
355            @Override
356            public Date getCreateDate() {
357                    return _createDate;
358            }
359    
360            @Override
361            public void setCreateDate(Date createDate) {
362                    _createDate = createDate;
363            }
364    
365            @JSON
366            @Override
367            public Date getModifiedDate() {
368                    return _modifiedDate;
369            }
370    
371            public boolean hasSetModifiedDate() {
372                    return _setModifiedDate;
373            }
374    
375            @Override
376            public void setModifiedDate(Date modifiedDate) {
377                    _setModifiedDate = true;
378    
379                    _modifiedDate = modifiedDate;
380            }
381    
382            @JSON
383            @Override
384            public long getCategoryId() {
385                    return _categoryId;
386            }
387    
388            @Override
389            public void setCategoryId(long categoryId) {
390                    _columnBitmask |= CATEGORYID_COLUMN_BITMASK;
391    
392                    if (!_setOriginalCategoryId) {
393                            _setOriginalCategoryId = true;
394    
395                            _originalCategoryId = _categoryId;
396                    }
397    
398                    _categoryId = categoryId;
399            }
400    
401            public long getOriginalCategoryId() {
402                    return _originalCategoryId;
403            }
404    
405            @JSON
406            @Override
407            public String getKey() {
408                    if (_key == null) {
409                            return StringPool.BLANK;
410                    }
411                    else {
412                            return _key;
413                    }
414            }
415    
416            @Override
417            public void setKey(String key) {
418                    _columnBitmask = -1L;
419    
420                    if (_originalKey == null) {
421                            _originalKey = _key;
422                    }
423    
424                    _key = key;
425            }
426    
427            public String getOriginalKey() {
428                    return GetterUtil.getString(_originalKey);
429            }
430    
431            @JSON
432            @Override
433            public String getValue() {
434                    if (_value == null) {
435                            return StringPool.BLANK;
436                    }
437                    else {
438                            return _value;
439                    }
440            }
441    
442            @Override
443            public void setValue(String value) {
444                    _value = value;
445            }
446    
447            public long getColumnBitmask() {
448                    return _columnBitmask;
449            }
450    
451            @Override
452            public ExpandoBridge getExpandoBridge() {
453                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
454                            AssetCategoryProperty.class.getName(), getPrimaryKey());
455            }
456    
457            @Override
458            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
459                    ExpandoBridge expandoBridge = getExpandoBridge();
460    
461                    expandoBridge.setAttributes(serviceContext);
462            }
463    
464            @Override
465            public AssetCategoryProperty toEscapedModel() {
466                    if (_escapedModel == null) {
467                            _escapedModel = (AssetCategoryProperty)ProxyUtil.newProxyInstance(_classLoader,
468                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
469                    }
470    
471                    return _escapedModel;
472            }
473    
474            @Override
475            public Object clone() {
476                    AssetCategoryPropertyImpl assetCategoryPropertyImpl = new AssetCategoryPropertyImpl();
477    
478                    assetCategoryPropertyImpl.setCategoryPropertyId(getCategoryPropertyId());
479                    assetCategoryPropertyImpl.setCompanyId(getCompanyId());
480                    assetCategoryPropertyImpl.setUserId(getUserId());
481                    assetCategoryPropertyImpl.setUserName(getUserName());
482                    assetCategoryPropertyImpl.setCreateDate(getCreateDate());
483                    assetCategoryPropertyImpl.setModifiedDate(getModifiedDate());
484                    assetCategoryPropertyImpl.setCategoryId(getCategoryId());
485                    assetCategoryPropertyImpl.setKey(getKey());
486                    assetCategoryPropertyImpl.setValue(getValue());
487    
488                    assetCategoryPropertyImpl.resetOriginalValues();
489    
490                    return assetCategoryPropertyImpl;
491            }
492    
493            @Override
494            public int compareTo(AssetCategoryProperty assetCategoryProperty) {
495                    int value = 0;
496    
497                    value = getKey().compareTo(assetCategoryProperty.getKey());
498    
499                    if (value != 0) {
500                            return value;
501                    }
502    
503                    return 0;
504            }
505    
506            @Override
507            public boolean equals(Object obj) {
508                    if (this == obj) {
509                            return true;
510                    }
511    
512                    if (!(obj instanceof AssetCategoryProperty)) {
513                            return false;
514                    }
515    
516                    AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)obj;
517    
518                    long primaryKey = assetCategoryProperty.getPrimaryKey();
519    
520                    if (getPrimaryKey() == primaryKey) {
521                            return true;
522                    }
523                    else {
524                            return false;
525                    }
526            }
527    
528            @Override
529            public int hashCode() {
530                    return (int)getPrimaryKey();
531            }
532    
533            @Override
534            public boolean isEntityCacheEnabled() {
535                    return ENTITY_CACHE_ENABLED;
536            }
537    
538            @Override
539            public boolean isFinderCacheEnabled() {
540                    return FINDER_CACHE_ENABLED;
541            }
542    
543            @Override
544            public void resetOriginalValues() {
545                    AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = this;
546    
547                    assetCategoryPropertyModelImpl._originalCompanyId = assetCategoryPropertyModelImpl._companyId;
548    
549                    assetCategoryPropertyModelImpl._setOriginalCompanyId = false;
550    
551                    assetCategoryPropertyModelImpl._setModifiedDate = false;
552    
553                    assetCategoryPropertyModelImpl._originalCategoryId = assetCategoryPropertyModelImpl._categoryId;
554    
555                    assetCategoryPropertyModelImpl._setOriginalCategoryId = false;
556    
557                    assetCategoryPropertyModelImpl._originalKey = assetCategoryPropertyModelImpl._key;
558    
559                    assetCategoryPropertyModelImpl._columnBitmask = 0;
560            }
561    
562            @Override
563            public CacheModel<AssetCategoryProperty> toCacheModel() {
564                    AssetCategoryPropertyCacheModel assetCategoryPropertyCacheModel = new AssetCategoryPropertyCacheModel();
565    
566                    assetCategoryPropertyCacheModel.categoryPropertyId = getCategoryPropertyId();
567    
568                    assetCategoryPropertyCacheModel.companyId = getCompanyId();
569    
570                    assetCategoryPropertyCacheModel.userId = getUserId();
571    
572                    assetCategoryPropertyCacheModel.userName = getUserName();
573    
574                    String userName = assetCategoryPropertyCacheModel.userName;
575    
576                    if ((userName != null) && (userName.length() == 0)) {
577                            assetCategoryPropertyCacheModel.userName = null;
578                    }
579    
580                    Date createDate = getCreateDate();
581    
582                    if (createDate != null) {
583                            assetCategoryPropertyCacheModel.createDate = createDate.getTime();
584                    }
585                    else {
586                            assetCategoryPropertyCacheModel.createDate = Long.MIN_VALUE;
587                    }
588    
589                    Date modifiedDate = getModifiedDate();
590    
591                    if (modifiedDate != null) {
592                            assetCategoryPropertyCacheModel.modifiedDate = modifiedDate.getTime();
593                    }
594                    else {
595                            assetCategoryPropertyCacheModel.modifiedDate = Long.MIN_VALUE;
596                    }
597    
598                    assetCategoryPropertyCacheModel.categoryId = getCategoryId();
599    
600                    assetCategoryPropertyCacheModel.key = getKey();
601    
602                    String key = assetCategoryPropertyCacheModel.key;
603    
604                    if ((key != null) && (key.length() == 0)) {
605                            assetCategoryPropertyCacheModel.key = null;
606                    }
607    
608                    assetCategoryPropertyCacheModel.value = getValue();
609    
610                    String value = assetCategoryPropertyCacheModel.value;
611    
612                    if ((value != null) && (value.length() == 0)) {
613                            assetCategoryPropertyCacheModel.value = null;
614                    }
615    
616                    return assetCategoryPropertyCacheModel;
617            }
618    
619            @Override
620            public String toString() {
621                    StringBundler sb = new StringBundler(19);
622    
623                    sb.append("{categoryPropertyId=");
624                    sb.append(getCategoryPropertyId());
625                    sb.append(", companyId=");
626                    sb.append(getCompanyId());
627                    sb.append(", userId=");
628                    sb.append(getUserId());
629                    sb.append(", userName=");
630                    sb.append(getUserName());
631                    sb.append(", createDate=");
632                    sb.append(getCreateDate());
633                    sb.append(", modifiedDate=");
634                    sb.append(getModifiedDate());
635                    sb.append(", categoryId=");
636                    sb.append(getCategoryId());
637                    sb.append(", key=");
638                    sb.append(getKey());
639                    sb.append(", value=");
640                    sb.append(getValue());
641                    sb.append("}");
642    
643                    return sb.toString();
644            }
645    
646            @Override
647            public String toXmlString() {
648                    StringBundler sb = new StringBundler(31);
649    
650                    sb.append("<model><model-name>");
651                    sb.append("com.liferay.portlet.asset.model.AssetCategoryProperty");
652                    sb.append("</model-name>");
653    
654                    sb.append(
655                            "<column><column-name>categoryPropertyId</column-name><column-value><![CDATA[");
656                    sb.append(getCategoryPropertyId());
657                    sb.append("]]></column-value></column>");
658                    sb.append(
659                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
660                    sb.append(getCompanyId());
661                    sb.append("]]></column-value></column>");
662                    sb.append(
663                            "<column><column-name>userId</column-name><column-value><![CDATA[");
664                    sb.append(getUserId());
665                    sb.append("]]></column-value></column>");
666                    sb.append(
667                            "<column><column-name>userName</column-name><column-value><![CDATA[");
668                    sb.append(getUserName());
669                    sb.append("]]></column-value></column>");
670                    sb.append(
671                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
672                    sb.append(getCreateDate());
673                    sb.append("]]></column-value></column>");
674                    sb.append(
675                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
676                    sb.append(getModifiedDate());
677                    sb.append("]]></column-value></column>");
678                    sb.append(
679                            "<column><column-name>categoryId</column-name><column-value><![CDATA[");
680                    sb.append(getCategoryId());
681                    sb.append("]]></column-value></column>");
682                    sb.append(
683                            "<column><column-name>key</column-name><column-value><![CDATA[");
684                    sb.append(getKey());
685                    sb.append("]]></column-value></column>");
686                    sb.append(
687                            "<column><column-name>value</column-name><column-value><![CDATA[");
688                    sb.append(getValue());
689                    sb.append("]]></column-value></column>");
690    
691                    sb.append("</model>");
692    
693                    return sb.toString();
694            }
695    
696            private static final ClassLoader _classLoader = AssetCategoryProperty.class.getClassLoader();
697            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
698                            AssetCategoryProperty.class
699                    };
700            private long _categoryPropertyId;
701            private long _companyId;
702            private long _originalCompanyId;
703            private boolean _setOriginalCompanyId;
704            private long _userId;
705            private String _userName;
706            private Date _createDate;
707            private Date _modifiedDate;
708            private boolean _setModifiedDate;
709            private long _categoryId;
710            private long _originalCategoryId;
711            private boolean _setOriginalCategoryId;
712            private String _key;
713            private String _originalKey;
714            private String _value;
715            private long _columnBitmask;
716            private AssetCategoryProperty _escapedModel;
717    }