1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.shopping.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.HtmlUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.model.impl.BaseModelImpl;
22  import com.liferay.portal.service.ServiceContext;
23  
24  import com.liferay.portlet.expando.model.ExpandoBridge;
25  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
26  import com.liferay.portlet.shopping.model.ShoppingItemField;
27  import com.liferay.portlet.shopping.model.ShoppingItemFieldSoap;
28  
29  import java.io.Serializable;
30  
31  import java.lang.reflect.Proxy;
32  
33  import java.sql.Types;
34  
35  import java.util.ArrayList;
36  import java.util.List;
37  
38  /**
39   * <a href="ShoppingItemFieldModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This interface is a model that represents the ShoppingItemField table in the
48   * database.
49   * </p>
50   *
51   * @author    Brian Wing Shun Chan
52   * @see       ShoppingItemFieldImpl
53   * @see       com.liferay.portlet.shopping.model.ShoppingItemField
54   * @see       com.liferay.portlet.shopping.model.ShoppingItemFieldModel
55   * @generated
56   */
57  public class ShoppingItemFieldModelImpl extends BaseModelImpl<ShoppingItemField> {
58      public static final String TABLE_NAME = "ShoppingItemField";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "itemFieldId", new Integer(Types.BIGINT) },
61              { "itemId", new Integer(Types.BIGINT) },
62              { "name", new Integer(Types.VARCHAR) },
63              { "values_", new Integer(Types.VARCHAR) },
64              { "description", new Integer(Types.VARCHAR) }
65          };
66      public static final String TABLE_SQL_CREATE = "create table ShoppingItemField (itemFieldId LONG not null primary key,itemId LONG,name VARCHAR(75) null,values_ STRING null,description STRING null)";
67      public static final String TABLE_SQL_DROP = "drop table ShoppingItemField";
68      public static final String ORDER_BY_JPQL = " ORDER BY shoppingItemField.itemId ASC, shoppingItemField.name ASC";
69      public static final String ORDER_BY_SQL = " ORDER BY ShoppingItemField.itemId ASC, ShoppingItemField.name ASC";
70      public static final String DATA_SOURCE = "liferayDataSource";
71      public static final String SESSION_FACTORY = "liferaySessionFactory";
72      public static final String TX_MANAGER = "liferayTransactionManager";
73      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
74                  "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
75              true);
76      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
77                  "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
78              true);
79  
80      public static ShoppingItemField toModel(ShoppingItemFieldSoap soapModel) {
81          ShoppingItemField model = new ShoppingItemFieldImpl();
82  
83          model.setItemFieldId(soapModel.getItemFieldId());
84          model.setItemId(soapModel.getItemId());
85          model.setName(soapModel.getName());
86          model.setValues(soapModel.getValues());
87          model.setDescription(soapModel.getDescription());
88  
89          return model;
90      }
91  
92      public static List<ShoppingItemField> toModels(
93          ShoppingItemFieldSoap[] soapModels) {
94          List<ShoppingItemField> models = new ArrayList<ShoppingItemField>(soapModels.length);
95  
96          for (ShoppingItemFieldSoap soapModel : soapModels) {
97              models.add(toModel(soapModel));
98          }
99  
100         return models;
101     }
102 
103     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
104                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemField"));
105 
106     public ShoppingItemFieldModelImpl() {
107     }
108 
109     public long getPrimaryKey() {
110         return _itemFieldId;
111     }
112 
113     public void setPrimaryKey(long pk) {
114         setItemFieldId(pk);
115     }
116 
117     public Serializable getPrimaryKeyObj() {
118         return new Long(_itemFieldId);
119     }
120 
121     public long getItemFieldId() {
122         return _itemFieldId;
123     }
124 
125     public void setItemFieldId(long itemFieldId) {
126         _itemFieldId = itemFieldId;
127     }
128 
129     public long getItemId() {
130         return _itemId;
131     }
132 
133     public void setItemId(long itemId) {
134         _itemId = itemId;
135     }
136 
137     public String getName() {
138         return GetterUtil.getString(_name);
139     }
140 
141     public void setName(String name) {
142         _name = name;
143     }
144 
145     public String getValues() {
146         return GetterUtil.getString(_values);
147     }
148 
149     public void setValues(String values) {
150         _values = values;
151     }
152 
153     public String getDescription() {
154         return GetterUtil.getString(_description);
155     }
156 
157     public void setDescription(String description) {
158         _description = description;
159     }
160 
161     public ShoppingItemField toEscapedModel() {
162         if (isEscapedModel()) {
163             return (ShoppingItemField)this;
164         }
165         else {
166             ShoppingItemField model = new ShoppingItemFieldImpl();
167 
168             model.setNew(isNew());
169             model.setEscapedModel(true);
170 
171             model.setItemFieldId(getItemFieldId());
172             model.setItemId(getItemId());
173             model.setName(HtmlUtil.escape(getName()));
174             model.setValues(HtmlUtil.escape(getValues()));
175             model.setDescription(HtmlUtil.escape(getDescription()));
176 
177             model = (ShoppingItemField)Proxy.newProxyInstance(ShoppingItemField.class.getClassLoader(),
178                     new Class[] { ShoppingItemField.class },
179                     new ReadOnlyBeanHandler(model));
180 
181             return model;
182         }
183     }
184 
185     public ExpandoBridge getExpandoBridge() {
186         if (_expandoBridge == null) {
187             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
188                     ShoppingItemField.class.getName(), getPrimaryKey());
189         }
190 
191         return _expandoBridge;
192     }
193 
194     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
195         getExpandoBridge().setAttributes(serviceContext);
196     }
197 
198     public Object clone() {
199         ShoppingItemFieldImpl clone = new ShoppingItemFieldImpl();
200 
201         clone.setItemFieldId(getItemFieldId());
202         clone.setItemId(getItemId());
203         clone.setName(getName());
204         clone.setValues(getValues());
205         clone.setDescription(getDescription());
206 
207         return clone;
208     }
209 
210     public int compareTo(ShoppingItemField shoppingItemField) {
211         int value = 0;
212 
213         if (getItemId() < shoppingItemField.getItemId()) {
214             value = -1;
215         }
216         else if (getItemId() > shoppingItemField.getItemId()) {
217             value = 1;
218         }
219         else {
220             value = 0;
221         }
222 
223         if (value != 0) {
224             return value;
225         }
226 
227         value = getName().toLowerCase()
228                     .compareTo(shoppingItemField.getName().toLowerCase());
229 
230         if (value != 0) {
231             return value;
232         }
233 
234         return 0;
235     }
236 
237     public boolean equals(Object obj) {
238         if (obj == null) {
239             return false;
240         }
241 
242         ShoppingItemField shoppingItemField = null;
243 
244         try {
245             shoppingItemField = (ShoppingItemField)obj;
246         }
247         catch (ClassCastException cce) {
248             return false;
249         }
250 
251         long pk = shoppingItemField.getPrimaryKey();
252 
253         if (getPrimaryKey() == pk) {
254             return true;
255         }
256         else {
257             return false;
258         }
259     }
260 
261     public int hashCode() {
262         return (int)getPrimaryKey();
263     }
264 
265     public String toString() {
266         StringBundler sb = new StringBundler(11);
267 
268         sb.append("{itemFieldId=");
269         sb.append(getItemFieldId());
270         sb.append(", itemId=");
271         sb.append(getItemId());
272         sb.append(", name=");
273         sb.append(getName());
274         sb.append(", values=");
275         sb.append(getValues());
276         sb.append(", description=");
277         sb.append(getDescription());
278         sb.append("}");
279 
280         return sb.toString();
281     }
282 
283     public String toXmlString() {
284         StringBundler sb = new StringBundler(19);
285 
286         sb.append("<model><model-name>");
287         sb.append("com.liferay.portlet.shopping.model.ShoppingItemField");
288         sb.append("</model-name>");
289 
290         sb.append(
291             "<column><column-name>itemFieldId</column-name><column-value><![CDATA[");
292         sb.append(getItemFieldId());
293         sb.append("]]></column-value></column>");
294         sb.append(
295             "<column><column-name>itemId</column-name><column-value><![CDATA[");
296         sb.append(getItemId());
297         sb.append("]]></column-value></column>");
298         sb.append(
299             "<column><column-name>name</column-name><column-value><![CDATA[");
300         sb.append(getName());
301         sb.append("]]></column-value></column>");
302         sb.append(
303             "<column><column-name>values</column-name><column-value><![CDATA[");
304         sb.append(getValues());
305         sb.append("]]></column-value></column>");
306         sb.append(
307             "<column><column-name>description</column-name><column-value><![CDATA[");
308         sb.append(getDescription());
309         sb.append("]]></column-value></column>");
310 
311         sb.append("</model>");
312 
313         return sb.toString();
314     }
315 
316     private long _itemFieldId;
317     private long _itemId;
318     private String _name;
319     private String _values;
320     private String _description;
321     private transient ExpandoBridge _expandoBridge;
322 }