1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  import com.liferay.portal.service.ServiceContext;
30  
31  import com.liferay.portlet.expando.model.ExpandoBridge;
32  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
33  import com.liferay.portlet.shopping.model.ShoppingOrderItem;
34  import com.liferay.portlet.shopping.model.ShoppingOrderItemSoap;
35  
36  import java.io.Serializable;
37  
38  import java.lang.reflect.Proxy;
39  
40  import java.sql.Types;
41  
42  import java.util.ArrayList;
43  import java.util.Date;
44  import java.util.List;
45  
46  /**
47   * <a href="ShoppingOrderItemModelImpl.java.html"><b><i>View Source</i></b></a>
48   *
49   * <p>
50   * ServiceBuilder generated this class. Modifications in this class will be
51   * overwritten the next time is generated.
52   * </p>
53   *
54   * <p>
55   * This interface is a model that represents the ShoppingOrderItem table in the
56   * database.
57   * </p>
58   *
59   * @author    Brian Wing Shun Chan
60   * @see       ShoppingOrderItemImpl
61   * @see       com.liferay.portlet.shopping.model.ShoppingOrderItem
62   * @see       com.liferay.portlet.shopping.model.ShoppingOrderItemModel
63   * @generated
64   */
65  public class ShoppingOrderItemModelImpl extends BaseModelImpl<ShoppingOrderItem> {
66      public static final String TABLE_NAME = "ShoppingOrderItem";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "orderItemId", new Integer(Types.BIGINT) },
69              { "orderId", new Integer(Types.BIGINT) },
70              { "itemId", new Integer(Types.VARCHAR) },
71              { "sku", new Integer(Types.VARCHAR) },
72              { "name", new Integer(Types.VARCHAR) },
73              { "description", new Integer(Types.VARCHAR) },
74              { "properties", new Integer(Types.VARCHAR) },
75              { "price", new Integer(Types.DOUBLE) },
76              { "quantity", new Integer(Types.INTEGER) },
77              { "shippedDate", new Integer(Types.TIMESTAMP) }
78          };
79      public static final String TABLE_SQL_CREATE = "create table ShoppingOrderItem (orderItemId LONG not null primary key,orderId LONG,itemId VARCHAR(75) null,sku VARCHAR(75) null,name VARCHAR(200) null,description STRING null,properties STRING null,price DOUBLE,quantity INTEGER,shippedDate DATE null)";
80      public static final String TABLE_SQL_DROP = "drop table ShoppingOrderItem";
81      public static final String DATA_SOURCE = "liferayDataSource";
82      public static final String SESSION_FACTORY = "liferaySessionFactory";
83      public static final String TX_MANAGER = "liferayTransactionManager";
84      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
85                  "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingOrderItem"),
86              true);
87      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
88                  "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingOrderItem"),
89              true);
90  
91      public static ShoppingOrderItem toModel(ShoppingOrderItemSoap soapModel) {
92          ShoppingOrderItem model = new ShoppingOrderItemImpl();
93  
94          model.setOrderItemId(soapModel.getOrderItemId());
95          model.setOrderId(soapModel.getOrderId());
96          model.setItemId(soapModel.getItemId());
97          model.setSku(soapModel.getSku());
98          model.setName(soapModel.getName());
99          model.setDescription(soapModel.getDescription());
100         model.setProperties(soapModel.getProperties());
101         model.setPrice(soapModel.getPrice());
102         model.setQuantity(soapModel.getQuantity());
103         model.setShippedDate(soapModel.getShippedDate());
104 
105         return model;
106     }
107 
108     public static List<ShoppingOrderItem> toModels(
109         ShoppingOrderItemSoap[] soapModels) {
110         List<ShoppingOrderItem> models = new ArrayList<ShoppingOrderItem>(soapModels.length);
111 
112         for (ShoppingOrderItemSoap soapModel : soapModels) {
113             models.add(toModel(soapModel));
114         }
115 
116         return models;
117     }
118 
119     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
120                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingOrderItem"));
121 
122     public ShoppingOrderItemModelImpl() {
123     }
124 
125     public long getPrimaryKey() {
126         return _orderItemId;
127     }
128 
129     public void setPrimaryKey(long pk) {
130         setOrderItemId(pk);
131     }
132 
133     public Serializable getPrimaryKeyObj() {
134         return new Long(_orderItemId);
135     }
136 
137     public long getOrderItemId() {
138         return _orderItemId;
139     }
140 
141     public void setOrderItemId(long orderItemId) {
142         _orderItemId = orderItemId;
143     }
144 
145     public long getOrderId() {
146         return _orderId;
147     }
148 
149     public void setOrderId(long orderId) {
150         _orderId = orderId;
151     }
152 
153     public String getItemId() {
154         return GetterUtil.getString(_itemId);
155     }
156 
157     public void setItemId(String itemId) {
158         _itemId = itemId;
159     }
160 
161     public String getSku() {
162         return GetterUtil.getString(_sku);
163     }
164 
165     public void setSku(String sku) {
166         _sku = sku;
167     }
168 
169     public String getName() {
170         return GetterUtil.getString(_name);
171     }
172 
173     public void setName(String name) {
174         _name = name;
175     }
176 
177     public String getDescription() {
178         return GetterUtil.getString(_description);
179     }
180 
181     public void setDescription(String description) {
182         _description = description;
183     }
184 
185     public String getProperties() {
186         return GetterUtil.getString(_properties);
187     }
188 
189     public void setProperties(String properties) {
190         _properties = properties;
191     }
192 
193     public double getPrice() {
194         return _price;
195     }
196 
197     public void setPrice(double price) {
198         _price = price;
199     }
200 
201     public int getQuantity() {
202         return _quantity;
203     }
204 
205     public void setQuantity(int quantity) {
206         _quantity = quantity;
207     }
208 
209     public Date getShippedDate() {
210         return _shippedDate;
211     }
212 
213     public void setShippedDate(Date shippedDate) {
214         _shippedDate = shippedDate;
215     }
216 
217     public ShoppingOrderItem toEscapedModel() {
218         if (isEscapedModel()) {
219             return (ShoppingOrderItem)this;
220         }
221         else {
222             ShoppingOrderItem model = new ShoppingOrderItemImpl();
223 
224             model.setNew(isNew());
225             model.setEscapedModel(true);
226 
227             model.setOrderItemId(getOrderItemId());
228             model.setOrderId(getOrderId());
229             model.setItemId(HtmlUtil.escape(getItemId()));
230             model.setSku(HtmlUtil.escape(getSku()));
231             model.setName(HtmlUtil.escape(getName()));
232             model.setDescription(HtmlUtil.escape(getDescription()));
233             model.setProperties(HtmlUtil.escape(getProperties()));
234             model.setPrice(getPrice());
235             model.setQuantity(getQuantity());
236             model.setShippedDate(getShippedDate());
237 
238             model = (ShoppingOrderItem)Proxy.newProxyInstance(ShoppingOrderItem.class.getClassLoader(),
239                     new Class[] { ShoppingOrderItem.class },
240                     new ReadOnlyBeanHandler(model));
241 
242             return model;
243         }
244     }
245 
246     public ExpandoBridge getExpandoBridge() {
247         if (_expandoBridge == null) {
248             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(ShoppingOrderItem.class.getName(),
249                     getPrimaryKey());
250         }
251 
252         return _expandoBridge;
253     }
254 
255     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
256         getExpandoBridge().setAttributes(serviceContext);
257     }
258 
259     public Object clone() {
260         ShoppingOrderItemImpl clone = new ShoppingOrderItemImpl();
261 
262         clone.setOrderItemId(getOrderItemId());
263         clone.setOrderId(getOrderId());
264         clone.setItemId(getItemId());
265         clone.setSku(getSku());
266         clone.setName(getName());
267         clone.setDescription(getDescription());
268         clone.setProperties(getProperties());
269         clone.setPrice(getPrice());
270         clone.setQuantity(getQuantity());
271         clone.setShippedDate(getShippedDate());
272 
273         return clone;
274     }
275 
276     public int compareTo(ShoppingOrderItem shoppingOrderItem) {
277         int value = 0;
278 
279         value = getName().compareTo(shoppingOrderItem.getName());
280 
281         if (value != 0) {
282             return value;
283         }
284 
285         value = getDescription().compareTo(shoppingOrderItem.getDescription());
286 
287         if (value != 0) {
288             return value;
289         }
290 
291         return 0;
292     }
293 
294     public boolean equals(Object obj) {
295         if (obj == null) {
296             return false;
297         }
298 
299         ShoppingOrderItem shoppingOrderItem = null;
300 
301         try {
302             shoppingOrderItem = (ShoppingOrderItem)obj;
303         }
304         catch (ClassCastException cce) {
305             return false;
306         }
307 
308         long pk = shoppingOrderItem.getPrimaryKey();
309 
310         if (getPrimaryKey() == pk) {
311             return true;
312         }
313         else {
314             return false;
315         }
316     }
317 
318     public int hashCode() {
319         return (int)getPrimaryKey();
320     }
321 
322     public String toString() {
323         StringBuilder sb = new StringBuilder();
324 
325         sb.append("{orderItemId=");
326         sb.append(getOrderItemId());
327         sb.append(", orderId=");
328         sb.append(getOrderId());
329         sb.append(", itemId=");
330         sb.append(getItemId());
331         sb.append(", sku=");
332         sb.append(getSku());
333         sb.append(", name=");
334         sb.append(getName());
335         sb.append(", description=");
336         sb.append(getDescription());
337         sb.append(", properties=");
338         sb.append(getProperties());
339         sb.append(", price=");
340         sb.append(getPrice());
341         sb.append(", quantity=");
342         sb.append(getQuantity());
343         sb.append(", shippedDate=");
344         sb.append(getShippedDate());
345         sb.append("}");
346 
347         return sb.toString();
348     }
349 
350     public String toXmlString() {
351         StringBuilder sb = new StringBuilder();
352 
353         sb.append("<model><model-name>");
354         sb.append("com.liferay.portlet.shopping.model.ShoppingOrderItem");
355         sb.append("</model-name>");
356 
357         sb.append(
358             "<column><column-name>orderItemId</column-name><column-value><![CDATA[");
359         sb.append(getOrderItemId());
360         sb.append("]]></column-value></column>");
361         sb.append(
362             "<column><column-name>orderId</column-name><column-value><![CDATA[");
363         sb.append(getOrderId());
364         sb.append("]]></column-value></column>");
365         sb.append(
366             "<column><column-name>itemId</column-name><column-value><![CDATA[");
367         sb.append(getItemId());
368         sb.append("]]></column-value></column>");
369         sb.append(
370             "<column><column-name>sku</column-name><column-value><![CDATA[");
371         sb.append(getSku());
372         sb.append("]]></column-value></column>");
373         sb.append(
374             "<column><column-name>name</column-name><column-value><![CDATA[");
375         sb.append(getName());
376         sb.append("]]></column-value></column>");
377         sb.append(
378             "<column><column-name>description</column-name><column-value><![CDATA[");
379         sb.append(getDescription());
380         sb.append("]]></column-value></column>");
381         sb.append(
382             "<column><column-name>properties</column-name><column-value><![CDATA[");
383         sb.append(getProperties());
384         sb.append("]]></column-value></column>");
385         sb.append(
386             "<column><column-name>price</column-name><column-value><![CDATA[");
387         sb.append(getPrice());
388         sb.append("]]></column-value></column>");
389         sb.append(
390             "<column><column-name>quantity</column-name><column-value><![CDATA[");
391         sb.append(getQuantity());
392         sb.append("]]></column-value></column>");
393         sb.append(
394             "<column><column-name>shippedDate</column-name><column-value><![CDATA[");
395         sb.append(getShippedDate());
396         sb.append("]]></column-value></column>");
397 
398         sb.append("</model>");
399 
400         return sb.toString();
401     }
402 
403     private long _orderItemId;
404     private long _orderId;
405     private String _itemId;
406     private String _sku;
407     private String _name;
408     private String _description;
409     private String _properties;
410     private double _price;
411     private int _quantity;
412     private Date _shippedDate;
413     private transient ExpandoBridge _expandoBridge;
414 }