001    /**
002     * Copyright (c) 2000-2013 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            @Override
095            public long getPrimaryKey() {
096                    return _itemPriceId;
097            }
098    
099            @Override
100            public void setPrimaryKey(long primaryKey) {
101                    setItemPriceId(primaryKey);
102            }
103    
104            @Override
105            public Serializable getPrimaryKeyObj() {
106                    return _itemPriceId;
107            }
108    
109            @Override
110            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
111                    setPrimaryKey(((Long)primaryKeyObj).longValue());
112            }
113    
114            @Override
115            public Class<?> getModelClass() {
116                    return ShoppingItemPrice.class;
117            }
118    
119            @Override
120            public String getModelClassName() {
121                    return ShoppingItemPrice.class.getName();
122            }
123    
124            @Override
125            public Map<String, Object> getModelAttributes() {
126                    Map<String, Object> attributes = new HashMap<String, Object>();
127    
128                    attributes.put("itemPriceId", getItemPriceId());
129                    attributes.put("itemId", getItemId());
130                    attributes.put("minQuantity", getMinQuantity());
131                    attributes.put("maxQuantity", getMaxQuantity());
132                    attributes.put("price", getPrice());
133                    attributes.put("discount", getDiscount());
134                    attributes.put("taxable", getTaxable());
135                    attributes.put("shipping", getShipping());
136                    attributes.put("useShippingFormula", getUseShippingFormula());
137                    attributes.put("status", getStatus());
138    
139                    return attributes;
140            }
141    
142            @Override
143            public void setModelAttributes(Map<String, Object> attributes) {
144                    Long itemPriceId = (Long)attributes.get("itemPriceId");
145    
146                    if (itemPriceId != null) {
147                            setItemPriceId(itemPriceId);
148                    }
149    
150                    Long itemId = (Long)attributes.get("itemId");
151    
152                    if (itemId != null) {
153                            setItemId(itemId);
154                    }
155    
156                    Integer minQuantity = (Integer)attributes.get("minQuantity");
157    
158                    if (minQuantity != null) {
159                            setMinQuantity(minQuantity);
160                    }
161    
162                    Integer maxQuantity = (Integer)attributes.get("maxQuantity");
163    
164                    if (maxQuantity != null) {
165                            setMaxQuantity(maxQuantity);
166                    }
167    
168                    Double price = (Double)attributes.get("price");
169    
170                    if (price != null) {
171                            setPrice(price);
172                    }
173    
174                    Double discount = (Double)attributes.get("discount");
175    
176                    if (discount != null) {
177                            setDiscount(discount);
178                    }
179    
180                    Boolean taxable = (Boolean)attributes.get("taxable");
181    
182                    if (taxable != null) {
183                            setTaxable(taxable);
184                    }
185    
186                    Double shipping = (Double)attributes.get("shipping");
187    
188                    if (shipping != null) {
189                            setShipping(shipping);
190                    }
191    
192                    Boolean useShippingFormula = (Boolean)attributes.get(
193                                    "useShippingFormula");
194    
195                    if (useShippingFormula != null) {
196                            setUseShippingFormula(useShippingFormula);
197                    }
198    
199                    Integer status = (Integer)attributes.get("status");
200    
201                    if (status != null) {
202                            setStatus(status);
203                    }
204            }
205    
206            @Override
207            public long getItemPriceId() {
208                    return _itemPriceId;
209            }
210    
211            @Override
212            public void setItemPriceId(long itemPriceId) {
213                    _columnBitmask = -1L;
214    
215                    _itemPriceId = itemPriceId;
216            }
217    
218            @Override
219            public long getItemId() {
220                    return _itemId;
221            }
222    
223            @Override
224            public void setItemId(long itemId) {
225                    _columnBitmask = -1L;
226    
227                    if (!_setOriginalItemId) {
228                            _setOriginalItemId = true;
229    
230                            _originalItemId = _itemId;
231                    }
232    
233                    _itemId = itemId;
234            }
235    
236            public long getOriginalItemId() {
237                    return _originalItemId;
238            }
239    
240            @Override
241            public int getMinQuantity() {
242                    return _minQuantity;
243            }
244    
245            @Override
246            public void setMinQuantity(int minQuantity) {
247                    _minQuantity = minQuantity;
248            }
249    
250            @Override
251            public int getMaxQuantity() {
252                    return _maxQuantity;
253            }
254    
255            @Override
256            public void setMaxQuantity(int maxQuantity) {
257                    _maxQuantity = maxQuantity;
258            }
259    
260            @Override
261            public double getPrice() {
262                    return _price;
263            }
264    
265            @Override
266            public void setPrice(double price) {
267                    _price = price;
268            }
269    
270            @Override
271            public double getDiscount() {
272                    return _discount;
273            }
274    
275            @Override
276            public void setDiscount(double discount) {
277                    _discount = discount;
278            }
279    
280            @Override
281            public boolean getTaxable() {
282                    return _taxable;
283            }
284    
285            @Override
286            public boolean isTaxable() {
287                    return _taxable;
288            }
289    
290            @Override
291            public void setTaxable(boolean taxable) {
292                    _taxable = taxable;
293            }
294    
295            @Override
296            public double getShipping() {
297                    return _shipping;
298            }
299    
300            @Override
301            public void setShipping(double shipping) {
302                    _shipping = shipping;
303            }
304    
305            @Override
306            public boolean getUseShippingFormula() {
307                    return _useShippingFormula;
308            }
309    
310            @Override
311            public boolean isUseShippingFormula() {
312                    return _useShippingFormula;
313            }
314    
315            @Override
316            public void setUseShippingFormula(boolean useShippingFormula) {
317                    _useShippingFormula = useShippingFormula;
318            }
319    
320            @Override
321            public int getStatus() {
322                    return _status;
323            }
324    
325            @Override
326            public void setStatus(int status) {
327                    _status = status;
328            }
329    
330            public long getColumnBitmask() {
331                    return _columnBitmask;
332            }
333    
334            @Override
335            public ExpandoBridge getExpandoBridge() {
336                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
337                            ShoppingItemPrice.class.getName(), getPrimaryKey());
338            }
339    
340            @Override
341            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
342                    ExpandoBridge expandoBridge = getExpandoBridge();
343    
344                    expandoBridge.setAttributes(serviceContext);
345            }
346    
347            @Override
348            public ShoppingItemPrice toEscapedModel() {
349                    if (_escapedModel == null) {
350                            _escapedModel = (ShoppingItemPrice)ProxyUtil.newProxyInstance(_classLoader,
351                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
352                    }
353    
354                    return _escapedModel;
355            }
356    
357            @Override
358            public Object clone() {
359                    ShoppingItemPriceImpl shoppingItemPriceImpl = new ShoppingItemPriceImpl();
360    
361                    shoppingItemPriceImpl.setItemPriceId(getItemPriceId());
362                    shoppingItemPriceImpl.setItemId(getItemId());
363                    shoppingItemPriceImpl.setMinQuantity(getMinQuantity());
364                    shoppingItemPriceImpl.setMaxQuantity(getMaxQuantity());
365                    shoppingItemPriceImpl.setPrice(getPrice());
366                    shoppingItemPriceImpl.setDiscount(getDiscount());
367                    shoppingItemPriceImpl.setTaxable(getTaxable());
368                    shoppingItemPriceImpl.setShipping(getShipping());
369                    shoppingItemPriceImpl.setUseShippingFormula(getUseShippingFormula());
370                    shoppingItemPriceImpl.setStatus(getStatus());
371    
372                    shoppingItemPriceImpl.resetOriginalValues();
373    
374                    return shoppingItemPriceImpl;
375            }
376    
377            @Override
378            public int compareTo(ShoppingItemPrice shoppingItemPrice) {
379                    int value = 0;
380    
381                    if (getItemId() < shoppingItemPrice.getItemId()) {
382                            value = -1;
383                    }
384                    else if (getItemId() > shoppingItemPrice.getItemId()) {
385                            value = 1;
386                    }
387                    else {
388                            value = 0;
389                    }
390    
391                    if (value != 0) {
392                            return value;
393                    }
394    
395                    if (getItemPriceId() < shoppingItemPrice.getItemPriceId()) {
396                            value = -1;
397                    }
398                    else if (getItemPriceId() > shoppingItemPrice.getItemPriceId()) {
399                            value = 1;
400                    }
401                    else {
402                            value = 0;
403                    }
404    
405                    if (value != 0) {
406                            return value;
407                    }
408    
409                    return 0;
410            }
411    
412            @Override
413            public boolean equals(Object obj) {
414                    if (this == obj) {
415                            return true;
416                    }
417    
418                    if (!(obj instanceof ShoppingItemPrice)) {
419                            return false;
420                    }
421    
422                    ShoppingItemPrice shoppingItemPrice = (ShoppingItemPrice)obj;
423    
424                    long primaryKey = shoppingItemPrice.getPrimaryKey();
425    
426                    if (getPrimaryKey() == primaryKey) {
427                            return true;
428                    }
429                    else {
430                            return false;
431                    }
432            }
433    
434            @Override
435            public int hashCode() {
436                    return (int)getPrimaryKey();
437            }
438    
439            @Override
440            public void resetOriginalValues() {
441                    ShoppingItemPriceModelImpl shoppingItemPriceModelImpl = this;
442    
443                    shoppingItemPriceModelImpl._originalItemId = shoppingItemPriceModelImpl._itemId;
444    
445                    shoppingItemPriceModelImpl._setOriginalItemId = false;
446    
447                    shoppingItemPriceModelImpl._columnBitmask = 0;
448            }
449    
450            @Override
451            public CacheModel<ShoppingItemPrice> toCacheModel() {
452                    ShoppingItemPriceCacheModel shoppingItemPriceCacheModel = new ShoppingItemPriceCacheModel();
453    
454                    shoppingItemPriceCacheModel.itemPriceId = getItemPriceId();
455    
456                    shoppingItemPriceCacheModel.itemId = getItemId();
457    
458                    shoppingItemPriceCacheModel.minQuantity = getMinQuantity();
459    
460                    shoppingItemPriceCacheModel.maxQuantity = getMaxQuantity();
461    
462                    shoppingItemPriceCacheModel.price = getPrice();
463    
464                    shoppingItemPriceCacheModel.discount = getDiscount();
465    
466                    shoppingItemPriceCacheModel.taxable = getTaxable();
467    
468                    shoppingItemPriceCacheModel.shipping = getShipping();
469    
470                    shoppingItemPriceCacheModel.useShippingFormula = getUseShippingFormula();
471    
472                    shoppingItemPriceCacheModel.status = getStatus();
473    
474                    return shoppingItemPriceCacheModel;
475            }
476    
477            @Override
478            public String toString() {
479                    StringBundler sb = new StringBundler(21);
480    
481                    sb.append("{itemPriceId=");
482                    sb.append(getItemPriceId());
483                    sb.append(", itemId=");
484                    sb.append(getItemId());
485                    sb.append(", minQuantity=");
486                    sb.append(getMinQuantity());
487                    sb.append(", maxQuantity=");
488                    sb.append(getMaxQuantity());
489                    sb.append(", price=");
490                    sb.append(getPrice());
491                    sb.append(", discount=");
492                    sb.append(getDiscount());
493                    sb.append(", taxable=");
494                    sb.append(getTaxable());
495                    sb.append(", shipping=");
496                    sb.append(getShipping());
497                    sb.append(", useShippingFormula=");
498                    sb.append(getUseShippingFormula());
499                    sb.append(", status=");
500                    sb.append(getStatus());
501                    sb.append("}");
502    
503                    return sb.toString();
504            }
505    
506            @Override
507            public String toXmlString() {
508                    StringBundler sb = new StringBundler(34);
509    
510                    sb.append("<model><model-name>");
511                    sb.append("com.liferay.portlet.shopping.model.ShoppingItemPrice");
512                    sb.append("</model-name>");
513    
514                    sb.append(
515                            "<column><column-name>itemPriceId</column-name><column-value><![CDATA[");
516                    sb.append(getItemPriceId());
517                    sb.append("]]></column-value></column>");
518                    sb.append(
519                            "<column><column-name>itemId</column-name><column-value><![CDATA[");
520                    sb.append(getItemId());
521                    sb.append("]]></column-value></column>");
522                    sb.append(
523                            "<column><column-name>minQuantity</column-name><column-value><![CDATA[");
524                    sb.append(getMinQuantity());
525                    sb.append("]]></column-value></column>");
526                    sb.append(
527                            "<column><column-name>maxQuantity</column-name><column-value><![CDATA[");
528                    sb.append(getMaxQuantity());
529                    sb.append("]]></column-value></column>");
530                    sb.append(
531                            "<column><column-name>price</column-name><column-value><![CDATA[");
532                    sb.append(getPrice());
533                    sb.append("]]></column-value></column>");
534                    sb.append(
535                            "<column><column-name>discount</column-name><column-value><![CDATA[");
536                    sb.append(getDiscount());
537                    sb.append("]]></column-value></column>");
538                    sb.append(
539                            "<column><column-name>taxable</column-name><column-value><![CDATA[");
540                    sb.append(getTaxable());
541                    sb.append("]]></column-value></column>");
542                    sb.append(
543                            "<column><column-name>shipping</column-name><column-value><![CDATA[");
544                    sb.append(getShipping());
545                    sb.append("]]></column-value></column>");
546                    sb.append(
547                            "<column><column-name>useShippingFormula</column-name><column-value><![CDATA[");
548                    sb.append(getUseShippingFormula());
549                    sb.append("]]></column-value></column>");
550                    sb.append(
551                            "<column><column-name>status</column-name><column-value><![CDATA[");
552                    sb.append(getStatus());
553                    sb.append("]]></column-value></column>");
554    
555                    sb.append("</model>");
556    
557                    return sb.toString();
558            }
559    
560            private static ClassLoader _classLoader = ShoppingItemPrice.class.getClassLoader();
561            private static Class<?>[] _escapedModelInterfaces = new Class[] {
562                            ShoppingItemPrice.class
563                    };
564            private long _itemPriceId;
565            private long _itemId;
566            private long _originalItemId;
567            private boolean _setOriginalItemId;
568            private int _minQuantity;
569            private int _maxQuantity;
570            private double _price;
571            private double _discount;
572            private boolean _taxable;
573            private double _shipping;
574            private boolean _useShippingFormula;
575            private int _status;
576            private long _columnBitmask;
577            private ShoppingItemPrice _escapedModel;
578    }