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