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