001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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 clone = new ShoppingItemPriceImpl();
211    
212                    clone.setItemPriceId(getItemPriceId());
213                    clone.setItemId(getItemId());
214                    clone.setMinQuantity(getMinQuantity());
215                    clone.setMaxQuantity(getMaxQuantity());
216                    clone.setPrice(getPrice());
217                    clone.setDiscount(getDiscount());
218                    clone.setTaxable(getTaxable());
219                    clone.setShipping(getShipping());
220                    clone.setUseShippingFormula(getUseShippingFormula());
221                    clone.setStatus(getStatus());
222    
223                    return clone;
224            }
225    
226            public int compareTo(ShoppingItemPrice shoppingItemPrice) {
227                    int value = 0;
228    
229                    if (getItemId() < shoppingItemPrice.getItemId()) {
230                            value = -1;
231                    }
232                    else if (getItemId() > shoppingItemPrice.getItemId()) {
233                            value = 1;
234                    }
235                    else {
236                            value = 0;
237                    }
238    
239                    if (value != 0) {
240                            return value;
241                    }
242    
243                    if (getItemPriceId() < shoppingItemPrice.getItemPriceId()) {
244                            value = -1;
245                    }
246                    else if (getItemPriceId() > shoppingItemPrice.getItemPriceId()) {
247                            value = 1;
248                    }
249                    else {
250                            value = 0;
251                    }
252    
253                    if (value != 0) {
254                            return value;
255                    }
256    
257                    return 0;
258            }
259    
260            public boolean equals(Object obj) {
261                    if (obj == null) {
262                            return false;
263                    }
264    
265                    ShoppingItemPrice shoppingItemPrice = null;
266    
267                    try {
268                            shoppingItemPrice = (ShoppingItemPrice)obj;
269                    }
270                    catch (ClassCastException cce) {
271                            return false;
272                    }
273    
274                    long pk = shoppingItemPrice.getPrimaryKey();
275    
276                    if (getPrimaryKey() == pk) {
277                            return true;
278                    }
279                    else {
280                            return false;
281                    }
282            }
283    
284            public int hashCode() {
285                    return (int)getPrimaryKey();
286            }
287    
288            public String toString() {
289                    StringBundler sb = new StringBundler(21);
290    
291                    sb.append("{itemPriceId=");
292                    sb.append(getItemPriceId());
293                    sb.append(", itemId=");
294                    sb.append(getItemId());
295                    sb.append(", minQuantity=");
296                    sb.append(getMinQuantity());
297                    sb.append(", maxQuantity=");
298                    sb.append(getMaxQuantity());
299                    sb.append(", price=");
300                    sb.append(getPrice());
301                    sb.append(", discount=");
302                    sb.append(getDiscount());
303                    sb.append(", taxable=");
304                    sb.append(getTaxable());
305                    sb.append(", shipping=");
306                    sb.append(getShipping());
307                    sb.append(", useShippingFormula=");
308                    sb.append(getUseShippingFormula());
309                    sb.append(", status=");
310                    sb.append(getStatus());
311                    sb.append("}");
312    
313                    return sb.toString();
314            }
315    
316            public String toXmlString() {
317                    StringBundler sb = new StringBundler(34);
318    
319                    sb.append("<model><model-name>");
320                    sb.append("com.liferay.portlet.shopping.model.ShoppingItemPrice");
321                    sb.append("</model-name>");
322    
323                    sb.append(
324                            "<column><column-name>itemPriceId</column-name><column-value><![CDATA[");
325                    sb.append(getItemPriceId());
326                    sb.append("]]></column-value></column>");
327                    sb.append(
328                            "<column><column-name>itemId</column-name><column-value><![CDATA[");
329                    sb.append(getItemId());
330                    sb.append("]]></column-value></column>");
331                    sb.append(
332                            "<column><column-name>minQuantity</column-name><column-value><![CDATA[");
333                    sb.append(getMinQuantity());
334                    sb.append("]]></column-value></column>");
335                    sb.append(
336                            "<column><column-name>maxQuantity</column-name><column-value><![CDATA[");
337                    sb.append(getMaxQuantity());
338                    sb.append("]]></column-value></column>");
339                    sb.append(
340                            "<column><column-name>price</column-name><column-value><![CDATA[");
341                    sb.append(getPrice());
342                    sb.append("]]></column-value></column>");
343                    sb.append(
344                            "<column><column-name>discount</column-name><column-value><![CDATA[");
345                    sb.append(getDiscount());
346                    sb.append("]]></column-value></column>");
347                    sb.append(
348                            "<column><column-name>taxable</column-name><column-value><![CDATA[");
349                    sb.append(getTaxable());
350                    sb.append("]]></column-value></column>");
351                    sb.append(
352                            "<column><column-name>shipping</column-name><column-value><![CDATA[");
353                    sb.append(getShipping());
354                    sb.append("]]></column-value></column>");
355                    sb.append(
356                            "<column><column-name>useShippingFormula</column-name><column-value><![CDATA[");
357                    sb.append(getUseShippingFormula());
358                    sb.append("]]></column-value></column>");
359                    sb.append(
360                            "<column><column-name>status</column-name><column-value><![CDATA[");
361                    sb.append(getStatus());
362                    sb.append("]]></column-value></column>");
363    
364                    sb.append("</model>");
365    
366                    return sb.toString();
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            private transient ExpandoBridge _expandoBridge;
380    }