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