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