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.AssetTagProperty;
030    import com.liferay.portlet.asset.model.AssetTagPropertyModel;
031    import com.liferay.portlet.asset.model.AssetTagPropertySoap;
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 AssetTagProperty service. Represents a row in the "AssetTagProperty" 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.AssetTagPropertyModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AssetTagPropertyImpl}.
050     * </p>
051     *
052     * @author Brian Wing Shun Chan
053     * @see AssetTagPropertyImpl
054     * @see com.liferay.portlet.asset.model.AssetTagProperty
055     * @see com.liferay.portlet.asset.model.AssetTagPropertyModel
056     * @generated
057     */
058    @JSON(strict = true)
059    public class AssetTagPropertyModelImpl extends BaseModelImpl<AssetTagProperty>
060            implements AssetTagPropertyModel {
061            /*
062             * NOTE FOR DEVELOPERS:
063             *
064             * Never modify or reference this class directly. All methods that expect a asset tag property model instance should use the {@link com.liferay.portlet.asset.model.AssetTagProperty} interface instead.
065             */
066            public static final String TABLE_NAME = "AssetTagProperty";
067            public static final Object[][] TABLE_COLUMNS = {
068                            { "tagPropertyId", Types.BIGINT },
069                            { "companyId", Types.BIGINT },
070                            { "userId", Types.BIGINT },
071                            { "userName", Types.VARCHAR },
072                            { "createDate", Types.TIMESTAMP },
073                            { "modifiedDate", Types.TIMESTAMP },
074                            { "tagId", Types.BIGINT },
075                            { "key_", Types.VARCHAR },
076                            { "value", Types.VARCHAR }
077                    };
078            public static final String TABLE_SQL_CREATE = "create table AssetTagProperty (tagPropertyId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,tagId LONG,key_ VARCHAR(75) null,value VARCHAR(255) null)";
079            public static final String TABLE_SQL_DROP = "drop table AssetTagProperty";
080            public static final String ORDER_BY_JPQL = " ORDER BY assetTagProperty.key ASC";
081            public static final String ORDER_BY_SQL = " ORDER BY AssetTagProperty.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.AssetTagProperty"),
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.AssetTagProperty"),
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.AssetTagProperty"),
093                            true);
094            public static long COMPANYID_COLUMN_BITMASK = 1L;
095            public static long KEY_COLUMN_BITMASK = 2L;
096            public static long TAGID_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 AssetTagProperty toModel(AssetTagPropertySoap soapModel) {
105                    if (soapModel == null) {
106                            return null;
107                    }
108    
109                    AssetTagProperty model = new AssetTagPropertyImpl();
110    
111                    model.setTagPropertyId(soapModel.getTagPropertyId());
112                    model.setCompanyId(soapModel.getCompanyId());
113                    model.setUserId(soapModel.getUserId());
114                    model.setUserName(soapModel.getUserName());
115                    model.setCreateDate(soapModel.getCreateDate());
116                    model.setModifiedDate(soapModel.getModifiedDate());
117                    model.setTagId(soapModel.getTagId());
118                    model.setKey(soapModel.getKey());
119                    model.setValue(soapModel.getValue());
120    
121                    return model;
122            }
123    
124            /**
125             * Converts the soap model instances into normal model instances.
126             *
127             * @param soapModels the soap model instances to convert
128             * @return the normal model instances
129             */
130            public static List<AssetTagProperty> toModels(
131                    AssetTagPropertySoap[] soapModels) {
132                    if (soapModels == null) {
133                            return null;
134                    }
135    
136                    List<AssetTagProperty> models = new ArrayList<AssetTagProperty>(soapModels.length);
137    
138                    for (AssetTagPropertySoap soapModel : soapModels) {
139                            models.add(toModel(soapModel));
140                    }
141    
142                    return models;
143            }
144    
145            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
146                                    "lock.expiration.time.com.liferay.portlet.asset.model.AssetTagProperty"));
147    
148            public AssetTagPropertyModelImpl() {
149            }
150    
151            public long getPrimaryKey() {
152                    return _tagPropertyId;
153            }
154    
155            public void setPrimaryKey(long primaryKey) {
156                    setTagPropertyId(primaryKey);
157            }
158    
159            public Serializable getPrimaryKeyObj() {
160                    return new Long(_tagPropertyId);
161            }
162    
163            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
164                    setPrimaryKey(((Long)primaryKeyObj).longValue());
165            }
166    
167            public Class<?> getModelClass() {
168                    return AssetTagProperty.class;
169            }
170    
171            public String getModelClassName() {
172                    return AssetTagProperty.class.getName();
173            }
174    
175            @Override
176            public Map<String, Object> getModelAttributes() {
177                    Map<String, Object> attributes = new HashMap<String, Object>();
178    
179                    attributes.put("tagPropertyId", getTagPropertyId());
180                    attributes.put("companyId", getCompanyId());
181                    attributes.put("userId", getUserId());
182                    attributes.put("userName", getUserName());
183                    attributes.put("createDate", getCreateDate());
184                    attributes.put("modifiedDate", getModifiedDate());
185                    attributes.put("tagId", getTagId());
186                    attributes.put("key", getKey());
187                    attributes.put("value", getValue());
188    
189                    return attributes;
190            }
191    
192            @Override
193            public void setModelAttributes(Map<String, Object> attributes) {
194                    Long tagPropertyId = (Long)attributes.get("tagPropertyId");
195    
196                    if (tagPropertyId != null) {
197                            setTagPropertyId(tagPropertyId);
198                    }
199    
200                    Long companyId = (Long)attributes.get("companyId");
201    
202                    if (companyId != null) {
203                            setCompanyId(companyId);
204                    }
205    
206                    Long userId = (Long)attributes.get("userId");
207    
208                    if (userId != null) {
209                            setUserId(userId);
210                    }
211    
212                    String userName = (String)attributes.get("userName");
213    
214                    if (userName != null) {
215                            setUserName(userName);
216                    }
217    
218                    Date createDate = (Date)attributes.get("createDate");
219    
220                    if (createDate != null) {
221                            setCreateDate(createDate);
222                    }
223    
224                    Date modifiedDate = (Date)attributes.get("modifiedDate");
225    
226                    if (modifiedDate != null) {
227                            setModifiedDate(modifiedDate);
228                    }
229    
230                    Long tagId = (Long)attributes.get("tagId");
231    
232                    if (tagId != null) {
233                            setTagId(tagId);
234                    }
235    
236                    String key = (String)attributes.get("key");
237    
238                    if (key != null) {
239                            setKey(key);
240                    }
241    
242                    String value = (String)attributes.get("value");
243    
244                    if (value != null) {
245                            setValue(value);
246                    }
247            }
248    
249            @JSON
250            public long getTagPropertyId() {
251                    return _tagPropertyId;
252            }
253    
254            public void setTagPropertyId(long tagPropertyId) {
255                    _tagPropertyId = tagPropertyId;
256            }
257    
258            @JSON
259            public long getCompanyId() {
260                    return _companyId;
261            }
262    
263            public void setCompanyId(long companyId) {
264                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
265    
266                    if (!_setOriginalCompanyId) {
267                            _setOriginalCompanyId = true;
268    
269                            _originalCompanyId = _companyId;
270                    }
271    
272                    _companyId = companyId;
273            }
274    
275            public long getOriginalCompanyId() {
276                    return _originalCompanyId;
277            }
278    
279            @JSON
280            public long getUserId() {
281                    return _userId;
282            }
283    
284            public void setUserId(long userId) {
285                    _userId = userId;
286            }
287    
288            public String getUserUuid() throws SystemException {
289                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
290            }
291    
292            public void setUserUuid(String userUuid) {
293                    _userUuid = userUuid;
294            }
295    
296            @JSON
297            public String getUserName() {
298                    if (_userName == null) {
299                            return StringPool.BLANK;
300                    }
301                    else {
302                            return _userName;
303                    }
304            }
305    
306            public void setUserName(String userName) {
307                    _userName = userName;
308            }
309    
310            @JSON
311            public Date getCreateDate() {
312                    return _createDate;
313            }
314    
315            public void setCreateDate(Date createDate) {
316                    _createDate = createDate;
317            }
318    
319            @JSON
320            public Date getModifiedDate() {
321                    return _modifiedDate;
322            }
323    
324            public void setModifiedDate(Date modifiedDate) {
325                    _modifiedDate = modifiedDate;
326            }
327    
328            @JSON
329            public long getTagId() {
330                    return _tagId;
331            }
332    
333            public void setTagId(long tagId) {
334                    _columnBitmask |= TAGID_COLUMN_BITMASK;
335    
336                    if (!_setOriginalTagId) {
337                            _setOriginalTagId = true;
338    
339                            _originalTagId = _tagId;
340                    }
341    
342                    _tagId = tagId;
343            }
344    
345            public long getOriginalTagId() {
346                    return _originalTagId;
347            }
348    
349            @JSON
350            public String getKey() {
351                    if (_key == null) {
352                            return StringPool.BLANK;
353                    }
354                    else {
355                            return _key;
356                    }
357            }
358    
359            public void setKey(String key) {
360                    _columnBitmask = -1L;
361    
362                    if (_originalKey == null) {
363                            _originalKey = _key;
364                    }
365    
366                    _key = key;
367            }
368    
369            public String getOriginalKey() {
370                    return GetterUtil.getString(_originalKey);
371            }
372    
373            @JSON
374            public String getValue() {
375                    if (_value == null) {
376                            return StringPool.BLANK;
377                    }
378                    else {
379                            return _value;
380                    }
381            }
382    
383            public void setValue(String value) {
384                    _value = value;
385            }
386    
387            public long getColumnBitmask() {
388                    return _columnBitmask;
389            }
390    
391            @Override
392            public ExpandoBridge getExpandoBridge() {
393                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
394                            AssetTagProperty.class.getName(), getPrimaryKey());
395            }
396    
397            @Override
398            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
399                    ExpandoBridge expandoBridge = getExpandoBridge();
400    
401                    expandoBridge.setAttributes(serviceContext);
402            }
403    
404            @Override
405            public AssetTagProperty toEscapedModel() {
406                    if (_escapedModel == null) {
407                            _escapedModel = (AssetTagProperty)ProxyUtil.newProxyInstance(_classLoader,
408                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
409                    }
410    
411                    return _escapedModel;
412            }
413    
414            public AssetTagProperty toUnescapedModel() {
415                    return (AssetTagProperty)this;
416            }
417    
418            @Override
419            public Object clone() {
420                    AssetTagPropertyImpl assetTagPropertyImpl = new AssetTagPropertyImpl();
421    
422                    assetTagPropertyImpl.setTagPropertyId(getTagPropertyId());
423                    assetTagPropertyImpl.setCompanyId(getCompanyId());
424                    assetTagPropertyImpl.setUserId(getUserId());
425                    assetTagPropertyImpl.setUserName(getUserName());
426                    assetTagPropertyImpl.setCreateDate(getCreateDate());
427                    assetTagPropertyImpl.setModifiedDate(getModifiedDate());
428                    assetTagPropertyImpl.setTagId(getTagId());
429                    assetTagPropertyImpl.setKey(getKey());
430                    assetTagPropertyImpl.setValue(getValue());
431    
432                    assetTagPropertyImpl.resetOriginalValues();
433    
434                    return assetTagPropertyImpl;
435            }
436    
437            public int compareTo(AssetTagProperty assetTagProperty) {
438                    int value = 0;
439    
440                    value = getKey().compareTo(assetTagProperty.getKey());
441    
442                    if (value != 0) {
443                            return value;
444                    }
445    
446                    return 0;
447            }
448    
449            @Override
450            public boolean equals(Object obj) {
451                    if (this == obj) {
452                            return true;
453                    }
454    
455                    if (!(obj instanceof AssetTagProperty)) {
456                            return false;
457                    }
458    
459                    AssetTagProperty assetTagProperty = (AssetTagProperty)obj;
460    
461                    long primaryKey = assetTagProperty.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                    AssetTagPropertyModelImpl assetTagPropertyModelImpl = this;
479    
480                    assetTagPropertyModelImpl._originalCompanyId = assetTagPropertyModelImpl._companyId;
481    
482                    assetTagPropertyModelImpl._setOriginalCompanyId = false;
483    
484                    assetTagPropertyModelImpl._originalTagId = assetTagPropertyModelImpl._tagId;
485    
486                    assetTagPropertyModelImpl._setOriginalTagId = false;
487    
488                    assetTagPropertyModelImpl._originalKey = assetTagPropertyModelImpl._key;
489    
490                    assetTagPropertyModelImpl._columnBitmask = 0;
491            }
492    
493            @Override
494            public CacheModel<AssetTagProperty> toCacheModel() {
495                    AssetTagPropertyCacheModel assetTagPropertyCacheModel = new AssetTagPropertyCacheModel();
496    
497                    assetTagPropertyCacheModel.tagPropertyId = getTagPropertyId();
498    
499                    assetTagPropertyCacheModel.companyId = getCompanyId();
500    
501                    assetTagPropertyCacheModel.userId = getUserId();
502    
503                    assetTagPropertyCacheModel.userName = getUserName();
504    
505                    String userName = assetTagPropertyCacheModel.userName;
506    
507                    if ((userName != null) && (userName.length() == 0)) {
508                            assetTagPropertyCacheModel.userName = null;
509                    }
510    
511                    Date createDate = getCreateDate();
512    
513                    if (createDate != null) {
514                            assetTagPropertyCacheModel.createDate = createDate.getTime();
515                    }
516                    else {
517                            assetTagPropertyCacheModel.createDate = Long.MIN_VALUE;
518                    }
519    
520                    Date modifiedDate = getModifiedDate();
521    
522                    if (modifiedDate != null) {
523                            assetTagPropertyCacheModel.modifiedDate = modifiedDate.getTime();
524                    }
525                    else {
526                            assetTagPropertyCacheModel.modifiedDate = Long.MIN_VALUE;
527                    }
528    
529                    assetTagPropertyCacheModel.tagId = getTagId();
530    
531                    assetTagPropertyCacheModel.key = getKey();
532    
533                    String key = assetTagPropertyCacheModel.key;
534    
535                    if ((key != null) && (key.length() == 0)) {
536                            assetTagPropertyCacheModel.key = null;
537                    }
538    
539                    assetTagPropertyCacheModel.value = getValue();
540    
541                    String value = assetTagPropertyCacheModel.value;
542    
543                    if ((value != null) && (value.length() == 0)) {
544                            assetTagPropertyCacheModel.value = null;
545                    }
546    
547                    return assetTagPropertyCacheModel;
548            }
549    
550            @Override
551            public String toString() {
552                    StringBundler sb = new StringBundler(19);
553    
554                    sb.append("{tagPropertyId=");
555                    sb.append(getTagPropertyId());
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(", tagId=");
567                    sb.append(getTagId());
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.AssetTagProperty");
582                    sb.append("</model-name>");
583    
584                    sb.append(
585                            "<column><column-name>tagPropertyId</column-name><column-value><![CDATA[");
586                    sb.append(getTagPropertyId());
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>tagId</column-name><column-value><![CDATA[");
610                    sb.append(getTagId());
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 = AssetTagProperty.class.getClassLoader();
627            private static Class<?>[] _escapedModelInterfaces = new Class[] {
628                            AssetTagProperty.class
629                    };
630            private long _tagPropertyId;
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 _tagId;
640            private long _originalTagId;
641            private boolean _setOriginalTagId;
642            private String _key;
643            private String _originalKey;
644            private String _value;
645            private long _columnBitmask;
646            private AssetTagProperty _escapedModel;
647    }