1   /**
2    * Copyright (c) 2000-2008 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.model.impl.BaseModelImpl;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.portlet.shopping.model.ShoppingOrderItem;
31  
32  import com.liferay.util.Html;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.Date;
41  
42  /**
43   * <a href="ShoppingOrderItemModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>ShoppingOrderItem</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portlet.shopping.service.model.ShoppingOrderItem
58   * @see com.liferay.portlet.shopping.service.model.ShoppingOrderItemModel
59   * @see com.liferay.portlet.shopping.service.model.impl.ShoppingOrderItemImpl
60   *
61   */
62  public class ShoppingOrderItemModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "ShoppingOrderItem";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "orderItemId", new Integer(Types.BIGINT) },
66              
67  
68              { "orderId", new Integer(Types.BIGINT) },
69              
70  
71              { "itemId", new Integer(Types.VARCHAR) },
72              
73  
74              { "sku", new Integer(Types.VARCHAR) },
75              
76  
77              { "name", new Integer(Types.VARCHAR) },
78              
79  
80              { "description", new Integer(Types.VARCHAR) },
81              
82  
83              { "properties", new Integer(Types.VARCHAR) },
84              
85  
86              { "price", new Integer(Types.DOUBLE) },
87              
88  
89              { "quantity", new Integer(Types.INTEGER) },
90              
91  
92              { "shippedDate", new Integer(Types.TIMESTAMP) }
93          };
94      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)";
95      public static final String TABLE_SQL_DROP = "drop table ShoppingOrderItem";
96      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
97                  "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingOrderItem"),
98              true);
99      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
100                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingOrderItem"));
101 
102     public ShoppingOrderItemModelImpl() {
103     }
104 
105     public long getPrimaryKey() {
106         return _orderItemId;
107     }
108 
109     public void setPrimaryKey(long pk) {
110         setOrderItemId(pk);
111     }
112 
113     public Serializable getPrimaryKeyObj() {
114         return new Long(_orderItemId);
115     }
116 
117     public long getOrderItemId() {
118         return _orderItemId;
119     }
120 
121     public void setOrderItemId(long orderItemId) {
122         if (orderItemId != _orderItemId) {
123             _orderItemId = orderItemId;
124         }
125     }
126 
127     public long getOrderId() {
128         return _orderId;
129     }
130 
131     public void setOrderId(long orderId) {
132         if (orderId != _orderId) {
133             _orderId = orderId;
134         }
135     }
136 
137     public String getItemId() {
138         return GetterUtil.getString(_itemId);
139     }
140 
141     public void setItemId(String itemId) {
142         if (((itemId == null) && (_itemId != null)) ||
143                 ((itemId != null) && (_itemId == null)) ||
144                 ((itemId != null) && (_itemId != null) &&
145                 !itemId.equals(_itemId))) {
146             _itemId = itemId;
147         }
148     }
149 
150     public String getSku() {
151         return GetterUtil.getString(_sku);
152     }
153 
154     public void setSku(String sku) {
155         if (((sku == null) && (_sku != null)) ||
156                 ((sku != null) && (_sku == null)) ||
157                 ((sku != null) && (_sku != null) && !sku.equals(_sku))) {
158             _sku = sku;
159         }
160     }
161 
162     public String getName() {
163         return GetterUtil.getString(_name);
164     }
165 
166     public void setName(String name) {
167         if (((name == null) && (_name != null)) ||
168                 ((name != null) && (_name == null)) ||
169                 ((name != null) && (_name != null) && !name.equals(_name))) {
170             _name = name;
171         }
172     }
173 
174     public String getDescription() {
175         return GetterUtil.getString(_description);
176     }
177 
178     public void setDescription(String description) {
179         if (((description == null) && (_description != null)) ||
180                 ((description != null) && (_description == null)) ||
181                 ((description != null) && (_description != null) &&
182                 !description.equals(_description))) {
183             _description = description;
184         }
185     }
186 
187     public String getProperties() {
188         return GetterUtil.getString(_properties);
189     }
190 
191     public void setProperties(String properties) {
192         if (((properties == null) && (_properties != null)) ||
193                 ((properties != null) && (_properties == null)) ||
194                 ((properties != null) && (_properties != null) &&
195                 !properties.equals(_properties))) {
196             _properties = properties;
197         }
198     }
199 
200     public double getPrice() {
201         return _price;
202     }
203 
204     public void setPrice(double price) {
205         if (price != _price) {
206             _price = price;
207         }
208     }
209 
210     public int getQuantity() {
211         return _quantity;
212     }
213 
214     public void setQuantity(int quantity) {
215         if (quantity != _quantity) {
216             _quantity = quantity;
217         }
218     }
219 
220     public Date getShippedDate() {
221         return _shippedDate;
222     }
223 
224     public void setShippedDate(Date shippedDate) {
225         if (((shippedDate == null) && (_shippedDate != null)) ||
226                 ((shippedDate != null) && (_shippedDate == null)) ||
227                 ((shippedDate != null) && (_shippedDate != null) &&
228                 !shippedDate.equals(_shippedDate))) {
229             _shippedDate = shippedDate;
230         }
231     }
232 
233     public ShoppingOrderItem toEscapedModel() {
234         if (isEscapedModel()) {
235             return (ShoppingOrderItem)this;
236         }
237         else {
238             ShoppingOrderItem model = new ShoppingOrderItemImpl();
239 
240             model.setEscapedModel(true);
241 
242             model.setOrderItemId(getOrderItemId());
243             model.setOrderId(getOrderId());
244             model.setItemId(Html.escape(getItemId()));
245             model.setSku(Html.escape(getSku()));
246             model.setName(Html.escape(getName()));
247             model.setDescription(Html.escape(getDescription()));
248             model.setProperties(Html.escape(getProperties()));
249             model.setPrice(getPrice());
250             model.setQuantity(getQuantity());
251             model.setShippedDate(getShippedDate());
252 
253             model = (ShoppingOrderItem)Proxy.newProxyInstance(ShoppingOrderItem.class.getClassLoader(),
254                     new Class[] { ShoppingOrderItem.class },
255                     new ReadOnlyBeanHandler(model));
256 
257             return model;
258         }
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(Object obj) {
279         if (obj == null) {
280             return -1;
281         }
282 
283         ShoppingOrderItemImpl shoppingOrderItem = (ShoppingOrderItemImpl)obj;
284 
285         int value = 0;
286 
287         value = getName().compareTo(shoppingOrderItem.getName());
288 
289         if (value != 0) {
290             return value;
291         }
292 
293         value = getDescription().compareTo(shoppingOrderItem.getDescription());
294 
295         if (value != 0) {
296             return value;
297         }
298 
299         return 0;
300     }
301 
302     public boolean equals(Object obj) {
303         if (obj == null) {
304             return false;
305         }
306 
307         ShoppingOrderItemImpl shoppingOrderItem = null;
308 
309         try {
310             shoppingOrderItem = (ShoppingOrderItemImpl)obj;
311         }
312         catch (ClassCastException cce) {
313             return false;
314         }
315 
316         long pk = shoppingOrderItem.getPrimaryKey();
317 
318         if (getPrimaryKey() == pk) {
319             return true;
320         }
321         else {
322             return false;
323         }
324     }
325 
326     public int hashCode() {
327         return (int)getPrimaryKey();
328     }
329 
330     private long _orderItemId;
331     private long _orderId;
332     private String _itemId;
333     private String _sku;
334     private String _name;
335     private String _description;
336     private String _properties;
337     private double _price;
338     private int _quantity;
339     private Date _shippedDate;
340 }