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.service.model.ShoppingItemField
58   * @see com.liferay.portlet.shopping.service.model.ShoppingItemFieldModel
59   * @see com.liferay.portlet.shopping.service.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.setEscapedModel(true);
195 
196             model.setItemFieldId(getItemFieldId());
197             model.setItemId(getItemId());
198             model.setName(HtmlUtil.escape(getName()));
199             model.setValues(HtmlUtil.escape(getValues()));
200             model.setDescription(HtmlUtil.escape(getDescription()));
201 
202             model = (ShoppingItemField)Proxy.newProxyInstance(ShoppingItemField.class.getClassLoader(),
203                     new Class[] { ShoppingItemField.class },
204                     new ReadOnlyBeanHandler(model));
205 
206             return model;
207         }
208     }
209 
210     public Object clone() {
211         ShoppingItemFieldImpl clone = new ShoppingItemFieldImpl();
212 
213         clone.setItemFieldId(getItemFieldId());
214         clone.setItemId(getItemId());
215         clone.setName(getName());
216         clone.setValues(getValues());
217         clone.setDescription(getDescription());
218 
219         return clone;
220     }
221 
222     public int compareTo(Object obj) {
223         if (obj == null) {
224             return -1;
225         }
226 
227         ShoppingItemFieldImpl shoppingItemField = (ShoppingItemFieldImpl)obj;
228 
229         int value = 0;
230 
231         if (getItemId() < shoppingItemField.getItemId()) {
232             value = -1;
233         }
234         else if (getItemId() > shoppingItemField.getItemId()) {
235             value = 1;
236         }
237         else {
238             value = 0;
239         }
240 
241         if (value != 0) {
242             return value;
243         }
244 
245         value = getName().toLowerCase()
246                     .compareTo(shoppingItemField.getName().toLowerCase());
247 
248         if (value != 0) {
249             return value;
250         }
251 
252         return 0;
253     }
254 
255     public boolean equals(Object obj) {
256         if (obj == null) {
257             return false;
258         }
259 
260         ShoppingItemFieldImpl shoppingItemField = null;
261 
262         try {
263             shoppingItemField = (ShoppingItemFieldImpl)obj;
264         }
265         catch (ClassCastException cce) {
266             return false;
267         }
268 
269         long pk = shoppingItemField.getPrimaryKey();
270 
271         if (getPrimaryKey() == pk) {
272             return true;
273         }
274         else {
275             return false;
276         }
277     }
278 
279     public int hashCode() {
280         return (int)getPrimaryKey();
281     }
282 
283     private long _itemFieldId;
284     private long _itemId;
285     private String _name;
286     private String _values;
287     private String _description;
288 }