001    /**
002     * Copyright (c) 2000-2013 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            @Override
153            public long getPrimaryKey() {
154                    return _categoryPropertyId;
155            }
156    
157            @Override
158            public void setPrimaryKey(long primaryKey) {
159                    setCategoryPropertyId(primaryKey);
160            }
161    
162            @Override
163            public Serializable getPrimaryKeyObj() {
164                    return _categoryPropertyId;
165            }
166    
167            @Override
168            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
169                    setPrimaryKey(((Long)primaryKeyObj).longValue());
170            }
171    
172            @Override
173            public Class<?> getModelClass() {
174                    return AssetCategoryProperty.class;
175            }
176    
177            @Override
178            public String getModelClassName() {
179                    return AssetCategoryProperty.class.getName();
180            }
181    
182            @Override
183            public Map<String, Object> getModelAttributes() {
184                    Map<String, Object> attributes = new HashMap<String, Object>();
185    
186                    attributes.put("categoryPropertyId", getCategoryPropertyId());
187                    attributes.put("companyId", getCompanyId());
188                    attributes.put("userId", getUserId());
189                    attributes.put("userName", getUserName());
190                    attributes.put("createDate", getCreateDate());
191                    attributes.put("modifiedDate", getModifiedDate());
192                    attributes.put("categoryId", getCategoryId());
193                    attributes.put("key", getKey());
194                    attributes.put("value", getValue());
195    
196                    return attributes;
197            }
198    
199            @Override
200            public void setModelAttributes(Map<String, Object> attributes) {
201                    Long categoryPropertyId = (Long)attributes.get("categoryPropertyId");
202    
203                    if (categoryPropertyId != null) {
204                            setCategoryPropertyId(categoryPropertyId);
205                    }
206    
207                    Long companyId = (Long)attributes.get("companyId");
208    
209                    if (companyId != null) {
210                            setCompanyId(companyId);
211                    }
212    
213                    Long userId = (Long)attributes.get("userId");
214    
215                    if (userId != null) {
216                            setUserId(userId);
217                    }
218    
219                    String userName = (String)attributes.get("userName");
220    
221                    if (userName != null) {
222                            setUserName(userName);
223                    }
224    
225                    Date createDate = (Date)attributes.get("createDate");
226    
227                    if (createDate != null) {
228                            setCreateDate(createDate);
229                    }
230    
231                    Date modifiedDate = (Date)attributes.get("modifiedDate");
232    
233                    if (modifiedDate != null) {
234                            setModifiedDate(modifiedDate);
235                    }
236    
237                    Long categoryId = (Long)attributes.get("categoryId");
238    
239                    if (categoryId != null) {
240                            setCategoryId(categoryId);
241                    }
242    
243                    String key = (String)attributes.get("key");
244    
245                    if (key != null) {
246                            setKey(key);
247                    }
248    
249                    String value = (String)attributes.get("value");
250    
251                    if (value != null) {
252                            setValue(value);
253                    }
254            }
255    
256            @JSON
257            @Override
258            public long getCategoryPropertyId() {
259                    return _categoryPropertyId;
260            }
261    
262            @Override
263            public void setCategoryPropertyId(long categoryPropertyId) {
264                    _categoryPropertyId = categoryPropertyId;
265            }
266    
267            @JSON
268            @Override
269            public long getCompanyId() {
270                    return _companyId;
271            }
272    
273            @Override
274            public void setCompanyId(long companyId) {
275                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
276    
277                    if (!_setOriginalCompanyId) {
278                            _setOriginalCompanyId = true;
279    
280                            _originalCompanyId = _companyId;
281                    }
282    
283                    _companyId = companyId;
284            }
285    
286            public long getOriginalCompanyId() {
287                    return _originalCompanyId;
288            }
289    
290            @JSON
291            @Override
292            public long getUserId() {
293                    return _userId;
294            }
295    
296            @Override
297            public void setUserId(long userId) {
298                    _userId = userId;
299            }
300    
301            @Override
302            public String getUserUuid() throws SystemException {
303                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
304            }
305    
306            @Override
307            public void setUserUuid(String userUuid) {
308                    _userUuid = userUuid;
309            }
310    
311            @JSON
312            @Override
313            public String getUserName() {
314                    if (_userName == null) {
315                            return StringPool.BLANK;
316                    }
317                    else {
318                            return _userName;
319                    }
320            }
321    
322            @Override
323            public void setUserName(String userName) {
324                    _userName = userName;
325            }
326    
327            @JSON
328            @Override
329            public Date getCreateDate() {
330                    return _createDate;
331            }
332    
333            @Override
334            public void setCreateDate(Date createDate) {
335                    _createDate = createDate;
336            }
337    
338            @JSON
339            @Override
340            public Date getModifiedDate() {
341                    return _modifiedDate;
342            }
343    
344            @Override
345            public void setModifiedDate(Date modifiedDate) {
346                    _modifiedDate = modifiedDate;
347            }
348    
349            @JSON
350            @Override
351            public long getCategoryId() {
352                    return _categoryId;
353            }
354    
355            @Override
356            public void setCategoryId(long categoryId) {
357                    _columnBitmask |= CATEGORYID_COLUMN_BITMASK;
358    
359                    if (!_setOriginalCategoryId) {
360                            _setOriginalCategoryId = true;
361    
362                            _originalCategoryId = _categoryId;
363                    }
364    
365                    _categoryId = categoryId;
366            }
367    
368            public long getOriginalCategoryId() {
369                    return _originalCategoryId;
370            }
371    
372            @JSON
373            @Override
374            public String getKey() {
375                    if (_key == null) {
376                            return StringPool.BLANK;
377                    }
378                    else {
379                            return _key;
380                    }
381            }
382    
383            @Override
384            public void setKey(String key) {
385                    _columnBitmask = -1L;
386    
387                    if (_originalKey == null) {
388                            _originalKey = _key;
389                    }
390    
391                    _key = key;
392            }
393    
394            public String getOriginalKey() {
395                    return GetterUtil.getString(_originalKey);
396            }
397    
398            @JSON
399            @Override
400            public String getValue() {
401                    if (_value == null) {
402                            return StringPool.BLANK;
403                    }
404                    else {
405                            return _value;
406                    }
407            }
408    
409            @Override
410            public void setValue(String value) {
411                    _value = value;
412            }
413    
414            public long getColumnBitmask() {
415                    return _columnBitmask;
416            }
417    
418            @Override
419            public ExpandoBridge getExpandoBridge() {
420                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
421                            AssetCategoryProperty.class.getName(), getPrimaryKey());
422            }
423    
424            @Override
425            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
426                    ExpandoBridge expandoBridge = getExpandoBridge();
427    
428                    expandoBridge.setAttributes(serviceContext);
429            }
430    
431            @Override
432            public AssetCategoryProperty toEscapedModel() {
433                    if (_escapedModel == null) {
434                            _escapedModel = (AssetCategoryProperty)ProxyUtil.newProxyInstance(_classLoader,
435                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
436                    }
437    
438                    return _escapedModel;
439            }
440    
441            @Override
442            public Object clone() {
443                    AssetCategoryPropertyImpl assetCategoryPropertyImpl = new AssetCategoryPropertyImpl();
444    
445                    assetCategoryPropertyImpl.setCategoryPropertyId(getCategoryPropertyId());
446                    assetCategoryPropertyImpl.setCompanyId(getCompanyId());
447                    assetCategoryPropertyImpl.setUserId(getUserId());
448                    assetCategoryPropertyImpl.setUserName(getUserName());
449                    assetCategoryPropertyImpl.setCreateDate(getCreateDate());
450                    assetCategoryPropertyImpl.setModifiedDate(getModifiedDate());
451                    assetCategoryPropertyImpl.setCategoryId(getCategoryId());
452                    assetCategoryPropertyImpl.setKey(getKey());
453                    assetCategoryPropertyImpl.setValue(getValue());
454    
455                    assetCategoryPropertyImpl.resetOriginalValues();
456    
457                    return assetCategoryPropertyImpl;
458            }
459    
460            @Override
461            public int compareTo(AssetCategoryProperty assetCategoryProperty) {
462                    int value = 0;
463    
464                    value = getKey().compareTo(assetCategoryProperty.getKey());
465    
466                    if (value != 0) {
467                            return value;
468                    }
469    
470                    return 0;
471            }
472    
473            @Override
474            public boolean equals(Object obj) {
475                    if (this == obj) {
476                            return true;
477                    }
478    
479                    if (!(obj instanceof AssetCategoryProperty)) {
480                            return false;
481                    }
482    
483                    AssetCategoryProperty assetCategoryProperty = (AssetCategoryProperty)obj;
484    
485                    long primaryKey = assetCategoryProperty.getPrimaryKey();
486    
487                    if (getPrimaryKey() == primaryKey) {
488                            return true;
489                    }
490                    else {
491                            return false;
492                    }
493            }
494    
495            @Override
496            public int hashCode() {
497                    return (int)getPrimaryKey();
498            }
499    
500            @Override
501            public void resetOriginalValues() {
502                    AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = this;
503    
504                    assetCategoryPropertyModelImpl._originalCompanyId = assetCategoryPropertyModelImpl._companyId;
505    
506                    assetCategoryPropertyModelImpl._setOriginalCompanyId = false;
507    
508                    assetCategoryPropertyModelImpl._originalCategoryId = assetCategoryPropertyModelImpl._categoryId;
509    
510                    assetCategoryPropertyModelImpl._setOriginalCategoryId = false;
511    
512                    assetCategoryPropertyModelImpl._originalKey = assetCategoryPropertyModelImpl._key;
513    
514                    assetCategoryPropertyModelImpl._columnBitmask = 0;
515            }
516    
517            @Override
518            public CacheModel<AssetCategoryProperty> toCacheModel() {
519                    AssetCategoryPropertyCacheModel assetCategoryPropertyCacheModel = new AssetCategoryPropertyCacheModel();
520    
521                    assetCategoryPropertyCacheModel.categoryPropertyId = getCategoryPropertyId();
522    
523                    assetCategoryPropertyCacheModel.companyId = getCompanyId();
524    
525                    assetCategoryPropertyCacheModel.userId = getUserId();
526    
527                    assetCategoryPropertyCacheModel.userName = getUserName();
528    
529                    String userName = assetCategoryPropertyCacheModel.userName;
530    
531                    if ((userName != null) && (userName.length() == 0)) {
532                            assetCategoryPropertyCacheModel.userName = null;
533                    }
534    
535                    Date createDate = getCreateDate();
536    
537                    if (createDate != null) {
538                            assetCategoryPropertyCacheModel.createDate = createDate.getTime();
539                    }
540                    else {
541                            assetCategoryPropertyCacheModel.createDate = Long.MIN_VALUE;
542                    }
543    
544                    Date modifiedDate = getModifiedDate();
545    
546                    if (modifiedDate != null) {
547                            assetCategoryPropertyCacheModel.modifiedDate = modifiedDate.getTime();
548                    }
549                    else {
550                            assetCategoryPropertyCacheModel.modifiedDate = Long.MIN_VALUE;
551                    }
552    
553                    assetCategoryPropertyCacheModel.categoryId = getCategoryId();
554    
555                    assetCategoryPropertyCacheModel.key = getKey();
556    
557                    String key = assetCategoryPropertyCacheModel.key;
558    
559                    if ((key != null) && (key.length() == 0)) {
560                            assetCategoryPropertyCacheModel.key = null;
561                    }
562    
563                    assetCategoryPropertyCacheModel.value = getValue();
564    
565                    String value = assetCategoryPropertyCacheModel.value;
566    
567                    if ((value != null) && (value.length() == 0)) {
568                            assetCategoryPropertyCacheModel.value = null;
569                    }
570    
571                    return assetCategoryPropertyCacheModel;
572            }
573    
574            @Override
575            public String toString() {
576                    StringBundler sb = new StringBundler(19);
577    
578                    sb.append("{categoryPropertyId=");
579                    sb.append(getCategoryPropertyId());
580                    sb.append(", companyId=");
581                    sb.append(getCompanyId());
582                    sb.append(", userId=");
583                    sb.append(getUserId());
584                    sb.append(", userName=");
585                    sb.append(getUserName());
586                    sb.append(", createDate=");
587                    sb.append(getCreateDate());
588                    sb.append(", modifiedDate=");
589                    sb.append(getModifiedDate());
590                    sb.append(", categoryId=");
591                    sb.append(getCategoryId());
592                    sb.append(", key=");
593                    sb.append(getKey());
594                    sb.append(", value=");
595                    sb.append(getValue());
596                    sb.append("}");
597    
598                    return sb.toString();
599            }
600    
601            @Override
602            public String toXmlString() {
603                    StringBundler sb = new StringBundler(31);
604    
605                    sb.append("<model><model-name>");
606                    sb.append("com.liferay.portlet.asset.model.AssetCategoryProperty");
607                    sb.append("</model-name>");
608    
609                    sb.append(
610                            "<column><column-name>categoryPropertyId</column-name><column-value><![CDATA[");
611                    sb.append(getCategoryPropertyId());
612                    sb.append("]]></column-value></column>");
613                    sb.append(
614                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
615                    sb.append(getCompanyId());
616                    sb.append("]]></column-value></column>");
617                    sb.append(
618                            "<column><column-name>userId</column-name><column-value><![CDATA[");
619                    sb.append(getUserId());
620                    sb.append("]]></column-value></column>");
621                    sb.append(
622                            "<column><column-name>userName</column-name><column-value><![CDATA[");
623                    sb.append(getUserName());
624                    sb.append("]]></column-value></column>");
625                    sb.append(
626                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
627                    sb.append(getCreateDate());
628                    sb.append("]]></column-value></column>");
629                    sb.append(
630                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
631                    sb.append(getModifiedDate());
632                    sb.append("]]></column-value></column>");
633                    sb.append(
634                            "<column><column-name>categoryId</column-name><column-value><![CDATA[");
635                    sb.append(getCategoryId());
636                    sb.append("]]></column-value></column>");
637                    sb.append(
638                            "<column><column-name>key</column-name><column-value><![CDATA[");
639                    sb.append(getKey());
640                    sb.append("]]></column-value></column>");
641                    sb.append(
642                            "<column><column-name>value</column-name><column-value><![CDATA[");
643                    sb.append(getValue());
644                    sb.append("]]></column-value></column>");
645    
646                    sb.append("</model>");
647    
648                    return sb.toString();
649            }
650    
651            private static ClassLoader _classLoader = AssetCategoryProperty.class.getClassLoader();
652            private static Class<?>[] _escapedModelInterfaces = new Class[] {
653                            AssetCategoryProperty.class
654                    };
655            private long _categoryPropertyId;
656            private long _companyId;
657            private long _originalCompanyId;
658            private boolean _setOriginalCompanyId;
659            private long _userId;
660            private String _userUuid;
661            private String _userName;
662            private Date _createDate;
663            private Date _modifiedDate;
664            private long _categoryId;
665            private long _originalCategoryId;
666            private boolean _setOriginalCategoryId;
667            private String _key;
668            private String _originalKey;
669            private String _value;
670            private long _columnBitmask;
671            private AssetCategoryProperty _escapedModel;
672    }