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