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