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.DateUtil;
27 import com.liferay.portal.kernel.util.GetterUtil;
28 import com.liferay.portal.kernel.util.HtmlUtil;
29 import com.liferay.portal.model.impl.BaseModelImpl;
30 import com.liferay.portal.util.PropsUtil;
31
32 import com.liferay.portlet.shopping.model.ShoppingCoupon;
33 import com.liferay.portlet.shopping.model.ShoppingCouponSoap;
34
35 import java.io.Serializable;
36
37 import java.lang.reflect.Proxy;
38
39 import java.sql.Types;
40
41 import java.util.ArrayList;
42 import java.util.Date;
43 import java.util.List;
44
45
65 public class ShoppingCouponModelImpl extends BaseModelImpl {
66 public static final String TABLE_NAME = "ShoppingCoupon";
67 public static final Object[][] TABLE_COLUMNS = {
68 { "couponId", new Integer(Types.BIGINT) },
69
70
71 { "groupId", new Integer(Types.BIGINT) },
72
73
74 { "companyId", new Integer(Types.BIGINT) },
75
76
77 { "userId", new Integer(Types.BIGINT) },
78
79
80 { "userName", new Integer(Types.VARCHAR) },
81
82
83 { "createDate", new Integer(Types.TIMESTAMP) },
84
85
86 { "modifiedDate", new Integer(Types.TIMESTAMP) },
87
88
89 { "code_", new Integer(Types.VARCHAR) },
90
91
92 { "name", new Integer(Types.VARCHAR) },
93
94
95 { "description", new Integer(Types.VARCHAR) },
96
97
98 { "startDate", new Integer(Types.TIMESTAMP) },
99
100
101 { "endDate", new Integer(Types.TIMESTAMP) },
102
103
104 { "active_", new Integer(Types.BOOLEAN) },
105
106
107 { "limitCategories", new Integer(Types.VARCHAR) },
108
109
110 { "limitSkus", new Integer(Types.VARCHAR) },
111
112
113 { "minOrder", new Integer(Types.DOUBLE) },
114
115
116 { "discount", new Integer(Types.DOUBLE) },
117
118
119 { "discountType", new Integer(Types.VARCHAR) }
120 };
121 public static final String TABLE_SQL_CREATE = "create table ShoppingCoupon (couponId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,code_ VARCHAR(75) null,name VARCHAR(75) null,description STRING null,startDate DATE null,endDate DATE null,active_ BOOLEAN,limitCategories STRING null,limitSkus STRING null,minOrder DOUBLE,discount DOUBLE,discountType VARCHAR(75) null)";
122 public static final String TABLE_SQL_DROP = "drop table ShoppingCoupon";
123 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
124 "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCoupon"),
125 true);
126
127 public static ShoppingCoupon toModel(ShoppingCouponSoap soapModel) {
128 ShoppingCoupon model = new ShoppingCouponImpl();
129
130 model.setCouponId(soapModel.getCouponId());
131 model.setGroupId(soapModel.getGroupId());
132 model.setCompanyId(soapModel.getCompanyId());
133 model.setUserId(soapModel.getUserId());
134 model.setUserName(soapModel.getUserName());
135 model.setCreateDate(soapModel.getCreateDate());
136 model.setModifiedDate(soapModel.getModifiedDate());
137 model.setCode(soapModel.getCode());
138 model.setName(soapModel.getName());
139 model.setDescription(soapModel.getDescription());
140 model.setStartDate(soapModel.getStartDate());
141 model.setEndDate(soapModel.getEndDate());
142 model.setActive(soapModel.getActive());
143 model.setLimitCategories(soapModel.getLimitCategories());
144 model.setLimitSkus(soapModel.getLimitSkus());
145 model.setMinOrder(soapModel.getMinOrder());
146 model.setDiscount(soapModel.getDiscount());
147 model.setDiscountType(soapModel.getDiscountType());
148
149 return model;
150 }
151
152 public static List<ShoppingCoupon> toModels(ShoppingCouponSoap[] soapModels) {
153 List<ShoppingCoupon> models = new ArrayList<ShoppingCoupon>(soapModels.length);
154
155 for (ShoppingCouponSoap soapModel : soapModels) {
156 models.add(toModel(soapModel));
157 }
158
159 return models;
160 }
161
162 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
163 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingCoupon"));
164
165 public ShoppingCouponModelImpl() {
166 }
167
168 public long getPrimaryKey() {
169 return _couponId;
170 }
171
172 public void setPrimaryKey(long pk) {
173 setCouponId(pk);
174 }
175
176 public Serializable getPrimaryKeyObj() {
177 return new Long(_couponId);
178 }
179
180 public long getCouponId() {
181 return _couponId;
182 }
183
184 public void setCouponId(long couponId) {
185 if (couponId != _couponId) {
186 _couponId = couponId;
187 }
188 }
189
190 public long getGroupId() {
191 return _groupId;
192 }
193
194 public void setGroupId(long groupId) {
195 if (groupId != _groupId) {
196 _groupId = groupId;
197 }
198 }
199
200 public long getCompanyId() {
201 return _companyId;
202 }
203
204 public void setCompanyId(long companyId) {
205 if (companyId != _companyId) {
206 _companyId = companyId;
207 }
208 }
209
210 public long getUserId() {
211 return _userId;
212 }
213
214 public void setUserId(long userId) {
215 if (userId != _userId) {
216 _userId = userId;
217 }
218 }
219
220 public String getUserName() {
221 return GetterUtil.getString(_userName);
222 }
223
224 public void setUserName(String userName) {
225 if (((userName == null) && (_userName != null)) ||
226 ((userName != null) && (_userName == null)) ||
227 ((userName != null) && (_userName != null) &&
228 !userName.equals(_userName))) {
229 _userName = userName;
230 }
231 }
232
233 public Date getCreateDate() {
234 return _createDate;
235 }
236
237 public void setCreateDate(Date createDate) {
238 if (((createDate == null) && (_createDate != null)) ||
239 ((createDate != null) && (_createDate == null)) ||
240 ((createDate != null) && (_createDate != null) &&
241 !createDate.equals(_createDate))) {
242 _createDate = createDate;
243 }
244 }
245
246 public Date getModifiedDate() {
247 return _modifiedDate;
248 }
249
250 public void setModifiedDate(Date modifiedDate) {
251 if (((modifiedDate == null) && (_modifiedDate != null)) ||
252 ((modifiedDate != null) && (_modifiedDate == null)) ||
253 ((modifiedDate != null) && (_modifiedDate != null) &&
254 !modifiedDate.equals(_modifiedDate))) {
255 _modifiedDate = modifiedDate;
256 }
257 }
258
259 public String getCode() {
260 return GetterUtil.getString(_code);
261 }
262
263 public void setCode(String code) {
264 if (((code == null) && (_code != null)) ||
265 ((code != null) && (_code == null)) ||
266 ((code != null) && (_code != null) && !code.equals(_code))) {
267 _code = code;
268 }
269 }
270
271 public String getName() {
272 return GetterUtil.getString(_name);
273 }
274
275 public void setName(String name) {
276 if (((name == null) && (_name != null)) ||
277 ((name != null) && (_name == null)) ||
278 ((name != null) && (_name != null) && !name.equals(_name))) {
279 _name = name;
280 }
281 }
282
283 public String getDescription() {
284 return GetterUtil.getString(_description);
285 }
286
287 public void setDescription(String description) {
288 if (((description == null) && (_description != null)) ||
289 ((description != null) && (_description == null)) ||
290 ((description != null) && (_description != null) &&
291 !description.equals(_description))) {
292 _description = description;
293 }
294 }
295
296 public Date getStartDate() {
297 return _startDate;
298 }
299
300 public void setStartDate(Date startDate) {
301 if (((startDate == null) && (_startDate != null)) ||
302 ((startDate != null) && (_startDate == null)) ||
303 ((startDate != null) && (_startDate != null) &&
304 !startDate.equals(_startDate))) {
305 _startDate = startDate;
306 }
307 }
308
309 public Date getEndDate() {
310 return _endDate;
311 }
312
313 public void setEndDate(Date endDate) {
314 if (((endDate == null) && (_endDate != null)) ||
315 ((endDate != null) && (_endDate == null)) ||
316 ((endDate != null) && (_endDate != null) &&
317 !endDate.equals(_endDate))) {
318 _endDate = endDate;
319 }
320 }
321
322 public boolean getActive() {
323 return _active;
324 }
325
326 public boolean isActive() {
327 return _active;
328 }
329
330 public void setActive(boolean active) {
331 if (active != _active) {
332 _active = active;
333 }
334 }
335
336 public String getLimitCategories() {
337 return GetterUtil.getString(_limitCategories);
338 }
339
340 public void setLimitCategories(String limitCategories) {
341 if (((limitCategories == null) && (_limitCategories != null)) ||
342 ((limitCategories != null) && (_limitCategories == null)) ||
343 ((limitCategories != null) && (_limitCategories != null) &&
344 !limitCategories.equals(_limitCategories))) {
345 _limitCategories = limitCategories;
346 }
347 }
348
349 public String getLimitSkus() {
350 return GetterUtil.getString(_limitSkus);
351 }
352
353 public void setLimitSkus(String limitSkus) {
354 if (((limitSkus == null) && (_limitSkus != null)) ||
355 ((limitSkus != null) && (_limitSkus == null)) ||
356 ((limitSkus != null) && (_limitSkus != null) &&
357 !limitSkus.equals(_limitSkus))) {
358 _limitSkus = limitSkus;
359 }
360 }
361
362 public double getMinOrder() {
363 return _minOrder;
364 }
365
366 public void setMinOrder(double minOrder) {
367 if (minOrder != _minOrder) {
368 _minOrder = minOrder;
369 }
370 }
371
372 public double getDiscount() {
373 return _discount;
374 }
375
376 public void setDiscount(double discount) {
377 if (discount != _discount) {
378 _discount = discount;
379 }
380 }
381
382 public String getDiscountType() {
383 return GetterUtil.getString(_discountType);
384 }
385
386 public void setDiscountType(String discountType) {
387 if (((discountType == null) && (_discountType != null)) ||
388 ((discountType != null) && (_discountType == null)) ||
389 ((discountType != null) && (_discountType != null) &&
390 !discountType.equals(_discountType))) {
391 _discountType = discountType;
392 }
393 }
394
395 public ShoppingCoupon toEscapedModel() {
396 if (isEscapedModel()) {
397 return (ShoppingCoupon)this;
398 }
399 else {
400 ShoppingCoupon model = new ShoppingCouponImpl();
401
402 model.setEscapedModel(true);
403
404 model.setCouponId(getCouponId());
405 model.setGroupId(getGroupId());
406 model.setCompanyId(getCompanyId());
407 model.setUserId(getUserId());
408 model.setUserName(HtmlUtil.escape(getUserName()));
409 model.setCreateDate(getCreateDate());
410 model.setModifiedDate(getModifiedDate());
411 model.setCode(HtmlUtil.escape(getCode()));
412 model.setName(HtmlUtil.escape(getName()));
413 model.setDescription(HtmlUtil.escape(getDescription()));
414 model.setStartDate(getStartDate());
415 model.setEndDate(getEndDate());
416 model.setActive(getActive());
417 model.setLimitCategories(HtmlUtil.escape(getLimitCategories()));
418 model.setLimitSkus(HtmlUtil.escape(getLimitSkus()));
419 model.setMinOrder(getMinOrder());
420 model.setDiscount(getDiscount());
421 model.setDiscountType(HtmlUtil.escape(getDiscountType()));
422
423 model = (ShoppingCoupon)Proxy.newProxyInstance(ShoppingCoupon.class.getClassLoader(),
424 new Class[] { ShoppingCoupon.class },
425 new ReadOnlyBeanHandler(model));
426
427 return model;
428 }
429 }
430
431 public Object clone() {
432 ShoppingCouponImpl clone = new ShoppingCouponImpl();
433
434 clone.setCouponId(getCouponId());
435 clone.setGroupId(getGroupId());
436 clone.setCompanyId(getCompanyId());
437 clone.setUserId(getUserId());
438 clone.setUserName(getUserName());
439 clone.setCreateDate(getCreateDate());
440 clone.setModifiedDate(getModifiedDate());
441 clone.setCode(getCode());
442 clone.setName(getName());
443 clone.setDescription(getDescription());
444 clone.setStartDate(getStartDate());
445 clone.setEndDate(getEndDate());
446 clone.setActive(getActive());
447 clone.setLimitCategories(getLimitCategories());
448 clone.setLimitSkus(getLimitSkus());
449 clone.setMinOrder(getMinOrder());
450 clone.setDiscount(getDiscount());
451 clone.setDiscountType(getDiscountType());
452
453 return clone;
454 }
455
456 public int compareTo(Object obj) {
457 if (obj == null) {
458 return -1;
459 }
460
461 ShoppingCouponImpl shoppingCoupon = (ShoppingCouponImpl)obj;
462
463 int value = 0;
464
465 value = DateUtil.compareTo(getCreateDate(),
466 shoppingCoupon.getCreateDate());
467
468 if (value != 0) {
469 return value;
470 }
471
472 return 0;
473 }
474
475 public boolean equals(Object obj) {
476 if (obj == null) {
477 return false;
478 }
479
480 ShoppingCouponImpl shoppingCoupon = null;
481
482 try {
483 shoppingCoupon = (ShoppingCouponImpl)obj;
484 }
485 catch (ClassCastException cce) {
486 return false;
487 }
488
489 long pk = shoppingCoupon.getPrimaryKey();
490
491 if (getPrimaryKey() == pk) {
492 return true;
493 }
494 else {
495 return false;
496 }
497 }
498
499 public int hashCode() {
500 return (int)getPrimaryKey();
501 }
502
503 private long _couponId;
504 private long _groupId;
505 private long _companyId;
506 private long _userId;
507 private String _userName;
508 private Date _createDate;
509 private Date _modifiedDate;
510 private String _code;
511 private String _name;
512 private String _description;
513 private Date _startDate;
514 private Date _endDate;
515 private boolean _active;
516 private String _limitCategories;
517 private String _limitSkus;
518 private double _minOrder;
519 private double _discount;
520 private String _discountType;
521 }