1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.asset.model.impl;
16  
17  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.kernel.util.StringPool;
22  import com.liferay.portal.model.impl.BaseModelImpl;
23  import com.liferay.portal.service.ServiceContext;
24  import com.liferay.portal.util.PortalUtil;
25  
26  import com.liferay.portlet.asset.model.AssetCategoryProperty;
27  import com.liferay.portlet.asset.model.AssetCategoryPropertySoap;
28  import com.liferay.portlet.expando.model.ExpandoBridge;
29  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.Date;
39  import java.util.List;
40  
41  /**
42   * <a href="AssetCategoryPropertyModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This interface is a model that represents the AssetCategoryProperty table in the
51   * database.
52   * </p>
53   *
54   * @author    Brian Wing Shun Chan
55   * @see       AssetCategoryPropertyImpl
56   * @see       com.liferay.portlet.asset.model.AssetCategoryProperty
57   * @see       com.liferay.portlet.asset.model.AssetCategoryPropertyModel
58   * @generated
59   */
60  public class AssetCategoryPropertyModelImpl extends BaseModelImpl<AssetCategoryProperty> {
61      public static final String TABLE_NAME = "AssetCategoryProperty";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "categoryPropertyId", new Integer(Types.BIGINT) },
64              { "companyId", new Integer(Types.BIGINT) },
65              { "userId", new Integer(Types.BIGINT) },
66              { "userName", new Integer(Types.VARCHAR) },
67              { "createDate", new Integer(Types.TIMESTAMP) },
68              { "modifiedDate", new Integer(Types.TIMESTAMP) },
69              { "categoryId", new Integer(Types.BIGINT) },
70              { "key_", new Integer(Types.VARCHAR) },
71              { "value", new Integer(Types.VARCHAR) }
72          };
73      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)";
74      public static final String TABLE_SQL_DROP = "drop table AssetCategoryProperty";
75      public static final String ORDER_BY_JPQL = " ORDER BY assetCategoryProperty.key ASC";
76      public static final String ORDER_BY_SQL = " ORDER BY AssetCategoryProperty.key_ ASC";
77      public static final String DATA_SOURCE = "liferayDataSource";
78      public static final String SESSION_FACTORY = "liferaySessionFactory";
79      public static final String TX_MANAGER = "liferayTransactionManager";
80      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
81                  "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetCategoryProperty"),
82              true);
83      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
84                  "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetCategoryProperty"),
85              true);
86  
87      public static AssetCategoryProperty toModel(
88          AssetCategoryPropertySoap soapModel) {
89          AssetCategoryProperty model = new AssetCategoryPropertyImpl();
90  
91          model.setCategoryPropertyId(soapModel.getCategoryPropertyId());
92          model.setCompanyId(soapModel.getCompanyId());
93          model.setUserId(soapModel.getUserId());
94          model.setUserName(soapModel.getUserName());
95          model.setCreateDate(soapModel.getCreateDate());
96          model.setModifiedDate(soapModel.getModifiedDate());
97          model.setCategoryId(soapModel.getCategoryId());
98          model.setKey(soapModel.getKey());
99          model.setValue(soapModel.getValue());
100 
101         return model;
102     }
103 
104     public static List<AssetCategoryProperty> toModels(
105         AssetCategoryPropertySoap[] soapModels) {
106         List<AssetCategoryProperty> models = new ArrayList<AssetCategoryProperty>(soapModels.length);
107 
108         for (AssetCategoryPropertySoap soapModel : soapModels) {
109             models.add(toModel(soapModel));
110         }
111 
112         return models;
113     }
114 
115     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
116                 "lock.expiration.time.com.liferay.portlet.asset.model.AssetCategoryProperty"));
117 
118     public AssetCategoryPropertyModelImpl() {
119     }
120 
121     public long getPrimaryKey() {
122         return _categoryPropertyId;
123     }
124 
125     public void setPrimaryKey(long pk) {
126         setCategoryPropertyId(pk);
127     }
128 
129     public Serializable getPrimaryKeyObj() {
130         return new Long(_categoryPropertyId);
131     }
132 
133     public long getCategoryPropertyId() {
134         return _categoryPropertyId;
135     }
136 
137     public void setCategoryPropertyId(long categoryPropertyId) {
138         _categoryPropertyId = categoryPropertyId;
139     }
140 
141     public long getCompanyId() {
142         return _companyId;
143     }
144 
145     public void setCompanyId(long companyId) {
146         _companyId = companyId;
147     }
148 
149     public long getUserId() {
150         return _userId;
151     }
152 
153     public void setUserId(long userId) {
154         _userId = userId;
155     }
156 
157     public String getUserUuid() throws SystemException {
158         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
159     }
160 
161     public void setUserUuid(String userUuid) {
162         _userUuid = userUuid;
163     }
164 
165     public String getUserName() {
166         if (_userName == null) {
167             return StringPool.BLANK;
168         }
169         else {
170             return _userName;
171         }
172     }
173 
174     public void setUserName(String userName) {
175         _userName = userName;
176     }
177 
178     public Date getCreateDate() {
179         return _createDate;
180     }
181 
182     public void setCreateDate(Date createDate) {
183         _createDate = createDate;
184     }
185 
186     public Date getModifiedDate() {
187         return _modifiedDate;
188     }
189 
190     public void setModifiedDate(Date modifiedDate) {
191         _modifiedDate = modifiedDate;
192     }
193 
194     public long getCategoryId() {
195         return _categoryId;
196     }
197 
198     public void setCategoryId(long categoryId) {
199         _categoryId = categoryId;
200 
201         if (!_setOriginalCategoryId) {
202             _setOriginalCategoryId = true;
203 
204             _originalCategoryId = categoryId;
205         }
206     }
207 
208     public long getOriginalCategoryId() {
209         return _originalCategoryId;
210     }
211 
212     public String getKey() {
213         if (_key == null) {
214             return StringPool.BLANK;
215         }
216         else {
217             return _key;
218         }
219     }
220 
221     public void setKey(String key) {
222         _key = key;
223 
224         if (_originalKey == null) {
225             _originalKey = key;
226         }
227     }
228 
229     public String getOriginalKey() {
230         return GetterUtil.getString(_originalKey);
231     }
232 
233     public String getValue() {
234         if (_value == null) {
235             return StringPool.BLANK;
236         }
237         else {
238             return _value;
239         }
240     }
241 
242     public void setValue(String value) {
243         _value = value;
244     }
245 
246     public AssetCategoryProperty toEscapedModel() {
247         if (isEscapedModel()) {
248             return (AssetCategoryProperty)this;
249         }
250         else {
251             return (AssetCategoryProperty)Proxy.newProxyInstance(AssetCategoryProperty.class.getClassLoader(),
252                 new Class[] { AssetCategoryProperty.class },
253                 new AutoEscapeBeanHandler(this));
254         }
255     }
256 
257     public ExpandoBridge getExpandoBridge() {
258         if (_expandoBridge == null) {
259             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
260                     AssetCategoryProperty.class.getName(), getPrimaryKey());
261         }
262 
263         return _expandoBridge;
264     }
265 
266     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
267         getExpandoBridge().setAttributes(serviceContext);
268     }
269 
270     public Object clone() {
271         AssetCategoryPropertyImpl clone = new AssetCategoryPropertyImpl();
272 
273         clone.setCategoryPropertyId(getCategoryPropertyId());
274         clone.setCompanyId(getCompanyId());
275         clone.setUserId(getUserId());
276         clone.setUserName(getUserName());
277         clone.setCreateDate(getCreateDate());
278         clone.setModifiedDate(getModifiedDate());
279         clone.setCategoryId(getCategoryId());
280         clone.setKey(getKey());
281         clone.setValue(getValue());
282 
283         return clone;
284     }
285 
286     public int compareTo(AssetCategoryProperty assetCategoryProperty) {
287         int value = 0;
288 
289         value = getKey().compareTo(assetCategoryProperty.getKey());
290 
291         if (value != 0) {
292             return value;
293         }
294 
295         return 0;
296     }
297 
298     public boolean equals(Object obj) {
299         if (obj == null) {
300             return false;
301         }
302 
303         AssetCategoryProperty assetCategoryProperty = null;
304 
305         try {
306             assetCategoryProperty = (AssetCategoryProperty)obj;
307         }
308         catch (ClassCastException cce) {
309             return false;
310         }
311 
312         long pk = assetCategoryProperty.getPrimaryKey();
313 
314         if (getPrimaryKey() == pk) {
315             return true;
316         }
317         else {
318             return false;
319         }
320     }
321 
322     public int hashCode() {
323         return (int)getPrimaryKey();
324     }
325 
326     public String toString() {
327         StringBundler sb = new StringBundler(19);
328 
329         sb.append("{categoryPropertyId=");
330         sb.append(getCategoryPropertyId());
331         sb.append(", companyId=");
332         sb.append(getCompanyId());
333         sb.append(", userId=");
334         sb.append(getUserId());
335         sb.append(", userName=");
336         sb.append(getUserName());
337         sb.append(", createDate=");
338         sb.append(getCreateDate());
339         sb.append(", modifiedDate=");
340         sb.append(getModifiedDate());
341         sb.append(", categoryId=");
342         sb.append(getCategoryId());
343         sb.append(", key=");
344         sb.append(getKey());
345         sb.append(", value=");
346         sb.append(getValue());
347         sb.append("}");
348 
349         return sb.toString();
350     }
351 
352     public String toXmlString() {
353         StringBundler sb = new StringBundler(31);
354 
355         sb.append("<model><model-name>");
356         sb.append("com.liferay.portlet.asset.model.AssetCategoryProperty");
357         sb.append("</model-name>");
358 
359         sb.append(
360             "<column><column-name>categoryPropertyId</column-name><column-value><![CDATA[");
361         sb.append(getCategoryPropertyId());
362         sb.append("]]></column-value></column>");
363         sb.append(
364             "<column><column-name>companyId</column-name><column-value><![CDATA[");
365         sb.append(getCompanyId());
366         sb.append("]]></column-value></column>");
367         sb.append(
368             "<column><column-name>userId</column-name><column-value><![CDATA[");
369         sb.append(getUserId());
370         sb.append("]]></column-value></column>");
371         sb.append(
372             "<column><column-name>userName</column-name><column-value><![CDATA[");
373         sb.append(getUserName());
374         sb.append("]]></column-value></column>");
375         sb.append(
376             "<column><column-name>createDate</column-name><column-value><![CDATA[");
377         sb.append(getCreateDate());
378         sb.append("]]></column-value></column>");
379         sb.append(
380             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
381         sb.append(getModifiedDate());
382         sb.append("]]></column-value></column>");
383         sb.append(
384             "<column><column-name>categoryId</column-name><column-value><![CDATA[");
385         sb.append(getCategoryId());
386         sb.append("]]></column-value></column>");
387         sb.append(
388             "<column><column-name>key</column-name><column-value><![CDATA[");
389         sb.append(getKey());
390         sb.append("]]></column-value></column>");
391         sb.append(
392             "<column><column-name>value</column-name><column-value><![CDATA[");
393         sb.append(getValue());
394         sb.append("]]></column-value></column>");
395 
396         sb.append("</model>");
397 
398         return sb.toString();
399     }
400 
401     private long _categoryPropertyId;
402     private long _companyId;
403     private long _userId;
404     private String _userUuid;
405     private String _userName;
406     private Date _createDate;
407     private Date _modifiedDate;
408     private long _categoryId;
409     private long _originalCategoryId;
410     private boolean _setOriginalCategoryId;
411     private String _key;
412     private String _originalKey;
413     private String _value;
414     private transient ExpandoBridge _expandoBridge;
415 }