001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.shopping.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.model.impl.BaseModelImpl;
021    import com.liferay.portal.service.ServiceContext;
022    
023    import com.liferay.portlet.expando.model.ExpandoBridge;
024    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
025    import com.liferay.portlet.shopping.model.ShoppingItemPrice;
026    import com.liferay.portlet.shopping.model.ShoppingItemPriceModel;
027    
028    import java.io.Serializable;
029    
030    import java.lang.reflect.Proxy;
031    
032    import java.sql.Types;
033    
034    /**
035     * The base model implementation for the ShoppingItemPrice service. Represents a row in the "ShoppingItemPrice" database table, with each column mapped to a property of this class.
036     *
037     * <p>
038     * This implementation and its corresponding interface {@link com.liferay.portlet.shopping.model.ShoppingItemPriceModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ShoppingItemPriceImpl}.
039     * </p>
040     *
041     * <p>
042     * Never modify or reference this class directly. All methods that expect a shopping item price model instance should use the {@link com.liferay.portlet.shopping.model.ShoppingItemPrice} interface instead.
043     * </p>
044     *
045     * @author Brian Wing Shun Chan
046     * @see ShoppingItemPriceImpl
047     * @see com.liferay.portlet.shopping.model.ShoppingItemPrice
048     * @see com.liferay.portlet.shopping.model.ShoppingItemPriceModel
049     * @generated
050     */
051    public class ShoppingItemPriceModelImpl extends BaseModelImpl<ShoppingItemPrice>
052            implements ShoppingItemPriceModel {
053            public static final String TABLE_NAME = "ShoppingItemPrice";
054            public static final Object[][] TABLE_COLUMNS = {
055                            { "itemPriceId", new Integer(Types.BIGINT) },
056                            { "itemId", new Integer(Types.BIGINT) },
057                            { "minQuantity", new Integer(Types.INTEGER) },
058                            { "maxQuantity", new Integer(Types.INTEGER) },
059                            { "price", new Integer(Types.DOUBLE) },
060                            { "discount", new Integer(Types.DOUBLE) },
061                            { "taxable", new Integer(Types.BOOLEAN) },
062                            { "shipping", new Integer(Types.DOUBLE) },
063                            { "useShippingFormula", new Integer(Types.BOOLEAN) },
064                            { "status", new Integer(Types.INTEGER) }
065                    };
066            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)";
067            public static final String TABLE_SQL_DROP = "drop table ShoppingItemPrice";
068            public static final String ORDER_BY_JPQL = " ORDER BY shoppingItemPrice.itemId ASC, shoppingItemPrice.itemPriceId ASC";
069            public static final String ORDER_BY_SQL = " ORDER BY ShoppingItemPrice.itemId ASC, ShoppingItemPrice.itemPriceId ASC";
070            public static final String DATA_SOURCE = "liferayDataSource";
071            public static final String SESSION_FACTORY = "liferaySessionFactory";
072            public static final String TX_MANAGER = "liferayTransactionManager";
073            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074                                    "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemPrice"),
075                            true);
076            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemPrice"),
078                            true);
079            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
080                                    "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemPrice"));
081    
082            public ShoppingItemPriceModelImpl() {
083            }
084    
085            public long getPrimaryKey() {
086                    return _itemPriceId;
087            }
088    
089            public void setPrimaryKey(long pk) {
090                    setItemPriceId(pk);
091            }
092    
093            public Serializable getPrimaryKeyObj() {
094                    return new Long(_itemPriceId);
095            }
096    
097            public long getItemPriceId() {
098                    return _itemPriceId;
099            }
100    
101            public void setItemPriceId(long itemPriceId) {
102                    _itemPriceId = itemPriceId;
103            }
104    
105            public long getItemId() {
106                    return _itemId;
107            }
108    
109            public void setItemId(long itemId) {
110                    _itemId = itemId;
111            }
112    
113            public int getMinQuantity() {
114                    return _minQuantity;
115            }
116    
117            public void setMinQuantity(int minQuantity) {
118                    _minQuantity = minQuantity;
119            }
120    
121            public int getMaxQuantity() {
122                    return _maxQuantity;
123            }
124    
125            public void setMaxQuantity(int maxQuantity) {
126                    _maxQuantity = maxQuantity;
127            }
128    
129            public double getPrice() {
130                    return _price;
131            }
132    
133            public void setPrice(double price) {
134                    _price = price;
135            }
136    
137            public double getDiscount() {
138                    return _discount;
139            }
140    
141            public void setDiscount(double discount) {
142                    _discount = discount;
143            }
144    
145            public boolean getTaxable() {
146                    return _taxable;
147            }
148    
149            public boolean isTaxable() {
150                    return _taxable;
151            }
152    
153            public void setTaxable(boolean taxable) {
154                    _taxable = taxable;
155            }
156    
157            public double getShipping() {
158                    return _shipping;
159            }
160    
161            public void setShipping(double shipping) {
162                    _shipping = shipping;
163            }
164    
165            public boolean getUseShippingFormula() {
166                    return _useShippingFormula;
167            }
168    
169            public boolean isUseShippingFormula() {
170                    return _useShippingFormula;
171            }
172    
173            public void setUseShippingFormula(boolean useShippingFormula) {
174                    _useShippingFormula = useShippingFormula;
175            }
176    
177            public int getStatus() {
178                    return _status;
179            }
180    
181            public void setStatus(int status) {
182                    _status = status;
183            }
184    
185            public ShoppingItemPrice toEscapedModel() {
186                    if (isEscapedModel()) {
187                            return (ShoppingItemPrice)this;
188                    }
189                    else {
190                            return (ShoppingItemPrice)Proxy.newProxyInstance(ShoppingItemPrice.class.getClassLoader(),
191                                    new Class[] { ShoppingItemPrice.class },
192                                    new AutoEscapeBeanHandler(this));
193                    }
194            }
195    
196            public ExpandoBridge getExpandoBridge() {
197                    if (_expandoBridge == null) {
198                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
199                                            ShoppingItemPrice.class.getName(), getPrimaryKey());
200                    }
201    
202                    return _expandoBridge;
203            }
204    
205            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
206                    getExpandoBridge().setAttributes(serviceContext);
207            }
208    
209            public Object clone() {
210                    ShoppingItemPriceImpl shoppingItemPriceImpl = new ShoppingItemPriceImpl();
211    
212                    shoppingItemPriceImpl.setItemPriceId(getItemPriceId());
213    
214                    shoppingItemPriceImpl.setItemId(getItemId());
215    
216                    shoppingItemPriceImpl.setMinQuantity(getMinQuantity());
217    
218                    shoppingItemPriceImpl.setMaxQuantity(getMaxQuantity());
219    
220                    shoppingItemPriceImpl.setPrice(getPrice());
221    
222                    shoppingItemPriceImpl.setDiscount(getDiscount());
223    
224                    shoppingItemPriceImpl.setTaxable(getTaxable());
225    
226                    shoppingItemPriceImpl.setShipping(getShipping());
227    
228                    shoppingItemPriceImpl.setUseShippingFormula(getUseShippingFormula());
229    
230                    shoppingItemPriceImpl.setStatus(getStatus());
231    
232                    return shoppingItemPriceImpl;
233            }
234    
235            public int compareTo(ShoppingItemPrice shoppingItemPrice) {
236                    int value = 0;
237    
238                    if (getItemId() < shoppingItemPrice.getItemId()) {
239                            value = -1;
240                    }
241                    else if (getItemId() > shoppingItemPrice.getItemId()) {
242                            value = 1;
243                    }
244                    else {
245                            value = 0;
246                    }
247    
248                    if (value != 0) {
249                            return value;
250                    }
251    
252                    if (getItemPriceId() < shoppingItemPrice.getItemPriceId()) {
253                            value = -1;
254                    }
255                    else if (getItemPriceId() > shoppingItemPrice.getItemPriceId()) {
256                            value = 1;
257                    }
258                    else {
259                            value = 0;
260                    }
261    
262                    if (value != 0) {
263                            return value;
264                    }
265    
266                    return 0;
267            }
268    
269            public boolean equals(Object obj) {
270                    if (obj == null) {
271                            return false;
272                    }
273    
274                    ShoppingItemPrice shoppingItemPrice = null;
275    
276                    try {
277                            shoppingItemPrice = (ShoppingItemPrice)obj;
278                    }
279                    catch (ClassCastException cce) {
280                            return false;
281                    }
282    
283                    long pk = shoppingItemPrice.getPrimaryKey();
284    
285                    if (getPrimaryKey() == pk) {
286                            return true;
287                    }
288                    else {
289                            return false;
290                    }
291            }
292    
293            public int hashCode() {
294                    return (int)getPrimaryKey();
295            }
296    
297            public String toString() {
298                    StringBundler sb = new StringBundler(21);
299    
300                    sb.append("{itemPriceId=");
301                    sb.append(getItemPriceId());
302                    sb.append(", itemId=");
303                    sb.append(getItemId());
304                    sb.append(", minQuantity=");
305                    sb.append(getMinQuantity());
306                    sb.append(", maxQuantity=");
307                    sb.append(getMaxQuantity());
308                    sb.append(", price=");
309                    sb.append(getPrice());
310                    sb.append(", discount=");
311                    sb.append(getDiscount());
312                    sb.append(", taxable=");
313                    sb.append(getTaxable());
314                    sb.append(", shipping=");
315                    sb.append(getShipping());
316                    sb.append(", useShippingFormula=");
317                    sb.append(getUseShippingFormula());
318                    sb.append(", status=");
319                    sb.append(getStatus());
320                    sb.append("}");
321    
322                    return sb.toString();
323            }
324    
325            public String toXmlString() {
326                    StringBundler sb = new StringBundler(34);
327    
328                    sb.append("<model><model-name>");
329                    sb.append("com.liferay.portlet.shopping.model.ShoppingItemPrice");
330                    sb.append("</model-name>");
331    
332                    sb.append(
333                            "<column><column-name>itemPriceId</column-name><column-value><![CDATA[");
334                    sb.append(getItemPriceId());
335                    sb.append("]]></column-value></column>");
336                    sb.append(
337                            "<column><column-name>itemId</column-name><column-value><![CDATA[");
338                    sb.append(getItemId());
339                    sb.append("]]></column-value></column>");
340                    sb.append(
341                            "<column><column-name>minQuantity</column-name><column-value><![CDATA[");
342                    sb.append(getMinQuantity());
343                    sb.append("]]></column-value></column>");
344                    sb.append(
345                            "<column><column-name>maxQuantity</column-name><column-value><![CDATA[");
346                    sb.append(getMaxQuantity());
347                    sb.append("]]></column-value></column>");
348                    sb.append(
349                            "<column><column-name>price</column-name><column-value><![CDATA[");
350                    sb.append(getPrice());
351                    sb.append("]]></column-value></column>");
352                    sb.append(
353                            "<column><column-name>discount</column-name><column-value><![CDATA[");
354                    sb.append(getDiscount());
355                    sb.append("]]></column-value></column>");
356                    sb.append(
357                            "<column><column-name>taxable</column-name><column-value><![CDATA[");
358                    sb.append(getTaxable());
359                    sb.append("]]></column-value></column>");
360                    sb.append(
361                            "<column><column-name>shipping</column-name><column-value><![CDATA[");
362                    sb.append(getShipping());
363                    sb.append("]]></column-value></column>");
364                    sb.append(
365                            "<column><column-name>useShippingFormula</column-name><column-value><![CDATA[");
366                    sb.append(getUseShippingFormula());
367                    sb.append("]]></column-value></column>");
368                    sb.append(
369                            "<column><column-name>status</column-name><column-value><![CDATA[");
370                    sb.append(getStatus());
371                    sb.append("]]></column-value></column>");
372    
373                    sb.append("</model>");
374    
375                    return sb.toString();
376            }
377    
378            private long _itemPriceId;
379            private long _itemId;
380            private int _minQuantity;
381            private int _maxQuantity;
382            private double _price;
383            private double _discount;
384            private boolean _taxable;
385            private double _shipping;
386            private boolean _useShippingFormula;
387            private int _status;
388            private transient ExpandoBridge _expandoBridge;
389    }