1   /**
2    * Copyright (c) 2000-2008 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 {
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 CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
85                  "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
86              true);
87  
88      public static ShoppingItemField toModel(ShoppingItemFieldSoap soapModel) {
89          ShoppingItemField model = new ShoppingItemFieldImpl();
90  
91          model.setItemFieldId(soapModel.getItemFieldId());
92          model.setItemId(soapModel.getItemId());
93          model.setName(soapModel.getName());
94          model.setValues(soapModel.getValues());
95          model.setDescription(soapModel.getDescription());
96  
97          return model;
98      }
99  
100     public static List<ShoppingItemField> toModels(
101         ShoppingItemFieldSoap[] soapModels) {
102         List<ShoppingItemField> models = new ArrayList<ShoppingItemField>(soapModels.length);
103 
104         for (ShoppingItemFieldSoap soapModel : soapModels) {
105             models.add(toModel(soapModel));
106         }
107 
108         return models;
109     }
110 
111     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
112                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemField"));
113 
114     public ShoppingItemFieldModelImpl() {
115     }
116 
117     public long getPrimaryKey() {
118         return _itemFieldId;
119     }
120 
121     public void setPrimaryKey(long pk) {
122         setItemFieldId(pk);
123     }
124 
125     public Serializable getPrimaryKeyObj() {
126         return new Long(_itemFieldId);
127     }
128 
129     public long getItemFieldId() {
130         return _itemFieldId;
131     }
132 
133     public void setItemFieldId(long itemFieldId) {
134         if (itemFieldId != _itemFieldId) {
135             _itemFieldId = itemFieldId;
136         }
137     }
138 
139     public long getItemId() {
140         return _itemId;
141     }
142 
143     public void setItemId(long itemId) {
144         if (itemId != _itemId) {
145             _itemId = itemId;
146         }
147     }
148 
149     public String getName() {
150         return GetterUtil.getString(_name);
151     }
152 
153     public void setName(String name) {
154         if (((name == null) && (_name != null)) ||
155                 ((name != null) && (_name == null)) ||
156                 ((name != null) && (_name != null) && !name.equals(_name))) {
157             _name = name;
158         }
159     }
160 
161     public String getValues() {
162         return GetterUtil.getString(_values);
163     }
164 
165     public void setValues(String values) {
166         if (((values == null) && (_values != null)) ||
167                 ((values != null) && (_values == null)) ||
168                 ((values != null) && (_values != null) &&
169                 !values.equals(_values))) {
170             _values = values;
171         }
172     }
173 
174     public String getDescription() {
175         return GetterUtil.getString(_description);
176     }
177 
178     public void setDescription(String description) {
179         if (((description == null) && (_description != null)) ||
180                 ((description != null) && (_description == null)) ||
181                 ((description != null) && (_description != null) &&
182                 !description.equals(_description))) {
183             _description = description;
184         }
185     }
186 
187     public ShoppingItemField toEscapedModel() {
188         if (isEscapedModel()) {
189             return (ShoppingItemField)this;
190         }
191         else {
192             ShoppingItemField model = new ShoppingItemFieldImpl();
193 
194             model.setNew(isNew());
195             model.setEscapedModel(true);
196 
197             model.setItemFieldId(getItemFieldId());
198             model.setItemId(getItemId());
199             model.setName(HtmlUtil.escape(getName()));
200             model.setValues(HtmlUtil.escape(getValues()));
201             model.setDescription(HtmlUtil.escape(getDescription()));
202 
203             model = (ShoppingItemField)Proxy.newProxyInstance(ShoppingItemField.class.getClassLoader(),
204                     new Class[] { ShoppingItemField.class },
205                     new ReadOnlyBeanHandler(model));
206 
207             return model;
208         }
209     }
210 
211     public Object clone() {
212         ShoppingItemFieldImpl clone = new ShoppingItemFieldImpl();
213 
214         clone.setItemFieldId(getItemFieldId());
215         clone.setItemId(getItemId());
216         clone.setName(getName());
217         clone.setValues(getValues());
218         clone.setDescription(getDescription());
219 
220         return clone;
221     }
222 
223     public int compareTo(Object obj) {
224         if (obj == null) {
225             return -1;
226         }
227 
228         ShoppingItemFieldImpl shoppingItemField = (ShoppingItemFieldImpl)obj;
229 
230         int value = 0;
231 
232         if (getItemId() < shoppingItemField.getItemId()) {
233             value = -1;
234         }
235         else if (getItemId() > shoppingItemField.getItemId()) {
236             value = 1;
237         }
238         else {
239             value = 0;
240         }
241 
242         if (value != 0) {
243             return value;
244         }
245 
246         value = getName().toLowerCase()
247                     .compareTo(shoppingItemField.getName().toLowerCase());
248 
249         if (value != 0) {
250             return value;
251         }
252 
253         return 0;
254     }
255 
256     public boolean equals(Object obj) {
257         if (obj == null) {
258             return false;
259         }
260 
261         ShoppingItemFieldImpl shoppingItemField = null;
262 
263         try {
264             shoppingItemField = (ShoppingItemFieldImpl)obj;
265         }
266         catch (ClassCastException cce) {
267             return false;
268         }
269 
270         long pk = shoppingItemField.getPrimaryKey();
271 
272         if (getPrimaryKey() == pk) {
273             return true;
274         }
275         else {
276             return false;
277         }
278     }
279 
280     public int hashCode() {
281         return (int)getPrimaryKey();
282     }
283 
284     private long _itemFieldId;
285     private long _itemId;
286     private String _name;
287     private String _values;
288     private String _description;
289 }