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