1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.shopping.model.impl;
24  
25  import com.liferay.portal.kernel.util.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import com.liferay.util.XSSUtil;
30  
31  import java.io.Serializable;
32  
33  import java.sql.Types;
34  
35  import java.util.Date;
36  
37  /**
38   * <a href="ShoppingCartModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be overwritten
42   * the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class is a model that represents the <code>ShoppingCart</code> table in
47   * the database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portlet.shopping.service.model.ShoppingCart
53   * @see com.liferay.portlet.shopping.service.model.ShoppingCartModel
54   * @see com.liferay.portlet.shopping.service.model.impl.ShoppingCartImpl
55   *
56   */
57  public class ShoppingCartModelImpl extends BaseModelImpl {
58      public static String TABLE_NAME = "ShoppingCart";
59      public static Object[][] TABLE_COLUMNS = {
60              { "cartId", new Integer(Types.BIGINT) },
61              { "groupId", new Integer(Types.BIGINT) },
62              { "companyId", new Integer(Types.BIGINT) },
63              { "userId", new Integer(Types.BIGINT) },
64              { "userName", new Integer(Types.VARCHAR) },
65              { "createDate", new Integer(Types.TIMESTAMP) },
66              { "modifiedDate", new Integer(Types.TIMESTAMP) },
67              { "itemIds", new Integer(Types.VARCHAR) },
68              { "couponCodes", new Integer(Types.VARCHAR) },
69              { "altShipping", new Integer(Types.INTEGER) },
70              { "insure", new Integer(Types.BOOLEAN) }
71          };
72      public static 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)";
73      public static String TABLE_SQL_DROP = "drop table ShoppingCart";
74      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
75                  "xss.allow.com.liferay.portlet.shopping.model.ShoppingCart"),
76              XSS_ALLOW);
77      public static boolean XSS_ALLOW_USERNAME = GetterUtil.getBoolean(PropsUtil.get(
78                  "xss.allow.com.liferay.portlet.shopping.model.ShoppingCart.userName"),
79              XSS_ALLOW_BY_MODEL);
80      public static boolean XSS_ALLOW_ITEMIDS = GetterUtil.getBoolean(PropsUtil.get(
81                  "xss.allow.com.liferay.portlet.shopping.model.ShoppingCart.itemIds"),
82              XSS_ALLOW_BY_MODEL);
83      public static boolean XSS_ALLOW_COUPONCODES = GetterUtil.getBoolean(PropsUtil.get(
84                  "xss.allow.com.liferay.portlet.shopping.model.ShoppingCart.couponCodes"),
85              XSS_ALLOW_BY_MODEL);
86      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
87                  "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingCartModel"));
88  
89      public ShoppingCartModelImpl() {
90      }
91  
92      public long getPrimaryKey() {
93          return _cartId;
94      }
95  
96      public void setPrimaryKey(long pk) {
97          setCartId(pk);
98      }
99  
100     public Serializable getPrimaryKeyObj() {
101         return new Long(_cartId);
102     }
103 
104     public long getCartId() {
105         return _cartId;
106     }
107 
108     public void setCartId(long cartId) {
109         if (cartId != _cartId) {
110             _cartId = cartId;
111         }
112     }
113 
114     public long getGroupId() {
115         return _groupId;
116     }
117 
118     public void setGroupId(long groupId) {
119         if (groupId != _groupId) {
120             _groupId = groupId;
121         }
122     }
123 
124     public long getCompanyId() {
125         return _companyId;
126     }
127 
128     public void setCompanyId(long companyId) {
129         if (companyId != _companyId) {
130             _companyId = companyId;
131         }
132     }
133 
134     public long getUserId() {
135         return _userId;
136     }
137 
138     public void setUserId(long userId) {
139         if (userId != _userId) {
140             _userId = userId;
141         }
142     }
143 
144     public String getUserName() {
145         return GetterUtil.getString(_userName);
146     }
147 
148     public void setUserName(String userName) {
149         if (((userName == null) && (_userName != null)) ||
150                 ((userName != null) && (_userName == null)) ||
151                 ((userName != null) && (_userName != null) &&
152                 !userName.equals(_userName))) {
153             if (!XSS_ALLOW_USERNAME) {
154                 userName = XSSUtil.strip(userName);
155             }
156 
157             _userName = userName;
158         }
159     }
160 
161     public Date getCreateDate() {
162         return _createDate;
163     }
164 
165     public void setCreateDate(Date createDate) {
166         if (((createDate == null) && (_createDate != null)) ||
167                 ((createDate != null) && (_createDate == null)) ||
168                 ((createDate != null) && (_createDate != null) &&
169                 !createDate.equals(_createDate))) {
170             _createDate = createDate;
171         }
172     }
173 
174     public Date getModifiedDate() {
175         return _modifiedDate;
176     }
177 
178     public void setModifiedDate(Date modifiedDate) {
179         if (((modifiedDate == null) && (_modifiedDate != null)) ||
180                 ((modifiedDate != null) && (_modifiedDate == null)) ||
181                 ((modifiedDate != null) && (_modifiedDate != null) &&
182                 !modifiedDate.equals(_modifiedDate))) {
183             _modifiedDate = modifiedDate;
184         }
185     }
186 
187     public String getItemIds() {
188         return GetterUtil.getString(_itemIds);
189     }
190 
191     public void setItemIds(String itemIds) {
192         if (((itemIds == null) && (_itemIds != null)) ||
193                 ((itemIds != null) && (_itemIds == null)) ||
194                 ((itemIds != null) && (_itemIds != null) &&
195                 !itemIds.equals(_itemIds))) {
196             if (!XSS_ALLOW_ITEMIDS) {
197                 itemIds = XSSUtil.strip(itemIds);
198             }
199 
200             _itemIds = itemIds;
201         }
202     }
203 
204     public String getCouponCodes() {
205         return GetterUtil.getString(_couponCodes);
206     }
207 
208     public void setCouponCodes(String couponCodes) {
209         if (((couponCodes == null) && (_couponCodes != null)) ||
210                 ((couponCodes != null) && (_couponCodes == null)) ||
211                 ((couponCodes != null) && (_couponCodes != null) &&
212                 !couponCodes.equals(_couponCodes))) {
213             if (!XSS_ALLOW_COUPONCODES) {
214                 couponCodes = XSSUtil.strip(couponCodes);
215             }
216 
217             _couponCodes = couponCodes;
218         }
219     }
220 
221     public int getAltShipping() {
222         return _altShipping;
223     }
224 
225     public void setAltShipping(int altShipping) {
226         if (altShipping != _altShipping) {
227             _altShipping = altShipping;
228         }
229     }
230 
231     public boolean getInsure() {
232         return _insure;
233     }
234 
235     public boolean isInsure() {
236         return _insure;
237     }
238 
239     public void setInsure(boolean insure) {
240         if (insure != _insure) {
241             _insure = insure;
242         }
243     }
244 
245     public Object clone() {
246         ShoppingCartImpl clone = new ShoppingCartImpl();
247         clone.setCartId(getCartId());
248         clone.setGroupId(getGroupId());
249         clone.setCompanyId(getCompanyId());
250         clone.setUserId(getUserId());
251         clone.setUserName(getUserName());
252         clone.setCreateDate(getCreateDate());
253         clone.setModifiedDate(getModifiedDate());
254         clone.setItemIds(getItemIds());
255         clone.setCouponCodes(getCouponCodes());
256         clone.setAltShipping(getAltShipping());
257         clone.setInsure(getInsure());
258 
259         return clone;
260     }
261 
262     public int compareTo(Object obj) {
263         if (obj == null) {
264             return -1;
265         }
266 
267         ShoppingCartImpl shoppingCart = (ShoppingCartImpl)obj;
268         long pk = shoppingCart.getPrimaryKey();
269 
270         if (getPrimaryKey() < pk) {
271             return -1;
272         }
273         else if (getPrimaryKey() > pk) {
274             return 1;
275         }
276         else {
277             return 0;
278         }
279     }
280 
281     public boolean equals(Object obj) {
282         if (obj == null) {
283             return false;
284         }
285 
286         ShoppingCartImpl shoppingCart = null;
287 
288         try {
289             shoppingCart = (ShoppingCartImpl)obj;
290         }
291         catch (ClassCastException cce) {
292             return false;
293         }
294 
295         long pk = shoppingCart.getPrimaryKey();
296 
297         if (getPrimaryKey() == pk) {
298             return true;
299         }
300         else {
301             return false;
302         }
303     }
304 
305     public int hashCode() {
306         return (int)getPrimaryKey();
307     }
308 
309     private long _cartId;
310     private long _groupId;
311     private long _companyId;
312     private long _userId;
313     private String _userName;
314     private Date _createDate;
315     private Date _modifiedDate;
316     private String _itemIds;
317     private String _couponCodes;
318     private int _altShipping;
319     private boolean _insure;
320 }