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.AssetTag;
030    import com.liferay.portlet.asset.model.AssetTagModel;
031    import com.liferay.portlet.asset.model.AssetTagSoap;
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 AssetTag service. Represents a row in the "AssetTag" 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.AssetTagModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AssetTagImpl}.
050     * </p>
051     *
052     * @author Brian Wing Shun Chan
053     * @see AssetTagImpl
054     * @see com.liferay.portlet.asset.model.AssetTag
055     * @see com.liferay.portlet.asset.model.AssetTagModel
056     * @generated
057     */
058    @JSON(strict = true)
059    public class AssetTagModelImpl extends BaseModelImpl<AssetTag>
060            implements AssetTagModel {
061            /*
062             * NOTE FOR DEVELOPERS:
063             *
064             * Never modify or reference this class directly. All methods that expect a asset tag model instance should use the {@link com.liferay.portlet.asset.model.AssetTag} interface instead.
065             */
066            public static final String TABLE_NAME = "AssetTag";
067            public static final Object[][] TABLE_COLUMNS = {
068                            { "tagId", Types.BIGINT },
069                            { "groupId", Types.BIGINT },
070                            { "companyId", Types.BIGINT },
071                            { "userId", Types.BIGINT },
072                            { "userName", Types.VARCHAR },
073                            { "createDate", Types.TIMESTAMP },
074                            { "modifiedDate", Types.TIMESTAMP },
075                            { "name", Types.VARCHAR },
076                            { "assetCount", Types.INTEGER }
077                    };
078            public static final String TABLE_SQL_CREATE = "create table AssetTag (tagId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,name VARCHAR(75) null,assetCount INTEGER)";
079            public static final String TABLE_SQL_DROP = "drop table AssetTag";
080            public static final String ORDER_BY_JPQL = " ORDER BY assetTag.name ASC";
081            public static final String ORDER_BY_SQL = " ORDER BY AssetTag.name 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.AssetTag"),
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.AssetTag"),
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.AssetTag"),
093                            true);
094            public static long GROUPID_COLUMN_BITMASK = 1L;
095            public static long NAME_COLUMN_BITMASK = 2L;
096    
097            /**
098             * Converts the soap model instance into a normal model instance.
099             *
100             * @param soapModel the soap model instance to convert
101             * @return the normal model instance
102             */
103            public static AssetTag toModel(AssetTagSoap soapModel) {
104                    if (soapModel == null) {
105                            return null;
106                    }
107    
108                    AssetTag model = new AssetTagImpl();
109    
110                    model.setTagId(soapModel.getTagId());
111                    model.setGroupId(soapModel.getGroupId());
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.setName(soapModel.getName());
118                    model.setAssetCount(soapModel.getAssetCount());
119    
120                    return model;
121            }
122    
123            /**
124             * Converts the soap model instances into normal model instances.
125             *
126             * @param soapModels the soap model instances to convert
127             * @return the normal model instances
128             */
129            public static List<AssetTag> toModels(AssetTagSoap[] soapModels) {
130                    if (soapModels == null) {
131                            return null;
132                    }
133    
134                    List<AssetTag> models = new ArrayList<AssetTag>(soapModels.length);
135    
136                    for (AssetTagSoap soapModel : soapModels) {
137                            models.add(toModel(soapModel));
138                    }
139    
140                    return models;
141            }
142    
143            public static final String MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_NAME = "AssetEntries_AssetTags";
144            public static final Object[][] MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_COLUMNS = {
145                            { "entryId", Types.BIGINT },
146                            { "tagId", Types.BIGINT }
147                    };
148            public static final String MAPPING_TABLE_ASSETENTRIES_ASSETTAGS_SQL_CREATE = "create table AssetEntries_AssetTags (entryId LONG not null,tagId LONG not null,primary key (entryId, tagId))";
149            public static final boolean FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETTAGS = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
150                                    "value.object.finder.cache.enabled.AssetEntries_AssetTags"),
151                            true);
152            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
153                                    "lock.expiration.time.com.liferay.portlet.asset.model.AssetTag"));
154    
155            public AssetTagModelImpl() {
156            }
157    
158            public long getPrimaryKey() {
159                    return _tagId;
160            }
161    
162            public void setPrimaryKey(long primaryKey) {
163                    setTagId(primaryKey);
164            }
165    
166            public Serializable getPrimaryKeyObj() {
167                    return new Long(_tagId);
168            }
169    
170            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
171                    setPrimaryKey(((Long)primaryKeyObj).longValue());
172            }
173    
174            public Class<?> getModelClass() {
175                    return AssetTag.class;
176            }
177    
178            public String getModelClassName() {
179                    return AssetTag.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("tagId", getTagId());
187                    attributes.put("groupId", getGroupId());
188                    attributes.put("companyId", getCompanyId());
189                    attributes.put("userId", getUserId());
190                    attributes.put("userName", getUserName());
191                    attributes.put("createDate", getCreateDate());
192                    attributes.put("modifiedDate", getModifiedDate());
193                    attributes.put("name", getName());
194                    attributes.put("assetCount", getAssetCount());
195    
196                    return attributes;
197            }
198    
199            @Override
200            public void setModelAttributes(Map<String, Object> attributes) {
201                    Long tagId = (Long)attributes.get("tagId");
202    
203                    if (tagId != null) {
204                            setTagId(tagId);
205                    }
206    
207                    Long groupId = (Long)attributes.get("groupId");
208    
209                    if (groupId != null) {
210                            setGroupId(groupId);
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                    String name = (String)attributes.get("name");
244    
245                    if (name != null) {
246                            setName(name);
247                    }
248    
249                    Integer assetCount = (Integer)attributes.get("assetCount");
250    
251                    if (assetCount != null) {
252                            setAssetCount(assetCount);
253                    }
254            }
255    
256            @JSON
257            public long getTagId() {
258                    return _tagId;
259            }
260    
261            public void setTagId(long tagId) {
262                    _tagId = tagId;
263            }
264    
265            @JSON
266            public long getGroupId() {
267                    return _groupId;
268            }
269    
270            public void setGroupId(long groupId) {
271                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
272    
273                    if (!_setOriginalGroupId) {
274                            _setOriginalGroupId = true;
275    
276                            _originalGroupId = _groupId;
277                    }
278    
279                    _groupId = groupId;
280            }
281    
282            public long getOriginalGroupId() {
283                    return _originalGroupId;
284            }
285    
286            @JSON
287            public long getCompanyId() {
288                    return _companyId;
289            }
290    
291            public void setCompanyId(long companyId) {
292                    _companyId = companyId;
293            }
294    
295            @JSON
296            public long getUserId() {
297                    return _userId;
298            }
299    
300            public void setUserId(long userId) {
301                    _userId = userId;
302            }
303    
304            public String getUserUuid() throws SystemException {
305                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
306            }
307    
308            public void setUserUuid(String userUuid) {
309                    _userUuid = userUuid;
310            }
311    
312            @JSON
313            public String getUserName() {
314                    if (_userName == null) {
315                            return StringPool.BLANK;
316                    }
317                    else {
318                            return _userName;
319                    }
320            }
321    
322            public void setUserName(String userName) {
323                    _userName = userName;
324            }
325    
326            @JSON
327            public Date getCreateDate() {
328                    return _createDate;
329            }
330    
331            public void setCreateDate(Date createDate) {
332                    _createDate = createDate;
333            }
334    
335            @JSON
336            public Date getModifiedDate() {
337                    return _modifiedDate;
338            }
339    
340            public void setModifiedDate(Date modifiedDate) {
341                    _modifiedDate = modifiedDate;
342            }
343    
344            @JSON
345            public String getName() {
346                    if (_name == null) {
347                            return StringPool.BLANK;
348                    }
349                    else {
350                            return _name;
351                    }
352            }
353    
354            public void setName(String name) {
355                    _columnBitmask = -1L;
356    
357                    if (_originalName == null) {
358                            _originalName = _name;
359                    }
360    
361                    _name = name;
362            }
363    
364            public String getOriginalName() {
365                    return GetterUtil.getString(_originalName);
366            }
367    
368            @JSON
369            public int getAssetCount() {
370                    return _assetCount;
371            }
372    
373            public void setAssetCount(int assetCount) {
374                    _assetCount = assetCount;
375            }
376    
377            public long getColumnBitmask() {
378                    return _columnBitmask;
379            }
380    
381            @Override
382            public ExpandoBridge getExpandoBridge() {
383                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
384                            AssetTag.class.getName(), getPrimaryKey());
385            }
386    
387            @Override
388            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
389                    ExpandoBridge expandoBridge = getExpandoBridge();
390    
391                    expandoBridge.setAttributes(serviceContext);
392            }
393    
394            @Override
395            public AssetTag toEscapedModel() {
396                    if (_escapedModel == null) {
397                            _escapedModel = (AssetTag)ProxyUtil.newProxyInstance(_classLoader,
398                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
399                    }
400    
401                    return _escapedModel;
402            }
403    
404            public AssetTag toUnescapedModel() {
405                    return (AssetTag)this;
406            }
407    
408            @Override
409            public Object clone() {
410                    AssetTagImpl assetTagImpl = new AssetTagImpl();
411    
412                    assetTagImpl.setTagId(getTagId());
413                    assetTagImpl.setGroupId(getGroupId());
414                    assetTagImpl.setCompanyId(getCompanyId());
415                    assetTagImpl.setUserId(getUserId());
416                    assetTagImpl.setUserName(getUserName());
417                    assetTagImpl.setCreateDate(getCreateDate());
418                    assetTagImpl.setModifiedDate(getModifiedDate());
419                    assetTagImpl.setName(getName());
420                    assetTagImpl.setAssetCount(getAssetCount());
421    
422                    assetTagImpl.resetOriginalValues();
423    
424                    return assetTagImpl;
425            }
426    
427            public int compareTo(AssetTag assetTag) {
428                    int value = 0;
429    
430                    value = getName().compareTo(assetTag.getName());
431    
432                    if (value != 0) {
433                            return value;
434                    }
435    
436                    return 0;
437            }
438    
439            @Override
440            public boolean equals(Object obj) {
441                    if (this == obj) {
442                            return true;
443                    }
444    
445                    if (!(obj instanceof AssetTag)) {
446                            return false;
447                    }
448    
449                    AssetTag assetTag = (AssetTag)obj;
450    
451                    long primaryKey = assetTag.getPrimaryKey();
452    
453                    if (getPrimaryKey() == primaryKey) {
454                            return true;
455                    }
456                    else {
457                            return false;
458                    }
459            }
460    
461            @Override
462            public int hashCode() {
463                    return (int)getPrimaryKey();
464            }
465    
466            @Override
467            public void resetOriginalValues() {
468                    AssetTagModelImpl assetTagModelImpl = this;
469    
470                    assetTagModelImpl._originalGroupId = assetTagModelImpl._groupId;
471    
472                    assetTagModelImpl._setOriginalGroupId = false;
473    
474                    assetTagModelImpl._originalName = assetTagModelImpl._name;
475    
476                    assetTagModelImpl._columnBitmask = 0;
477            }
478    
479            @Override
480            public CacheModel<AssetTag> toCacheModel() {
481                    AssetTagCacheModel assetTagCacheModel = new AssetTagCacheModel();
482    
483                    assetTagCacheModel.tagId = getTagId();
484    
485                    assetTagCacheModel.groupId = getGroupId();
486    
487                    assetTagCacheModel.companyId = getCompanyId();
488    
489                    assetTagCacheModel.userId = getUserId();
490    
491                    assetTagCacheModel.userName = getUserName();
492    
493                    String userName = assetTagCacheModel.userName;
494    
495                    if ((userName != null) && (userName.length() == 0)) {
496                            assetTagCacheModel.userName = null;
497                    }
498    
499                    Date createDate = getCreateDate();
500    
501                    if (createDate != null) {
502                            assetTagCacheModel.createDate = createDate.getTime();
503                    }
504                    else {
505                            assetTagCacheModel.createDate = Long.MIN_VALUE;
506                    }
507    
508                    Date modifiedDate = getModifiedDate();
509    
510                    if (modifiedDate != null) {
511                            assetTagCacheModel.modifiedDate = modifiedDate.getTime();
512                    }
513                    else {
514                            assetTagCacheModel.modifiedDate = Long.MIN_VALUE;
515                    }
516    
517                    assetTagCacheModel.name = getName();
518    
519                    String name = assetTagCacheModel.name;
520    
521                    if ((name != null) && (name.length() == 0)) {
522                            assetTagCacheModel.name = null;
523                    }
524    
525                    assetTagCacheModel.assetCount = getAssetCount();
526    
527                    return assetTagCacheModel;
528            }
529    
530            @Override
531            public String toString() {
532                    StringBundler sb = new StringBundler(19);
533    
534                    sb.append("{tagId=");
535                    sb.append(getTagId());
536                    sb.append(", groupId=");
537                    sb.append(getGroupId());
538                    sb.append(", companyId=");
539                    sb.append(getCompanyId());
540                    sb.append(", userId=");
541                    sb.append(getUserId());
542                    sb.append(", userName=");
543                    sb.append(getUserName());
544                    sb.append(", createDate=");
545                    sb.append(getCreateDate());
546                    sb.append(", modifiedDate=");
547                    sb.append(getModifiedDate());
548                    sb.append(", name=");
549                    sb.append(getName());
550                    sb.append(", assetCount=");
551                    sb.append(getAssetCount());
552                    sb.append("}");
553    
554                    return sb.toString();
555            }
556    
557            public String toXmlString() {
558                    StringBundler sb = new StringBundler(31);
559    
560                    sb.append("<model><model-name>");
561                    sb.append("com.liferay.portlet.asset.model.AssetTag");
562                    sb.append("</model-name>");
563    
564                    sb.append(
565                            "<column><column-name>tagId</column-name><column-value><![CDATA[");
566                    sb.append(getTagId());
567                    sb.append("]]></column-value></column>");
568                    sb.append(
569                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
570                    sb.append(getGroupId());
571                    sb.append("]]></column-value></column>");
572                    sb.append(
573                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
574                    sb.append(getCompanyId());
575                    sb.append("]]></column-value></column>");
576                    sb.append(
577                            "<column><column-name>userId</column-name><column-value><![CDATA[");
578                    sb.append(getUserId());
579                    sb.append("]]></column-value></column>");
580                    sb.append(
581                            "<column><column-name>userName</column-name><column-value><![CDATA[");
582                    sb.append(getUserName());
583                    sb.append("]]></column-value></column>");
584                    sb.append(
585                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
586                    sb.append(getCreateDate());
587                    sb.append("]]></column-value></column>");
588                    sb.append(
589                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
590                    sb.append(getModifiedDate());
591                    sb.append("]]></column-value></column>");
592                    sb.append(
593                            "<column><column-name>name</column-name><column-value><![CDATA[");
594                    sb.append(getName());
595                    sb.append("]]></column-value></column>");
596                    sb.append(
597                            "<column><column-name>assetCount</column-name><column-value><![CDATA[");
598                    sb.append(getAssetCount());
599                    sb.append("]]></column-value></column>");
600    
601                    sb.append("</model>");
602    
603                    return sb.toString();
604            }
605    
606            private static ClassLoader _classLoader = AssetTag.class.getClassLoader();
607            private static Class<?>[] _escapedModelInterfaces = new Class[] {
608                            AssetTag.class
609                    };
610            private long _tagId;
611            private long _groupId;
612            private long _originalGroupId;
613            private boolean _setOriginalGroupId;
614            private long _companyId;
615            private long _userId;
616            private String _userUuid;
617            private String _userName;
618            private Date _createDate;
619            private Date _modifiedDate;
620            private String _name;
621            private String _originalName;
622            private int _assetCount;
623            private long _columnBitmask;
624            private AssetTag _escapedModel;
625    }