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.AssetCategoryProperty;
027    import com.liferay.portlet.asset.model.AssetCategoryPropertyModel;
028    import com.liferay.portlet.asset.model.AssetCategoryPropertySoap;
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 AssetCategoryProperty service. Represents a row in the "AssetCategoryProperty" 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.AssetCategoryPropertyModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AssetCategoryPropertyImpl}.
047     * </p>
048     *
049     * <p>
050     * Never modify or reference this class directly. All methods that expect a asset category property model instance should use the {@link com.liferay.portlet.asset.model.AssetCategoryProperty} interface instead.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see AssetCategoryPropertyImpl
055     * @see com.liferay.portlet.asset.model.AssetCategoryProperty
056     * @see com.liferay.portlet.asset.model.AssetCategoryPropertyModel
057     * @generated
058     */
059    public class AssetCategoryPropertyModelImpl extends BaseModelImpl<AssetCategoryProperty>
060            implements AssetCategoryPropertyModel {
061            public static final String TABLE_NAME = "AssetCategoryProperty";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "categoryPropertyId", 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                            { "categoryId", 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 AssetCategoryProperty (categoryPropertyId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,categoryId LONG,key_ VARCHAR(75) null,value VARCHAR(75) null)";
074            public static final String TABLE_SQL_DROP = "drop table AssetCategoryProperty";
075            public static final String ORDER_BY_JPQL = " ORDER BY assetCategoryProperty.key ASC";
076            public static final String ORDER_BY_SQL = " ORDER BY AssetCategoryProperty.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.AssetCategoryProperty"),
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.AssetCategoryProperty"),
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 AssetCategoryProperty toModel(
094                    AssetCategoryPropertySoap soapModel) {
095                    AssetCategoryProperty model = new AssetCategoryPropertyImpl();
096    
097                    model.setCategoryPropertyId(soapModel.getCategoryPropertyId());
098                    model.setCompanyId(soapModel.getCompanyId());
099                    model.setUserId(soapModel.getUserId());
100                    model.setUserName(soapModel.getUserName());
101                    model.setCreateDate(soapModel.getCreateDate());
102                    model.setModifiedDate(soapModel.getModifiedDate());
103                    model.setCategoryId(soapModel.getCategoryId());
104                    model.setKey(soapModel.getKey());
105                    model.setValue(soapModel.getValue());
106    
107                    return model;
108            }
109    
110            /**
111             * Converts the soap model instances into normal model instances.
112             *
113             * @param soapModels the soap model instances to convert
114             * @return the normal model instances
115             */
116            public static List<AssetCategoryProperty> toModels(
117                    AssetCategoryPropertySoap[] soapModels) {
118                    List<AssetCategoryProperty> models = new ArrayList<AssetCategoryProperty>(soapModels.length);
119    
120                    for (AssetCategoryPropertySoap soapModel : soapModels) {
121                            models.add(toModel(soapModel));
122                    }
123    
124                    return models;
125            }
126    
127            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
128                                    "lock.expiration.time.com.liferay.portlet.asset.model.AssetCategoryProperty"));
129    
130            public AssetCategoryPropertyModelImpl() {
131            }
132    
133            public long getPrimaryKey() {
134                    return _categoryPropertyId;
135            }
136    
137            public void setPrimaryKey(long pk) {
138                    setCategoryPropertyId(pk);
139            }
140    
141            public Serializable getPrimaryKeyObj() {
142                    return new Long(_categoryPropertyId);
143            }
144    
145            public long getCategoryPropertyId() {
146                    return _categoryPropertyId;
147            }
148    
149            public void setCategoryPropertyId(long categoryPropertyId) {
150                    _categoryPropertyId = categoryPropertyId;
151            }
152    
153            public long getCompanyId() {
154                    return _companyId;
155            }
156    
157            public void setCompanyId(long companyId) {
158                    _companyId = companyId;
159            }
160    
161            public long getUserId() {
162                    return _userId;
163            }
164    
165            public void setUserId(long userId) {
166                    _userId = userId;
167            }
168    
169            public String getUserUuid() throws SystemException {
170                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
171            }
172    
173            public void setUserUuid(String userUuid) {
174                    _userUuid = userUuid;
175            }
176    
177            public String getUserName() {
178                    if (_userName == null) {
179                            return StringPool.BLANK;
180                    }
181                    else {
182                            return _userName;
183                    }
184            }
185    
186            public void setUserName(String userName) {
187                    _userName = userName;
188            }
189    
190            public Date getCreateDate() {
191                    return _createDate;
192            }
193    
194            public void setCreateDate(Date createDate) {
195                    _createDate = createDate;
196            }
197    
198            public Date getModifiedDate() {
199                    return _modifiedDate;
200            }
201    
202            public void setModifiedDate(Date modifiedDate) {
203                    _modifiedDate = modifiedDate;
204            }
205    
206            public long getCategoryId() {
207                    return _categoryId;
208            }
209    
210            public void setCategoryId(long categoryId) {
211                    if (!_setOriginalCategoryId) {
212                            _setOriginalCategoryId = true;
213    
214                            _originalCategoryId = _categoryId;
215                    }
216    
217                    _categoryId = categoryId;
218            }
219    
220            public long getOriginalCategoryId() {
221                    return _originalCategoryId;
222            }
223    
224            public String getKey() {
225                    if (_key == null) {
226                            return StringPool.BLANK;
227                    }
228                    else {
229                            return _key;
230                    }
231            }
232    
233            public void setKey(String key) {
234                    if (_originalKey == null) {
235                            _originalKey = _key;
236                    }
237    
238                    _key = key;
239            }
240    
241            public String getOriginalKey() {
242                    return GetterUtil.getString(_originalKey);
243            }
244    
245            public String getValue() {
246                    if (_value == null) {
247                            return StringPool.BLANK;
248                    }
249                    else {
250                            return _value;
251                    }
252            }
253    
254            public void setValue(String value) {
255                    _value = value;
256            }
257    
258            public AssetCategoryProperty toEscapedModel() {
259                    if (isEscapedModel()) {
260                            return (AssetCategoryProperty)this;
261                    }
262                    else {
263                            return (AssetCategoryProperty)Proxy.newProxyInstance(AssetCategoryProperty.class.getClassLoader(),
264                                    new Class[] { AssetCategoryProperty.class },
265                                    new AutoEscapeBeanHandler(this));
266                    }
267            }
268    
269            public ExpandoBridge getExpandoBridge() {
270                    if (_expandoBridge == null) {
271                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
272                                            AssetCategoryProperty.class.getName(), getPrimaryKey());
273                    }
274    
275                    return _expandoBridge;
276            }
277    
278            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
279                    getExpandoBridge().setAttributes(serviceContext);
280            }
281    
282            public Object clone() {
283                    AssetCategoryPropertyImpl assetCategoryPropertyImpl = new AssetCategoryPropertyImpl();
284    
285                    assetCategoryPropertyImpl.setCategoryPropertyId(getCategoryPropertyId());
286    
287                    assetCategoryPropertyImpl.setCompanyId(getCompanyId());
288    
289                    assetCategoryPropertyImpl.setUserId(getUserId());
290    
291                    assetCategoryPropertyImpl.setUserName(getUserName());
292    
293                    assetCategoryPropertyImpl.setCreateDate(getCreateDate());
294    
295                    assetCategoryPropertyImpl.setModifiedDate(getModifiedDate());
296    
297                    assetCategoryPropertyImpl.setCategoryId(getCategoryId());
298    
299                    AssetCategoryPropertyModelImpl assetCategoryPropertyModelImpl = assetCategoryPropertyImpl;
300    
301                    assetCategoryPropertyModelImpl._originalCategoryId = assetCategoryPropertyModelImpl._categoryId;
302    
303                    assetCategoryPropertyModelImpl._setOriginalCategoryId = false;
304                    assetCategoryPropertyImpl.setKey(getKey());
305    
306                    assetCategoryPropertyModelImpl._originalKey = assetCategoryPropertyModelImpl._key;
307    
308                    assetCategoryPropertyImpl.setValue(getValue());
309    
310                    return assetCategoryPropertyImpl;
311            }
312    
313            public int compareTo(AssetCategoryProperty assetCategoryProperty) {
314                    int value = 0;
315    
316                    value = getKey().compareTo(assetCategoryProperty.getKey());
317    
318                    if (value != 0) {
319                            return value;
320                    }
321    
322                    return 0;
323            }
324    
325            public boolean equals(Object obj) {
326                    if (obj == null) {
327                            return false;
328                    }
329    
330                    AssetCategoryProperty assetCategoryProperty = null;
331    
332                    try {
333                            assetCategoryProperty = (AssetCategoryProperty)obj;
334                    }
335                    catch (ClassCastException cce) {
336                            return false;
337                    }
338    
339                    long pk = assetCategoryProperty.getPrimaryKey();
340    
341                    if (getPrimaryKey() == pk) {
342                            return true;
343                    }
344                    else {
345                            return false;
346                    }
347            }
348    
349            public int hashCode() {
350                    return (int)getPrimaryKey();
351            }
352    
353            public String toString() {
354                    StringBundler sb = new StringBundler(19);
355    
356                    sb.append("{categoryPropertyId=");
357                    sb.append(getCategoryPropertyId());
358                    sb.append(", companyId=");
359                    sb.append(getCompanyId());
360                    sb.append(", userId=");
361                    sb.append(getUserId());
362                    sb.append(", userName=");
363                    sb.append(getUserName());
364                    sb.append(", createDate=");
365                    sb.append(getCreateDate());
366                    sb.append(", modifiedDate=");
367                    sb.append(getModifiedDate());
368                    sb.append(", categoryId=");
369                    sb.append(getCategoryId());
370                    sb.append(", key=");
371                    sb.append(getKey());
372                    sb.append(", value=");
373                    sb.append(getValue());
374                    sb.append("}");
375    
376                    return sb.toString();
377            }
378    
379            public String toXmlString() {
380                    StringBundler sb = new StringBundler(31);
381    
382                    sb.append("<model><model-name>");
383                    sb.append("com.liferay.portlet.asset.model.AssetCategoryProperty");
384                    sb.append("</model-name>");
385    
386                    sb.append(
387                            "<column><column-name>categoryPropertyId</column-name><column-value><![CDATA[");
388                    sb.append(getCategoryPropertyId());
389                    sb.append("]]></column-value></column>");
390                    sb.append(
391                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
392                    sb.append(getCompanyId());
393                    sb.append("]]></column-value></column>");
394                    sb.append(
395                            "<column><column-name>userId</column-name><column-value><![CDATA[");
396                    sb.append(getUserId());
397                    sb.append("]]></column-value></column>");
398                    sb.append(
399                            "<column><column-name>userName</column-name><column-value><![CDATA[");
400                    sb.append(getUserName());
401                    sb.append("]]></column-value></column>");
402                    sb.append(
403                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
404                    sb.append(getCreateDate());
405                    sb.append("]]></column-value></column>");
406                    sb.append(
407                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
408                    sb.append(getModifiedDate());
409                    sb.append("]]></column-value></column>");
410                    sb.append(
411                            "<column><column-name>categoryId</column-name><column-value><![CDATA[");
412                    sb.append(getCategoryId());
413                    sb.append("]]></column-value></column>");
414                    sb.append(
415                            "<column><column-name>key</column-name><column-value><![CDATA[");
416                    sb.append(getKey());
417                    sb.append("]]></column-value></column>");
418                    sb.append(
419                            "<column><column-name>value</column-name><column-value><![CDATA[");
420                    sb.append(getValue());
421                    sb.append("]]></column-value></column>");
422    
423                    sb.append("</model>");
424    
425                    return sb.toString();
426            }
427    
428            private long _categoryPropertyId;
429            private long _companyId;
430            private long _userId;
431            private String _userUuid;
432            private String _userName;
433            private Date _createDate;
434            private Date _modifiedDate;
435            private long _categoryId;
436            private long _originalCategoryId;
437            private boolean _setOriginalCategoryId;
438            private String _key;
439            private String _originalKey;
440            private String _value;
441            private transient ExpandoBridge _expandoBridge;
442    }