1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.shopping.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.impl.BaseModelImpl;
26  
27  import com.liferay.portlet.shopping.model.ShoppingCart;
28  import com.liferay.portlet.shopping.model.ShoppingCartSoap;
29  
30  import java.io.Serializable;
31  
32  import java.lang.reflect.Proxy;
33  
34  import java.sql.Types;
35  
36  import java.util.ArrayList;
37  import java.util.Date;
38  import java.util.List;
39  
40  /**
41   * <a href="ShoppingCartModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This class is a model that represents the <code>ShoppingCart</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portlet.shopping.model.ShoppingCart
56   * @see com.liferay.portlet.shopping.model.ShoppingCartModel
57   * @see com.liferay.portlet.shopping.model.impl.ShoppingCartImpl
58   *
59   */
60  public class ShoppingCartModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "ShoppingCart";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "cartId", new Integer(Types.BIGINT) },
64              
65  
66              { "groupId", new Integer(Types.BIGINT) },
67              
68  
69              { "companyId", new Integer(Types.BIGINT) },
70              
71  
72              { "userId", new Integer(Types.BIGINT) },
73              
74  
75              { "userName", new Integer(Types.VARCHAR) },
76              
77  
78              { "createDate", new Integer(Types.TIMESTAMP) },
79              
80  
81              { "modifiedDate", new Integer(Types.TIMESTAMP) },
82              
83  
84              { "itemIds", new Integer(Types.VARCHAR) },
85              
86  
87              { "couponCodes", new Integer(Types.VARCHAR) },
88              
89  
90              { "altShipping", new Integer(Types.INTEGER) },
91              
92  
93              { "insure", new Integer(Types.BOOLEAN) }
94          };
95      public static final String TABLE_SQL_CREATE = "create table ShoppingCart (cartId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,itemIds STRING null,couponCodes VARCHAR(75) null,altShipping INTEGER,insure BOOLEAN)";
96      public static final String TABLE_SQL_DROP = "drop table ShoppingCart";
97      public static final String DATA_SOURCE = "liferayDataSource";
98      public static final String SESSION_FACTORY = "liferaySessionFactory";
99      public static final String TX_MANAGER = "liferayTransactionManager";
100     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
101                 "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCart"),
102             true);
103 
104     public static ShoppingCart toModel(ShoppingCartSoap soapModel) {
105         ShoppingCart model = new ShoppingCartImpl();
106 
107         model.setCartId(soapModel.getCartId());
108         model.setGroupId(soapModel.getGroupId());
109         model.setCompanyId(soapModel.getCompanyId());
110         model.setUserId(soapModel.getUserId());
111         model.setUserName(soapModel.getUserName());
112         model.setCreateDate(soapModel.getCreateDate());
113         model.setModifiedDate(soapModel.getModifiedDate());
114         model.setItemIds(soapModel.getItemIds());
115         model.setCouponCodes(soapModel.getCouponCodes());
116         model.setAltShipping(soapModel.getAltShipping());
117         model.setInsure(soapModel.getInsure());
118 
119         return model;
120     }
121 
122     public static List<ShoppingCart> toModels(ShoppingCartSoap[] soapModels) {
123         List<ShoppingCart> models = new ArrayList<ShoppingCart>(soapModels.length);
124 
125         for (ShoppingCartSoap soapModel : soapModels) {
126             models.add(toModel(soapModel));
127         }
128 
129         return models;
130     }
131 
132     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
133                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingCart"));
134 
135     public ShoppingCartModelImpl() {
136     }
137 
138     public long getPrimaryKey() {
139         return _cartId;
140     }
141 
142     public void setPrimaryKey(long pk) {
143         setCartId(pk);
144     }
145 
146     public Serializable getPrimaryKeyObj() {
147         return new Long(_cartId);
148     }
149 
150     public long getCartId() {
151         return _cartId;
152     }
153 
154     public void setCartId(long cartId) {
155         if (cartId != _cartId) {
156             _cartId = cartId;
157         }
158     }
159 
160     public long getGroupId() {
161         return _groupId;
162     }
163 
164     public void setGroupId(long groupId) {
165         if (groupId != _groupId) {
166             _groupId = groupId;
167         }
168     }
169 
170     public long getCompanyId() {
171         return _companyId;
172     }
173 
174     public void setCompanyId(long companyId) {
175         if (companyId != _companyId) {
176             _companyId = companyId;
177         }
178     }
179 
180     public long getUserId() {
181         return _userId;
182     }
183 
184     public void setUserId(long userId) {
185         if (userId != _userId) {
186             _userId = userId;
187         }
188     }
189 
190     public String getUserName() {
191         return GetterUtil.getString(_userName);
192     }
193 
194     public void setUserName(String userName) {
195         if (((userName == null) && (_userName != null)) ||
196                 ((userName != null) && (_userName == null)) ||
197                 ((userName != null) && (_userName != null) &&
198                 !userName.equals(_userName))) {
199             _userName = userName;
200         }
201     }
202 
203     public Date getCreateDate() {
204         return _createDate;
205     }
206 
207     public void setCreateDate(Date createDate) {
208         if (((createDate == null) && (_createDate != null)) ||
209                 ((createDate != null) && (_createDate == null)) ||
210                 ((createDate != null) && (_createDate != null) &&
211                 !createDate.equals(_createDate))) {
212             _createDate = createDate;
213         }
214     }
215 
216     public Date getModifiedDate() {
217         return _modifiedDate;
218     }
219 
220     public void setModifiedDate(Date modifiedDate) {
221         if (((modifiedDate == null) && (_modifiedDate != null)) ||
222                 ((modifiedDate != null) && (_modifiedDate == null)) ||
223                 ((modifiedDate != null) && (_modifiedDate != null) &&
224                 !modifiedDate.equals(_modifiedDate))) {
225             _modifiedDate = modifiedDate;
226         }
227     }
228 
229     public String getItemIds() {
230         return GetterUtil.getString(_itemIds);
231     }
232 
233     public void setItemIds(String itemIds) {
234         if (((itemIds == null) && (_itemIds != null)) ||
235                 ((itemIds != null) && (_itemIds == null)) ||
236                 ((itemIds != null) && (_itemIds != null) &&
237                 !itemIds.equals(_itemIds))) {
238             _itemIds = itemIds;
239         }
240     }
241 
242     public String getCouponCodes() {
243         return GetterUtil.getString(_couponCodes);
244     }
245 
246     public void setCouponCodes(String couponCodes) {
247         if (((couponCodes == null) && (_couponCodes != null)) ||
248                 ((couponCodes != null) && (_couponCodes == null)) ||
249                 ((couponCodes != null) && (_couponCodes != null) &&
250                 !couponCodes.equals(_couponCodes))) {
251             _couponCodes = couponCodes;
252         }
253     }
254 
255     public int getAltShipping() {
256         return _altShipping;
257     }
258 
259     public void setAltShipping(int altShipping) {
260         if (altShipping != _altShipping) {
261             _altShipping = altShipping;
262         }
263     }
264 
265     public boolean getInsure() {
266         return _insure;
267     }
268 
269     public boolean isInsure() {
270         return _insure;
271     }
272 
273     public void setInsure(boolean insure) {
274         if (insure != _insure) {
275             _insure = insure;
276         }
277     }
278 
279     public ShoppingCart toEscapedModel() {
280         if (isEscapedModel()) {
281             return (ShoppingCart)this;
282         }
283         else {
284             ShoppingCart model = new ShoppingCartImpl();
285 
286             model.setNew(isNew());
287             model.setEscapedModel(true);
288 
289             model.setCartId(getCartId());
290             model.setGroupId(getGroupId());
291             model.setCompanyId(getCompanyId());
292             model.setUserId(getUserId());
293             model.setUserName(HtmlUtil.escape(getUserName()));
294             model.setCreateDate(getCreateDate());
295             model.setModifiedDate(getModifiedDate());
296             model.setItemIds(HtmlUtil.escape(getItemIds()));
297             model.setCouponCodes(HtmlUtil.escape(getCouponCodes()));
298             model.setAltShipping(getAltShipping());
299             model.setInsure(getInsure());
300 
301             model = (ShoppingCart)Proxy.newProxyInstance(ShoppingCart.class.getClassLoader(),
302                     new Class[] { ShoppingCart.class },
303                     new ReadOnlyBeanHandler(model));
304 
305             return model;
306         }
307     }
308 
309     public Object clone() {
310         ShoppingCartImpl clone = new ShoppingCartImpl();
311 
312         clone.setCartId(getCartId());
313         clone.setGroupId(getGroupId());
314         clone.setCompanyId(getCompanyId());
315         clone.setUserId(getUserId());
316         clone.setUserName(getUserName());
317         clone.setCreateDate(getCreateDate());
318         clone.setModifiedDate(getModifiedDate());
319         clone.setItemIds(getItemIds());
320         clone.setCouponCodes(getCouponCodes());
321         clone.setAltShipping(getAltShipping());
322         clone.setInsure(getInsure());
323 
324         return clone;
325     }
326 
327     public int compareTo(Object obj) {
328         if (obj == null) {
329             return -1;
330         }
331 
332         ShoppingCartImpl shoppingCart = (ShoppingCartImpl)obj;
333 
334         long pk = shoppingCart.getPrimaryKey();
335 
336         if (getPrimaryKey() < pk) {
337             return -1;
338         }
339         else if (getPrimaryKey() > pk) {
340             return 1;
341         }
342         else {
343             return 0;
344         }
345     }
346 
347     public boolean equals(Object obj) {
348         if (obj == null) {
349             return false;
350         }
351 
352         ShoppingCartImpl shoppingCart = null;
353 
354         try {
355             shoppingCart = (ShoppingCartImpl)obj;
356         }
357         catch (ClassCastException cce) {
358             return false;
359         }
360 
361         long pk = shoppingCart.getPrimaryKey();
362 
363         if (getPrimaryKey() == pk) {
364             return true;
365         }
366         else {
367             return false;
368         }
369     }
370 
371     public int hashCode() {
372         return (int)getPrimaryKey();
373     }
374 
375     private long _cartId;
376     private long _groupId;
377     private long _companyId;
378     private long _userId;
379     private String _userName;
380     private Date _createDate;
381     private Date _modifiedDate;
382     private String _itemIds;
383     private String _couponCodes;
384     private int _altShipping;
385     private boolean _insure;
386 }