001    /**
002     * Copyright (c) 2000-2011 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.util.GetterUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.impl.BaseModelImpl;
023    import com.liferay.portal.service.ServiceContext;
024    import com.liferay.portal.util.PortalUtil;
025    
026    import com.liferay.portlet.asset.model.AssetTagProperty;
027    import com.liferay.portlet.asset.model.AssetTagPropertyModel;
028    import com.liferay.portlet.asset.model.AssetTagPropertySoap;
029    import com.liferay.portlet.expando.model.ExpandoBridge;
030    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031    
032    import java.io.Serializable;
033    
034    import java.lang.reflect.Proxy;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.List;
041    
042    /**
043     * 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.
044     *
045     * <p>
046     * 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}.
047     * </p>
048     *
049     * <p>
050     * 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.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see AssetTagPropertyImpl
055     * @see com.liferay.portlet.asset.model.AssetTagProperty
056     * @see com.liferay.portlet.asset.model.AssetTagPropertyModel
057     * @generated
058     */
059    public class AssetTagPropertyModelImpl extends BaseModelImpl<AssetTagProperty>
060            implements AssetTagPropertyModel {
061            public static final String TABLE_NAME = "AssetTagProperty";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "tagPropertyId", new Integer(Types.BIGINT) },
064                            { "companyId", new Integer(Types.BIGINT) },
065                            { "userId", new Integer(Types.BIGINT) },
066                            { "userName", new Integer(Types.VARCHAR) },
067                            { "createDate", new Integer(Types.TIMESTAMP) },
068                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
069                            { "tagId", new Integer(Types.BIGINT) },
070                            { "key_", new Integer(Types.VARCHAR) },
071                            { "value", new Integer(Types.VARCHAR) }
072                    };
073            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)";
074            public static final String TABLE_SQL_DROP = "drop table AssetTagProperty";
075            public static final String ORDER_BY_JPQL = " ORDER BY assetTagProperty.key ASC";
076            public static final String ORDER_BY_SQL = " ORDER BY AssetTagProperty.key_ ASC";
077            public static final String DATA_SOURCE = "liferayDataSource";
078            public static final String SESSION_FACTORY = "liferaySessionFactory";
079            public static final String TX_MANAGER = "liferayTransactionManager";
080            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
081                                    "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetTagProperty"),
082                            true);
083            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084                                    "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetTagProperty"),
085                            true);
086    
087            /**
088             * Converts the soap model instance into a normal model instance.
089             *
090             * @param soapModel the soap model instance to convert
091             * @return the normal model instance
092             */
093            public static AssetTagProperty toModel(AssetTagPropertySoap soapModel) {
094                    AssetTagProperty model = new AssetTagPropertyImpl();
095    
096                    model.setTagPropertyId(soapModel.getTagPropertyId());
097                    model.setCompanyId(soapModel.getCompanyId());
098                    model.setUserId(soapModel.getUserId());
099                    model.setUserName(soapModel.getUserName());
100                    model.setCreateDate(soapModel.getCreateDate());
101                    model.setModifiedDate(soapModel.getModifiedDate());
102                    model.setTagId(soapModel.getTagId());
103                    model.setKey(soapModel.getKey());
104                    model.setValue(soapModel.getValue());
105    
106                    return model;
107            }
108    
109            /**
110             * Converts the soap model instances into normal model instances.
111             *
112             * @param soapModels the soap model instances to convert
113             * @return the normal model instances
114             */
115            public static List<AssetTagProperty> toModels(
116                    AssetTagPropertySoap[] soapModels) {
117                    List<AssetTagProperty> models = new ArrayList<AssetTagProperty>(soapModels.length);
118    
119                    for (AssetTagPropertySoap soapModel : soapModels) {
120                            models.add(toModel(soapModel));
121                    }
122    
123                    return models;
124            }
125    
126            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
127                                    "lock.expiration.time.com.liferay.portlet.asset.model.AssetTagProperty"));
128    
129            public AssetTagPropertyModelImpl() {
130            }
131    
132            public long getPrimaryKey() {
133                    return _tagPropertyId;
134            }
135    
136            public void setPrimaryKey(long pk) {
137                    setTagPropertyId(pk);
138            }
139    
140            public Serializable getPrimaryKeyObj() {
141                    return new Long(_tagPropertyId);
142            }
143    
144            public long getTagPropertyId() {
145                    return _tagPropertyId;
146            }
147    
148            public void setTagPropertyId(long tagPropertyId) {
149                    _tagPropertyId = tagPropertyId;
150            }
151    
152            public long getCompanyId() {
153                    return _companyId;
154            }
155    
156            public void setCompanyId(long companyId) {
157                    _companyId = companyId;
158            }
159    
160            public long getUserId() {
161                    return _userId;
162            }
163    
164            public void setUserId(long userId) {
165                    _userId = userId;
166            }
167    
168            public String getUserUuid() throws SystemException {
169                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
170            }
171    
172            public void setUserUuid(String userUuid) {
173                    _userUuid = userUuid;
174            }
175    
176            public String getUserName() {
177                    if (_userName == null) {
178                            return StringPool.BLANK;
179                    }
180                    else {
181                            return _userName;
182                    }
183            }
184    
185            public void setUserName(String userName) {
186                    _userName = userName;
187            }
188    
189            public Date getCreateDate() {
190                    return _createDate;
191            }
192    
193            public void setCreateDate(Date createDate) {
194                    _createDate = createDate;
195            }
196    
197            public Date getModifiedDate() {
198                    return _modifiedDate;
199            }
200    
201            public void setModifiedDate(Date modifiedDate) {
202                    _modifiedDate = modifiedDate;
203            }
204    
205            public long getTagId() {
206                    return _tagId;
207            }
208    
209            public void setTagId(long tagId) {
210                    if (!_setOriginalTagId) {
211                            _setOriginalTagId = true;
212    
213                            _originalTagId = _tagId;
214                    }
215    
216                    _tagId = tagId;
217            }
218    
219            public long getOriginalTagId() {
220                    return _originalTagId;
221            }
222    
223            public String getKey() {
224                    if (_key == null) {
225                            return StringPool.BLANK;
226                    }
227                    else {
228                            return _key;
229                    }
230            }
231    
232            public void setKey(String key) {
233                    if (_originalKey == null) {
234                            _originalKey = _key;
235                    }
236    
237                    _key = key;
238            }
239    
240            public String getOriginalKey() {
241                    return GetterUtil.getString(_originalKey);
242            }
243    
244            public String getValue() {
245                    if (_value == null) {
246                            return StringPool.BLANK;
247                    }
248                    else {
249                            return _value;
250                    }
251            }
252    
253            public void setValue(String value) {
254                    _value = value;
255            }
256    
257            public AssetTagProperty toEscapedModel() {
258                    if (isEscapedModel()) {
259                            return (AssetTagProperty)this;
260                    }
261                    else {
262                            return (AssetTagProperty)Proxy.newProxyInstance(AssetTagProperty.class.getClassLoader(),
263                                    new Class[] { AssetTagProperty.class },
264                                    new AutoEscapeBeanHandler(this));
265                    }
266            }
267    
268            public ExpandoBridge getExpandoBridge() {
269                    if (_expandoBridge == null) {
270                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
271                                            AssetTagProperty.class.getName(), getPrimaryKey());
272                    }
273    
274                    return _expandoBridge;
275            }
276    
277            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
278                    getExpandoBridge().setAttributes(serviceContext);
279            }
280    
281            public Object clone() {
282                    AssetTagPropertyImpl assetTagPropertyImpl = new AssetTagPropertyImpl();
283    
284                    assetTagPropertyImpl.setTagPropertyId(getTagPropertyId());
285    
286                    assetTagPropertyImpl.setCompanyId(getCompanyId());
287    
288                    assetTagPropertyImpl.setUserId(getUserId());
289    
290                    assetTagPropertyImpl.setUserName(getUserName());
291    
292                    assetTagPropertyImpl.setCreateDate(getCreateDate());
293    
294                    assetTagPropertyImpl.setModifiedDate(getModifiedDate());
295    
296                    assetTagPropertyImpl.setTagId(getTagId());
297    
298                    AssetTagPropertyModelImpl assetTagPropertyModelImpl = assetTagPropertyImpl;
299    
300                    assetTagPropertyModelImpl._originalTagId = assetTagPropertyModelImpl._tagId;
301    
302                    assetTagPropertyModelImpl._setOriginalTagId = false;
303                    assetTagPropertyImpl.setKey(getKey());
304    
305                    assetTagPropertyModelImpl._originalKey = assetTagPropertyModelImpl._key;
306    
307                    assetTagPropertyImpl.setValue(getValue());
308    
309                    return assetTagPropertyImpl;
310            }
311    
312            public int compareTo(AssetTagProperty assetTagProperty) {
313                    int value = 0;
314    
315                    value = getKey().compareTo(assetTagProperty.getKey());
316    
317                    if (value != 0) {
318                            return value;
319                    }
320    
321                    return 0;
322            }
323    
324            public boolean equals(Object obj) {
325                    if (obj == null) {
326                            return false;
327                    }
328    
329                    AssetTagProperty assetTagProperty = null;
330    
331                    try {
332                            assetTagProperty = (AssetTagProperty)obj;
333                    }
334                    catch (ClassCastException cce) {
335                            return false;
336                    }
337    
338                    long pk = assetTagProperty.getPrimaryKey();
339    
340                    if (getPrimaryKey() == pk) {
341                            return true;
342                    }
343                    else {
344                            return false;
345                    }
346            }
347    
348            public int hashCode() {
349                    return (int)getPrimaryKey();
350            }
351    
352            public String toString() {
353                    StringBundler sb = new StringBundler(19);
354    
355                    sb.append("{tagPropertyId=");
356                    sb.append(getTagPropertyId());
357                    sb.append(", companyId=");
358                    sb.append(getCompanyId());
359                    sb.append(", userId=");
360                    sb.append(getUserId());
361                    sb.append(", userName=");
362                    sb.append(getUserName());
363                    sb.append(", createDate=");
364                    sb.append(getCreateDate());
365                    sb.append(", modifiedDate=");
366                    sb.append(getModifiedDate());
367                    sb.append(", tagId=");
368                    sb.append(getTagId());
369                    sb.append(", key=");
370                    sb.append(getKey());
371                    sb.append(", value=");
372                    sb.append(getValue());
373                    sb.append("}");
374    
375                    return sb.toString();
376            }
377    
378            public String toXmlString() {
379                    StringBundler sb = new StringBundler(31);
380    
381                    sb.append("<model><model-name>");
382                    sb.append("com.liferay.portlet.asset.model.AssetTagProperty");
383                    sb.append("</model-name>");
384    
385                    sb.append(
386                            "<column><column-name>tagPropertyId</column-name><column-value><![CDATA[");
387                    sb.append(getTagPropertyId());
388                    sb.append("]]></column-value></column>");
389                    sb.append(
390                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
391                    sb.append(getCompanyId());
392                    sb.append("]]></column-value></column>");
393                    sb.append(
394                            "<column><column-name>userId</column-name><column-value><![CDATA[");
395                    sb.append(getUserId());
396                    sb.append("]]></column-value></column>");
397                    sb.append(
398                            "<column><column-name>userName</column-name><column-value><![CDATA[");
399                    sb.append(getUserName());
400                    sb.append("]]></column-value></column>");
401                    sb.append(
402                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
403                    sb.append(getCreateDate());
404                    sb.append("]]></column-value></column>");
405                    sb.append(
406                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
407                    sb.append(getModifiedDate());
408                    sb.append("]]></column-value></column>");
409                    sb.append(
410                            "<column><column-name>tagId</column-name><column-value><![CDATA[");
411                    sb.append(getTagId());
412                    sb.append("]]></column-value></column>");
413                    sb.append(
414                            "<column><column-name>key</column-name><column-value><![CDATA[");
415                    sb.append(getKey());
416                    sb.append("]]></column-value></column>");
417                    sb.append(
418                            "<column><column-name>value</column-name><column-value><![CDATA[");
419                    sb.append(getValue());
420                    sb.append("]]></column-value></column>");
421    
422                    sb.append("</model>");
423    
424                    return sb.toString();
425            }
426    
427            private long _tagPropertyId;
428            private long _companyId;
429            private long _userId;
430            private String _userUuid;
431            private String _userName;
432            private Date _createDate;
433            private Date _modifiedDate;
434            private long _tagId;
435            private long _originalTagId;
436            private boolean _setOriginalTagId;
437            private String _key;
438            private String _originalKey;
439            private String _value;
440            private transient ExpandoBridge _expandoBridge;
441    }