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