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