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 {
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 CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
103                 "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingOrderItem"),
104             true);
105 
106     public static ShoppingOrderItem toModel(ShoppingOrderItemSoap soapModel) {
107         ShoppingOrderItem model = new ShoppingOrderItemImpl();
108 
109         model.setOrderItemId(soapModel.getOrderItemId());
110         model.setOrderId(soapModel.getOrderId());
111         model.setItemId(soapModel.getItemId());
112         model.setSku(soapModel.getSku());
113         model.setName(soapModel.getName());
114         model.setDescription(soapModel.getDescription());
115         model.setProperties(soapModel.getProperties());
116         model.setPrice(soapModel.getPrice());
117         model.setQuantity(soapModel.getQuantity());
118         model.setShippedDate(soapModel.getShippedDate());
119 
120         return model;
121     }
122 
123     public static List<ShoppingOrderItem> toModels(
124         ShoppingOrderItemSoap[] soapModels) {
125         List<ShoppingOrderItem> models = new ArrayList<ShoppingOrderItem>(soapModels.length);
126 
127         for (ShoppingOrderItemSoap soapModel : soapModels) {
128             models.add(toModel(soapModel));
129         }
130 
131         return models;
132     }
133 
134     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
135                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingOrderItem"));
136 
137     public ShoppingOrderItemModelImpl() {
138     }
139 
140     public long getPrimaryKey() {
141         return _orderItemId;
142     }
143 
144     public void setPrimaryKey(long pk) {
145         setOrderItemId(pk);
146     }
147 
148     public Serializable getPrimaryKeyObj() {
149         return new Long(_orderItemId);
150     }
151 
152     public long getOrderItemId() {
153         return _orderItemId;
154     }
155 
156     public void setOrderItemId(long orderItemId) {
157         if (orderItemId != _orderItemId) {
158             _orderItemId = orderItemId;
159         }
160     }
161 
162     public long getOrderId() {
163         return _orderId;
164     }
165 
166     public void setOrderId(long orderId) {
167         if (orderId != _orderId) {
168             _orderId = orderId;
169         }
170     }
171 
172     public String getItemId() {
173         return GetterUtil.getString(_itemId);
174     }
175 
176     public void setItemId(String itemId) {
177         if (((itemId == null) && (_itemId != null)) ||
178                 ((itemId != null) && (_itemId == null)) ||
179                 ((itemId != null) && (_itemId != null) &&
180                 !itemId.equals(_itemId))) {
181             _itemId = itemId;
182         }
183     }
184 
185     public String getSku() {
186         return GetterUtil.getString(_sku);
187     }
188 
189     public void setSku(String sku) {
190         if (((sku == null) && (_sku != null)) ||
191                 ((sku != null) && (_sku == null)) ||
192                 ((sku != null) && (_sku != null) && !sku.equals(_sku))) {
193             _sku = sku;
194         }
195     }
196 
197     public String getName() {
198         return GetterUtil.getString(_name);
199     }
200 
201     public void setName(String name) {
202         if (((name == null) && (_name != null)) ||
203                 ((name != null) && (_name == null)) ||
204                 ((name != null) && (_name != null) && !name.equals(_name))) {
205             _name = name;
206         }
207     }
208 
209     public String getDescription() {
210         return GetterUtil.getString(_description);
211     }
212 
213     public void setDescription(String description) {
214         if (((description == null) && (_description != null)) ||
215                 ((description != null) && (_description == null)) ||
216                 ((description != null) && (_description != null) &&
217                 !description.equals(_description))) {
218             _description = description;
219         }
220     }
221 
222     public String getProperties() {
223         return GetterUtil.getString(_properties);
224     }
225 
226     public void setProperties(String properties) {
227         if (((properties == null) && (_properties != null)) ||
228                 ((properties != null) && (_properties == null)) ||
229                 ((properties != null) && (_properties != null) &&
230                 !properties.equals(_properties))) {
231             _properties = properties;
232         }
233     }
234 
235     public double getPrice() {
236         return _price;
237     }
238 
239     public void setPrice(double price) {
240         if (price != _price) {
241             _price = price;
242         }
243     }
244 
245     public int getQuantity() {
246         return _quantity;
247     }
248 
249     public void setQuantity(int quantity) {
250         if (quantity != _quantity) {
251             _quantity = quantity;
252         }
253     }
254 
255     public Date getShippedDate() {
256         return _shippedDate;
257     }
258 
259     public void setShippedDate(Date shippedDate) {
260         if (((shippedDate == null) && (_shippedDate != null)) ||
261                 ((shippedDate != null) && (_shippedDate == null)) ||
262                 ((shippedDate != null) && (_shippedDate != null) &&
263                 !shippedDate.equals(_shippedDate))) {
264             _shippedDate = shippedDate;
265         }
266     }
267 
268     public ShoppingOrderItem toEscapedModel() {
269         if (isEscapedModel()) {
270             return (ShoppingOrderItem)this;
271         }
272         else {
273             ShoppingOrderItem model = new ShoppingOrderItemImpl();
274 
275             model.setNew(isNew());
276             model.setEscapedModel(true);
277 
278             model.setOrderItemId(getOrderItemId());
279             model.setOrderId(getOrderId());
280             model.setItemId(HtmlUtil.escape(getItemId()));
281             model.setSku(HtmlUtil.escape(getSku()));
282             model.setName(HtmlUtil.escape(getName()));
283             model.setDescription(HtmlUtil.escape(getDescription()));
284             model.setProperties(HtmlUtil.escape(getProperties()));
285             model.setPrice(getPrice());
286             model.setQuantity(getQuantity());
287             model.setShippedDate(getShippedDate());
288 
289             model = (ShoppingOrderItem)Proxy.newProxyInstance(ShoppingOrderItem.class.getClassLoader(),
290                     new Class[] { ShoppingOrderItem.class },
291                     new ReadOnlyBeanHandler(model));
292 
293             return model;
294         }
295     }
296 
297     public ExpandoBridge getExpandoBridge() {
298         if (_expandoBridge == null) {
299             _expandoBridge = new ExpandoBridgeImpl(ShoppingOrderItem.class.getName(),
300                     getPrimaryKey());
301         }
302 
303         return _expandoBridge;
304     }
305 
306     public Object clone() {
307         ShoppingOrderItemImpl clone = new ShoppingOrderItemImpl();
308 
309         clone.setOrderItemId(getOrderItemId());
310         clone.setOrderId(getOrderId());
311         clone.setItemId(getItemId());
312         clone.setSku(getSku());
313         clone.setName(getName());
314         clone.setDescription(getDescription());
315         clone.setProperties(getProperties());
316         clone.setPrice(getPrice());
317         clone.setQuantity(getQuantity());
318         clone.setShippedDate(getShippedDate());
319 
320         return clone;
321     }
322 
323     public int compareTo(Object obj) {
324         if (obj == null) {
325             return -1;
326         }
327 
328         ShoppingOrderItemImpl shoppingOrderItem = (ShoppingOrderItemImpl)obj;
329 
330         int value = 0;
331 
332         value = getName().compareTo(shoppingOrderItem.getName());
333 
334         if (value != 0) {
335             return value;
336         }
337 
338         value = getDescription().compareTo(shoppingOrderItem.getDescription());
339 
340         if (value != 0) {
341             return value;
342         }
343 
344         return 0;
345     }
346 
347     public boolean equals(Object obj) {
348         if (obj == null) {
349             return false;
350         }
351 
352         ShoppingOrderItemImpl shoppingOrderItem = null;
353 
354         try {
355             shoppingOrderItem = (ShoppingOrderItemImpl)obj;
356         }
357         catch (ClassCastException cce) {
358             return false;
359         }
360 
361         long pk = shoppingOrderItem.getPrimaryKey();
362 
363         if (getPrimaryKey() == pk) {
364             return true;
365         }
366         else {
367             return false;
368         }
369     }
370 
371     public int hashCode() {
372         return (int)getPrimaryKey();
373     }
374 
375     private long _orderItemId;
376     private long _orderId;
377     private String _itemId;
378     private String _sku;
379     private String _name;
380     private String _description;
381     private String _properties;
382     private double _price;
383     private int _quantity;
384     private Date _shippedDate;
385     private transient ExpandoBridge _expandoBridge;
386 }