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