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.ShoppingItemPrice;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  /**
39   * <a href="ShoppingItemPriceModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>ShoppingItemPrice</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portlet.shopping.service.model.ShoppingItemPrice
54   * @see com.liferay.portlet.shopping.service.model.ShoppingItemPriceModel
55   * @see com.liferay.portlet.shopping.service.model.impl.ShoppingItemPriceImpl
56   *
57   */
58  public class ShoppingItemPriceModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "ShoppingItemPrice";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "itemPriceId", new Integer(Types.BIGINT) },
62              
63  
64              { "itemId", new Integer(Types.BIGINT) },
65              
66  
67              { "minQuantity", new Integer(Types.INTEGER) },
68              
69  
70              { "maxQuantity", new Integer(Types.INTEGER) },
71              
72  
73              { "price", new Integer(Types.DOUBLE) },
74              
75  
76              { "discount", new Integer(Types.DOUBLE) },
77              
78  
79              { "taxable", new Integer(Types.BOOLEAN) },
80              
81  
82              { "shipping", new Integer(Types.DOUBLE) },
83              
84  
85              { "useShippingFormula", new Integer(Types.BOOLEAN) },
86              
87  
88              { "status", new Integer(Types.INTEGER) }
89          };
90      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)";
91      public static final String TABLE_SQL_DROP = "drop table ShoppingItemPrice";
92      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
93                  "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemPrice"),
94              true);
95      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
96                  "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemPrice"));
97  
98      public ShoppingItemPriceModelImpl() {
99      }
100 
101     public long getPrimaryKey() {
102         return _itemPriceId;
103     }
104 
105     public void setPrimaryKey(long pk) {
106         setItemPriceId(pk);
107     }
108 
109     public Serializable getPrimaryKeyObj() {
110         return new Long(_itemPriceId);
111     }
112 
113     public long getItemPriceId() {
114         return _itemPriceId;
115     }
116 
117     public void setItemPriceId(long itemPriceId) {
118         if (itemPriceId != _itemPriceId) {
119             _itemPriceId = itemPriceId;
120         }
121     }
122 
123     public long getItemId() {
124         return _itemId;
125     }
126 
127     public void setItemId(long itemId) {
128         if (itemId != _itemId) {
129             _itemId = itemId;
130         }
131     }
132 
133     public int getMinQuantity() {
134         return _minQuantity;
135     }
136 
137     public void setMinQuantity(int minQuantity) {
138         if (minQuantity != _minQuantity) {
139             _minQuantity = minQuantity;
140         }
141     }
142 
143     public int getMaxQuantity() {
144         return _maxQuantity;
145     }
146 
147     public void setMaxQuantity(int maxQuantity) {
148         if (maxQuantity != _maxQuantity) {
149             _maxQuantity = maxQuantity;
150         }
151     }
152 
153     public double getPrice() {
154         return _price;
155     }
156 
157     public void setPrice(double price) {
158         if (price != _price) {
159             _price = price;
160         }
161     }
162 
163     public double getDiscount() {
164         return _discount;
165     }
166 
167     public void setDiscount(double discount) {
168         if (discount != _discount) {
169             _discount = discount;
170         }
171     }
172 
173     public boolean getTaxable() {
174         return _taxable;
175     }
176 
177     public boolean isTaxable() {
178         return _taxable;
179     }
180 
181     public void setTaxable(boolean taxable) {
182         if (taxable != _taxable) {
183             _taxable = taxable;
184         }
185     }
186 
187     public double getShipping() {
188         return _shipping;
189     }
190 
191     public void setShipping(double shipping) {
192         if (shipping != _shipping) {
193             _shipping = shipping;
194         }
195     }
196 
197     public boolean getUseShippingFormula() {
198         return _useShippingFormula;
199     }
200 
201     public boolean isUseShippingFormula() {
202         return _useShippingFormula;
203     }
204 
205     public void setUseShippingFormula(boolean useShippingFormula) {
206         if (useShippingFormula != _useShippingFormula) {
207             _useShippingFormula = useShippingFormula;
208         }
209     }
210 
211     public int getStatus() {
212         return _status;
213     }
214 
215     public void setStatus(int status) {
216         if (status != _status) {
217             _status = status;
218         }
219     }
220 
221     public ShoppingItemPrice toEscapedModel() {
222         if (isEscapedModel()) {
223             return (ShoppingItemPrice)this;
224         }
225         else {
226             ShoppingItemPrice model = new ShoppingItemPriceImpl();
227 
228             model.setEscapedModel(true);
229 
230             model.setItemPriceId(getItemPriceId());
231             model.setItemId(getItemId());
232             model.setMinQuantity(getMinQuantity());
233             model.setMaxQuantity(getMaxQuantity());
234             model.setPrice(getPrice());
235             model.setDiscount(getDiscount());
236             model.setTaxable(getTaxable());
237             model.setShipping(getShipping());
238             model.setUseShippingFormula(getUseShippingFormula());
239             model.setStatus(getStatus());
240 
241             model = (ShoppingItemPrice)Proxy.newProxyInstance(ShoppingItemPrice.class.getClassLoader(),
242                     new Class[] { ShoppingItemPrice.class },
243                     new ReadOnlyBeanHandler(model));
244 
245             return model;
246         }
247     }
248 
249     public Object clone() {
250         ShoppingItemPriceImpl clone = new ShoppingItemPriceImpl();
251 
252         clone.setItemPriceId(getItemPriceId());
253         clone.setItemId(getItemId());
254         clone.setMinQuantity(getMinQuantity());
255         clone.setMaxQuantity(getMaxQuantity());
256         clone.setPrice(getPrice());
257         clone.setDiscount(getDiscount());
258         clone.setTaxable(getTaxable());
259         clone.setShipping(getShipping());
260         clone.setUseShippingFormula(getUseShippingFormula());
261         clone.setStatus(getStatus());
262 
263         return clone;
264     }
265 
266     public int compareTo(Object obj) {
267         if (obj == null) {
268             return -1;
269         }
270 
271         ShoppingItemPriceImpl shoppingItemPrice = (ShoppingItemPriceImpl)obj;
272 
273         int value = 0;
274 
275         if (getItemId() < shoppingItemPrice.getItemId()) {
276             value = -1;
277         }
278         else if (getItemId() > shoppingItemPrice.getItemId()) {
279             value = 1;
280         }
281         else {
282             value = 0;
283         }
284 
285         if (value != 0) {
286             return value;
287         }
288 
289         if (getItemPriceId() < shoppingItemPrice.getItemPriceId()) {
290             value = -1;
291         }
292         else if (getItemPriceId() > shoppingItemPrice.getItemPriceId()) {
293             value = 1;
294         }
295         else {
296             value = 0;
297         }
298 
299         if (value != 0) {
300             return value;
301         }
302 
303         return 0;
304     }
305 
306     public boolean equals(Object obj) {
307         if (obj == null) {
308             return false;
309         }
310 
311         ShoppingItemPriceImpl shoppingItemPrice = null;
312 
313         try {
314             shoppingItemPrice = (ShoppingItemPriceImpl)obj;
315         }
316         catch (ClassCastException cce) {
317             return false;
318         }
319 
320         long pk = shoppingItemPrice.getPrimaryKey();
321 
322         if (getPrimaryKey() == pk) {
323             return true;
324         }
325         else {
326             return false;
327         }
328     }
329 
330     public int hashCode() {
331         return (int)getPrimaryKey();
332     }
333 
334     private long _itemPriceId;
335     private long _itemId;
336     private int _minQuantity;
337     private int _maxQuantity;
338     private double _price;
339     private double _discount;
340     private boolean _taxable;
341     private double _shipping;
342     private boolean _useShippingFormula;
343     private int _status;
344 }