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