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