1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.shopping.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.StringBundler;
20  import com.liferay.portal.model.impl.BaseModelImpl;
21  import com.liferay.portal.service.ServiceContext;
22  
23  import com.liferay.portlet.expando.model.ExpandoBridge;
24  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
25  import com.liferay.portlet.shopping.model.ShoppingItemPrice;
26  import com.liferay.portlet.shopping.model.ShoppingItemPriceSoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  /**
38   * <a href="ShoppingItemPriceModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This interface is a model that represents the ShoppingItemPrice table in the
47   * database.
48   * </p>
49   *
50   * @author    Brian Wing Shun Chan
51   * @see       ShoppingItemPriceImpl
52   * @see       com.liferay.portlet.shopping.model.ShoppingItemPrice
53   * @see       com.liferay.portlet.shopping.model.ShoppingItemPriceModel
54   * @generated
55   */
56  public class ShoppingItemPriceModelImpl extends BaseModelImpl<ShoppingItemPrice> {
57      public static final String TABLE_NAME = "ShoppingItemPrice";
58      public static final Object[][] TABLE_COLUMNS = {
59              { "itemPriceId", new Integer(Types.BIGINT) },
60              { "itemId", new Integer(Types.BIGINT) },
61              { "minQuantity", new Integer(Types.INTEGER) },
62              { "maxQuantity", new Integer(Types.INTEGER) },
63              { "price", new Integer(Types.DOUBLE) },
64              { "discount", new Integer(Types.DOUBLE) },
65              { "taxable", new Integer(Types.BOOLEAN) },
66              { "shipping", new Integer(Types.DOUBLE) },
67              { "useShippingFormula", new Integer(Types.BOOLEAN) },
68              { "status", new Integer(Types.INTEGER) }
69          };
70      public static final String TABLE_SQL_CREATE = "create table ShoppingItemPrice (itemPriceId LONG not null primary key,itemId LONG,minQuantity INTEGER,maxQuantity INTEGER,price DOUBLE,discount DOUBLE,taxable BOOLEAN,shipping DOUBLE,useShippingFormula BOOLEAN,status INTEGER)";
71      public static final String TABLE_SQL_DROP = "drop table ShoppingItemPrice";
72      public static final String ORDER_BY_JPQL = " ORDER BY shoppingItemPrice.itemId ASC, shoppingItemPrice.itemPriceId ASC";
73      public static final String ORDER_BY_SQL = " ORDER BY ShoppingItemPrice.itemId ASC, ShoppingItemPrice.itemPriceId ASC";
74      public static final String DATA_SOURCE = "liferayDataSource";
75      public static final String SESSION_FACTORY = "liferaySessionFactory";
76      public static final String TX_MANAGER = "liferayTransactionManager";
77      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
78                  "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemPrice"),
79              true);
80      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
81                  "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemPrice"),
82              true);
83  
84      public static ShoppingItemPrice toModel(ShoppingItemPriceSoap soapModel) {
85          ShoppingItemPrice model = new ShoppingItemPriceImpl();
86  
87          model.setItemPriceId(soapModel.getItemPriceId());
88          model.setItemId(soapModel.getItemId());
89          model.setMinQuantity(soapModel.getMinQuantity());
90          model.setMaxQuantity(soapModel.getMaxQuantity());
91          model.setPrice(soapModel.getPrice());
92          model.setDiscount(soapModel.getDiscount());
93          model.setTaxable(soapModel.getTaxable());
94          model.setShipping(soapModel.getShipping());
95          model.setUseShippingFormula(soapModel.getUseShippingFormula());
96          model.setStatus(soapModel.getStatus());
97  
98          return model;
99      }
100 
101     public static List<ShoppingItemPrice> toModels(
102         ShoppingItemPriceSoap[] soapModels) {
103         List<ShoppingItemPrice> models = new ArrayList<ShoppingItemPrice>(soapModels.length);
104 
105         for (ShoppingItemPriceSoap soapModel : soapModels) {
106             models.add(toModel(soapModel));
107         }
108 
109         return models;
110     }
111 
112     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
113                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemPrice"));
114 
115     public ShoppingItemPriceModelImpl() {
116     }
117 
118     public long getPrimaryKey() {
119         return _itemPriceId;
120     }
121 
122     public void setPrimaryKey(long pk) {
123         setItemPriceId(pk);
124     }
125 
126     public Serializable getPrimaryKeyObj() {
127         return new Long(_itemPriceId);
128     }
129 
130     public long getItemPriceId() {
131         return _itemPriceId;
132     }
133 
134     public void setItemPriceId(long itemPriceId) {
135         _itemPriceId = itemPriceId;
136     }
137 
138     public long getItemId() {
139         return _itemId;
140     }
141 
142     public void setItemId(long itemId) {
143         _itemId = itemId;
144     }
145 
146     public int getMinQuantity() {
147         return _minQuantity;
148     }
149 
150     public void setMinQuantity(int minQuantity) {
151         _minQuantity = minQuantity;
152     }
153 
154     public int getMaxQuantity() {
155         return _maxQuantity;
156     }
157 
158     public void setMaxQuantity(int maxQuantity) {
159         _maxQuantity = maxQuantity;
160     }
161 
162     public double getPrice() {
163         return _price;
164     }
165 
166     public void setPrice(double price) {
167         _price = price;
168     }
169 
170     public double getDiscount() {
171         return _discount;
172     }
173 
174     public void setDiscount(double discount) {
175         _discount = discount;
176     }
177 
178     public boolean getTaxable() {
179         return _taxable;
180     }
181 
182     public boolean isTaxable() {
183         return _taxable;
184     }
185 
186     public void setTaxable(boolean taxable) {
187         _taxable = taxable;
188     }
189 
190     public double getShipping() {
191         return _shipping;
192     }
193 
194     public void setShipping(double shipping) {
195         _shipping = shipping;
196     }
197 
198     public boolean getUseShippingFormula() {
199         return _useShippingFormula;
200     }
201 
202     public boolean isUseShippingFormula() {
203         return _useShippingFormula;
204     }
205 
206     public void setUseShippingFormula(boolean useShippingFormula) {
207         _useShippingFormula = useShippingFormula;
208     }
209 
210     public int getStatus() {
211         return _status;
212     }
213 
214     public void setStatus(int status) {
215         _status = status;
216     }
217 
218     public ShoppingItemPrice toEscapedModel() {
219         if (isEscapedModel()) {
220             return (ShoppingItemPrice)this;
221         }
222         else {
223             ShoppingItemPrice model = new ShoppingItemPriceImpl();
224 
225             model.setNew(isNew());
226             model.setEscapedModel(true);
227 
228             model.setItemPriceId(getItemPriceId());
229             model.setItemId(getItemId());
230             model.setMinQuantity(getMinQuantity());
231             model.setMaxQuantity(getMaxQuantity());
232             model.setPrice(getPrice());
233             model.setDiscount(getDiscount());
234             model.setTaxable(getTaxable());
235             model.setShipping(getShipping());
236             model.setUseShippingFormula(getUseShippingFormula());
237             model.setStatus(getStatus());
238 
239             model = (ShoppingItemPrice)Proxy.newProxyInstance(ShoppingItemPrice.class.getClassLoader(),
240                     new Class[] { ShoppingItemPrice.class },
241                     new ReadOnlyBeanHandler(model));
242 
243             return model;
244         }
245     }
246 
247     public ExpandoBridge getExpandoBridge() {
248         if (_expandoBridge == null) {
249             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
250                     ShoppingItemPrice.class.getName(), getPrimaryKey());
251         }
252 
253         return _expandoBridge;
254     }
255 
256     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
257         getExpandoBridge().setAttributes(serviceContext);
258     }
259 
260     public Object clone() {
261         ShoppingItemPriceImpl clone = new ShoppingItemPriceImpl();
262 
263         clone.setItemPriceId(getItemPriceId());
264         clone.setItemId(getItemId());
265         clone.setMinQuantity(getMinQuantity());
266         clone.setMaxQuantity(getMaxQuantity());
267         clone.setPrice(getPrice());
268         clone.setDiscount(getDiscount());
269         clone.setTaxable(getTaxable());
270         clone.setShipping(getShipping());
271         clone.setUseShippingFormula(getUseShippingFormula());
272         clone.setStatus(getStatus());
273 
274         return clone;
275     }
276 
277     public int compareTo(ShoppingItemPrice shoppingItemPrice) {
278         int value = 0;
279 
280         if (getItemId() < shoppingItemPrice.getItemId()) {
281             value = -1;
282         }
283         else if (getItemId() > shoppingItemPrice.getItemId()) {
284             value = 1;
285         }
286         else {
287             value = 0;
288         }
289 
290         if (value != 0) {
291             return value;
292         }
293 
294         if (getItemPriceId() < shoppingItemPrice.getItemPriceId()) {
295             value = -1;
296         }
297         else if (getItemPriceId() > shoppingItemPrice.getItemPriceId()) {
298             value = 1;
299         }
300         else {
301             value = 0;
302         }
303 
304         if (value != 0) {
305             return value;
306         }
307 
308         return 0;
309     }
310 
311     public boolean equals(Object obj) {
312         if (obj == null) {
313             return false;
314         }
315 
316         ShoppingItemPrice shoppingItemPrice = null;
317 
318         try {
319             shoppingItemPrice = (ShoppingItemPrice)obj;
320         }
321         catch (ClassCastException cce) {
322             return false;
323         }
324 
325         long pk = shoppingItemPrice.getPrimaryKey();
326 
327         if (getPrimaryKey() == pk) {
328             return true;
329         }
330         else {
331             return false;
332         }
333     }
334 
335     public int hashCode() {
336         return (int)getPrimaryKey();
337     }
338 
339     public String toString() {
340         StringBundler sb = new StringBundler(21);
341 
342         sb.append("{itemPriceId=");
343         sb.append(getItemPriceId());
344         sb.append(", itemId=");
345         sb.append(getItemId());
346         sb.append(", minQuantity=");
347         sb.append(getMinQuantity());
348         sb.append(", maxQuantity=");
349         sb.append(getMaxQuantity());
350         sb.append(", price=");
351         sb.append(getPrice());
352         sb.append(", discount=");
353         sb.append(getDiscount());
354         sb.append(", taxable=");
355         sb.append(getTaxable());
356         sb.append(", shipping=");
357         sb.append(getShipping());
358         sb.append(", useShippingFormula=");
359         sb.append(getUseShippingFormula());
360         sb.append(", status=");
361         sb.append(getStatus());
362         sb.append("}");
363 
364         return sb.toString();
365     }
366 
367     public String toXmlString() {
368         StringBundler sb = new StringBundler(34);
369 
370         sb.append("<model><model-name>");
371         sb.append("com.liferay.portlet.shopping.model.ShoppingItemPrice");
372         sb.append("</model-name>");
373 
374         sb.append(
375             "<column><column-name>itemPriceId</column-name><column-value><![CDATA[");
376         sb.append(getItemPriceId());
377         sb.append("]]></column-value></column>");
378         sb.append(
379             "<column><column-name>itemId</column-name><column-value><![CDATA[");
380         sb.append(getItemId());
381         sb.append("]]></column-value></column>");
382         sb.append(
383             "<column><column-name>minQuantity</column-name><column-value><![CDATA[");
384         sb.append(getMinQuantity());
385         sb.append("]]></column-value></column>");
386         sb.append(
387             "<column><column-name>maxQuantity</column-name><column-value><![CDATA[");
388         sb.append(getMaxQuantity());
389         sb.append("]]></column-value></column>");
390         sb.append(
391             "<column><column-name>price</column-name><column-value><![CDATA[");
392         sb.append(getPrice());
393         sb.append("]]></column-value></column>");
394         sb.append(
395             "<column><column-name>discount</column-name><column-value><![CDATA[");
396         sb.append(getDiscount());
397         sb.append("]]></column-value></column>");
398         sb.append(
399             "<column><column-name>taxable</column-name><column-value><![CDATA[");
400         sb.append(getTaxable());
401         sb.append("]]></column-value></column>");
402         sb.append(
403             "<column><column-name>shipping</column-name><column-value><![CDATA[");
404         sb.append(getShipping());
405         sb.append("]]></column-value></column>");
406         sb.append(
407             "<column><column-name>useShippingFormula</column-name><column-value><![CDATA[");
408         sb.append(getUseShippingFormula());
409         sb.append("]]></column-value></column>");
410         sb.append(
411             "<column><column-name>status</column-name><column-value><![CDATA[");
412         sb.append(getStatus());
413         sb.append("]]></column-value></column>");
414 
415         sb.append("</model>");
416 
417         return sb.toString();
418     }
419 
420     private long _itemPriceId;
421     private long _itemId;
422     private int _minQuantity;
423     private int _maxQuantity;
424     private double _price;
425     private double _discount;
426     private boolean _taxable;
427     private double _shipping;
428     private boolean _useShippingFormula;
429     private int _status;
430     private transient ExpandoBridge _expandoBridge;
431 }