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.AutoEscapeBeanHandler;
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.expando.model.ExpandoBridge;
27  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
28  import com.liferay.portlet.shopping.model.ShoppingCategory;
29  import com.liferay.portlet.shopping.model.ShoppingCategorySoap;
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="ShoppingCategoryModelImpl.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 ShoppingCategory table in the
51   * database.
52   * </p>
53   *
54   * @author    Brian Wing Shun Chan
55   * @see       ShoppingCategoryImpl
56   * @see       com.liferay.portlet.shopping.model.ShoppingCategory
57   * @see       com.liferay.portlet.shopping.model.ShoppingCategoryModel
58   * @generated
59   */
60  public class ShoppingCategoryModelImpl extends BaseModelImpl<ShoppingCategory> {
61      public static final String TABLE_NAME = "ShoppingCategory";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "categoryId", new Integer(Types.BIGINT) },
64              { "groupId", new Integer(Types.BIGINT) },
65              { "companyId", new Integer(Types.BIGINT) },
66              { "userId", new Integer(Types.BIGINT) },
67              { "userName", new Integer(Types.VARCHAR) },
68              { "createDate", new Integer(Types.TIMESTAMP) },
69              { "modifiedDate", new Integer(Types.TIMESTAMP) },
70              { "parentCategoryId", new Integer(Types.BIGINT) },
71              { "name", new Integer(Types.VARCHAR) },
72              { "description", new Integer(Types.VARCHAR) }
73          };
74      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)";
75      public static final String TABLE_SQL_DROP = "drop table ShoppingCategory";
76      public static final String ORDER_BY_JPQL = " ORDER BY shoppingCategory.parentCategoryId ASC, shoppingCategory.name ASC";
77      public static final String ORDER_BY_SQL = " ORDER BY ShoppingCategory.parentCategoryId ASC, ShoppingCategory.name ASC";
78      public static final String DATA_SOURCE = "liferayDataSource";
79      public static final String SESSION_FACTORY = "liferaySessionFactory";
80      public static final String TX_MANAGER = "liferayTransactionManager";
81      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
82                  "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
83              true);
84      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
85                  "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
86              true);
87  
88      public static ShoppingCategory toModel(ShoppingCategorySoap soapModel) {
89          ShoppingCategory model = new ShoppingCategoryImpl();
90  
91          model.setCategoryId(soapModel.getCategoryId());
92          model.setGroupId(soapModel.getGroupId());
93          model.setCompanyId(soapModel.getCompanyId());
94          model.setUserId(soapModel.getUserId());
95          model.setUserName(soapModel.getUserName());
96          model.setCreateDate(soapModel.getCreateDate());
97          model.setModifiedDate(soapModel.getModifiedDate());
98          model.setParentCategoryId(soapModel.getParentCategoryId());
99          model.setName(soapModel.getName());
100         model.setDescription(soapModel.getDescription());
101 
102         return model;
103     }
104 
105     public static List<ShoppingCategory> toModels(
106         ShoppingCategorySoap[] soapModels) {
107         List<ShoppingCategory> models = new ArrayList<ShoppingCategory>(soapModels.length);
108 
109         for (ShoppingCategorySoap soapModel : soapModels) {
110             models.add(toModel(soapModel));
111         }
112 
113         return models;
114     }
115 
116     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
117                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingCategory"));
118 
119     public ShoppingCategoryModelImpl() {
120     }
121 
122     public long getPrimaryKey() {
123         return _categoryId;
124     }
125 
126     public void setPrimaryKey(long pk) {
127         setCategoryId(pk);
128     }
129 
130     public Serializable getPrimaryKeyObj() {
131         return new Long(_categoryId);
132     }
133 
134     public long getCategoryId() {
135         return _categoryId;
136     }
137 
138     public void setCategoryId(long categoryId) {
139         _categoryId = categoryId;
140     }
141 
142     public long getGroupId() {
143         return _groupId;
144     }
145 
146     public void setGroupId(long groupId) {
147         _groupId = groupId;
148     }
149 
150     public long getCompanyId() {
151         return _companyId;
152     }
153 
154     public void setCompanyId(long companyId) {
155         _companyId = companyId;
156     }
157 
158     public long getUserId() {
159         return _userId;
160     }
161 
162     public void setUserId(long userId) {
163         _userId = userId;
164     }
165 
166     public String getUserUuid() throws SystemException {
167         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
168     }
169 
170     public void setUserUuid(String userUuid) {
171         _userUuid = userUuid;
172     }
173 
174     public String getUserName() {
175         if (_userName == null) {
176             return StringPool.BLANK;
177         }
178         else {
179             return _userName;
180         }
181     }
182 
183     public void setUserName(String userName) {
184         _userName = userName;
185     }
186 
187     public Date getCreateDate() {
188         return _createDate;
189     }
190 
191     public void setCreateDate(Date createDate) {
192         _createDate = createDate;
193     }
194 
195     public Date getModifiedDate() {
196         return _modifiedDate;
197     }
198 
199     public void setModifiedDate(Date modifiedDate) {
200         _modifiedDate = modifiedDate;
201     }
202 
203     public long getParentCategoryId() {
204         return _parentCategoryId;
205     }
206 
207     public void setParentCategoryId(long parentCategoryId) {
208         _parentCategoryId = parentCategoryId;
209     }
210 
211     public String getName() {
212         if (_name == null) {
213             return StringPool.BLANK;
214         }
215         else {
216             return _name;
217         }
218     }
219 
220     public void setName(String name) {
221         _name = name;
222     }
223 
224     public String getDescription() {
225         if (_description == null) {
226             return StringPool.BLANK;
227         }
228         else {
229             return _description;
230         }
231     }
232 
233     public void setDescription(String description) {
234         _description = description;
235     }
236 
237     public ShoppingCategory toEscapedModel() {
238         if (isEscapedModel()) {
239             return (ShoppingCategory)this;
240         }
241         else {
242             return (ShoppingCategory)Proxy.newProxyInstance(ShoppingCategory.class.getClassLoader(),
243                 new Class[] { ShoppingCategory.class },
244                 new AutoEscapeBeanHandler(this));
245         }
246     }
247 
248     public ExpandoBridge getExpandoBridge() {
249         if (_expandoBridge == null) {
250             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(ShoppingCategory.class.getName(),
251                     getPrimaryKey());
252         }
253 
254         return _expandoBridge;
255     }
256 
257     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
258         getExpandoBridge().setAttributes(serviceContext);
259     }
260 
261     public Object clone() {
262         ShoppingCategoryImpl clone = new ShoppingCategoryImpl();
263 
264         clone.setCategoryId(getCategoryId());
265         clone.setGroupId(getGroupId());
266         clone.setCompanyId(getCompanyId());
267         clone.setUserId(getUserId());
268         clone.setUserName(getUserName());
269         clone.setCreateDate(getCreateDate());
270         clone.setModifiedDate(getModifiedDate());
271         clone.setParentCategoryId(getParentCategoryId());
272         clone.setName(getName());
273         clone.setDescription(getDescription());
274 
275         return clone;
276     }
277 
278     public int compareTo(ShoppingCategory shoppingCategory) {
279         int value = 0;
280 
281         if (getParentCategoryId() < shoppingCategory.getParentCategoryId()) {
282             value = -1;
283         }
284         else if (getParentCategoryId() > shoppingCategory.getParentCategoryId()) {
285             value = 1;
286         }
287         else {
288             value = 0;
289         }
290 
291         if (value != 0) {
292             return value;
293         }
294 
295         value = getName().toLowerCase()
296                     .compareTo(shoppingCategory.getName().toLowerCase());
297 
298         if (value != 0) {
299             return value;
300         }
301 
302         return 0;
303     }
304 
305     public boolean equals(Object obj) {
306         if (obj == null) {
307             return false;
308         }
309 
310         ShoppingCategory shoppingCategory = null;
311 
312         try {
313             shoppingCategory = (ShoppingCategory)obj;
314         }
315         catch (ClassCastException cce) {
316             return false;
317         }
318 
319         long pk = shoppingCategory.getPrimaryKey();
320 
321         if (getPrimaryKey() == pk) {
322             return true;
323         }
324         else {
325             return false;
326         }
327     }
328 
329     public int hashCode() {
330         return (int)getPrimaryKey();
331     }
332 
333     public String toString() {
334         StringBundler sb = new StringBundler(21);
335 
336         sb.append("{categoryId=");
337         sb.append(getCategoryId());
338         sb.append(", groupId=");
339         sb.append(getGroupId());
340         sb.append(", companyId=");
341         sb.append(getCompanyId());
342         sb.append(", userId=");
343         sb.append(getUserId());
344         sb.append(", userName=");
345         sb.append(getUserName());
346         sb.append(", createDate=");
347         sb.append(getCreateDate());
348         sb.append(", modifiedDate=");
349         sb.append(getModifiedDate());
350         sb.append(", parentCategoryId=");
351         sb.append(getParentCategoryId());
352         sb.append(", name=");
353         sb.append(getName());
354         sb.append(", description=");
355         sb.append(getDescription());
356         sb.append("}");
357 
358         return sb.toString();
359     }
360 
361     public String toXmlString() {
362         StringBundler sb = new StringBundler(34);
363 
364         sb.append("<model><model-name>");
365         sb.append("com.liferay.portlet.shopping.model.ShoppingCategory");
366         sb.append("</model-name>");
367 
368         sb.append(
369             "<column><column-name>categoryId</column-name><column-value><![CDATA[");
370         sb.append(getCategoryId());
371         sb.append("]]></column-value></column>");
372         sb.append(
373             "<column><column-name>groupId</column-name><column-value><![CDATA[");
374         sb.append(getGroupId());
375         sb.append("]]></column-value></column>");
376         sb.append(
377             "<column><column-name>companyId</column-name><column-value><![CDATA[");
378         sb.append(getCompanyId());
379         sb.append("]]></column-value></column>");
380         sb.append(
381             "<column><column-name>userId</column-name><column-value><![CDATA[");
382         sb.append(getUserId());
383         sb.append("]]></column-value></column>");
384         sb.append(
385             "<column><column-name>userName</column-name><column-value><![CDATA[");
386         sb.append(getUserName());
387         sb.append("]]></column-value></column>");
388         sb.append(
389             "<column><column-name>createDate</column-name><column-value><![CDATA[");
390         sb.append(getCreateDate());
391         sb.append("]]></column-value></column>");
392         sb.append(
393             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
394         sb.append(getModifiedDate());
395         sb.append("]]></column-value></column>");
396         sb.append(
397             "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
398         sb.append(getParentCategoryId());
399         sb.append("]]></column-value></column>");
400         sb.append(
401             "<column><column-name>name</column-name><column-value><![CDATA[");
402         sb.append(getName());
403         sb.append("]]></column-value></column>");
404         sb.append(
405             "<column><column-name>description</column-name><column-value><![CDATA[");
406         sb.append(getDescription());
407         sb.append("]]></column-value></column>");
408 
409         sb.append("</model>");
410 
411         return sb.toString();
412     }
413 
414     private long _categoryId;
415     private long _groupId;
416     private long _companyId;
417     private long _userId;
418     private String _userUuid;
419     private String _userName;
420     private Date _createDate;
421     private Date _modifiedDate;
422     private long _parentCategoryId;
423     private String _name;
424     private String _description;
425     private transient ExpandoBridge _expandoBridge;
426 }