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