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.List;
042    
043    /**
044     * 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.
045     *
046     * <p>
047     * 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}.
048     * </p>
049     *
050     * @author Brian Wing Shun Chan
051     * @see AssetCategoryPropertyImpl
052     * @see com.liferay.portlet.asset.model.AssetCategoryProperty
053     * @see com.liferay.portlet.asset.model.AssetCategoryPropertyModel
054     * @generated
055     */
056    @JSON(strict = true)
057    public class AssetCategoryPropertyModelImpl extends BaseModelImpl<AssetCategoryProperty>
058            implements AssetCategoryPropertyModel {
059            /*
060             * NOTE FOR DEVELOPERS:
061             *
062             * 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.
063             */
064            public static final String TABLE_NAME = "AssetCategoryProperty";
065            public static final Object[][] TABLE_COLUMNS = {
066                            { "categoryPropertyId", Types.BIGINT },
067                            { "companyId", Types.BIGINT },
068                            { "userId", Types.BIGINT },
069                            { "userName", Types.VARCHAR },
070                            { "createDate", Types.TIMESTAMP },
071                            { "modifiedDate", Types.TIMESTAMP },
072                            { "categoryId", Types.BIGINT },
073                            { "key_", Types.VARCHAR },
074                            { "value", Types.VARCHAR }
075                    };
076            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)";
077            public static final String TABLE_SQL_DROP = "drop table AssetCategoryProperty";
078            public static final String ORDER_BY_JPQL = " ORDER BY assetCategoryProperty.key ASC";
079            public static final String ORDER_BY_SQL = " ORDER BY AssetCategoryProperty.key_ ASC";
080            public static final String DATA_SOURCE = "liferayDataSource";
081            public static final String SESSION_FACTORY = "liferaySessionFactory";
082            public static final String TX_MANAGER = "liferayTransactionManager";
083            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084                                    "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetCategoryProperty"),
085                            true);
086            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
087                                    "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetCategoryProperty"),
088                            true);
089            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
090                                    "value.object.column.bitmask.enabled.com.liferay.portlet.asset.model.AssetCategoryProperty"),
091                            true);
092            public static long CATEGORYID_COLUMN_BITMASK = 1L;
093            public static long COMPANYID_COLUMN_BITMASK = 2L;
094            public static long KEY_COLUMN_BITMASK = 4L;
095    
096            /**
097             * Converts the soap model instance into a normal model instance.
098             *
099             * @param soapModel the soap model instance to convert
100             * @return the normal model instance
101             */
102            public static AssetCategoryProperty toModel(
103                    AssetCategoryPropertySoap soapModel) {
104                    AssetCategoryProperty model = new AssetCategoryPropertyImpl();
105    
106                    model.setCategoryPropertyId(soapModel.getCategoryPropertyId());
107                    model.setCompanyId(soapModel.getCompanyId());
108                    model.setUserId(soapModel.getUserId());
109                    model.setUserName(soapModel.getUserName());
110                    model.setCreateDate(soapModel.getCreateDate());
111                    model.setModifiedDate(soapModel.getModifiedDate());
112                    model.setCategoryId(soapModel.getCategoryId());
113                    model.setKey(soapModel.getKey());
114                    model.setValue(soapModel.getValue());
115    
116                    return model;
117            }
118    
119            /**
120             * Converts the soap model instances into normal model instances.
121             *
122             * @param soapModels the soap model instances to convert
123             * @return the normal model instances
124             */
125            public static List<AssetCategoryProperty> toModels(
126                    AssetCategoryPropertySoap[] soapModels) {
127                    List<AssetCategoryProperty> models = new ArrayList<AssetCategoryProperty>(soapModels.length);
128    
129                    for (AssetCategoryPropertySoap soapModel : soapModels) {
130                            models.add(toModel(soapModel));
131                    }
132    
133                    return models;
134            }
135    
136            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
137                                    "lock.expiration.time.com.liferay.portlet.asset.model.AssetCategoryProperty"));
138    
139            public AssetCategoryPropertyModelImpl() {
140            }
141    
142            public long getPrimaryKey() {
143                    return _categoryPropertyId;
144            }
145    
146            public void setPrimaryKey(long primaryKey) {
147                    setCategoryPropertyId(primaryKey);
148            }
149    
150            public Serializable getPrimaryKeyObj() {
151                    return new Long(_categoryPropertyId);
152            }
153    
154            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
155                    setPrimaryKey(((Long)primaryKeyObj).longValue());
156            }
157    
158            public Class<?> getModelClass() {
159                    return AssetCategoryProperty.class;
160            }
161    
162            public String getModelClassName() {
163                    return AssetCategoryProperty.class.getName();
164            }
165    
166            @JSON
167            public long getCategoryPropertyId() {
168                    return _categoryPropertyId;
169            }
170    
171            public void setCategoryPropertyId(long categoryPropertyId) {
172                    _categoryPropertyId = categoryPropertyId;
173            }
174    
175            @JSON
176            public long getCompanyId() {
177                    return _companyId;
178            }
179    
180            public void setCompanyId(long companyId) {
181                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
182    
183                    if (!_setOriginalCompanyId) {
184                            _setOriginalCompanyId = true;
185    
186                            _originalCompanyId = _companyId;
187                    }
188    
189                    _companyId = companyId;
190            }
191    
192            public long getOriginalCompanyId() {
193                    return _originalCompanyId;
194            }
195    
196            @JSON
197            public long getUserId() {
198                    return _userId;
199            }
200    
201            public void setUserId(long userId) {
202                    _userId = userId;
203            }
204    
205            public String getUserUuid() throws SystemException {
206                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
207            }
208    
209            public void setUserUuid(String userUuid) {
210                    _userUuid = userUuid;
211            }
212    
213            @JSON
214            public String getUserName() {
215                    if (_userName == null) {
216                            return StringPool.BLANK;
217                    }
218                    else {
219                            return _userName;
220                    }
221            }
222    
223            public void setUserName(String userName) {
224                    _userName = userName;
225            }
226    
227            @JSON
228            public Date getCreateDate() {
229                    return _createDate;
230            }
231    
232            public void setCreateDate(Date createDate) {
233                    _createDate = createDate;
234            }
235    
236            @JSON
237            public Date getModifiedDate() {
238                    return _modifiedDate;
239            }
240    
241            public void setModifiedDate(Date modifiedDate) {
242                    _modifiedDate = modifiedDate;
243            }
244    
245            @JSON
246            public long getCategoryId() {
247                    return _categoryId;
248            }
249    
250            public void setCategoryId(long categoryId) {
251                    _columnBitmask |= CATEGORYID_COLUMN_BITMASK;
252    
253                    if (!_setOriginalCategoryId) {
254                            _setOriginalCategoryId = true;
255    
256                            _originalCategoryId = _categoryId;
257                    }
258    
259                    _categoryId = categoryId;
260            }
261    
262            public long getOriginalCategoryId() {
263                    return _originalCategoryId;
264            }
265    
266            @JSON
267            public String getKey() {
268                    if (_key == null) {
269                            return StringPool.BLANK;
270                    }
271                    else {
272                            return _key;
273                    }
274            }
275    
276            public void setKey(String key) {
277                    _columnBitmask = -1L;
278    
279                    if (_originalKey == null) {
280                            _originalKey = _key;
281                    }
282    
283                    _key = key;
284            }
285    
286            public String getOriginalKey() {
287                    return GetterUtil.getString(_originalKey);
288            }
289    
290            @JSON
291            public String getValue() {
292                    if (_value == null) {
293                            return StringPool.BLANK;
294                    }
295                    else {
296                            return _value;
297                    }
298            }
299    
300            public void setValue(String value) {
301                    _value = value;
302            }
303    
304            public long getColumnBitmask() {
305                    return _columnBitmask;
306            }
307    
308            @Override
309            public AssetCategoryProperty toEscapedModel() {
310                    if (_escapedModelProxy == null) {
311                            _escapedModelProxy = (AssetCategoryProperty)ProxyUtil.newProxyInstance(_classLoader,
312                                            _escapedModelProxyInterfaces,
313                                            new AutoEscapeBeanHandler(this));
314                    }
315    
316                    return _escapedModelProxy;
317            }
318    
319            @Override
320            public ExpandoBridge getExpandoBridge() {
321                    if (_expandoBridge == null) {
322                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
323                                            AssetCategoryProperty.class.getName(), getPrimaryKey());
324                    }
325    
326                    return _expandoBridge;
327            }
328    
329            @Override
330            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
331                    getExpandoBridge().setAttributes(serviceContext);
332            }
333    
334            @Override
335            public Object clone() {
336                    AssetCategoryPropertyImpl assetCategoryPropertyImpl = new AssetCategoryPropertyImpl();
337    
338                    assetCategoryPropertyImpl.setCategoryPropertyId(getCategoryPropertyId());
339                    assetCategoryPropertyImpl.setCompanyId(getCompanyId());
340                    assetCategoryPropertyImpl.setUserId(getUserId());
341                    assetCategoryPropertyImpl.setUserName(getUserName());
342                    assetCategoryPropertyImpl.setCreateDate(getCreateDate());
343                    assetCategoryPropertyImpl.setModifiedDate(getModifiedDate());
344                    assetCategoryPropertyImpl.setCategoryId(getCategoryId());
345                    assetCategoryPropertyImpl.setKey(getKey());
346                    assetCategoryPropertyImpl.setValue(getValue());
347    
348                    assetCategoryPropertyImpl.resetOriginalValues();
349    
350                    return assetCategoryPropertyImpl;
351            }
352    
353            public int compareTo(AssetCategoryProperty assetCategoryProperty) {
354                    int value = 0;
355    
356                    value = getKey().compareTo(assetCategoryProperty.getKey());
357    
358                    if (value != 0) {
359                            return value;
360                    }
361    
362                    return 0;
363            }
364    
365            @Override
366            public boolean equals(Object obj) {
367                    if (obj == null) {
368                            return false;
369                    }
370    
371                    AssetCategoryProperty assetCategoryProperty = null;
372    
373                    try {
374                            assetCategoryProperty = (AssetCategoryProperty)obj;
375                    }
376                    catch (ClassCastException cce) {
377                            return false;
378                    }
379    
380                    long primaryKey = assetCategoryProperty.getPrimaryKey();
381    
382                    if (getPrimaryKey() == primaryKey) {
383                            return true;
384                    }
385                    else {
386                            return false;
387                    }
388            }
389    
390            @Override
391            public int hashCode() {
392                    return (int)getPrimaryKey();
393            }
394    
395            @Override
396            public void resetOriginalValues() {
397                    AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = this;
398    
399                    assetCategoryPropertyModelImpl._originalCompanyId = assetCategoryPropertyModelImpl._companyId;
400    
401                    assetCategoryPropertyModelImpl._setOriginalCompanyId = false;
402    
403                    assetCategoryPropertyModelImpl._originalCategoryId = assetCategoryPropertyModelImpl._categoryId;
404    
405                    assetCategoryPropertyModelImpl._setOriginalCategoryId = false;
406    
407                    assetCategoryPropertyModelImpl._originalKey = assetCategoryPropertyModelImpl._key;
408    
409                    assetCategoryPropertyModelImpl._columnBitmask = 0;
410            }
411    
412            @Override
413            public CacheModel<AssetCategoryProperty> toCacheModel() {
414                    AssetCategoryPropertyCacheModel assetCategoryPropertyCacheModel = new AssetCategoryPropertyCacheModel();
415    
416                    assetCategoryPropertyCacheModel.categoryPropertyId = getCategoryPropertyId();
417    
418                    assetCategoryPropertyCacheModel.companyId = getCompanyId();
419    
420                    assetCategoryPropertyCacheModel.userId = getUserId();
421    
422                    assetCategoryPropertyCacheModel.userName = getUserName();
423    
424                    String userName = assetCategoryPropertyCacheModel.userName;
425    
426                    if ((userName != null) && (userName.length() == 0)) {
427                            assetCategoryPropertyCacheModel.userName = null;
428                    }
429    
430                    Date createDate = getCreateDate();
431    
432                    if (createDate != null) {
433                            assetCategoryPropertyCacheModel.createDate = createDate.getTime();
434                    }
435                    else {
436                            assetCategoryPropertyCacheModel.createDate = Long.MIN_VALUE;
437                    }
438    
439                    Date modifiedDate = getModifiedDate();
440    
441                    if (modifiedDate != null) {
442                            assetCategoryPropertyCacheModel.modifiedDate = modifiedDate.getTime();
443                    }
444                    else {
445                            assetCategoryPropertyCacheModel.modifiedDate = Long.MIN_VALUE;
446                    }
447    
448                    assetCategoryPropertyCacheModel.categoryId = getCategoryId();
449    
450                    assetCategoryPropertyCacheModel.key = getKey();
451    
452                    String key = assetCategoryPropertyCacheModel.key;
453    
454                    if ((key != null) && (key.length() == 0)) {
455                            assetCategoryPropertyCacheModel.key = null;
456                    }
457    
458                    assetCategoryPropertyCacheModel.value = getValue();
459    
460                    String value = assetCategoryPropertyCacheModel.value;
461    
462                    if ((value != null) && (value.length() == 0)) {
463                            assetCategoryPropertyCacheModel.value = null;
464                    }
465    
466                    return assetCategoryPropertyCacheModel;
467            }
468    
469            @Override
470            public String toString() {
471                    StringBundler sb = new StringBundler(19);
472    
473                    sb.append("{categoryPropertyId=");
474                    sb.append(getCategoryPropertyId());
475                    sb.append(", companyId=");
476                    sb.append(getCompanyId());
477                    sb.append(", userId=");
478                    sb.append(getUserId());
479                    sb.append(", userName=");
480                    sb.append(getUserName());
481                    sb.append(", createDate=");
482                    sb.append(getCreateDate());
483                    sb.append(", modifiedDate=");
484                    sb.append(getModifiedDate());
485                    sb.append(", categoryId=");
486                    sb.append(getCategoryId());
487                    sb.append(", key=");
488                    sb.append(getKey());
489                    sb.append(", value=");
490                    sb.append(getValue());
491                    sb.append("}");
492    
493                    return sb.toString();
494            }
495    
496            public String toXmlString() {
497                    StringBundler sb = new StringBundler(31);
498    
499                    sb.append("<model><model-name>");
500                    sb.append("com.liferay.portlet.asset.model.AssetCategoryProperty");
501                    sb.append("</model-name>");
502    
503                    sb.append(
504                            "<column><column-name>categoryPropertyId</column-name><column-value><![CDATA[");
505                    sb.append(getCategoryPropertyId());
506                    sb.append("]]></column-value></column>");
507                    sb.append(
508                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
509                    sb.append(getCompanyId());
510                    sb.append("]]></column-value></column>");
511                    sb.append(
512                            "<column><column-name>userId</column-name><column-value><![CDATA[");
513                    sb.append(getUserId());
514                    sb.append("]]></column-value></column>");
515                    sb.append(
516                            "<column><column-name>userName</column-name><column-value><![CDATA[");
517                    sb.append(getUserName());
518                    sb.append("]]></column-value></column>");
519                    sb.append(
520                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
521                    sb.append(getCreateDate());
522                    sb.append("]]></column-value></column>");
523                    sb.append(
524                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
525                    sb.append(getModifiedDate());
526                    sb.append("]]></column-value></column>");
527                    sb.append(
528                            "<column><column-name>categoryId</column-name><column-value><![CDATA[");
529                    sb.append(getCategoryId());
530                    sb.append("]]></column-value></column>");
531                    sb.append(
532                            "<column><column-name>key</column-name><column-value><![CDATA[");
533                    sb.append(getKey());
534                    sb.append("]]></column-value></column>");
535                    sb.append(
536                            "<column><column-name>value</column-name><column-value><![CDATA[");
537                    sb.append(getValue());
538                    sb.append("]]></column-value></column>");
539    
540                    sb.append("</model>");
541    
542                    return sb.toString();
543            }
544    
545            private static ClassLoader _classLoader = AssetCategoryProperty.class.getClassLoader();
546            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
547                            AssetCategoryProperty.class
548                    };
549            private long _categoryPropertyId;
550            private long _companyId;
551            private long _originalCompanyId;
552            private boolean _setOriginalCompanyId;
553            private long _userId;
554            private String _userUuid;
555            private String _userName;
556            private Date _createDate;
557            private Date _modifiedDate;
558            private long _categoryId;
559            private long _originalCategoryId;
560            private boolean _setOriginalCategoryId;
561            private String _key;
562            private String _originalKey;
563            private String _value;
564            private transient ExpandoBridge _expandoBridge;
565            private long _columnBitmask;
566            private AssetCategoryProperty _escapedModelProxy;
567    }