1
22
23 package com.liferay.portlet.shopping.model.impl;
24
25 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26 import com.liferay.portal.kernel.util.GetterUtil;
27 import com.liferay.portal.kernel.util.HtmlUtil;
28 import com.liferay.portal.model.impl.BaseModelImpl;
29
30 import com.liferay.portlet.shopping.model.ShoppingCart;
31 import com.liferay.portlet.shopping.model.ShoppingCartSoap;
32
33 import java.io.Serializable;
34
35 import java.lang.reflect.Proxy;
36
37 import java.sql.Types;
38
39 import java.util.ArrayList;
40 import java.util.Date;
41 import java.util.List;
42
43
63 public class ShoppingCartModelImpl extends BaseModelImpl {
64 public static final String TABLE_NAME = "ShoppingCart";
65 public static final Object[][] TABLE_COLUMNS = {
66 { "cartId", new Integer(Types.BIGINT) },
67
68
69 { "groupId", new Integer(Types.BIGINT) },
70
71
72 { "companyId", new Integer(Types.BIGINT) },
73
74
75 { "userId", new Integer(Types.BIGINT) },
76
77
78 { "userName", new Integer(Types.VARCHAR) },
79
80
81 { "createDate", new Integer(Types.TIMESTAMP) },
82
83
84 { "modifiedDate", new Integer(Types.TIMESTAMP) },
85
86
87 { "itemIds", new Integer(Types.VARCHAR) },
88
89
90 { "couponCodes", new Integer(Types.VARCHAR) },
91
92
93 { "altShipping", new Integer(Types.INTEGER) },
94
95
96 { "insure", new Integer(Types.BOOLEAN) }
97 };
98 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)";
99 public static final String TABLE_SQL_DROP = "drop table ShoppingCart";
100 public static final String DATA_SOURCE = "liferayDataSource";
101 public static final String SESSION_FACTORY = "liferaySessionFactory";
102 public static final String TX_MANAGER = "liferayTransactionManager";
103 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
104 "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCart"),
105 true);
106
107 public static ShoppingCart toModel(ShoppingCartSoap soapModel) {
108 ShoppingCart model = new ShoppingCartImpl();
109
110 model.setCartId(soapModel.getCartId());
111 model.setGroupId(soapModel.getGroupId());
112 model.setCompanyId(soapModel.getCompanyId());
113 model.setUserId(soapModel.getUserId());
114 model.setUserName(soapModel.getUserName());
115 model.setCreateDate(soapModel.getCreateDate());
116 model.setModifiedDate(soapModel.getModifiedDate());
117 model.setItemIds(soapModel.getItemIds());
118 model.setCouponCodes(soapModel.getCouponCodes());
119 model.setAltShipping(soapModel.getAltShipping());
120 model.setInsure(soapModel.getInsure());
121
122 return model;
123 }
124
125 public static List<ShoppingCart> toModels(ShoppingCartSoap[] soapModels) {
126 List<ShoppingCart> models = new ArrayList<ShoppingCart>(soapModels.length);
127
128 for (ShoppingCartSoap soapModel : soapModels) {
129 models.add(toModel(soapModel));
130 }
131
132 return models;
133 }
134
135 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
136 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingCart"));
137
138 public ShoppingCartModelImpl() {
139 }
140
141 public long getPrimaryKey() {
142 return _cartId;
143 }
144
145 public void setPrimaryKey(long pk) {
146 setCartId(pk);
147 }
148
149 public Serializable getPrimaryKeyObj() {
150 return new Long(_cartId);
151 }
152
153 public long getCartId() {
154 return _cartId;
155 }
156
157 public void setCartId(long cartId) {
158 if (cartId != _cartId) {
159 _cartId = cartId;
160 }
161 }
162
163 public long getGroupId() {
164 return _groupId;
165 }
166
167 public void setGroupId(long groupId) {
168 if (groupId != _groupId) {
169 _groupId = groupId;
170 }
171 }
172
173 public long getCompanyId() {
174 return _companyId;
175 }
176
177 public void setCompanyId(long companyId) {
178 if (companyId != _companyId) {
179 _companyId = companyId;
180 }
181 }
182
183 public long getUserId() {
184 return _userId;
185 }
186
187 public void setUserId(long userId) {
188 if (userId != _userId) {
189 _userId = userId;
190 }
191 }
192
193 public String getUserName() {
194 return GetterUtil.getString(_userName);
195 }
196
197 public void setUserName(String userName) {
198 if (((userName == null) && (_userName != null)) ||
199 ((userName != null) && (_userName == null)) ||
200 ((userName != null) && (_userName != null) &&
201 !userName.equals(_userName))) {
202 _userName = userName;
203 }
204 }
205
206 public Date getCreateDate() {
207 return _createDate;
208 }
209
210 public void setCreateDate(Date createDate) {
211 if (((createDate == null) && (_createDate != null)) ||
212 ((createDate != null) && (_createDate == null)) ||
213 ((createDate != null) && (_createDate != null) &&
214 !createDate.equals(_createDate))) {
215 _createDate = createDate;
216 }
217 }
218
219 public Date getModifiedDate() {
220 return _modifiedDate;
221 }
222
223 public void setModifiedDate(Date modifiedDate) {
224 if (((modifiedDate == null) && (_modifiedDate != null)) ||
225 ((modifiedDate != null) && (_modifiedDate == null)) ||
226 ((modifiedDate != null) && (_modifiedDate != null) &&
227 !modifiedDate.equals(_modifiedDate))) {
228 _modifiedDate = modifiedDate;
229 }
230 }
231
232 public String getItemIds() {
233 return GetterUtil.getString(_itemIds);
234 }
235
236 public void setItemIds(String itemIds) {
237 if (((itemIds == null) && (_itemIds != null)) ||
238 ((itemIds != null) && (_itemIds == null)) ||
239 ((itemIds != null) && (_itemIds != null) &&
240 !itemIds.equals(_itemIds))) {
241 _itemIds = itemIds;
242 }
243 }
244
245 public String getCouponCodes() {
246 return GetterUtil.getString(_couponCodes);
247 }
248
249 public void setCouponCodes(String couponCodes) {
250 if (((couponCodes == null) && (_couponCodes != null)) ||
251 ((couponCodes != null) && (_couponCodes == null)) ||
252 ((couponCodes != null) && (_couponCodes != null) &&
253 !couponCodes.equals(_couponCodes))) {
254 _couponCodes = couponCodes;
255 }
256 }
257
258 public int getAltShipping() {
259 return _altShipping;
260 }
261
262 public void setAltShipping(int altShipping) {
263 if (altShipping != _altShipping) {
264 _altShipping = altShipping;
265 }
266 }
267
268 public boolean getInsure() {
269 return _insure;
270 }
271
272 public boolean isInsure() {
273 return _insure;
274 }
275
276 public void setInsure(boolean insure) {
277 if (insure != _insure) {
278 _insure = insure;
279 }
280 }
281
282 public ShoppingCart toEscapedModel() {
283 if (isEscapedModel()) {
284 return (ShoppingCart)this;
285 }
286 else {
287 ShoppingCart model = new ShoppingCartImpl();
288
289 model.setEscapedModel(true);
290
291 model.setCartId(getCartId());
292 model.setGroupId(getGroupId());
293 model.setCompanyId(getCompanyId());
294 model.setUserId(getUserId());
295 model.setUserName(HtmlUtil.escape(getUserName()));
296 model.setCreateDate(getCreateDate());
297 model.setModifiedDate(getModifiedDate());
298 model.setItemIds(HtmlUtil.escape(getItemIds()));
299 model.setCouponCodes(HtmlUtil.escape(getCouponCodes()));
300 model.setAltShipping(getAltShipping());
301 model.setInsure(getInsure());
302
303 model = (ShoppingCart)Proxy.newProxyInstance(ShoppingCart.class.getClassLoader(),
304 new Class[] { ShoppingCart.class },
305 new ReadOnlyBeanHandler(model));
306
307 return model;
308 }
309 }
310
311 public Object clone() {
312 ShoppingCartImpl clone = new ShoppingCartImpl();
313
314 clone.setCartId(getCartId());
315 clone.setGroupId(getGroupId());
316 clone.setCompanyId(getCompanyId());
317 clone.setUserId(getUserId());
318 clone.setUserName(getUserName());
319 clone.setCreateDate(getCreateDate());
320 clone.setModifiedDate(getModifiedDate());
321 clone.setItemIds(getItemIds());
322 clone.setCouponCodes(getCouponCodes());
323 clone.setAltShipping(getAltShipping());
324 clone.setInsure(getInsure());
325
326 return clone;
327 }
328
329 public int compareTo(Object obj) {
330 if (obj == null) {
331 return -1;
332 }
333
334 ShoppingCartImpl shoppingCart = (ShoppingCartImpl)obj;
335
336 long pk = shoppingCart.getPrimaryKey();
337
338 if (getPrimaryKey() < pk) {
339 return -1;
340 }
341 else if (getPrimaryKey() > pk) {
342 return 1;
343 }
344 else {
345 return 0;
346 }
347 }
348
349 public boolean equals(Object obj) {
350 if (obj == null) {
351 return false;
352 }
353
354 ShoppingCartImpl shoppingCart = null;
355
356 try {
357 shoppingCart = (ShoppingCartImpl)obj;
358 }
359 catch (ClassCastException cce) {
360 return false;
361 }
362
363 long pk = shoppingCart.getPrimaryKey();
364
365 if (getPrimaryKey() == pk) {
366 return true;
367 }
368 else {
369 return false;
370 }
371 }
372
373 public int hashCode() {
374 return (int)getPrimaryKey();
375 }
376
377 private long _cartId;
378 private long _groupId;
379 private long _companyId;
380 private long _userId;
381 private String _userName;
382 private Date _createDate;
383 private Date _modifiedDate;
384 private String _itemIds;
385 private String _couponCodes;
386 private int _altShipping;
387 private boolean _insure;
388 }