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