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.model.ShoppingItemPrice
57   * @see com.liferay.portlet.shopping.model.ShoppingItemPriceModel
58   * @see com.liferay.portlet.shopping.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.setNew(isNew());
264             model.setEscapedModel(true);
265 
266             model.setItemPriceId(getItemPriceId());
267             model.setItemId(getItemId());
268             model.setMinQuantity(getMinQuantity());
269             model.setMaxQuantity(getMaxQuantity());
270             model.setPrice(getPrice());
271             model.setDiscount(getDiscount());
272             model.setTaxable(getTaxable());
273             model.setShipping(getShipping());
274             model.setUseShippingFormula(getUseShippingFormula());
275             model.setStatus(getStatus());
276 
277             model = (ShoppingItemPrice)Proxy.newProxyInstance(ShoppingItemPrice.class.getClassLoader(),
278                     new Class[] { ShoppingItemPrice.class },
279                     new ReadOnlyBeanHandler(model));
280 
281             return model;
282         }
283     }
284 
285     public Object clone() {
286         ShoppingItemPriceImpl clone = new ShoppingItemPriceImpl();
287 
288         clone.setItemPriceId(getItemPriceId());
289         clone.setItemId(getItemId());
290         clone.setMinQuantity(getMinQuantity());
291         clone.setMaxQuantity(getMaxQuantity());
292         clone.setPrice(getPrice());
293         clone.setDiscount(getDiscount());
294         clone.setTaxable(getTaxable());
295         clone.setShipping(getShipping());
296         clone.setUseShippingFormula(getUseShippingFormula());
297         clone.setStatus(getStatus());
298 
299         return clone;
300     }
301 
302     public int compareTo(Object obj) {
303         if (obj == null) {
304             return -1;
305         }
306 
307         ShoppingItemPriceImpl shoppingItemPrice = (ShoppingItemPriceImpl)obj;
308 
309         int value = 0;
310 
311         if (getItemId() < shoppingItemPrice.getItemId()) {
312             value = -1;
313         }
314         else if (getItemId() > shoppingItemPrice.getItemId()) {
315             value = 1;
316         }
317         else {
318             value = 0;
319         }
320 
321         if (value != 0) {
322             return value;
323         }
324 
325         if (getItemPriceId() < shoppingItemPrice.getItemPriceId()) {
326             value = -1;
327         }
328         else if (getItemPriceId() > shoppingItemPrice.getItemPriceId()) {
329             value = 1;
330         }
331         else {
332             value = 0;
333         }
334 
335         if (value != 0) {
336             return value;
337         }
338 
339         return 0;
340     }
341 
342     public boolean equals(Object obj) {
343         if (obj == null) {
344             return false;
345         }
346 
347         ShoppingItemPriceImpl shoppingItemPrice = null;
348 
349         try {
350             shoppingItemPrice = (ShoppingItemPriceImpl)obj;
351         }
352         catch (ClassCastException cce) {
353             return false;
354         }
355 
356         long pk = shoppingItemPrice.getPrimaryKey();
357 
358         if (getPrimaryKey() == pk) {
359             return true;
360         }
361         else {
362             return false;
363         }
364     }
365 
366     public int hashCode() {
367         return (int)getPrimaryKey();
368     }
369 
370     private long _itemPriceId;
371     private long _itemId;
372     private int _minQuantity;
373     private int _maxQuantity;
374     private double _price;
375     private double _discount;
376     private boolean _taxable;
377     private double _shipping;
378     private boolean _useShippingFormula;
379     private int _status;
380 }