001    /**
002     * Copyright (c) 2000-2012 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.ProxyUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.model.CacheModel;
022    import com.liferay.portal.model.impl.BaseModelImpl;
023    import com.liferay.portal.service.ServiceContext;
024    
025    import com.liferay.portlet.expando.model.ExpandoBridge;
026    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
027    import com.liferay.portlet.shopping.model.ShoppingItemPrice;
028    import com.liferay.portlet.shopping.model.ShoppingItemPriceModel;
029    
030    import java.io.Serializable;
031    
032    import java.sql.Types;
033    
034    import java.util.HashMap;
035    import java.util.Map;
036    
037    /**
038     * 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.
039     *
040     * <p>
041     * 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}.
042     * </p>
043     *
044     * @author Brian Wing Shun Chan
045     * @see ShoppingItemPriceImpl
046     * @see com.liferay.portlet.shopping.model.ShoppingItemPrice
047     * @see com.liferay.portlet.shopping.model.ShoppingItemPriceModel
048     * @generated
049     */
050    public class ShoppingItemPriceModelImpl extends BaseModelImpl<ShoppingItemPrice>
051            implements ShoppingItemPriceModel {
052            /*
053             * NOTE FOR DEVELOPERS:
054             *
055             * 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.
056             */
057            public static final String TABLE_NAME = "ShoppingItemPrice";
058            public static final Object[][] TABLE_COLUMNS = {
059                            { "itemPriceId", Types.BIGINT },
060                            { "itemId", Types.BIGINT },
061                            { "minQuantity", Types.INTEGER },
062                            { "maxQuantity", Types.INTEGER },
063                            { "price", Types.DOUBLE },
064                            { "discount", Types.DOUBLE },
065                            { "taxable", Types.BOOLEAN },
066                            { "shipping", Types.DOUBLE },
067                            { "useShippingFormula", Types.BOOLEAN },
068                            { "status", Types.INTEGER }
069                    };
070            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)";
071            public static final String TABLE_SQL_DROP = "drop table ShoppingItemPrice";
072            public static final String ORDER_BY_JPQL = " ORDER BY shoppingItemPrice.itemId ASC, shoppingItemPrice.itemPriceId ASC";
073            public static final String ORDER_BY_SQL = " ORDER BY ShoppingItemPrice.itemId ASC, ShoppingItemPrice.itemPriceId ASC";
074            public static final String DATA_SOURCE = "liferayDataSource";
075            public static final String SESSION_FACTORY = "liferaySessionFactory";
076            public static final String TX_MANAGER = "liferayTransactionManager";
077            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
078                                    "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemPrice"),
079                            true);
080            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
081                                    "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemPrice"),
082                            true);
083            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084                                    "value.object.column.bitmask.enabled.com.liferay.portlet.shopping.model.ShoppingItemPrice"),
085                            true);
086            public static long ITEMID_COLUMN_BITMASK = 1L;
087            public static long ITEMPRICEID_COLUMN_BITMASK = 2L;
088            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
089                                    "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemPrice"));
090    
091            public ShoppingItemPriceModelImpl() {
092            }
093    
094            public long getPrimaryKey() {
095                    return _itemPriceId;
096            }
097    
098            public void setPrimaryKey(long primaryKey) {
099                    setItemPriceId(primaryKey);
100            }
101    
102            public Serializable getPrimaryKeyObj() {
103                    return new Long(_itemPriceId);
104            }
105    
106            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
107                    setPrimaryKey(((Long)primaryKeyObj).longValue());
108            }
109    
110            public Class<?> getModelClass() {
111                    return ShoppingItemPrice.class;
112            }
113    
114            public String getModelClassName() {
115                    return ShoppingItemPrice.class.getName();
116            }
117    
118            @Override
119            public Map<String, Object> getModelAttributes() {
120                    Map<String, Object> attributes = new HashMap<String, Object>();
121    
122                    attributes.put("itemPriceId", getItemPriceId());
123                    attributes.put("itemId", getItemId());
124                    attributes.put("minQuantity", getMinQuantity());
125                    attributes.put("maxQuantity", getMaxQuantity());
126                    attributes.put("price", getPrice());
127                    attributes.put("discount", getDiscount());
128                    attributes.put("taxable", getTaxable());
129                    attributes.put("shipping", getShipping());
130                    attributes.put("useShippingFormula", getUseShippingFormula());
131                    attributes.put("status", getStatus());
132    
133                    return attributes;
134            }
135    
136            @Override
137            public void setModelAttributes(Map<String, Object> attributes) {
138                    Long itemPriceId = (Long)attributes.get("itemPriceId");
139    
140                    if (itemPriceId != null) {
141                            setItemPriceId(itemPriceId);
142                    }
143    
144                    Long itemId = (Long)attributes.get("itemId");
145    
146                    if (itemId != null) {
147                            setItemId(itemId);
148                    }
149    
150                    Integer minQuantity = (Integer)attributes.get("minQuantity");
151    
152                    if (minQuantity != null) {
153                            setMinQuantity(minQuantity);
154                    }
155    
156                    Integer maxQuantity = (Integer)attributes.get("maxQuantity");
157    
158                    if (maxQuantity != null) {
159                            setMaxQuantity(maxQuantity);
160                    }
161    
162                    Double price = (Double)attributes.get("price");
163    
164                    if (price != null) {
165                            setPrice(price);
166                    }
167    
168                    Double discount = (Double)attributes.get("discount");
169    
170                    if (discount != null) {
171                            setDiscount(discount);
172                    }
173    
174                    Boolean taxable = (Boolean)attributes.get("taxable");
175    
176                    if (taxable != null) {
177                            setTaxable(taxable);
178                    }
179    
180                    Double shipping = (Double)attributes.get("shipping");
181    
182                    if (shipping != null) {
183                            setShipping(shipping);
184                    }
185    
186                    Boolean useShippingFormula = (Boolean)attributes.get(
187                                    "useShippingFormula");
188    
189                    if (useShippingFormula != null) {
190                            setUseShippingFormula(useShippingFormula);
191                    }
192    
193                    Integer status = (Integer)attributes.get("status");
194    
195                    if (status != null) {
196                            setStatus(status);
197                    }
198            }
199    
200            public long getItemPriceId() {
201                    return _itemPriceId;
202            }
203    
204            public void setItemPriceId(long itemPriceId) {
205                    _columnBitmask = -1L;
206    
207                    _itemPriceId = itemPriceId;
208            }
209    
210            public long getItemId() {
211                    return _itemId;
212            }
213    
214            public void setItemId(long itemId) {
215                    _columnBitmask = -1L;
216    
217                    if (!_setOriginalItemId) {
218                            _setOriginalItemId = true;
219    
220                            _originalItemId = _itemId;
221                    }
222    
223                    _itemId = itemId;
224            }
225    
226            public long getOriginalItemId() {
227                    return _originalItemId;
228            }
229    
230            public int getMinQuantity() {
231                    return _minQuantity;
232            }
233    
234            public void setMinQuantity(int minQuantity) {
235                    _minQuantity = minQuantity;
236            }
237    
238            public int getMaxQuantity() {
239                    return _maxQuantity;
240            }
241    
242            public void setMaxQuantity(int maxQuantity) {
243                    _maxQuantity = maxQuantity;
244            }
245    
246            public double getPrice() {
247                    return _price;
248            }
249    
250            public void setPrice(double price) {
251                    _price = price;
252            }
253    
254            public double getDiscount() {
255                    return _discount;
256            }
257    
258            public void setDiscount(double discount) {
259                    _discount = discount;
260            }
261    
262            public boolean getTaxable() {
263                    return _taxable;
264            }
265    
266            public boolean isTaxable() {
267                    return _taxable;
268            }
269    
270            public void setTaxable(boolean taxable) {
271                    _taxable = taxable;
272            }
273    
274            public double getShipping() {
275                    return _shipping;
276            }
277    
278            public void setShipping(double shipping) {
279                    _shipping = shipping;
280            }
281    
282            public boolean getUseShippingFormula() {
283                    return _useShippingFormula;
284            }
285    
286            public boolean isUseShippingFormula() {
287                    return _useShippingFormula;
288            }
289    
290            public void setUseShippingFormula(boolean useShippingFormula) {
291                    _useShippingFormula = useShippingFormula;
292            }
293    
294            public int getStatus() {
295                    return _status;
296            }
297    
298            public void setStatus(int status) {
299                    _status = status;
300            }
301    
302            public long getColumnBitmask() {
303                    return _columnBitmask;
304            }
305    
306            @Override
307            public ExpandoBridge getExpandoBridge() {
308                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
309                            ShoppingItemPrice.class.getName(), getPrimaryKey());
310            }
311    
312            @Override
313            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
314                    ExpandoBridge expandoBridge = getExpandoBridge();
315    
316                    expandoBridge.setAttributes(serviceContext);
317            }
318    
319            @Override
320            public ShoppingItemPrice toEscapedModel() {
321                    if (_escapedModel == null) {
322                            _escapedModel = (ShoppingItemPrice)ProxyUtil.newProxyInstance(_classLoader,
323                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
324                    }
325    
326                    return _escapedModel;
327            }
328    
329            @Override
330            public Object clone() {
331                    ShoppingItemPriceImpl shoppingItemPriceImpl = new ShoppingItemPriceImpl();
332    
333                    shoppingItemPriceImpl.setItemPriceId(getItemPriceId());
334                    shoppingItemPriceImpl.setItemId(getItemId());
335                    shoppingItemPriceImpl.setMinQuantity(getMinQuantity());
336                    shoppingItemPriceImpl.setMaxQuantity(getMaxQuantity());
337                    shoppingItemPriceImpl.setPrice(getPrice());
338                    shoppingItemPriceImpl.setDiscount(getDiscount());
339                    shoppingItemPriceImpl.setTaxable(getTaxable());
340                    shoppingItemPriceImpl.setShipping(getShipping());
341                    shoppingItemPriceImpl.setUseShippingFormula(getUseShippingFormula());
342                    shoppingItemPriceImpl.setStatus(getStatus());
343    
344                    shoppingItemPriceImpl.resetOriginalValues();
345    
346                    return shoppingItemPriceImpl;
347            }
348    
349            public int compareTo(ShoppingItemPrice shoppingItemPrice) {
350                    int value = 0;
351    
352                    if (getItemId() < shoppingItemPrice.getItemId()) {
353                            value = -1;
354                    }
355                    else if (getItemId() > shoppingItemPrice.getItemId()) {
356                            value = 1;
357                    }
358                    else {
359                            value = 0;
360                    }
361    
362                    if (value != 0) {
363                            return value;
364                    }
365    
366                    if (getItemPriceId() < shoppingItemPrice.getItemPriceId()) {
367                            value = -1;
368                    }
369                    else if (getItemPriceId() > shoppingItemPrice.getItemPriceId()) {
370                            value = 1;
371                    }
372                    else {
373                            value = 0;
374                    }
375    
376                    if (value != 0) {
377                            return value;
378                    }
379    
380                    return 0;
381            }
382    
383            @Override
384            public boolean equals(Object obj) {
385                    if (obj == null) {
386                            return false;
387                    }
388    
389                    ShoppingItemPrice shoppingItemPrice = null;
390    
391                    try {
392                            shoppingItemPrice = (ShoppingItemPrice)obj;
393                    }
394                    catch (ClassCastException cce) {
395                            return false;
396                    }
397    
398                    long primaryKey = shoppingItemPrice.getPrimaryKey();
399    
400                    if (getPrimaryKey() == primaryKey) {
401                            return true;
402                    }
403                    else {
404                            return false;
405                    }
406            }
407    
408            @Override
409            public int hashCode() {
410                    return (int)getPrimaryKey();
411            }
412    
413            @Override
414            public void resetOriginalValues() {
415                    ShoppingItemPriceModelImpl shoppingItemPriceModelImpl = this;
416    
417                    shoppingItemPriceModelImpl._originalItemId = shoppingItemPriceModelImpl._itemId;
418    
419                    shoppingItemPriceModelImpl._setOriginalItemId = false;
420    
421                    shoppingItemPriceModelImpl._columnBitmask = 0;
422            }
423    
424            @Override
425            public CacheModel<ShoppingItemPrice> toCacheModel() {
426                    ShoppingItemPriceCacheModel shoppingItemPriceCacheModel = new ShoppingItemPriceCacheModel();
427    
428                    shoppingItemPriceCacheModel.itemPriceId = getItemPriceId();
429    
430                    shoppingItemPriceCacheModel.itemId = getItemId();
431    
432                    shoppingItemPriceCacheModel.minQuantity = getMinQuantity();
433    
434                    shoppingItemPriceCacheModel.maxQuantity = getMaxQuantity();
435    
436                    shoppingItemPriceCacheModel.price = getPrice();
437    
438                    shoppingItemPriceCacheModel.discount = getDiscount();
439    
440                    shoppingItemPriceCacheModel.taxable = getTaxable();
441    
442                    shoppingItemPriceCacheModel.shipping = getShipping();
443    
444                    shoppingItemPriceCacheModel.useShippingFormula = getUseShippingFormula();
445    
446                    shoppingItemPriceCacheModel.status = getStatus();
447    
448                    return shoppingItemPriceCacheModel;
449            }
450    
451            @Override
452            public String toString() {
453                    StringBundler sb = new StringBundler(21);
454    
455                    sb.append("{itemPriceId=");
456                    sb.append(getItemPriceId());
457                    sb.append(", itemId=");
458                    sb.append(getItemId());
459                    sb.append(", minQuantity=");
460                    sb.append(getMinQuantity());
461                    sb.append(", maxQuantity=");
462                    sb.append(getMaxQuantity());
463                    sb.append(", price=");
464                    sb.append(getPrice());
465                    sb.append(", discount=");
466                    sb.append(getDiscount());
467                    sb.append(", taxable=");
468                    sb.append(getTaxable());
469                    sb.append(", shipping=");
470                    sb.append(getShipping());
471                    sb.append(", useShippingFormula=");
472                    sb.append(getUseShippingFormula());
473                    sb.append(", status=");
474                    sb.append(getStatus());
475                    sb.append("}");
476    
477                    return sb.toString();
478            }
479    
480            public String toXmlString() {
481                    StringBundler sb = new StringBundler(34);
482    
483                    sb.append("<model><model-name>");
484                    sb.append("com.liferay.portlet.shopping.model.ShoppingItemPrice");
485                    sb.append("</model-name>");
486    
487                    sb.append(
488                            "<column><column-name>itemPriceId</column-name><column-value><![CDATA[");
489                    sb.append(getItemPriceId());
490                    sb.append("]]></column-value></column>");
491                    sb.append(
492                            "<column><column-name>itemId</column-name><column-value><![CDATA[");
493                    sb.append(getItemId());
494                    sb.append("]]></column-value></column>");
495                    sb.append(
496                            "<column><column-name>minQuantity</column-name><column-value><![CDATA[");
497                    sb.append(getMinQuantity());
498                    sb.append("]]></column-value></column>");
499                    sb.append(
500                            "<column><column-name>maxQuantity</column-name><column-value><![CDATA[");
501                    sb.append(getMaxQuantity());
502                    sb.append("]]></column-value></column>");
503                    sb.append(
504                            "<column><column-name>price</column-name><column-value><![CDATA[");
505                    sb.append(getPrice());
506                    sb.append("]]></column-value></column>");
507                    sb.append(
508                            "<column><column-name>discount</column-name><column-value><![CDATA[");
509                    sb.append(getDiscount());
510                    sb.append("]]></column-value></column>");
511                    sb.append(
512                            "<column><column-name>taxable</column-name><column-value><![CDATA[");
513                    sb.append(getTaxable());
514                    sb.append("]]></column-value></column>");
515                    sb.append(
516                            "<column><column-name>shipping</column-name><column-value><![CDATA[");
517                    sb.append(getShipping());
518                    sb.append("]]></column-value></column>");
519                    sb.append(
520                            "<column><column-name>useShippingFormula</column-name><column-value><![CDATA[");
521                    sb.append(getUseShippingFormula());
522                    sb.append("]]></column-value></column>");
523                    sb.append(
524                            "<column><column-name>status</column-name><column-value><![CDATA[");
525                    sb.append(getStatus());
526                    sb.append("]]></column-value></column>");
527    
528                    sb.append("</model>");
529    
530                    return sb.toString();
531            }
532    
533            private static ClassLoader _classLoader = ShoppingItemPrice.class.getClassLoader();
534            private static Class<?>[] _escapedModelInterfaces = new Class[] {
535                            ShoppingItemPrice.class
536                    };
537            private long _itemPriceId;
538            private long _itemId;
539            private long _originalItemId;
540            private boolean _setOriginalItemId;
541            private int _minQuantity;
542            private int _maxQuantity;
543            private double _price;
544            private double _discount;
545            private boolean _taxable;
546            private double _shipping;
547            private boolean _useShippingFormula;
548            private int _status;
549            private long _columnBitmask;
550            private ShoppingItemPrice _escapedModel;
551    }