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