1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet.shopping.model.impl;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.HtmlUtil;
21  import com.liferay.portal.kernel.util.StringBundler;
22  import com.liferay.portal.model.impl.BaseModelImpl;
23  import com.liferay.portal.util.PortalUtil;
24  
25  import com.liferay.portlet.shopping.model.ShoppingCategory;
26  import com.liferay.portlet.shopping.model.ShoppingCategorySoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.Date;
36  import java.util.List;
37  
38  /**
39   * <a href="ShoppingCategoryModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This interface is a model that represents the ShoppingCategory table in the
48   * database.
49   * </p>
50   *
51   * @author    Brian Wing Shun Chan
52   * @see       ShoppingCategoryImpl
53   * @see       com.liferay.portlet.shopping.model.ShoppingCategory
54   * @see       com.liferay.portlet.shopping.model.ShoppingCategoryModel
55   * @generated
56   */
57  public class ShoppingCategoryModelImpl extends BaseModelImpl<ShoppingCategory> {
58      public static final String TABLE_NAME = "ShoppingCategory";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "categoryId", new Integer(Types.BIGINT) },
61              { "groupId", new Integer(Types.BIGINT) },
62              { "companyId", new Integer(Types.BIGINT) },
63              { "userId", new Integer(Types.BIGINT) },
64              { "userName", new Integer(Types.VARCHAR) },
65              { "createDate", new Integer(Types.TIMESTAMP) },
66              { "modifiedDate", new Integer(Types.TIMESTAMP) },
67              { "parentCategoryId", new Integer(Types.BIGINT) },
68              { "name", new Integer(Types.VARCHAR) },
69              { "description", new Integer(Types.VARCHAR) }
70          };
71      public static final String TABLE_SQL_CREATE = "create table ShoppingCategory (categoryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,parentCategoryId LONG,name VARCHAR(75) null,description STRING null)";
72      public static final String TABLE_SQL_DROP = "drop table ShoppingCategory";
73      public static final String ORDER_BY_JPQL = " ORDER BY shoppingCategory.parentCategoryId ASC, shoppingCategory.name ASC";
74      public static final String ORDER_BY_SQL = " ORDER BY ShoppingCategory.parentCategoryId ASC, ShoppingCategory.name ASC";
75      public static final String DATA_SOURCE = "liferayDataSource";
76      public static final String SESSION_FACTORY = "liferaySessionFactory";
77      public static final String TX_MANAGER = "liferayTransactionManager";
78      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79                  "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
80              true);
81      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
82                  "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
83              true);
84  
85      public static ShoppingCategory toModel(ShoppingCategorySoap soapModel) {
86          ShoppingCategory model = new ShoppingCategoryImpl();
87  
88          model.setCategoryId(soapModel.getCategoryId());
89          model.setGroupId(soapModel.getGroupId());
90          model.setCompanyId(soapModel.getCompanyId());
91          model.setUserId(soapModel.getUserId());
92          model.setUserName(soapModel.getUserName());
93          model.setCreateDate(soapModel.getCreateDate());
94          model.setModifiedDate(soapModel.getModifiedDate());
95          model.setParentCategoryId(soapModel.getParentCategoryId());
96          model.setName(soapModel.getName());
97          model.setDescription(soapModel.getDescription());
98  
99          return model;
100     }
101 
102     public static List<ShoppingCategory> toModels(
103         ShoppingCategorySoap[] soapModels) {
104         List<ShoppingCategory> models = new ArrayList<ShoppingCategory>(soapModels.length);
105 
106         for (ShoppingCategorySoap soapModel : soapModels) {
107             models.add(toModel(soapModel));
108         }
109 
110         return models;
111     }
112 
113     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
114                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingCategory"));
115 
116     public ShoppingCategoryModelImpl() {
117     }
118 
119     public long getPrimaryKey() {
120         return _categoryId;
121     }
122 
123     public void setPrimaryKey(long pk) {
124         setCategoryId(pk);
125     }
126 
127     public Serializable getPrimaryKeyObj() {
128         return new Long(_categoryId);
129     }
130 
131     public long getCategoryId() {
132         return _categoryId;
133     }
134 
135     public void setCategoryId(long categoryId) {
136         _categoryId = categoryId;
137     }
138 
139     public long getGroupId() {
140         return _groupId;
141     }
142 
143     public void setGroupId(long groupId) {
144         _groupId = groupId;
145     }
146 
147     public long getCompanyId() {
148         return _companyId;
149     }
150 
151     public void setCompanyId(long companyId) {
152         _companyId = companyId;
153     }
154 
155     public long getUserId() {
156         return _userId;
157     }
158 
159     public void setUserId(long userId) {
160         _userId = userId;
161     }
162 
163     public String getUserUuid() throws SystemException {
164         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
165     }
166 
167     public void setUserUuid(String userUuid) {
168         _userUuid = userUuid;
169     }
170 
171     public String getUserName() {
172         return GetterUtil.getString(_userName);
173     }
174 
175     public void setUserName(String userName) {
176         _userName = userName;
177     }
178 
179     public Date getCreateDate() {
180         return _createDate;
181     }
182 
183     public void setCreateDate(Date createDate) {
184         _createDate = createDate;
185     }
186 
187     public Date getModifiedDate() {
188         return _modifiedDate;
189     }
190 
191     public void setModifiedDate(Date modifiedDate) {
192         _modifiedDate = modifiedDate;
193     }
194 
195     public long getParentCategoryId() {
196         return _parentCategoryId;
197     }
198 
199     public void setParentCategoryId(long parentCategoryId) {
200         _parentCategoryId = parentCategoryId;
201     }
202 
203     public String getName() {
204         return GetterUtil.getString(_name);
205     }
206 
207     public void setName(String name) {
208         _name = name;
209     }
210 
211     public String getDescription() {
212         return GetterUtil.getString(_description);
213     }
214 
215     public void setDescription(String description) {
216         _description = description;
217     }
218 
219     public ShoppingCategory toEscapedModel() {
220         if (isEscapedModel()) {
221             return (ShoppingCategory)this;
222         }
223         else {
224             ShoppingCategory model = new ShoppingCategoryImpl();
225 
226             model.setNew(isNew());
227             model.setEscapedModel(true);
228 
229             model.setCategoryId(getCategoryId());
230             model.setGroupId(getGroupId());
231             model.setCompanyId(getCompanyId());
232             model.setUserId(getUserId());
233             model.setUserName(HtmlUtil.escape(getUserName()));
234             model.setCreateDate(getCreateDate());
235             model.setModifiedDate(getModifiedDate());
236             model.setParentCategoryId(getParentCategoryId());
237             model.setName(HtmlUtil.escape(getName()));
238             model.setDescription(HtmlUtil.escape(getDescription()));
239 
240             model = (ShoppingCategory)Proxy.newProxyInstance(ShoppingCategory.class.getClassLoader(),
241                     new Class[] { ShoppingCategory.class },
242                     new ReadOnlyBeanHandler(model));
243 
244             return model;
245         }
246     }
247 
248     public Object clone() {
249         ShoppingCategoryImpl clone = new ShoppingCategoryImpl();
250 
251         clone.setCategoryId(getCategoryId());
252         clone.setGroupId(getGroupId());
253         clone.setCompanyId(getCompanyId());
254         clone.setUserId(getUserId());
255         clone.setUserName(getUserName());
256         clone.setCreateDate(getCreateDate());
257         clone.setModifiedDate(getModifiedDate());
258         clone.setParentCategoryId(getParentCategoryId());
259         clone.setName(getName());
260         clone.setDescription(getDescription());
261 
262         return clone;
263     }
264 
265     public int compareTo(ShoppingCategory shoppingCategory) {
266         int value = 0;
267 
268         if (getParentCategoryId() < shoppingCategory.getParentCategoryId()) {
269             value = -1;
270         }
271         else if (getParentCategoryId() > shoppingCategory.getParentCategoryId()) {
272             value = 1;
273         }
274         else {
275             value = 0;
276         }
277 
278         if (value != 0) {
279             return value;
280         }
281 
282         value = getName().toLowerCase()
283                     .compareTo(shoppingCategory.getName().toLowerCase());
284 
285         if (value != 0) {
286             return value;
287         }
288 
289         return 0;
290     }
291 
292     public boolean equals(Object obj) {
293         if (obj == null) {
294             return false;
295         }
296 
297         ShoppingCategory shoppingCategory = null;
298 
299         try {
300             shoppingCategory = (ShoppingCategory)obj;
301         }
302         catch (ClassCastException cce) {
303             return false;
304         }
305 
306         long pk = shoppingCategory.getPrimaryKey();
307 
308         if (getPrimaryKey() == pk) {
309             return true;
310         }
311         else {
312             return false;
313         }
314     }
315 
316     public int hashCode() {
317         return (int)getPrimaryKey();
318     }
319 
320     public String toString() {
321         StringBundler sb = new StringBundler(21);
322 
323         sb.append("{categoryId=");
324         sb.append(getCategoryId());
325         sb.append(", groupId=");
326         sb.append(getGroupId());
327         sb.append(", companyId=");
328         sb.append(getCompanyId());
329         sb.append(", userId=");
330         sb.append(getUserId());
331         sb.append(", userName=");
332         sb.append(getUserName());
333         sb.append(", createDate=");
334         sb.append(getCreateDate());
335         sb.append(", modifiedDate=");
336         sb.append(getModifiedDate());
337         sb.append(", parentCategoryId=");
338         sb.append(getParentCategoryId());
339         sb.append(", name=");
340         sb.append(getName());
341         sb.append(", description=");
342         sb.append(getDescription());
343         sb.append("}");
344 
345         return sb.toString();
346     }
347 
348     public String toXmlString() {
349         StringBundler sb = new StringBundler(34);
350 
351         sb.append("<model><model-name>");
352         sb.append("com.liferay.portlet.shopping.model.ShoppingCategory");
353         sb.append("</model-name>");
354 
355         sb.append(
356             "<column><column-name>categoryId</column-name><column-value><![CDATA[");
357         sb.append(getCategoryId());
358         sb.append("]]></column-value></column>");
359         sb.append(
360             "<column><column-name>groupId</column-name><column-value><![CDATA[");
361         sb.append(getGroupId());
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>parentCategoryId</column-name><column-value><![CDATA[");
385         sb.append(getParentCategoryId());
386         sb.append("]]></column-value></column>");
387         sb.append(
388             "<column><column-name>name</column-name><column-value><![CDATA[");
389         sb.append(getName());
390         sb.append("]]></column-value></column>");
391         sb.append(
392             "<column><column-name>description</column-name><column-value><![CDATA[");
393         sb.append(getDescription());
394         sb.append("]]></column-value></column>");
395 
396         sb.append("</model>");
397 
398         return sb.toString();
399     }
400 
401     private long _categoryId;
402     private long _groupId;
403     private long _companyId;
404     private long _userId;
405     private String _userUuid;
406     private String _userName;
407     private Date _createDate;
408     private Date _modifiedDate;
409     private long _parentCategoryId;
410     private String _name;
411     private String _description;
412 }