1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.shopping.model.impl;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.kernel.util.HtmlUtil;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.service.ServiceContext;
31  import com.liferay.portal.util.PortalUtil;
32  
33  import com.liferay.portlet.expando.model.ExpandoBridge;
34  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
35  import com.liferay.portlet.shopping.model.ShoppingCategory;
36  import com.liferay.portlet.shopping.model.ShoppingCategorySoap;
37  
38  import java.io.Serializable;
39  
40  import java.lang.reflect.Proxy;
41  
42  import java.sql.Types;
43  
44  import java.util.ArrayList;
45  import java.util.Date;
46  import java.util.List;
47  
48  /**
49   * <a href="ShoppingCategoryModelImpl.java.html"><b><i>View Source</i></b></a>
50   *
51   * <p>
52   * ServiceBuilder generated this class. Modifications in this class will be
53   * overwritten the next time is generated.
54   * </p>
55   *
56   * <p>
57   * This interface is a model that represents the ShoppingCategory table in the
58   * database.
59   * </p>
60   *
61   * @author    Brian Wing Shun Chan
62   * @see       ShoppingCategoryImpl
63   * @see       com.liferay.portlet.shopping.model.ShoppingCategory
64   * @see       com.liferay.portlet.shopping.model.ShoppingCategoryModel
65   * @generated
66   */
67  public class ShoppingCategoryModelImpl extends BaseModelImpl<ShoppingCategory> {
68      public static final String TABLE_NAME = "ShoppingCategory";
69      public static final Object[][] TABLE_COLUMNS = {
70              { "categoryId", new Integer(Types.BIGINT) },
71              { "groupId", new Integer(Types.BIGINT) },
72              { "companyId", new Integer(Types.BIGINT) },
73              { "userId", new Integer(Types.BIGINT) },
74              { "userName", new Integer(Types.VARCHAR) },
75              { "createDate", new Integer(Types.TIMESTAMP) },
76              { "modifiedDate", new Integer(Types.TIMESTAMP) },
77              { "parentCategoryId", new Integer(Types.BIGINT) },
78              { "name", new Integer(Types.VARCHAR) },
79              { "description", new Integer(Types.VARCHAR) }
80          };
81      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)";
82      public static final String TABLE_SQL_DROP = "drop table ShoppingCategory";
83      public static final String DATA_SOURCE = "liferayDataSource";
84      public static final String SESSION_FACTORY = "liferaySessionFactory";
85      public static final String TX_MANAGER = "liferayTransactionManager";
86      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
87                  "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
88              true);
89      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
90                  "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
91              true);
92  
93      public static ShoppingCategory toModel(ShoppingCategorySoap soapModel) {
94          ShoppingCategory model = new ShoppingCategoryImpl();
95  
96          model.setCategoryId(soapModel.getCategoryId());
97          model.setGroupId(soapModel.getGroupId());
98          model.setCompanyId(soapModel.getCompanyId());
99          model.setUserId(soapModel.getUserId());
100         model.setUserName(soapModel.getUserName());
101         model.setCreateDate(soapModel.getCreateDate());
102         model.setModifiedDate(soapModel.getModifiedDate());
103         model.setParentCategoryId(soapModel.getParentCategoryId());
104         model.setName(soapModel.getName());
105         model.setDescription(soapModel.getDescription());
106 
107         return model;
108     }
109 
110     public static List<ShoppingCategory> toModels(
111         ShoppingCategorySoap[] soapModels) {
112         List<ShoppingCategory> models = new ArrayList<ShoppingCategory>(soapModels.length);
113 
114         for (ShoppingCategorySoap soapModel : soapModels) {
115             models.add(toModel(soapModel));
116         }
117 
118         return models;
119     }
120 
121     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
122                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingCategory"));
123 
124     public ShoppingCategoryModelImpl() {
125     }
126 
127     public long getPrimaryKey() {
128         return _categoryId;
129     }
130 
131     public void setPrimaryKey(long pk) {
132         setCategoryId(pk);
133     }
134 
135     public Serializable getPrimaryKeyObj() {
136         return new Long(_categoryId);
137     }
138 
139     public long getCategoryId() {
140         return _categoryId;
141     }
142 
143     public void setCategoryId(long categoryId) {
144         _categoryId = categoryId;
145     }
146 
147     public long getGroupId() {
148         return _groupId;
149     }
150 
151     public void setGroupId(long groupId) {
152         _groupId = groupId;
153     }
154 
155     public long getCompanyId() {
156         return _companyId;
157     }
158 
159     public void setCompanyId(long companyId) {
160         _companyId = companyId;
161     }
162 
163     public long getUserId() {
164         return _userId;
165     }
166 
167     public void setUserId(long userId) {
168         _userId = userId;
169     }
170 
171     public String getUserUuid() throws SystemException {
172         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
173     }
174 
175     public void setUserUuid(String userUuid) {
176         _userUuid = userUuid;
177     }
178 
179     public String getUserName() {
180         return GetterUtil.getString(_userName);
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         return GetterUtil.getString(_name);
213     }
214 
215     public void setName(String name) {
216         _name = name;
217     }
218 
219     public String getDescription() {
220         return GetterUtil.getString(_description);
221     }
222 
223     public void setDescription(String description) {
224         _description = description;
225     }
226 
227     public ShoppingCategory toEscapedModel() {
228         if (isEscapedModel()) {
229             return (ShoppingCategory)this;
230         }
231         else {
232             ShoppingCategory model = new ShoppingCategoryImpl();
233 
234             model.setNew(isNew());
235             model.setEscapedModel(true);
236 
237             model.setCategoryId(getCategoryId());
238             model.setGroupId(getGroupId());
239             model.setCompanyId(getCompanyId());
240             model.setUserId(getUserId());
241             model.setUserName(HtmlUtil.escape(getUserName()));
242             model.setCreateDate(getCreateDate());
243             model.setModifiedDate(getModifiedDate());
244             model.setParentCategoryId(getParentCategoryId());
245             model.setName(HtmlUtil.escape(getName()));
246             model.setDescription(HtmlUtil.escape(getDescription()));
247 
248             model = (ShoppingCategory)Proxy.newProxyInstance(ShoppingCategory.class.getClassLoader(),
249                     new Class[] { ShoppingCategory.class },
250                     new ReadOnlyBeanHandler(model));
251 
252             return model;
253         }
254     }
255 
256     public ExpandoBridge getExpandoBridge() {
257         if (_expandoBridge == null) {
258             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(ShoppingCategory.class.getName(),
259                     getPrimaryKey());
260         }
261 
262         return _expandoBridge;
263     }
264 
265     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
266         getExpandoBridge().setAttributes(serviceContext);
267     }
268 
269     public Object clone() {
270         ShoppingCategoryImpl clone = new ShoppingCategoryImpl();
271 
272         clone.setCategoryId(getCategoryId());
273         clone.setGroupId(getGroupId());
274         clone.setCompanyId(getCompanyId());
275         clone.setUserId(getUserId());
276         clone.setUserName(getUserName());
277         clone.setCreateDate(getCreateDate());
278         clone.setModifiedDate(getModifiedDate());
279         clone.setParentCategoryId(getParentCategoryId());
280         clone.setName(getName());
281         clone.setDescription(getDescription());
282 
283         return clone;
284     }
285 
286     public int compareTo(ShoppingCategory shoppingCategory) {
287         int value = 0;
288 
289         if (getParentCategoryId() < shoppingCategory.getParentCategoryId()) {
290             value = -1;
291         }
292         else if (getParentCategoryId() > shoppingCategory.getParentCategoryId()) {
293             value = 1;
294         }
295         else {
296             value = 0;
297         }
298 
299         if (value != 0) {
300             return value;
301         }
302 
303         value = getName().toLowerCase()
304                     .compareTo(shoppingCategory.getName().toLowerCase());
305 
306         if (value != 0) {
307             return value;
308         }
309 
310         return 0;
311     }
312 
313     public boolean equals(Object obj) {
314         if (obj == null) {
315             return false;
316         }
317 
318         ShoppingCategory shoppingCategory = null;
319 
320         try {
321             shoppingCategory = (ShoppingCategory)obj;
322         }
323         catch (ClassCastException cce) {
324             return false;
325         }
326 
327         long pk = shoppingCategory.getPrimaryKey();
328 
329         if (getPrimaryKey() == pk) {
330             return true;
331         }
332         else {
333             return false;
334         }
335     }
336 
337     public int hashCode() {
338         return (int)getPrimaryKey();
339     }
340 
341     public String toString() {
342         StringBuilder sb = new StringBuilder();
343 
344         sb.append("{categoryId=");
345         sb.append(getCategoryId());
346         sb.append(", groupId=");
347         sb.append(getGroupId());
348         sb.append(", companyId=");
349         sb.append(getCompanyId());
350         sb.append(", userId=");
351         sb.append(getUserId());
352         sb.append(", userName=");
353         sb.append(getUserName());
354         sb.append(", createDate=");
355         sb.append(getCreateDate());
356         sb.append(", modifiedDate=");
357         sb.append(getModifiedDate());
358         sb.append(", parentCategoryId=");
359         sb.append(getParentCategoryId());
360         sb.append(", name=");
361         sb.append(getName());
362         sb.append(", description=");
363         sb.append(getDescription());
364         sb.append("}");
365 
366         return sb.toString();
367     }
368 
369     public String toXmlString() {
370         StringBuilder sb = new StringBuilder();
371 
372         sb.append("<model><model-name>");
373         sb.append("com.liferay.portlet.shopping.model.ShoppingCategory");
374         sb.append("</model-name>");
375 
376         sb.append(
377             "<column><column-name>categoryId</column-name><column-value><![CDATA[");
378         sb.append(getCategoryId());
379         sb.append("]]></column-value></column>");
380         sb.append(
381             "<column><column-name>groupId</column-name><column-value><![CDATA[");
382         sb.append(getGroupId());
383         sb.append("]]></column-value></column>");
384         sb.append(
385             "<column><column-name>companyId</column-name><column-value><![CDATA[");
386         sb.append(getCompanyId());
387         sb.append("]]></column-value></column>");
388         sb.append(
389             "<column><column-name>userId</column-name><column-value><![CDATA[");
390         sb.append(getUserId());
391         sb.append("]]></column-value></column>");
392         sb.append(
393             "<column><column-name>userName</column-name><column-value><![CDATA[");
394         sb.append(getUserName());
395         sb.append("]]></column-value></column>");
396         sb.append(
397             "<column><column-name>createDate</column-name><column-value><![CDATA[");
398         sb.append(getCreateDate());
399         sb.append("]]></column-value></column>");
400         sb.append(
401             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
402         sb.append(getModifiedDate());
403         sb.append("]]></column-value></column>");
404         sb.append(
405             "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
406         sb.append(getParentCategoryId());
407         sb.append("]]></column-value></column>");
408         sb.append(
409             "<column><column-name>name</column-name><column-value><![CDATA[");
410         sb.append(getName());
411         sb.append("]]></column-value></column>");
412         sb.append(
413             "<column><column-name>description</column-name><column-value><![CDATA[");
414         sb.append(getDescription());
415         sb.append("]]></column-value></column>");
416 
417         sb.append("</model>");
418 
419         return sb.toString();
420     }
421 
422     private long _categoryId;
423     private long _groupId;
424     private long _companyId;
425     private long _userId;
426     private String _userUuid;
427     private String _userName;
428     private Date _createDate;
429     private Date _modifiedDate;
430     private long _parentCategoryId;
431     private String _name;
432     private String _description;
433     private transient ExpandoBridge _expandoBridge;
434 }