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