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.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.StringBundler;
20  import com.liferay.portal.kernel.util.StringPool;
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         if (_itemId == null) {
150             return StringPool.BLANK;
151         }
152         else {
153             return _itemId;
154         }
155     }
156 
157     public void setItemId(String itemId) {
158         _itemId = itemId;
159     }
160 
161     public String getSku() {
162         if (_sku == null) {
163             return StringPool.BLANK;
164         }
165         else {
166             return _sku;
167         }
168     }
169 
170     public void setSku(String sku) {
171         _sku = sku;
172     }
173 
174     public String getName() {
175         if (_name == null) {
176             return StringPool.BLANK;
177         }
178         else {
179             return _name;
180         }
181     }
182 
183     public void setName(String name) {
184         _name = name;
185     }
186 
187     public String getDescription() {
188         if (_description == null) {
189             return StringPool.BLANK;
190         }
191         else {
192             return _description;
193         }
194     }
195 
196     public void setDescription(String description) {
197         _description = description;
198     }
199 
200     public String getProperties() {
201         if (_properties == null) {
202             return StringPool.BLANK;
203         }
204         else {
205             return _properties;
206         }
207     }
208 
209     public void setProperties(String properties) {
210         _properties = properties;
211     }
212 
213     public double getPrice() {
214         return _price;
215     }
216 
217     public void setPrice(double price) {
218         _price = price;
219     }
220 
221     public int getQuantity() {
222         return _quantity;
223     }
224 
225     public void setQuantity(int quantity) {
226         _quantity = quantity;
227     }
228 
229     public Date getShippedDate() {
230         return _shippedDate;
231     }
232 
233     public void setShippedDate(Date shippedDate) {
234         _shippedDate = shippedDate;
235     }
236 
237     public ShoppingOrderItem toEscapedModel() {
238         if (isEscapedModel()) {
239             return (ShoppingOrderItem)this;
240         }
241         else {
242             return (ShoppingOrderItem)Proxy.newProxyInstance(ShoppingOrderItem.class.getClassLoader(),
243                 new Class[] { ShoppingOrderItem.class },
244                 new AutoEscapeBeanHandler(this));
245         }
246     }
247 
248     public ExpandoBridge getExpandoBridge() {
249         if (_expandoBridge == null) {
250             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(ShoppingOrderItem.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         ShoppingOrderItemImpl clone = new ShoppingOrderItemImpl();
263 
264         clone.setOrderItemId(getOrderItemId());
265         clone.setOrderId(getOrderId());
266         clone.setItemId(getItemId());
267         clone.setSku(getSku());
268         clone.setName(getName());
269         clone.setDescription(getDescription());
270         clone.setProperties(getProperties());
271         clone.setPrice(getPrice());
272         clone.setQuantity(getQuantity());
273         clone.setShippedDate(getShippedDate());
274 
275         return clone;
276     }
277 
278     public int compareTo(ShoppingOrderItem shoppingOrderItem) {
279         int value = 0;
280 
281         value = getName().compareTo(shoppingOrderItem.getName());
282 
283         if (value != 0) {
284             return value;
285         }
286 
287         value = getDescription().compareTo(shoppingOrderItem.getDescription());
288 
289         if (value != 0) {
290             return value;
291         }
292 
293         return 0;
294     }
295 
296     public boolean equals(Object obj) {
297         if (obj == null) {
298             return false;
299         }
300 
301         ShoppingOrderItem shoppingOrderItem = null;
302 
303         try {
304             shoppingOrderItem = (ShoppingOrderItem)obj;
305         }
306         catch (ClassCastException cce) {
307             return false;
308         }
309 
310         long pk = shoppingOrderItem.getPrimaryKey();
311 
312         if (getPrimaryKey() == pk) {
313             return true;
314         }
315         else {
316             return false;
317         }
318     }
319 
320     public int hashCode() {
321         return (int)getPrimaryKey();
322     }
323 
324     public String toString() {
325         StringBundler sb = new StringBundler(21);
326 
327         sb.append("{orderItemId=");
328         sb.append(getOrderItemId());
329         sb.append(", orderId=");
330         sb.append(getOrderId());
331         sb.append(", itemId=");
332         sb.append(getItemId());
333         sb.append(", sku=");
334         sb.append(getSku());
335         sb.append(", name=");
336         sb.append(getName());
337         sb.append(", description=");
338         sb.append(getDescription());
339         sb.append(", properties=");
340         sb.append(getProperties());
341         sb.append(", price=");
342         sb.append(getPrice());
343         sb.append(", quantity=");
344         sb.append(getQuantity());
345         sb.append(", shippedDate=");
346         sb.append(getShippedDate());
347         sb.append("}");
348 
349         return sb.toString();
350     }
351 
352     public String toXmlString() {
353         StringBundler sb = new StringBundler(34);
354 
355         sb.append("<model><model-name>");
356         sb.append("com.liferay.portlet.shopping.model.ShoppingOrderItem");
357         sb.append("</model-name>");
358 
359         sb.append(
360             "<column><column-name>orderItemId</column-name><column-value><![CDATA[");
361         sb.append(getOrderItemId());
362         sb.append("]]></column-value></column>");
363         sb.append(
364             "<column><column-name>orderId</column-name><column-value><![CDATA[");
365         sb.append(getOrderId());
366         sb.append("]]></column-value></column>");
367         sb.append(
368             "<column><column-name>itemId</column-name><column-value><![CDATA[");
369         sb.append(getItemId());
370         sb.append("]]></column-value></column>");
371         sb.append(
372             "<column><column-name>sku</column-name><column-value><![CDATA[");
373         sb.append(getSku());
374         sb.append("]]></column-value></column>");
375         sb.append(
376             "<column><column-name>name</column-name><column-value><![CDATA[");
377         sb.append(getName());
378         sb.append("]]></column-value></column>");
379         sb.append(
380             "<column><column-name>description</column-name><column-value><![CDATA[");
381         sb.append(getDescription());
382         sb.append("]]></column-value></column>");
383         sb.append(
384             "<column><column-name>properties</column-name><column-value><![CDATA[");
385         sb.append(getProperties());
386         sb.append("]]></column-value></column>");
387         sb.append(
388             "<column><column-name>price</column-name><column-value><![CDATA[");
389         sb.append(getPrice());
390         sb.append("]]></column-value></column>");
391         sb.append(
392             "<column><column-name>quantity</column-name><column-value><![CDATA[");
393         sb.append(getQuantity());
394         sb.append("]]></column-value></column>");
395         sb.append(
396             "<column><column-name>shippedDate</column-name><column-value><![CDATA[");
397         sb.append(getShippedDate());
398         sb.append("]]></column-value></column>");
399 
400         sb.append("</model>");
401 
402         return sb.toString();
403     }
404 
405     private long _orderItemId;
406     private long _orderId;
407     private String _itemId;
408     private String _sku;
409     private String _name;
410     private String _description;
411     private String _properties;
412     private double _price;
413     private int _quantity;
414     private Date _shippedDate;
415     private transient ExpandoBridge _expandoBridge;
416 }