1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.ShoppingItemField;
31  import com.liferay.portlet.shopping.model.ShoppingItemFieldSoap;
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.List;
41  
42  /**
43   * <a href="ShoppingItemFieldModelImpl.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>ShoppingItemField</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portlet.shopping.model.ShoppingItemField
58   * @see com.liferay.portlet.shopping.model.ShoppingItemFieldModel
59   * @see com.liferay.portlet.shopping.model.impl.ShoppingItemFieldImpl
60   *
61   */
62  public class ShoppingItemFieldModelImpl extends BaseModelImpl<ShoppingItemField> {
63      public static final String TABLE_NAME = "ShoppingItemField";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "itemFieldId", new Integer(Types.BIGINT) },
66              
67  
68              { "itemId", new Integer(Types.BIGINT) },
69              
70  
71              { "name", new Integer(Types.VARCHAR) },
72              
73  
74              { "values_", new Integer(Types.VARCHAR) },
75              
76  
77              { "description", new Integer(Types.VARCHAR) }
78          };
79      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)";
80      public static final String TABLE_SQL_DROP = "drop table ShoppingItemField";
81      public static final String DATA_SOURCE = "liferayDataSource";
82      public static final String SESSION_FACTORY = "liferaySessionFactory";
83      public static final String TX_MANAGER = "liferayTransactionManager";
84      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
85                  "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
86              true);
87      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
88                  "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
89              true);
90  
91      public static ShoppingItemField toModel(ShoppingItemFieldSoap soapModel) {
92          ShoppingItemField model = new ShoppingItemFieldImpl();
93  
94          model.setItemFieldId(soapModel.getItemFieldId());
95          model.setItemId(soapModel.getItemId());
96          model.setName(soapModel.getName());
97          model.setValues(soapModel.getValues());
98          model.setDescription(soapModel.getDescription());
99  
100         return model;
101     }
102 
103     public static List<ShoppingItemField> toModels(
104         ShoppingItemFieldSoap[] soapModels) {
105         List<ShoppingItemField> models = new ArrayList<ShoppingItemField>(soapModels.length);
106 
107         for (ShoppingItemFieldSoap soapModel : soapModels) {
108             models.add(toModel(soapModel));
109         }
110 
111         return models;
112     }
113 
114     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
115                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemField"));
116 
117     public ShoppingItemFieldModelImpl() {
118     }
119 
120     public long getPrimaryKey() {
121         return _itemFieldId;
122     }
123 
124     public void setPrimaryKey(long pk) {
125         setItemFieldId(pk);
126     }
127 
128     public Serializable getPrimaryKeyObj() {
129         return new Long(_itemFieldId);
130     }
131 
132     public long getItemFieldId() {
133         return _itemFieldId;
134     }
135 
136     public void setItemFieldId(long itemFieldId) {
137         _itemFieldId = itemFieldId;
138     }
139 
140     public long getItemId() {
141         return _itemId;
142     }
143 
144     public void setItemId(long itemId) {
145         _itemId = itemId;
146     }
147 
148     public String getName() {
149         return GetterUtil.getString(_name);
150     }
151 
152     public void setName(String name) {
153         _name = name;
154     }
155 
156     public String getValues() {
157         return GetterUtil.getString(_values);
158     }
159 
160     public void setValues(String values) {
161         _values = values;
162     }
163 
164     public String getDescription() {
165         return GetterUtil.getString(_description);
166     }
167 
168     public void setDescription(String description) {
169         _description = description;
170     }
171 
172     public ShoppingItemField toEscapedModel() {
173         if (isEscapedModel()) {
174             return (ShoppingItemField)this;
175         }
176         else {
177             ShoppingItemField model = new ShoppingItemFieldImpl();
178 
179             model.setNew(isNew());
180             model.setEscapedModel(true);
181 
182             model.setItemFieldId(getItemFieldId());
183             model.setItemId(getItemId());
184             model.setName(HtmlUtil.escape(getName()));
185             model.setValues(HtmlUtil.escape(getValues()));
186             model.setDescription(HtmlUtil.escape(getDescription()));
187 
188             model = (ShoppingItemField)Proxy.newProxyInstance(ShoppingItemField.class.getClassLoader(),
189                     new Class[] { ShoppingItemField.class },
190                     new ReadOnlyBeanHandler(model));
191 
192             return model;
193         }
194     }
195 
196     public Object clone() {
197         ShoppingItemFieldImpl clone = new ShoppingItemFieldImpl();
198 
199         clone.setItemFieldId(getItemFieldId());
200         clone.setItemId(getItemId());
201         clone.setName(getName());
202         clone.setValues(getValues());
203         clone.setDescription(getDescription());
204 
205         return clone;
206     }
207 
208     public int compareTo(ShoppingItemField shoppingItemField) {
209         int value = 0;
210 
211         if (getItemId() < shoppingItemField.getItemId()) {
212             value = -1;
213         }
214         else if (getItemId() > shoppingItemField.getItemId()) {
215             value = 1;
216         }
217         else {
218             value = 0;
219         }
220 
221         if (value != 0) {
222             return value;
223         }
224 
225         value = getName().toLowerCase()
226                     .compareTo(shoppingItemField.getName().toLowerCase());
227 
228         if (value != 0) {
229             return value;
230         }
231 
232         return 0;
233     }
234 
235     public boolean equals(Object obj) {
236         if (obj == null) {
237             return false;
238         }
239 
240         ShoppingItemField shoppingItemField = null;
241 
242         try {
243             shoppingItemField = (ShoppingItemField)obj;
244         }
245         catch (ClassCastException cce) {
246             return false;
247         }
248 
249         long pk = shoppingItemField.getPrimaryKey();
250 
251         if (getPrimaryKey() == pk) {
252             return true;
253         }
254         else {
255             return false;
256         }
257     }
258 
259     public int hashCode() {
260         return (int)getPrimaryKey();
261     }
262 
263     public String toString() {
264         StringBuilder sb = new StringBuilder();
265 
266         sb.append("{itemFieldId=");
267         sb.append(getItemFieldId());
268         sb.append(", itemId=");
269         sb.append(getItemId());
270         sb.append(", name=");
271         sb.append(getName());
272         sb.append(", values=");
273         sb.append(getValues());
274         sb.append(", description=");
275         sb.append(getDescription());
276         sb.append("}");
277 
278         return sb.toString();
279     }
280 
281     public String toXmlString() {
282         StringBuilder sb = new StringBuilder();
283 
284         sb.append("<model><model-name>");
285         sb.append("com.liferay.portlet.shopping.model.ShoppingItemField");
286         sb.append("</model-name>");
287 
288         sb.append(
289             "<column><column-name>itemFieldId</column-name><column-value><![CDATA[");
290         sb.append(getItemFieldId());
291         sb.append("]]></column-value></column>");
292         sb.append(
293             "<column><column-name>itemId</column-name><column-value><![CDATA[");
294         sb.append(getItemId());
295         sb.append("]]></column-value></column>");
296         sb.append(
297             "<column><column-name>name</column-name><column-value><![CDATA[");
298         sb.append(getName());
299         sb.append("]]></column-value></column>");
300         sb.append(
301             "<column><column-name>values</column-name><column-value><![CDATA[");
302         sb.append(getValues());
303         sb.append("]]></column-value></column>");
304         sb.append(
305             "<column><column-name>description</column-name><column-value><![CDATA[");
306         sb.append(getDescription());
307         sb.append("]]></column-value></column>");
308 
309         sb.append("</model>");
310 
311         return sb.toString();
312     }
313 
314     private long _itemFieldId;
315     private long _itemId;
316     private String _name;
317     private String _values;
318     private String _description;
319 }