1   /**
2    * Copyright (c) 2000-2007 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.util.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import com.liferay.util.XSSUtil;
30  
31  import java.io.Serializable;
32  
33  import java.sql.Types;
34  
35  import java.util.Date;
36  
37  /**
38   * <a href="ShoppingItemModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be overwritten
42   * the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class is a model that represents the <code>ShoppingItem</code> table in
47   * the database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portlet.shopping.service.model.ShoppingItem
53   * @see com.liferay.portlet.shopping.service.model.ShoppingItemModel
54   * @see com.liferay.portlet.shopping.service.model.impl.ShoppingItemImpl
55   *
56   */
57  public class ShoppingItemModelImpl extends BaseModelImpl {
58      public static String TABLE_NAME = "ShoppingItem";
59      public static Object[][] TABLE_COLUMNS = {
60              { "itemId", new Integer(Types.BIGINT) },
61              { "companyId", new Integer(Types.BIGINT) },
62              { "userId", new Integer(Types.BIGINT) },
63              { "userName", new Integer(Types.VARCHAR) },
64              { "createDate", new Integer(Types.TIMESTAMP) },
65              { "modifiedDate", new Integer(Types.TIMESTAMP) },
66              { "categoryId", new Integer(Types.BIGINT) },
67              { "sku", new Integer(Types.VARCHAR) },
68              { "name", new Integer(Types.VARCHAR) },
69              { "description", new Integer(Types.VARCHAR) },
70              { "properties", new Integer(Types.VARCHAR) },
71              { "fields_", new Integer(Types.BOOLEAN) },
72              { "fieldsQuantities", new Integer(Types.VARCHAR) },
73              { "minQuantity", new Integer(Types.INTEGER) },
74              { "maxQuantity", new Integer(Types.INTEGER) },
75              { "price", new Integer(Types.DOUBLE) },
76              { "discount", new Integer(Types.DOUBLE) },
77              { "taxable", new Integer(Types.BOOLEAN) },
78              { "shipping", new Integer(Types.DOUBLE) },
79              { "useShippingFormula", new Integer(Types.BOOLEAN) },
80              { "requiresShipping", new Integer(Types.BOOLEAN) },
81              { "stockQuantity", new Integer(Types.INTEGER) },
82              { "featured_", new Integer(Types.BOOLEAN) },
83              { "sale_", new Integer(Types.BOOLEAN) },
84              { "smallImage", new Integer(Types.BOOLEAN) },
85              { "smallImageId", new Integer(Types.BIGINT) },
86              { "smallImageURL", new Integer(Types.VARCHAR) },
87              { "mediumImage", new Integer(Types.BOOLEAN) },
88              { "mediumImageId", new Integer(Types.BIGINT) },
89              { "mediumImageURL", new Integer(Types.VARCHAR) },
90              { "largeImage", new Integer(Types.BOOLEAN) },
91              { "largeImageId", new Integer(Types.BIGINT) },
92              { "largeImageURL", new Integer(Types.VARCHAR) }
93          };
94      public static String TABLE_SQL_CREATE = "create table ShoppingItem (itemId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,categoryId LONG,sku VARCHAR(75) null,name VARCHAR(200) null,description STRING null,properties STRING null,fields_ BOOLEAN,fieldsQuantities STRING null,minQuantity INTEGER,maxQuantity INTEGER,price DOUBLE,discount DOUBLE,taxable BOOLEAN,shipping DOUBLE,useShippingFormula BOOLEAN,requiresShipping BOOLEAN,stockQuantity INTEGER,featured_ BOOLEAN,sale_ BOOLEAN,smallImage BOOLEAN,smallImageId LONG,smallImageURL VARCHAR(75) null,mediumImage BOOLEAN,mediumImageId LONG,mediumImageURL VARCHAR(75) null,largeImage BOOLEAN,largeImageId LONG,largeImageURL VARCHAR(75) null)";
95      public static String TABLE_SQL_DROP = "drop table ShoppingItem";
96      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
97                  "xss.allow.com.liferay.portlet.shopping.model.ShoppingItem"),
98              XSS_ALLOW);
99      public static boolean XSS_ALLOW_USERNAME = GetterUtil.getBoolean(PropsUtil.get(
100                 "xss.allow.com.liferay.portlet.shopping.model.ShoppingItem.userName"),
101             XSS_ALLOW_BY_MODEL);
102     public static boolean XSS_ALLOW_SKU = GetterUtil.getBoolean(PropsUtil.get(
103                 "xss.allow.com.liferay.portlet.shopping.model.ShoppingItem.sku"),
104             XSS_ALLOW_BY_MODEL);
105     public static boolean XSS_ALLOW_NAME = GetterUtil.getBoolean(PropsUtil.get(
106                 "xss.allow.com.liferay.portlet.shopping.model.ShoppingItem.name"),
107             XSS_ALLOW_BY_MODEL);
108     public static boolean XSS_ALLOW_DESCRIPTION = GetterUtil.getBoolean(PropsUtil.get(
109                 "xss.allow.com.liferay.portlet.shopping.model.ShoppingItem.description"),
110             XSS_ALLOW_BY_MODEL);
111     public static boolean XSS_ALLOW_PROPERTIES = GetterUtil.getBoolean(PropsUtil.get(
112                 "xss.allow.com.liferay.portlet.shopping.model.ShoppingItem.properties"),
113             XSS_ALLOW_BY_MODEL);
114     public static boolean XSS_ALLOW_FIELDSQUANTITIES = GetterUtil.getBoolean(PropsUtil.get(
115                 "xss.allow.com.liferay.portlet.shopping.model.ShoppingItem.fieldsQuantities"),
116             XSS_ALLOW_BY_MODEL);
117     public static boolean XSS_ALLOW_SMALLIMAGEURL = GetterUtil.getBoolean(PropsUtil.get(
118                 "xss.allow.com.liferay.portlet.shopping.model.ShoppingItem.smallImageURL"),
119             XSS_ALLOW_BY_MODEL);
120     public static boolean XSS_ALLOW_MEDIUMIMAGEURL = GetterUtil.getBoolean(PropsUtil.get(
121                 "xss.allow.com.liferay.portlet.shopping.model.ShoppingItem.mediumImageURL"),
122             XSS_ALLOW_BY_MODEL);
123     public static boolean XSS_ALLOW_LARGEIMAGEURL = GetterUtil.getBoolean(PropsUtil.get(
124                 "xss.allow.com.liferay.portlet.shopping.model.ShoppingItem.largeImageURL"),
125             XSS_ALLOW_BY_MODEL);
126     public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
127                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemModel"));
128 
129     public ShoppingItemModelImpl() {
130     }
131 
132     public long getPrimaryKey() {
133         return _itemId;
134     }
135 
136     public void setPrimaryKey(long pk) {
137         setItemId(pk);
138     }
139 
140     public Serializable getPrimaryKeyObj() {
141         return new Long(_itemId);
142     }
143 
144     public long getItemId() {
145         return _itemId;
146     }
147 
148     public void setItemId(long itemId) {
149         if (itemId != _itemId) {
150             _itemId = itemId;
151         }
152     }
153 
154     public long getCompanyId() {
155         return _companyId;
156     }
157 
158     public void setCompanyId(long companyId) {
159         if (companyId != _companyId) {
160             _companyId = companyId;
161         }
162     }
163 
164     public long getUserId() {
165         return _userId;
166     }
167 
168     public void setUserId(long userId) {
169         if (userId != _userId) {
170             _userId = userId;
171         }
172     }
173 
174     public String getUserName() {
175         return GetterUtil.getString(_userName);
176     }
177 
178     public void setUserName(String userName) {
179         if (((userName == null) && (_userName != null)) ||
180                 ((userName != null) && (_userName == null)) ||
181                 ((userName != null) && (_userName != null) &&
182                 !userName.equals(_userName))) {
183             if (!XSS_ALLOW_USERNAME) {
184                 userName = XSSUtil.strip(userName);
185             }
186 
187             _userName = userName;
188         }
189     }
190 
191     public Date getCreateDate() {
192         return _createDate;
193     }
194 
195     public void setCreateDate(Date createDate) {
196         if (((createDate == null) && (_createDate != null)) ||
197                 ((createDate != null) && (_createDate == null)) ||
198                 ((createDate != null) && (_createDate != null) &&
199                 !createDate.equals(_createDate))) {
200             _createDate = createDate;
201         }
202     }
203 
204     public Date getModifiedDate() {
205         return _modifiedDate;
206     }
207 
208     public void setModifiedDate(Date modifiedDate) {
209         if (((modifiedDate == null) && (_modifiedDate != null)) ||
210                 ((modifiedDate != null) && (_modifiedDate == null)) ||
211                 ((modifiedDate != null) && (_modifiedDate != null) &&
212                 !modifiedDate.equals(_modifiedDate))) {
213             _modifiedDate = modifiedDate;
214         }
215     }
216 
217     public long getCategoryId() {
218         return _categoryId;
219     }
220 
221     public void setCategoryId(long categoryId) {
222         if (categoryId != _categoryId) {
223             _categoryId = categoryId;
224         }
225     }
226 
227     public String getSku() {
228         return GetterUtil.getString(_sku);
229     }
230 
231     public void setSku(String sku) {
232         if (((sku == null) && (_sku != null)) ||
233                 ((sku != null) && (_sku == null)) ||
234                 ((sku != null) && (_sku != null) && !sku.equals(_sku))) {
235             if (!XSS_ALLOW_SKU) {
236                 sku = XSSUtil.strip(sku);
237             }
238 
239             _sku = sku;
240         }
241     }
242 
243     public String getName() {
244         return GetterUtil.getString(_name);
245     }
246 
247     public void setName(String name) {
248         if (((name == null) && (_name != null)) ||
249                 ((name != null) && (_name == null)) ||
250                 ((name != null) && (_name != null) && !name.equals(_name))) {
251             if (!XSS_ALLOW_NAME) {
252                 name = XSSUtil.strip(name);
253             }
254 
255             _name = name;
256         }
257     }
258 
259     public String getDescription() {
260         return GetterUtil.getString(_description);
261     }
262 
263     public void setDescription(String description) {
264         if (((description == null) && (_description != null)) ||
265                 ((description != null) && (_description == null)) ||
266                 ((description != null) && (_description != null) &&
267                 !description.equals(_description))) {
268             if (!XSS_ALLOW_DESCRIPTION) {
269                 description = XSSUtil.strip(description);
270             }
271 
272             _description = description;
273         }
274     }
275 
276     public String getProperties() {
277         return GetterUtil.getString(_properties);
278     }
279 
280     public void setProperties(String properties) {
281         if (((properties == null) && (_properties != null)) ||
282                 ((properties != null) && (_properties == null)) ||
283                 ((properties != null) && (_properties != null) &&
284                 !properties.equals(_properties))) {
285             if (!XSS_ALLOW_PROPERTIES) {
286                 properties = XSSUtil.strip(properties);
287             }
288 
289             _properties = properties;
290         }
291     }
292 
293     public boolean getFields() {
294         return _fields;
295     }
296 
297     public boolean isFields() {
298         return _fields;
299     }
300 
301     public void setFields(boolean fields) {
302         if (fields != _fields) {
303             _fields = fields;
304         }
305     }
306 
307     public String getFieldsQuantities() {
308         return GetterUtil.getString(_fieldsQuantities);
309     }
310 
311     public void setFieldsQuantities(String fieldsQuantities) {
312         if (((fieldsQuantities == null) && (_fieldsQuantities != null)) ||
313                 ((fieldsQuantities != null) && (_fieldsQuantities == null)) ||
314                 ((fieldsQuantities != null) && (_fieldsQuantities != null) &&
315                 !fieldsQuantities.equals(_fieldsQuantities))) {
316             if (!XSS_ALLOW_FIELDSQUANTITIES) {
317                 fieldsQuantities = XSSUtil.strip(fieldsQuantities);
318             }
319 
320             _fieldsQuantities = fieldsQuantities;
321         }
322     }
323 
324     public int getMinQuantity() {
325         return _minQuantity;
326     }
327 
328     public void setMinQuantity(int minQuantity) {
329         if (minQuantity != _minQuantity) {
330             _minQuantity = minQuantity;
331         }
332     }
333 
334     public int getMaxQuantity() {
335         return _maxQuantity;
336     }
337 
338     public void setMaxQuantity(int maxQuantity) {
339         if (maxQuantity != _maxQuantity) {
340             _maxQuantity = maxQuantity;
341         }
342     }
343 
344     public double getPrice() {
345         return _price;
346     }
347 
348     public void setPrice(double price) {
349         if (price != _price) {
350             _price = price;
351         }
352     }
353 
354     public double getDiscount() {
355         return _discount;
356     }
357 
358     public void setDiscount(double discount) {
359         if (discount != _discount) {
360             _discount = discount;
361         }
362     }
363 
364     public boolean getTaxable() {
365         return _taxable;
366     }
367 
368     public boolean isTaxable() {
369         return _taxable;
370     }
371 
372     public void setTaxable(boolean taxable) {
373         if (taxable != _taxable) {
374             _taxable = taxable;
375         }
376     }
377 
378     public double getShipping() {
379         return _shipping;
380     }
381 
382     public void setShipping(double shipping) {
383         if (shipping != _shipping) {
384             _shipping = shipping;
385         }
386     }
387 
388     public boolean getUseShippingFormula() {
389         return _useShippingFormula;
390     }
391 
392     public boolean isUseShippingFormula() {
393         return _useShippingFormula;
394     }
395 
396     public void setUseShippingFormula(boolean useShippingFormula) {
397         if (useShippingFormula != _useShippingFormula) {
398             _useShippingFormula = useShippingFormula;
399         }
400     }
401 
402     public boolean getRequiresShipping() {
403         return _requiresShipping;
404     }
405 
406     public boolean isRequiresShipping() {
407         return _requiresShipping;
408     }
409 
410     public void setRequiresShipping(boolean requiresShipping) {
411         if (requiresShipping != _requiresShipping) {
412             _requiresShipping = requiresShipping;
413         }
414     }
415 
416     public int getStockQuantity() {
417         return _stockQuantity;
418     }
419 
420     public void setStockQuantity(int stockQuantity) {
421         if (stockQuantity != _stockQuantity) {
422             _stockQuantity = stockQuantity;
423         }
424     }
425 
426     public boolean getFeatured() {
427         return _featured;
428     }
429 
430     public boolean isFeatured() {
431         return _featured;
432     }
433 
434     public void setFeatured(boolean featured) {
435         if (featured != _featured) {
436             _featured = featured;
437         }
438     }
439 
440     public boolean getSale() {
441         return _sale;
442     }
443 
444     public boolean isSale() {
445         return _sale;
446     }
447 
448     public void setSale(boolean sale) {
449         if (sale != _sale) {
450             _sale = sale;
451         }
452     }
453 
454     public boolean getSmallImage() {
455         return _smallImage;
456     }
457 
458     public boolean isSmallImage() {
459         return _smallImage;
460     }
461 
462     public void setSmallImage(boolean smallImage) {
463         if (smallImage != _smallImage) {
464             _smallImage = smallImage;
465         }
466     }
467 
468     public long getSmallImageId() {
469         return _smallImageId;
470     }
471 
472     public void setSmallImageId(long smallImageId) {
473         if (smallImageId != _smallImageId) {
474             _smallImageId = smallImageId;
475         }
476     }
477 
478     public String getSmallImageURL() {
479         return GetterUtil.getString(_smallImageURL);
480     }
481 
482     public void setSmallImageURL(String smallImageURL) {
483         if (((smallImageURL == null) && (_smallImageURL != null)) ||
484                 ((smallImageURL != null) && (_smallImageURL == null)) ||
485                 ((smallImageURL != null) && (_smallImageURL != null) &&
486                 !smallImageURL.equals(_smallImageURL))) {
487             if (!XSS_ALLOW_SMALLIMAGEURL) {
488                 smallImageURL = XSSUtil.strip(smallImageURL);
489             }
490 
491             _smallImageURL = smallImageURL;
492         }
493     }
494 
495     public boolean getMediumImage() {
496         return _mediumImage;
497     }
498 
499     public boolean isMediumImage() {
500         return _mediumImage;
501     }
502 
503     public void setMediumImage(boolean mediumImage) {
504         if (mediumImage != _mediumImage) {
505             _mediumImage = mediumImage;
506         }
507     }
508 
509     public long getMediumImageId() {
510         return _mediumImageId;
511     }
512 
513     public void setMediumImageId(long mediumImageId) {
514         if (mediumImageId != _mediumImageId) {
515             _mediumImageId = mediumImageId;
516         }
517     }
518 
519     public String getMediumImageURL() {
520         return GetterUtil.getString(_mediumImageURL);
521     }
522 
523     public void setMediumImageURL(String mediumImageURL) {
524         if (((mediumImageURL == null) && (_mediumImageURL != null)) ||
525                 ((mediumImageURL != null) && (_mediumImageURL == null)) ||
526                 ((mediumImageURL != null) && (_mediumImageURL != null) &&
527                 !mediumImageURL.equals(_mediumImageURL))) {
528             if (!XSS_ALLOW_MEDIUMIMAGEURL) {
529                 mediumImageURL = XSSUtil.strip(mediumImageURL);
530             }
531 
532             _mediumImageURL = mediumImageURL;
533         }
534     }
535 
536     public boolean getLargeImage() {
537         return _largeImage;
538     }
539 
540     public boolean isLargeImage() {
541         return _largeImage;
542     }
543 
544     public void setLargeImage(boolean largeImage) {
545         if (largeImage != _largeImage) {
546             _largeImage = largeImage;
547         }
548     }
549 
550     public long getLargeImageId() {
551         return _largeImageId;
552     }
553 
554     public void setLargeImageId(long largeImageId) {
555         if (largeImageId != _largeImageId) {
556             _largeImageId = largeImageId;
557         }
558     }
559 
560     public String getLargeImageURL() {
561         return GetterUtil.getString(_largeImageURL);
562     }
563 
564     public void setLargeImageURL(String largeImageURL) {
565         if (((largeImageURL == null) && (_largeImageURL != null)) ||
566                 ((largeImageURL != null) && (_largeImageURL == null)) ||
567                 ((largeImageURL != null) && (_largeImageURL != null) &&
568                 !largeImageURL.equals(_largeImageURL))) {
569             if (!XSS_ALLOW_LARGEIMAGEURL) {
570                 largeImageURL = XSSUtil.strip(largeImageURL);
571             }
572 
573             _largeImageURL = largeImageURL;
574         }
575     }
576 
577     public Object clone() {
578         ShoppingItemImpl clone = new ShoppingItemImpl();
579         clone.setItemId(getItemId());
580         clone.setCompanyId(getCompanyId());
581         clone.setUserId(getUserId());
582         clone.setUserName(getUserName());
583         clone.setCreateDate(getCreateDate());
584         clone.setModifiedDate(getModifiedDate());
585         clone.setCategoryId(getCategoryId());
586         clone.setSku(getSku());
587         clone.setName(getName());
588         clone.setDescription(getDescription());
589         clone.setProperties(getProperties());
590         clone.setFields(getFields());
591         clone.setFieldsQuantities(getFieldsQuantities());
592         clone.setMinQuantity(getMinQuantity());
593         clone.setMaxQuantity(getMaxQuantity());
594         clone.setPrice(getPrice());
595         clone.setDiscount(getDiscount());
596         clone.setTaxable(getTaxable());
597         clone.setShipping(getShipping());
598         clone.setUseShippingFormula(getUseShippingFormula());
599         clone.setRequiresShipping(getRequiresShipping());
600         clone.setStockQuantity(getStockQuantity());
601         clone.setFeatured(getFeatured());
602         clone.setSale(getSale());
603         clone.setSmallImage(getSmallImage());
604         clone.setSmallImageId(getSmallImageId());
605         clone.setSmallImageURL(getSmallImageURL());
606         clone.setMediumImage(getMediumImage());
607         clone.setMediumImageId(getMediumImageId());
608         clone.setMediumImageURL(getMediumImageURL());
609         clone.setLargeImage(getLargeImage());
610         clone.setLargeImageId(getLargeImageId());
611         clone.setLargeImageURL(getLargeImageURL());
612 
613         return clone;
614     }
615 
616     public int compareTo(Object obj) {
617         if (obj == null) {
618             return -1;
619         }
620 
621         ShoppingItemImpl shoppingItem = (ShoppingItemImpl)obj;
622         int value = 0;
623 
624         if (getItemId() < shoppingItem.getItemId()) {
625             value = -1;
626         }
627         else if (getItemId() > shoppingItem.getItemId()) {
628             value = 1;
629         }
630         else {
631             value = 0;
632         }
633 
634         if (value != 0) {
635             return value;
636         }
637 
638         return 0;
639     }
640 
641     public boolean equals(Object obj) {
642         if (obj == null) {
643             return false;
644         }
645 
646         ShoppingItemImpl shoppingItem = null;
647 
648         try {
649             shoppingItem = (ShoppingItemImpl)obj;
650         }
651         catch (ClassCastException cce) {
652             return false;
653         }
654 
655         long pk = shoppingItem.getPrimaryKey();
656 
657         if (getPrimaryKey() == pk) {
658             return true;
659         }
660         else {
661             return false;
662         }
663     }
664 
665     public int hashCode() {
666         return (int)getPrimaryKey();
667     }
668 
669     private long _itemId;
670     private long _companyId;
671     private long _userId;
672     private String _userName;
673     private Date _createDate;
674     private Date _modifiedDate;
675     private long _categoryId;
676     private String _sku;
677     private String _name;
678     private String _description;
679     private String _properties;
680     private boolean _fields;
681     private String _fieldsQuantities;
682     private int _minQuantity;
683     private int _maxQuantity;
684     private double _price;
685     private double _discount;
686     private boolean _taxable;
687     private double _shipping;
688     private boolean _useShippingFormula;
689     private boolean _requiresShipping;
690     private int _stockQuantity;
691     private boolean _featured;
692     private boolean _sale;
693     private boolean _smallImage;
694     private long _smallImageId;
695     private String _smallImageURL;
696     private boolean _mediumImage;
697     private long _mediumImageId;
698     private String _mediumImageURL;
699     private boolean _largeImage;
700     private long _largeImageId;
701     private String _largeImageURL;
702 }