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.setNew(isNew());
290 model.setEscapedModel(true);
291
292 model.setCartId(getCartId());
293 model.setGroupId(getGroupId());
294 model.setCompanyId(getCompanyId());
295 model.setUserId(getUserId());
296 model.setUserName(HtmlUtil.escape(getUserName()));
297 model.setCreateDate(getCreateDate());
298 model.setModifiedDate(getModifiedDate());
299 model.setItemIds(HtmlUtil.escape(getItemIds()));
300 model.setCouponCodes(HtmlUtil.escape(getCouponCodes()));
301 model.setAltShipping(getAltShipping());
302 model.setInsure(getInsure());
303
304 model = (ShoppingCart)Proxy.newProxyInstance(ShoppingCart.class.getClassLoader(),
305 new Class[] { ShoppingCart.class },
306 new ReadOnlyBeanHandler(model));
307
308 return model;
309 }
310 }
311
312 public Object clone() {
313 ShoppingCartImpl clone = new ShoppingCartImpl();
314
315 clone.setCartId(getCartId());
316 clone.setGroupId(getGroupId());
317 clone.setCompanyId(getCompanyId());
318 clone.setUserId(getUserId());
319 clone.setUserName(getUserName());
320 clone.setCreateDate(getCreateDate());
321 clone.setModifiedDate(getModifiedDate());
322 clone.setItemIds(getItemIds());
323 clone.setCouponCodes(getCouponCodes());
324 clone.setAltShipping(getAltShipping());
325 clone.setInsure(getInsure());
326
327 return clone;
328 }
329
330 public int compareTo(Object obj) {
331 if (obj == null) {
332 return -1;
333 }
334
335 ShoppingCartImpl shoppingCart = (ShoppingCartImpl)obj;
336
337 long pk = shoppingCart.getPrimaryKey();
338
339 if (getPrimaryKey() < pk) {
340 return -1;
341 }
342 else if (getPrimaryKey() > pk) {
343 return 1;
344 }
345 else {
346 return 0;
347 }
348 }
349
350 public boolean equals(Object obj) {
351 if (obj == null) {
352 return false;
353 }
354
355 ShoppingCartImpl shoppingCart = null;
356
357 try {
358 shoppingCart = (ShoppingCartImpl)obj;
359 }
360 catch (ClassCastException cce) {
361 return false;
362 }
363
364 long pk = shoppingCart.getPrimaryKey();
365
366 if (getPrimaryKey() == pk) {
367 return true;
368 }
369 else {
370 return false;
371 }
372 }
373
374 public int hashCode() {
375 return (int)getPrimaryKey();
376 }
377
378 private long _cartId;
379 private long _groupId;
380 private long _companyId;
381 private long _userId;
382 private String _userName;
383 private Date _createDate;
384 private Date _modifiedDate;
385 private String _itemIds;
386 private String _couponCodes;
387 private int _altShipping;
388 private boolean _insure;
389 }