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.exception.SystemException;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.ProxyUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
022    import com.liferay.portal.kernel.util.StringPool;
023    import com.liferay.portal.model.CacheModel;
024    import com.liferay.portal.model.impl.BaseModelImpl;
025    import com.liferay.portal.service.ServiceContext;
026    import com.liferay.portal.util.PortalUtil;
027    
028    import com.liferay.portlet.expando.model.ExpandoBridge;
029    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
030    import com.liferay.portlet.shopping.model.ShoppingCart;
031    import com.liferay.portlet.shopping.model.ShoppingCartModel;
032    
033    import java.io.Serializable;
034    
035    import java.sql.Types;
036    
037    import java.util.Date;
038    import java.util.HashMap;
039    import java.util.Map;
040    
041    /**
042     * The base model implementation for the ShoppingCart service. Represents a row in the "ShoppingCart" database table, with each column mapped to a property of this class.
043     *
044     * <p>
045     * This implementation and its corresponding interface {@link com.liferay.portlet.shopping.model.ShoppingCartModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ShoppingCartImpl}.
046     * </p>
047     *
048     * @author Brian Wing Shun Chan
049     * @see ShoppingCartImpl
050     * @see com.liferay.portlet.shopping.model.ShoppingCart
051     * @see com.liferay.portlet.shopping.model.ShoppingCartModel
052     * @generated
053     */
054    public class ShoppingCartModelImpl extends BaseModelImpl<ShoppingCart>
055            implements ShoppingCartModel {
056            /*
057             * NOTE FOR DEVELOPERS:
058             *
059             * Never modify or reference this class directly. All methods that expect a shopping cart model instance should use the {@link com.liferay.portlet.shopping.model.ShoppingCart} interface instead.
060             */
061            public static final String TABLE_NAME = "ShoppingCart";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "cartId", Types.BIGINT },
064                            { "groupId", Types.BIGINT },
065                            { "companyId", Types.BIGINT },
066                            { "userId", Types.BIGINT },
067                            { "userName", Types.VARCHAR },
068                            { "createDate", Types.TIMESTAMP },
069                            { "modifiedDate", Types.TIMESTAMP },
070                            { "itemIds", Types.VARCHAR },
071                            { "couponCodes", Types.VARCHAR },
072                            { "altShipping", Types.INTEGER },
073                            { "insure", Types.BOOLEAN }
074                    };
075            public static final String TABLE_SQL_CREATE = "create table ShoppingCart (cartId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,itemIds STRING null,couponCodes VARCHAR(75) null,altShipping INTEGER,insure BOOLEAN)";
076            public static final String TABLE_SQL_DROP = "drop table ShoppingCart";
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.ShoppingCart"),
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.ShoppingCart"),
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.ShoppingCart"),
088                            true);
089            public static long GROUPID_COLUMN_BITMASK = 1L;
090            public static long USERID_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.ShoppingCart"));
093    
094            public ShoppingCartModelImpl() {
095            }
096    
097            public long getPrimaryKey() {
098                    return _cartId;
099            }
100    
101            public void setPrimaryKey(long primaryKey) {
102                    setCartId(primaryKey);
103            }
104    
105            public Serializable getPrimaryKeyObj() {
106                    return new Long(_cartId);
107            }
108    
109            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
110                    setPrimaryKey(((Long)primaryKeyObj).longValue());
111            }
112    
113            public Class<?> getModelClass() {
114                    return ShoppingCart.class;
115            }
116    
117            public String getModelClassName() {
118                    return ShoppingCart.class.getName();
119            }
120    
121            @Override
122            public Map<String, Object> getModelAttributes() {
123                    Map<String, Object> attributes = new HashMap<String, Object>();
124    
125                    attributes.put("cartId", getCartId());
126                    attributes.put("groupId", getGroupId());
127                    attributes.put("companyId", getCompanyId());
128                    attributes.put("userId", getUserId());
129                    attributes.put("userName", getUserName());
130                    attributes.put("createDate", getCreateDate());
131                    attributes.put("modifiedDate", getModifiedDate());
132                    attributes.put("itemIds", getItemIds());
133                    attributes.put("couponCodes", getCouponCodes());
134                    attributes.put("altShipping", getAltShipping());
135                    attributes.put("insure", getInsure());
136    
137                    return attributes;
138            }
139    
140            @Override
141            public void setModelAttributes(Map<String, Object> attributes) {
142                    Long cartId = (Long)attributes.get("cartId");
143    
144                    if (cartId != null) {
145                            setCartId(cartId);
146                    }
147    
148                    Long groupId = (Long)attributes.get("groupId");
149    
150                    if (groupId != null) {
151                            setGroupId(groupId);
152                    }
153    
154                    Long companyId = (Long)attributes.get("companyId");
155    
156                    if (companyId != null) {
157                            setCompanyId(companyId);
158                    }
159    
160                    Long userId = (Long)attributes.get("userId");
161    
162                    if (userId != null) {
163                            setUserId(userId);
164                    }
165    
166                    String userName = (String)attributes.get("userName");
167    
168                    if (userName != null) {
169                            setUserName(userName);
170                    }
171    
172                    Date createDate = (Date)attributes.get("createDate");
173    
174                    if (createDate != null) {
175                            setCreateDate(createDate);
176                    }
177    
178                    Date modifiedDate = (Date)attributes.get("modifiedDate");
179    
180                    if (modifiedDate != null) {
181                            setModifiedDate(modifiedDate);
182                    }
183    
184                    String itemIds = (String)attributes.get("itemIds");
185    
186                    if (itemIds != null) {
187                            setItemIds(itemIds);
188                    }
189    
190                    String couponCodes = (String)attributes.get("couponCodes");
191    
192                    if (couponCodes != null) {
193                            setCouponCodes(couponCodes);
194                    }
195    
196                    Integer altShipping = (Integer)attributes.get("altShipping");
197    
198                    if (altShipping != null) {
199                            setAltShipping(altShipping);
200                    }
201    
202                    Boolean insure = (Boolean)attributes.get("insure");
203    
204                    if (insure != null) {
205                            setInsure(insure);
206                    }
207            }
208    
209            public long getCartId() {
210                    return _cartId;
211            }
212    
213            public void setCartId(long cartId) {
214                    _cartId = cartId;
215            }
216    
217            public long getGroupId() {
218                    return _groupId;
219            }
220    
221            public void setGroupId(long groupId) {
222                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
223    
224                    if (!_setOriginalGroupId) {
225                            _setOriginalGroupId = true;
226    
227                            _originalGroupId = _groupId;
228                    }
229    
230                    _groupId = groupId;
231            }
232    
233            public long getOriginalGroupId() {
234                    return _originalGroupId;
235            }
236    
237            public long getCompanyId() {
238                    return _companyId;
239            }
240    
241            public void setCompanyId(long companyId) {
242                    _companyId = companyId;
243            }
244    
245            public long getUserId() {
246                    return _userId;
247            }
248    
249            public void setUserId(long userId) {
250                    _columnBitmask |= USERID_COLUMN_BITMASK;
251    
252                    if (!_setOriginalUserId) {
253                            _setOriginalUserId = true;
254    
255                            _originalUserId = _userId;
256                    }
257    
258                    _userId = userId;
259            }
260    
261            public String getUserUuid() throws SystemException {
262                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
263            }
264    
265            public void setUserUuid(String userUuid) {
266                    _userUuid = userUuid;
267            }
268    
269            public long getOriginalUserId() {
270                    return _originalUserId;
271            }
272    
273            public String getUserName() {
274                    if (_userName == null) {
275                            return StringPool.BLANK;
276                    }
277                    else {
278                            return _userName;
279                    }
280            }
281    
282            public void setUserName(String userName) {
283                    _userName = userName;
284            }
285    
286            public Date getCreateDate() {
287                    return _createDate;
288            }
289    
290            public void setCreateDate(Date createDate) {
291                    _createDate = createDate;
292            }
293    
294            public Date getModifiedDate() {
295                    return _modifiedDate;
296            }
297    
298            public void setModifiedDate(Date modifiedDate) {
299                    _modifiedDate = modifiedDate;
300            }
301    
302            public String getItemIds() {
303                    if (_itemIds == null) {
304                            return StringPool.BLANK;
305                    }
306                    else {
307                            return _itemIds;
308                    }
309            }
310    
311            public void setItemIds(String itemIds) {
312                    _itemIds = itemIds;
313            }
314    
315            public String getCouponCodes() {
316                    if (_couponCodes == null) {
317                            return StringPool.BLANK;
318                    }
319                    else {
320                            return _couponCodes;
321                    }
322            }
323    
324            public void setCouponCodes(String couponCodes) {
325                    _couponCodes = couponCodes;
326            }
327    
328            public int getAltShipping() {
329                    return _altShipping;
330            }
331    
332            public void setAltShipping(int altShipping) {
333                    _altShipping = altShipping;
334            }
335    
336            public boolean getInsure() {
337                    return _insure;
338            }
339    
340            public boolean isInsure() {
341                    return _insure;
342            }
343    
344            public void setInsure(boolean insure) {
345                    _insure = insure;
346            }
347    
348            public long getColumnBitmask() {
349                    return _columnBitmask;
350            }
351    
352            @Override
353            public ExpandoBridge getExpandoBridge() {
354                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
355                            ShoppingCart.class.getName(), getPrimaryKey());
356            }
357    
358            @Override
359            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
360                    ExpandoBridge expandoBridge = getExpandoBridge();
361    
362                    expandoBridge.setAttributes(serviceContext);
363            }
364    
365            @Override
366            public ShoppingCart toEscapedModel() {
367                    if (_escapedModel == null) {
368                            _escapedModel = (ShoppingCart)ProxyUtil.newProxyInstance(_classLoader,
369                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
370                    }
371    
372                    return _escapedModel;
373            }
374    
375            public ShoppingCart toUnescapedModel() {
376                    return (ShoppingCart)this;
377            }
378    
379            @Override
380            public Object clone() {
381                    ShoppingCartImpl shoppingCartImpl = new ShoppingCartImpl();
382    
383                    shoppingCartImpl.setCartId(getCartId());
384                    shoppingCartImpl.setGroupId(getGroupId());
385                    shoppingCartImpl.setCompanyId(getCompanyId());
386                    shoppingCartImpl.setUserId(getUserId());
387                    shoppingCartImpl.setUserName(getUserName());
388                    shoppingCartImpl.setCreateDate(getCreateDate());
389                    shoppingCartImpl.setModifiedDate(getModifiedDate());
390                    shoppingCartImpl.setItemIds(getItemIds());
391                    shoppingCartImpl.setCouponCodes(getCouponCodes());
392                    shoppingCartImpl.setAltShipping(getAltShipping());
393                    shoppingCartImpl.setInsure(getInsure());
394    
395                    shoppingCartImpl.resetOriginalValues();
396    
397                    return shoppingCartImpl;
398            }
399    
400            public int compareTo(ShoppingCart shoppingCart) {
401                    long primaryKey = shoppingCart.getPrimaryKey();
402    
403                    if (getPrimaryKey() < primaryKey) {
404                            return -1;
405                    }
406                    else if (getPrimaryKey() > primaryKey) {
407                            return 1;
408                    }
409                    else {
410                            return 0;
411                    }
412            }
413    
414            @Override
415            public boolean equals(Object obj) {
416                    if (this == obj) {
417                            return true;
418                    }
419    
420                    if (!(obj instanceof ShoppingCart)) {
421                            return false;
422                    }
423    
424                    ShoppingCart shoppingCart = (ShoppingCart)obj;
425    
426                    long primaryKey = shoppingCart.getPrimaryKey();
427    
428                    if (getPrimaryKey() == primaryKey) {
429                            return true;
430                    }
431                    else {
432                            return false;
433                    }
434            }
435    
436            @Override
437            public int hashCode() {
438                    return (int)getPrimaryKey();
439            }
440    
441            @Override
442            public void resetOriginalValues() {
443                    ShoppingCartModelImpl shoppingCartModelImpl = this;
444    
445                    shoppingCartModelImpl._originalGroupId = shoppingCartModelImpl._groupId;
446    
447                    shoppingCartModelImpl._setOriginalGroupId = false;
448    
449                    shoppingCartModelImpl._originalUserId = shoppingCartModelImpl._userId;
450    
451                    shoppingCartModelImpl._setOriginalUserId = false;
452    
453                    shoppingCartModelImpl._columnBitmask = 0;
454            }
455    
456            @Override
457            public CacheModel<ShoppingCart> toCacheModel() {
458                    ShoppingCartCacheModel shoppingCartCacheModel = new ShoppingCartCacheModel();
459    
460                    shoppingCartCacheModel.cartId = getCartId();
461    
462                    shoppingCartCacheModel.groupId = getGroupId();
463    
464                    shoppingCartCacheModel.companyId = getCompanyId();
465    
466                    shoppingCartCacheModel.userId = getUserId();
467    
468                    shoppingCartCacheModel.userName = getUserName();
469    
470                    String userName = shoppingCartCacheModel.userName;
471    
472                    if ((userName != null) && (userName.length() == 0)) {
473                            shoppingCartCacheModel.userName = null;
474                    }
475    
476                    Date createDate = getCreateDate();
477    
478                    if (createDate != null) {
479                            shoppingCartCacheModel.createDate = createDate.getTime();
480                    }
481                    else {
482                            shoppingCartCacheModel.createDate = Long.MIN_VALUE;
483                    }
484    
485                    Date modifiedDate = getModifiedDate();
486    
487                    if (modifiedDate != null) {
488                            shoppingCartCacheModel.modifiedDate = modifiedDate.getTime();
489                    }
490                    else {
491                            shoppingCartCacheModel.modifiedDate = Long.MIN_VALUE;
492                    }
493    
494                    shoppingCartCacheModel.itemIds = getItemIds();
495    
496                    String itemIds = shoppingCartCacheModel.itemIds;
497    
498                    if ((itemIds != null) && (itemIds.length() == 0)) {
499                            shoppingCartCacheModel.itemIds = null;
500                    }
501    
502                    shoppingCartCacheModel.couponCodes = getCouponCodes();
503    
504                    String couponCodes = shoppingCartCacheModel.couponCodes;
505    
506                    if ((couponCodes != null) && (couponCodes.length() == 0)) {
507                            shoppingCartCacheModel.couponCodes = null;
508                    }
509    
510                    shoppingCartCacheModel.altShipping = getAltShipping();
511    
512                    shoppingCartCacheModel.insure = getInsure();
513    
514                    return shoppingCartCacheModel;
515            }
516    
517            @Override
518            public String toString() {
519                    StringBundler sb = new StringBundler(23);
520    
521                    sb.append("{cartId=");
522                    sb.append(getCartId());
523                    sb.append(", groupId=");
524                    sb.append(getGroupId());
525                    sb.append(", companyId=");
526                    sb.append(getCompanyId());
527                    sb.append(", userId=");
528                    sb.append(getUserId());
529                    sb.append(", userName=");
530                    sb.append(getUserName());
531                    sb.append(", createDate=");
532                    sb.append(getCreateDate());
533                    sb.append(", modifiedDate=");
534                    sb.append(getModifiedDate());
535                    sb.append(", itemIds=");
536                    sb.append(getItemIds());
537                    sb.append(", couponCodes=");
538                    sb.append(getCouponCodes());
539                    sb.append(", altShipping=");
540                    sb.append(getAltShipping());
541                    sb.append(", insure=");
542                    sb.append(getInsure());
543                    sb.append("}");
544    
545                    return sb.toString();
546            }
547    
548            public String toXmlString() {
549                    StringBundler sb = new StringBundler(37);
550    
551                    sb.append("<model><model-name>");
552                    sb.append("com.liferay.portlet.shopping.model.ShoppingCart");
553                    sb.append("</model-name>");
554    
555                    sb.append(
556                            "<column><column-name>cartId</column-name><column-value><![CDATA[");
557                    sb.append(getCartId());
558                    sb.append("]]></column-value></column>");
559                    sb.append(
560                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
561                    sb.append(getGroupId());
562                    sb.append("]]></column-value></column>");
563                    sb.append(
564                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
565                    sb.append(getCompanyId());
566                    sb.append("]]></column-value></column>");
567                    sb.append(
568                            "<column><column-name>userId</column-name><column-value><![CDATA[");
569                    sb.append(getUserId());
570                    sb.append("]]></column-value></column>");
571                    sb.append(
572                            "<column><column-name>userName</column-name><column-value><![CDATA[");
573                    sb.append(getUserName());
574                    sb.append("]]></column-value></column>");
575                    sb.append(
576                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
577                    sb.append(getCreateDate());
578                    sb.append("]]></column-value></column>");
579                    sb.append(
580                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
581                    sb.append(getModifiedDate());
582                    sb.append("]]></column-value></column>");
583                    sb.append(
584                            "<column><column-name>itemIds</column-name><column-value><![CDATA[");
585                    sb.append(getItemIds());
586                    sb.append("]]></column-value></column>");
587                    sb.append(
588                            "<column><column-name>couponCodes</column-name><column-value><![CDATA[");
589                    sb.append(getCouponCodes());
590                    sb.append("]]></column-value></column>");
591                    sb.append(
592                            "<column><column-name>altShipping</column-name><column-value><![CDATA[");
593                    sb.append(getAltShipping());
594                    sb.append("]]></column-value></column>");
595                    sb.append(
596                            "<column><column-name>insure</column-name><column-value><![CDATA[");
597                    sb.append(getInsure());
598                    sb.append("]]></column-value></column>");
599    
600                    sb.append("</model>");
601    
602                    return sb.toString();
603            }
604    
605            private static ClassLoader _classLoader = ShoppingCart.class.getClassLoader();
606            private static Class<?>[] _escapedModelInterfaces = new Class[] {
607                            ShoppingCart.class
608                    };
609            private long _cartId;
610            private long _groupId;
611            private long _originalGroupId;
612            private boolean _setOriginalGroupId;
613            private long _companyId;
614            private long _userId;
615            private String _userUuid;
616            private long _originalUserId;
617            private boolean _setOriginalUserId;
618            private String _userName;
619            private Date _createDate;
620            private Date _modifiedDate;
621            private String _itemIds;
622            private String _couponCodes;
623            private int _altShipping;
624            private boolean _insure;
625            private long _columnBitmask;
626            private ShoppingCart _escapedModel;
627    }