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