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