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.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            @Override
415            public Object clone() {
416                    AssetTagPropertyImpl assetTagPropertyImpl = new AssetTagPropertyImpl();
417    
418                    assetTagPropertyImpl.setTagPropertyId(getTagPropertyId());
419                    assetTagPropertyImpl.setCompanyId(getCompanyId());
420                    assetTagPropertyImpl.setUserId(getUserId());
421                    assetTagPropertyImpl.setUserName(getUserName());
422                    assetTagPropertyImpl.setCreateDate(getCreateDate());
423                    assetTagPropertyImpl.setModifiedDate(getModifiedDate());
424                    assetTagPropertyImpl.setTagId(getTagId());
425                    assetTagPropertyImpl.setKey(getKey());
426                    assetTagPropertyImpl.setValue(getValue());
427    
428                    assetTagPropertyImpl.resetOriginalValues();
429    
430                    return assetTagPropertyImpl;
431            }
432    
433            public int compareTo(AssetTagProperty assetTagProperty) {
434                    int value = 0;
435    
436                    value = getKey().compareTo(assetTagProperty.getKey());
437    
438                    if (value != 0) {
439                            return value;
440                    }
441    
442                    return 0;
443            }
444    
445            @Override
446            public boolean equals(Object obj) {
447                    if (obj == null) {
448                            return false;
449                    }
450    
451                    AssetTagProperty assetTagProperty = null;
452    
453                    try {
454                            assetTagProperty = (AssetTagProperty)obj;
455                    }
456                    catch (ClassCastException cce) {
457                            return false;
458                    }
459    
460                    long primaryKey = assetTagProperty.getPrimaryKey();
461    
462                    if (getPrimaryKey() == primaryKey) {
463                            return true;
464                    }
465                    else {
466                            return false;
467                    }
468            }
469    
470            @Override
471            public int hashCode() {
472                    return (int)getPrimaryKey();
473            }
474    
475            @Override
476            public void resetOriginalValues() {
477                    AssetTagPropertyModelImpl assetTagPropertyModelImpl = this;
478    
479                    assetTagPropertyModelImpl._originalCompanyId = assetTagPropertyModelImpl._companyId;
480    
481                    assetTagPropertyModelImpl._setOriginalCompanyId = false;
482    
483                    assetTagPropertyModelImpl._originalTagId = assetTagPropertyModelImpl._tagId;
484    
485                    assetTagPropertyModelImpl._setOriginalTagId = false;
486    
487                    assetTagPropertyModelImpl._originalKey = assetTagPropertyModelImpl._key;
488    
489                    assetTagPropertyModelImpl._columnBitmask = 0;
490            }
491    
492            @Override
493            public CacheModel<AssetTagProperty> toCacheModel() {
494                    AssetTagPropertyCacheModel assetTagPropertyCacheModel = new AssetTagPropertyCacheModel();
495    
496                    assetTagPropertyCacheModel.tagPropertyId = getTagPropertyId();
497    
498                    assetTagPropertyCacheModel.companyId = getCompanyId();
499    
500                    assetTagPropertyCacheModel.userId = getUserId();
501    
502                    assetTagPropertyCacheModel.userName = getUserName();
503    
504                    String userName = assetTagPropertyCacheModel.userName;
505    
506                    if ((userName != null) && (userName.length() == 0)) {
507                            assetTagPropertyCacheModel.userName = null;
508                    }
509    
510                    Date createDate = getCreateDate();
511    
512                    if (createDate != null) {
513                            assetTagPropertyCacheModel.createDate = createDate.getTime();
514                    }
515                    else {
516                            assetTagPropertyCacheModel.createDate = Long.MIN_VALUE;
517                    }
518    
519                    Date modifiedDate = getModifiedDate();
520    
521                    if (modifiedDate != null) {
522                            assetTagPropertyCacheModel.modifiedDate = modifiedDate.getTime();
523                    }
524                    else {
525                            assetTagPropertyCacheModel.modifiedDate = Long.MIN_VALUE;
526                    }
527    
528                    assetTagPropertyCacheModel.tagId = getTagId();
529    
530                    assetTagPropertyCacheModel.key = getKey();
531    
532                    String key = assetTagPropertyCacheModel.key;
533    
534                    if ((key != null) && (key.length() == 0)) {
535                            assetTagPropertyCacheModel.key = null;
536                    }
537    
538                    assetTagPropertyCacheModel.value = getValue();
539    
540                    String value = assetTagPropertyCacheModel.value;
541    
542                    if ((value != null) && (value.length() == 0)) {
543                            assetTagPropertyCacheModel.value = null;
544                    }
545    
546                    return assetTagPropertyCacheModel;
547            }
548    
549            @Override
550            public String toString() {
551                    StringBundler sb = new StringBundler(19);
552    
553                    sb.append("{tagPropertyId=");
554                    sb.append(getTagPropertyId());
555                    sb.append(", companyId=");
556                    sb.append(getCompanyId());
557                    sb.append(", userId=");
558                    sb.append(getUserId());
559                    sb.append(", userName=");
560                    sb.append(getUserName());
561                    sb.append(", createDate=");
562                    sb.append(getCreateDate());
563                    sb.append(", modifiedDate=");
564                    sb.append(getModifiedDate());
565                    sb.append(", tagId=");
566                    sb.append(getTagId());
567                    sb.append(", key=");
568                    sb.append(getKey());
569                    sb.append(", value=");
570                    sb.append(getValue());
571                    sb.append("}");
572    
573                    return sb.toString();
574            }
575    
576            public String toXmlString() {
577                    StringBundler sb = new StringBundler(31);
578    
579                    sb.append("<model><model-name>");
580                    sb.append("com.liferay.portlet.asset.model.AssetTagProperty");
581                    sb.append("</model-name>");
582    
583                    sb.append(
584                            "<column><column-name>tagPropertyId</column-name><column-value><![CDATA[");
585                    sb.append(getTagPropertyId());
586                    sb.append("]]></column-value></column>");
587                    sb.append(
588                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
589                    sb.append(getCompanyId());
590                    sb.append("]]></column-value></column>");
591                    sb.append(
592                            "<column><column-name>userId</column-name><column-value><![CDATA[");
593                    sb.append(getUserId());
594                    sb.append("]]></column-value></column>");
595                    sb.append(
596                            "<column><column-name>userName</column-name><column-value><![CDATA[");
597                    sb.append(getUserName());
598                    sb.append("]]></column-value></column>");
599                    sb.append(
600                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
601                    sb.append(getCreateDate());
602                    sb.append("]]></column-value></column>");
603                    sb.append(
604                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
605                    sb.append(getModifiedDate());
606                    sb.append("]]></column-value></column>");
607                    sb.append(
608                            "<column><column-name>tagId</column-name><column-value><![CDATA[");
609                    sb.append(getTagId());
610                    sb.append("]]></column-value></column>");
611                    sb.append(
612                            "<column><column-name>key</column-name><column-value><![CDATA[");
613                    sb.append(getKey());
614                    sb.append("]]></column-value></column>");
615                    sb.append(
616                            "<column><column-name>value</column-name><column-value><![CDATA[");
617                    sb.append(getValue());
618                    sb.append("]]></column-value></column>");
619    
620                    sb.append("</model>");
621    
622                    return sb.toString();
623            }
624    
625            private static ClassLoader _classLoader = AssetTagProperty.class.getClassLoader();
626            private static Class<?>[] _escapedModelInterfaces = new Class[] {
627                            AssetTagProperty.class
628                    };
629            private long _tagPropertyId;
630            private long _companyId;
631            private long _originalCompanyId;
632            private boolean _setOriginalCompanyId;
633            private long _userId;
634            private String _userUuid;
635            private String _userName;
636            private Date _createDate;
637            private Date _modifiedDate;
638            private long _tagId;
639            private long _originalTagId;
640            private boolean _setOriginalTagId;
641            private String _key;
642            private String _originalKey;
643            private String _value;
644            private long _columnBitmask;
645            private AssetTagProperty _escapedModel;
646    }