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 final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
088                                    "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemPrice"));
089    
090            public ShoppingItemPriceModelImpl() {
091            }
092    
093            public long getPrimaryKey() {
094                    return _itemPriceId;
095            }
096    
097            public void setPrimaryKey(long primaryKey) {
098                    setItemPriceId(primaryKey);
099            }
100    
101            public Serializable getPrimaryKeyObj() {
102                    return new Long(_itemPriceId);
103            }
104    
105            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
106                    setPrimaryKey(((Long)primaryKeyObj).longValue());
107            }
108    
109            public Class<?> getModelClass() {
110                    return ShoppingItemPrice.class;
111            }
112    
113            public String getModelClassName() {
114                    return ShoppingItemPrice.class.getName();
115            }
116    
117            @Override
118            public Map<String, Object> getModelAttributes() {
119                    Map<String, Object> attributes = new HashMap<String, Object>();
120    
121                    attributes.put("itemPriceId", getItemPriceId());
122                    attributes.put("itemId", getItemId());
123                    attributes.put("minQuantity", getMinQuantity());
124                    attributes.put("maxQuantity", getMaxQuantity());
125                    attributes.put("price", getPrice());
126                    attributes.put("discount", getDiscount());
127                    attributes.put("taxable", getTaxable());
128                    attributes.put("shipping", getShipping());
129                    attributes.put("useShippingFormula", getUseShippingFormula());
130                    attributes.put("status", getStatus());
131    
132                    return attributes;
133            }
134    
135            @Override
136            public void setModelAttributes(Map<String, Object> attributes) {
137                    Long itemPriceId = (Long)attributes.get("itemPriceId");
138    
139                    if (itemPriceId != null) {
140                            setItemPriceId(itemPriceId);
141                    }
142    
143                    Long itemId = (Long)attributes.get("itemId");
144    
145                    if (itemId != null) {
146                            setItemId(itemId);
147                    }
148    
149                    Integer minQuantity = (Integer)attributes.get("minQuantity");
150    
151                    if (minQuantity != null) {
152                            setMinQuantity(minQuantity);
153                    }
154    
155                    Integer maxQuantity = (Integer)attributes.get("maxQuantity");
156    
157                    if (maxQuantity != null) {
158                            setMaxQuantity(maxQuantity);
159                    }
160    
161                    Double price = (Double)attributes.get("price");
162    
163                    if (price != null) {
164                            setPrice(price);
165                    }
166    
167                    Double discount = (Double)attributes.get("discount");
168    
169                    if (discount != null) {
170                            setDiscount(discount);
171                    }
172    
173                    Boolean taxable = (Boolean)attributes.get("taxable");
174    
175                    if (taxable != null) {
176                            setTaxable(taxable);
177                    }
178    
179                    Double shipping = (Double)attributes.get("shipping");
180    
181                    if (shipping != null) {
182                            setShipping(shipping);
183                    }
184    
185                    Boolean useShippingFormula = (Boolean)attributes.get(
186                                    "useShippingFormula");
187    
188                    if (useShippingFormula != null) {
189                            setUseShippingFormula(useShippingFormula);
190                    }
191    
192                    Integer status = (Integer)attributes.get("status");
193    
194                    if (status != null) {
195                            setStatus(status);
196                    }
197            }
198    
199            public long getItemPriceId() {
200                    return _itemPriceId;
201            }
202    
203            public void setItemPriceId(long itemPriceId) {
204                    _columnBitmask = -1L;
205    
206                    _itemPriceId = itemPriceId;
207            }
208    
209            public long getItemId() {
210                    return _itemId;
211            }
212    
213            public void setItemId(long itemId) {
214                    _columnBitmask = -1L;
215    
216                    if (!_setOriginalItemId) {
217                            _setOriginalItemId = true;
218    
219                            _originalItemId = _itemId;
220                    }
221    
222                    _itemId = itemId;
223            }
224    
225            public long getOriginalItemId() {
226                    return _originalItemId;
227            }
228    
229            public int getMinQuantity() {
230                    return _minQuantity;
231            }
232    
233            public void setMinQuantity(int minQuantity) {
234                    _minQuantity = minQuantity;
235            }
236    
237            public int getMaxQuantity() {
238                    return _maxQuantity;
239            }
240    
241            public void setMaxQuantity(int maxQuantity) {
242                    _maxQuantity = maxQuantity;
243            }
244    
245            public double getPrice() {
246                    return _price;
247            }
248    
249            public void setPrice(double price) {
250                    _price = price;
251            }
252    
253            public double getDiscount() {
254                    return _discount;
255            }
256    
257            public void setDiscount(double discount) {
258                    _discount = discount;
259            }
260    
261            public boolean getTaxable() {
262                    return _taxable;
263            }
264    
265            public boolean isTaxable() {
266                    return _taxable;
267            }
268    
269            public void setTaxable(boolean taxable) {
270                    _taxable = taxable;
271            }
272    
273            public double getShipping() {
274                    return _shipping;
275            }
276    
277            public void setShipping(double shipping) {
278                    _shipping = shipping;
279            }
280    
281            public boolean getUseShippingFormula() {
282                    return _useShippingFormula;
283            }
284    
285            public boolean isUseShippingFormula() {
286                    return _useShippingFormula;
287            }
288    
289            public void setUseShippingFormula(boolean useShippingFormula) {
290                    _useShippingFormula = useShippingFormula;
291            }
292    
293            public int getStatus() {
294                    return _status;
295            }
296    
297            public void setStatus(int status) {
298                    _status = status;
299            }
300    
301            public long getColumnBitmask() {
302                    return _columnBitmask;
303            }
304    
305            @Override
306            public ExpandoBridge getExpandoBridge() {
307                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
308                            ShoppingItemPrice.class.getName(), getPrimaryKey());
309            }
310    
311            @Override
312            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
313                    ExpandoBridge expandoBridge = getExpandoBridge();
314    
315                    expandoBridge.setAttributes(serviceContext);
316            }
317    
318            @Override
319            public ShoppingItemPrice toEscapedModel() {
320                    if (_escapedModel == null) {
321                            _escapedModel = (ShoppingItemPrice)ProxyUtil.newProxyInstance(_classLoader,
322                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
323                    }
324    
325                    return _escapedModel;
326            }
327    
328            public ShoppingItemPrice toUnescapedModel() {
329                    return (ShoppingItemPrice)this;
330            }
331    
332            @Override
333            public Object clone() {
334                    ShoppingItemPriceImpl shoppingItemPriceImpl = new ShoppingItemPriceImpl();
335    
336                    shoppingItemPriceImpl.setItemPriceId(getItemPriceId());
337                    shoppingItemPriceImpl.setItemId(getItemId());
338                    shoppingItemPriceImpl.setMinQuantity(getMinQuantity());
339                    shoppingItemPriceImpl.setMaxQuantity(getMaxQuantity());
340                    shoppingItemPriceImpl.setPrice(getPrice());
341                    shoppingItemPriceImpl.setDiscount(getDiscount());
342                    shoppingItemPriceImpl.setTaxable(getTaxable());
343                    shoppingItemPriceImpl.setShipping(getShipping());
344                    shoppingItemPriceImpl.setUseShippingFormula(getUseShippingFormula());
345                    shoppingItemPriceImpl.setStatus(getStatus());
346    
347                    shoppingItemPriceImpl.resetOriginalValues();
348    
349                    return shoppingItemPriceImpl;
350            }
351    
352            public int compareTo(ShoppingItemPrice shoppingItemPrice) {
353                    int value = 0;
354    
355                    if (getItemId() < shoppingItemPrice.getItemId()) {
356                            value = -1;
357                    }
358                    else if (getItemId() > shoppingItemPrice.getItemId()) {
359                            value = 1;
360                    }
361                    else {
362                            value = 0;
363                    }
364    
365                    if (value != 0) {
366                            return value;
367                    }
368    
369                    if (getItemPriceId() < shoppingItemPrice.getItemPriceId()) {
370                            value = -1;
371                    }
372                    else if (getItemPriceId() > shoppingItemPrice.getItemPriceId()) {
373                            value = 1;
374                    }
375                    else {
376                            value = 0;
377                    }
378    
379                    if (value != 0) {
380                            return value;
381                    }
382    
383                    return 0;
384            }
385    
386            @Override
387            public boolean equals(Object obj) {
388                    if (this == obj) {
389                            return true;
390                    }
391    
392                    if (!(obj instanceof ShoppingItemPrice)) {
393                            return false;
394                    }
395    
396                    ShoppingItemPrice shoppingItemPrice = (ShoppingItemPrice)obj;
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    }