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