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