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.shopping.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.HtmlUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.model.impl.BaseModelImpl;
22  import com.liferay.portal.service.ServiceContext;
23  
24  import com.liferay.portlet.expando.model.ExpandoBridge;
25  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
26  import com.liferay.portlet.shopping.model.ShoppingOrderItem;
27  import com.liferay.portlet.shopping.model.ShoppingOrderItemSoap;
28  
29  import java.io.Serializable;
30  
31  import java.lang.reflect.Proxy;
32  
33  import java.sql.Types;
34  
35  import java.util.ArrayList;
36  import java.util.Date;
37  import java.util.List;
38  
39  /**
40   * <a href="ShoppingOrderItemModelImpl.java.html"><b><i>View Source</i></b></a>
41   *
42   * <p>
43   * ServiceBuilder generated this class. Modifications in this class will be
44   * overwritten the next time is generated.
45   * </p>
46   *
47   * <p>
48   * This interface is a model that represents the ShoppingOrderItem table in the
49   * database.
50   * </p>
51   *
52   * @author    Brian Wing Shun Chan
53   * @see       ShoppingOrderItemImpl
54   * @see       com.liferay.portlet.shopping.model.ShoppingOrderItem
55   * @see       com.liferay.portlet.shopping.model.ShoppingOrderItemModel
56   * @generated
57   */
58  public class ShoppingOrderItemModelImpl extends BaseModelImpl<ShoppingOrderItem> {
59      public static final String TABLE_NAME = "ShoppingOrderItem";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "orderItemId", new Integer(Types.BIGINT) },
62              { "orderId", new Integer(Types.BIGINT) },
63              { "itemId", new Integer(Types.VARCHAR) },
64              { "sku", new Integer(Types.VARCHAR) },
65              { "name", new Integer(Types.VARCHAR) },
66              { "description", new Integer(Types.VARCHAR) },
67              { "properties", new Integer(Types.VARCHAR) },
68              { "price", new Integer(Types.DOUBLE) },
69              { "quantity", new Integer(Types.INTEGER) },
70              { "shippedDate", new Integer(Types.TIMESTAMP) }
71          };
72      public static final String TABLE_SQL_CREATE = "create table ShoppingOrderItem (orderItemId LONG not null primary key,orderId LONG,itemId VARCHAR(75) null,sku VARCHAR(75) null,name VARCHAR(200) null,description STRING null,properties STRING null,price DOUBLE,quantity INTEGER,shippedDate DATE null)";
73      public static final String TABLE_SQL_DROP = "drop table ShoppingOrderItem";
74      public static final String ORDER_BY_JPQL = " ORDER BY shoppingOrderItem.name ASC, shoppingOrderItem.description ASC";
75      public static final String ORDER_BY_SQL = " ORDER BY ShoppingOrderItem.name ASC, ShoppingOrderItem.description ASC";
76      public static final String DATA_SOURCE = "liferayDataSource";
77      public static final String SESSION_FACTORY = "liferaySessionFactory";
78      public static final String TX_MANAGER = "liferayTransactionManager";
79      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
80                  "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingOrderItem"),
81              true);
82      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83                  "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingOrderItem"),
84              true);
85  
86      public static ShoppingOrderItem toModel(ShoppingOrderItemSoap soapModel) {
87          ShoppingOrderItem model = new ShoppingOrderItemImpl();
88  
89          model.setOrderItemId(soapModel.getOrderItemId());
90          model.setOrderId(soapModel.getOrderId());
91          model.setItemId(soapModel.getItemId());
92          model.setSku(soapModel.getSku());
93          model.setName(soapModel.getName());
94          model.setDescription(soapModel.getDescription());
95          model.setProperties(soapModel.getProperties());
96          model.setPrice(soapModel.getPrice());
97          model.setQuantity(soapModel.getQuantity());
98          model.setShippedDate(soapModel.getShippedDate());
99  
100         return model;
101     }
102 
103     public static List<ShoppingOrderItem> toModels(
104         ShoppingOrderItemSoap[] soapModels) {
105         List<ShoppingOrderItem> models = new ArrayList<ShoppingOrderItem>(soapModels.length);
106 
107         for (ShoppingOrderItemSoap soapModel : soapModels) {
108             models.add(toModel(soapModel));
109         }
110 
111         return models;
112     }
113 
114     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
115                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingOrderItem"));
116 
117     public ShoppingOrderItemModelImpl() {
118     }
119 
120     public long getPrimaryKey() {
121         return _orderItemId;
122     }
123 
124     public void setPrimaryKey(long pk) {
125         setOrderItemId(pk);
126     }
127 
128     public Serializable getPrimaryKeyObj() {
129         return new Long(_orderItemId);
130     }
131 
132     public long getOrderItemId() {
133         return _orderItemId;
134     }
135 
136     public void setOrderItemId(long orderItemId) {
137         _orderItemId = orderItemId;
138     }
139 
140     public long getOrderId() {
141         return _orderId;
142     }
143 
144     public void setOrderId(long orderId) {
145         _orderId = orderId;
146     }
147 
148     public String getItemId() {
149         return GetterUtil.getString(_itemId);
150     }
151 
152     public void setItemId(String itemId) {
153         _itemId = itemId;
154     }
155 
156     public String getSku() {
157         return GetterUtil.getString(_sku);
158     }
159 
160     public void setSku(String sku) {
161         _sku = sku;
162     }
163 
164     public String getName() {
165         return GetterUtil.getString(_name);
166     }
167 
168     public void setName(String name) {
169         _name = name;
170     }
171 
172     public String getDescription() {
173         return GetterUtil.getString(_description);
174     }
175 
176     public void setDescription(String description) {
177         _description = description;
178     }
179 
180     public String getProperties() {
181         return GetterUtil.getString(_properties);
182     }
183 
184     public void setProperties(String properties) {
185         _properties = properties;
186     }
187 
188     public double getPrice() {
189         return _price;
190     }
191 
192     public void setPrice(double price) {
193         _price = price;
194     }
195 
196     public int getQuantity() {
197         return _quantity;
198     }
199 
200     public void setQuantity(int quantity) {
201         _quantity = quantity;
202     }
203 
204     public Date getShippedDate() {
205         return _shippedDate;
206     }
207 
208     public void setShippedDate(Date shippedDate) {
209         _shippedDate = shippedDate;
210     }
211 
212     public ShoppingOrderItem toEscapedModel() {
213         if (isEscapedModel()) {
214             return (ShoppingOrderItem)this;
215         }
216         else {
217             ShoppingOrderItem model = new ShoppingOrderItemImpl();
218 
219             model.setNew(isNew());
220             model.setEscapedModel(true);
221 
222             model.setOrderItemId(getOrderItemId());
223             model.setOrderId(getOrderId());
224             model.setItemId(HtmlUtil.escape(getItemId()));
225             model.setSku(HtmlUtil.escape(getSku()));
226             model.setName(HtmlUtil.escape(getName()));
227             model.setDescription(HtmlUtil.escape(getDescription()));
228             model.setProperties(HtmlUtil.escape(getProperties()));
229             model.setPrice(getPrice());
230             model.setQuantity(getQuantity());
231             model.setShippedDate(getShippedDate());
232 
233             model = (ShoppingOrderItem)Proxy.newProxyInstance(ShoppingOrderItem.class.getClassLoader(),
234                     new Class[] { ShoppingOrderItem.class },
235                     new ReadOnlyBeanHandler(model));
236 
237             return model;
238         }
239     }
240 
241     public ExpandoBridge getExpandoBridge() {
242         if (_expandoBridge == null) {
243             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
244                     ShoppingOrderItem.class.getName(), getPrimaryKey());
245         }
246 
247         return _expandoBridge;
248     }
249 
250     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
251         getExpandoBridge().setAttributes(serviceContext);
252     }
253 
254     public Object clone() {
255         ShoppingOrderItemImpl clone = new ShoppingOrderItemImpl();
256 
257         clone.setOrderItemId(getOrderItemId());
258         clone.setOrderId(getOrderId());
259         clone.setItemId(getItemId());
260         clone.setSku(getSku());
261         clone.setName(getName());
262         clone.setDescription(getDescription());
263         clone.setProperties(getProperties());
264         clone.setPrice(getPrice());
265         clone.setQuantity(getQuantity());
266         clone.setShippedDate(getShippedDate());
267 
268         return clone;
269     }
270 
271     public int compareTo(ShoppingOrderItem shoppingOrderItem) {
272         int value = 0;
273 
274         value = getName().compareTo(shoppingOrderItem.getName());
275 
276         if (value != 0) {
277             return value;
278         }
279 
280         value = getDescription().compareTo(shoppingOrderItem.getDescription());
281 
282         if (value != 0) {
283             return value;
284         }
285 
286         return 0;
287     }
288 
289     public boolean equals(Object obj) {
290         if (obj == null) {
291             return false;
292         }
293 
294         ShoppingOrderItem shoppingOrderItem = null;
295 
296         try {
297             shoppingOrderItem = (ShoppingOrderItem)obj;
298         }
299         catch (ClassCastException cce) {
300             return false;
301         }
302 
303         long pk = shoppingOrderItem.getPrimaryKey();
304 
305         if (getPrimaryKey() == pk) {
306             return true;
307         }
308         else {
309             return false;
310         }
311     }
312 
313     public int hashCode() {
314         return (int)getPrimaryKey();
315     }
316 
317     public String toString() {
318         StringBundler sb = new StringBundler(21);
319 
320         sb.append("{orderItemId=");
321         sb.append(getOrderItemId());
322         sb.append(", orderId=");
323         sb.append(getOrderId());
324         sb.append(", itemId=");
325         sb.append(getItemId());
326         sb.append(", sku=");
327         sb.append(getSku());
328         sb.append(", name=");
329         sb.append(getName());
330         sb.append(", description=");
331         sb.append(getDescription());
332         sb.append(", properties=");
333         sb.append(getProperties());
334         sb.append(", price=");
335         sb.append(getPrice());
336         sb.append(", quantity=");
337         sb.append(getQuantity());
338         sb.append(", shippedDate=");
339         sb.append(getShippedDate());
340         sb.append("}");
341 
342         return sb.toString();
343     }
344 
345     public String toXmlString() {
346         StringBundler sb = new StringBundler(34);
347 
348         sb.append("<model><model-name>");
349         sb.append("com.liferay.portlet.shopping.model.ShoppingOrderItem");
350         sb.append("</model-name>");
351 
352         sb.append(
353             "<column><column-name>orderItemId</column-name><column-value><![CDATA[");
354         sb.append(getOrderItemId());
355         sb.append("]]></column-value></column>");
356         sb.append(
357             "<column><column-name>orderId</column-name><column-value><![CDATA[");
358         sb.append(getOrderId());
359         sb.append("]]></column-value></column>");
360         sb.append(
361             "<column><column-name>itemId</column-name><column-value><![CDATA[");
362         sb.append(getItemId());
363         sb.append("]]></column-value></column>");
364         sb.append(
365             "<column><column-name>sku</column-name><column-value><![CDATA[");
366         sb.append(getSku());
367         sb.append("]]></column-value></column>");
368         sb.append(
369             "<column><column-name>name</column-name><column-value><![CDATA[");
370         sb.append(getName());
371         sb.append("]]></column-value></column>");
372         sb.append(
373             "<column><column-name>description</column-name><column-value><![CDATA[");
374         sb.append(getDescription());
375         sb.append("]]></column-value></column>");
376         sb.append(
377             "<column><column-name>properties</column-name><column-value><![CDATA[");
378         sb.append(getProperties());
379         sb.append("]]></column-value></column>");
380         sb.append(
381             "<column><column-name>price</column-name><column-value><![CDATA[");
382         sb.append(getPrice());
383         sb.append("]]></column-value></column>");
384         sb.append(
385             "<column><column-name>quantity</column-name><column-value><![CDATA[");
386         sb.append(getQuantity());
387         sb.append("]]></column-value></column>");
388         sb.append(
389             "<column><column-name>shippedDate</column-name><column-value><![CDATA[");
390         sb.append(getShippedDate());
391         sb.append("]]></column-value></column>");
392 
393         sb.append("</model>");
394 
395         return sb.toString();
396     }
397 
398     private long _orderItemId;
399     private long _orderId;
400     private String _itemId;
401     private String _sku;
402     private String _name;
403     private String _description;
404     private String _properties;
405     private double _price;
406     private int _quantity;
407     private Date _shippedDate;
408     private transient ExpandoBridge _expandoBridge;
409 }