1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.shopping.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.model.impl.BaseModelImpl;
25  
26  import com.liferay.portlet.shopping.model.ShoppingItemPrice;
27  import com.liferay.portlet.shopping.model.ShoppingItemPriceSoap;
28  
29  import java.io.Serializable;
30  
31  import java.lang.reflect.Proxy;
32  
33  import java.sql.Types;
34  
35  import java.util.ArrayList;
36  import java.util.List;
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.model.ShoppingItemPrice
54   * @see com.liferay.portlet.shopping.model.ShoppingItemPriceModel
55   * @see com.liferay.portlet.shopping.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 String DATA_SOURCE = "liferayDataSource";
93      public static final String SESSION_FACTORY = "liferaySessionFactory";
94      public static final String TX_MANAGER = "liferayTransactionManager";
95      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
96                  "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemPrice"),
97              true);
98  
99      public static ShoppingItemPrice toModel(ShoppingItemPriceSoap soapModel) {
100         ShoppingItemPrice model = new ShoppingItemPriceImpl();
101 
102         model.setItemPriceId(soapModel.getItemPriceId());
103         model.setItemId(soapModel.getItemId());
104         model.setMinQuantity(soapModel.getMinQuantity());
105         model.setMaxQuantity(soapModel.getMaxQuantity());
106         model.setPrice(soapModel.getPrice());
107         model.setDiscount(soapModel.getDiscount());
108         model.setTaxable(soapModel.getTaxable());
109         model.setShipping(soapModel.getShipping());
110         model.setUseShippingFormula(soapModel.getUseShippingFormula());
111         model.setStatus(soapModel.getStatus());
112 
113         return model;
114     }
115 
116     public static List<ShoppingItemPrice> toModels(
117         ShoppingItemPriceSoap[] soapModels) {
118         List<ShoppingItemPrice> models = new ArrayList<ShoppingItemPrice>(soapModels.length);
119 
120         for (ShoppingItemPriceSoap soapModel : soapModels) {
121             models.add(toModel(soapModel));
122         }
123 
124         return models;
125     }
126 
127     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
128                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemPrice"));
129 
130     public ShoppingItemPriceModelImpl() {
131     }
132 
133     public long getPrimaryKey() {
134         return _itemPriceId;
135     }
136 
137     public void setPrimaryKey(long pk) {
138         setItemPriceId(pk);
139     }
140 
141     public Serializable getPrimaryKeyObj() {
142         return new Long(_itemPriceId);
143     }
144 
145     public long getItemPriceId() {
146         return _itemPriceId;
147     }
148 
149     public void setItemPriceId(long itemPriceId) {
150         if (itemPriceId != _itemPriceId) {
151             _itemPriceId = itemPriceId;
152         }
153     }
154 
155     public long getItemId() {
156         return _itemId;
157     }
158 
159     public void setItemId(long itemId) {
160         if (itemId != _itemId) {
161             _itemId = itemId;
162         }
163     }
164 
165     public int getMinQuantity() {
166         return _minQuantity;
167     }
168 
169     public void setMinQuantity(int minQuantity) {
170         if (minQuantity != _minQuantity) {
171             _minQuantity = minQuantity;
172         }
173     }
174 
175     public int getMaxQuantity() {
176         return _maxQuantity;
177     }
178 
179     public void setMaxQuantity(int maxQuantity) {
180         if (maxQuantity != _maxQuantity) {
181             _maxQuantity = maxQuantity;
182         }
183     }
184 
185     public double getPrice() {
186         return _price;
187     }
188 
189     public void setPrice(double price) {
190         if (price != _price) {
191             _price = price;
192         }
193     }
194 
195     public double getDiscount() {
196         return _discount;
197     }
198 
199     public void setDiscount(double discount) {
200         if (discount != _discount) {
201             _discount = discount;
202         }
203     }
204 
205     public boolean getTaxable() {
206         return _taxable;
207     }
208 
209     public boolean isTaxable() {
210         return _taxable;
211     }
212 
213     public void setTaxable(boolean taxable) {
214         if (taxable != _taxable) {
215             _taxable = taxable;
216         }
217     }
218 
219     public double getShipping() {
220         return _shipping;
221     }
222 
223     public void setShipping(double shipping) {
224         if (shipping != _shipping) {
225             _shipping = shipping;
226         }
227     }
228 
229     public boolean getUseShippingFormula() {
230         return _useShippingFormula;
231     }
232 
233     public boolean isUseShippingFormula() {
234         return _useShippingFormula;
235     }
236 
237     public void setUseShippingFormula(boolean useShippingFormula) {
238         if (useShippingFormula != _useShippingFormula) {
239             _useShippingFormula = useShippingFormula;
240         }
241     }
242 
243     public int getStatus() {
244         return _status;
245     }
246 
247     public void setStatus(int status) {
248         if (status != _status) {
249             _status = status;
250         }
251     }
252 
253     public ShoppingItemPrice toEscapedModel() {
254         if (isEscapedModel()) {
255             return (ShoppingItemPrice)this;
256         }
257         else {
258             ShoppingItemPrice model = new ShoppingItemPriceImpl();
259 
260             model.setNew(isNew());
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 }