1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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 interface is a model that represents the ShoppingItemField table in the
52   * database.
53   * </p>
54   *
55   * @author    Brian Wing Shun Chan
56   * @see       ShoppingItemFieldImpl
57   * @see       com.liferay.portlet.shopping.model.ShoppingItemField
58   * @see       com.liferay.portlet.shopping.model.ShoppingItemFieldModel
59   * @generated
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              { "itemId", new Integer(Types.BIGINT) },
66              { "name", new Integer(Types.VARCHAR) },
67              { "values_", new Integer(Types.VARCHAR) },
68              { "description", new Integer(Types.VARCHAR) }
69          };
70      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)";
71      public static final String TABLE_SQL_DROP = "drop table ShoppingItemField";
72      public static final String DATA_SOURCE = "liferayDataSource";
73      public static final String SESSION_FACTORY = "liferaySessionFactory";
74      public static final String TX_MANAGER = "liferayTransactionManager";
75      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
76                  "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
77              true);
78      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79                  "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
80              true);
81  
82      public static ShoppingItemField toModel(ShoppingItemFieldSoap soapModel) {
83          ShoppingItemField model = new ShoppingItemFieldImpl();
84  
85          model.setItemFieldId(soapModel.getItemFieldId());
86          model.setItemId(soapModel.getItemId());
87          model.setName(soapModel.getName());
88          model.setValues(soapModel.getValues());
89          model.setDescription(soapModel.getDescription());
90  
91          return model;
92      }
93  
94      public static List<ShoppingItemField> toModels(
95          ShoppingItemFieldSoap[] soapModels) {
96          List<ShoppingItemField> models = new ArrayList<ShoppingItemField>(soapModels.length);
97  
98          for (ShoppingItemFieldSoap soapModel : soapModels) {
99              models.add(toModel(soapModel));
100         }
101 
102         return models;
103     }
104 
105     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
106                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemField"));
107 
108     public ShoppingItemFieldModelImpl() {
109     }
110 
111     public long getPrimaryKey() {
112         return _itemFieldId;
113     }
114 
115     public void setPrimaryKey(long pk) {
116         setItemFieldId(pk);
117     }
118 
119     public Serializable getPrimaryKeyObj() {
120         return new Long(_itemFieldId);
121     }
122 
123     public long getItemFieldId() {
124         return _itemFieldId;
125     }
126 
127     public void setItemFieldId(long itemFieldId) {
128         _itemFieldId = itemFieldId;
129     }
130 
131     public long getItemId() {
132         return _itemId;
133     }
134 
135     public void setItemId(long itemId) {
136         _itemId = itemId;
137     }
138 
139     public String getName() {
140         return GetterUtil.getString(_name);
141     }
142 
143     public void setName(String name) {
144         _name = name;
145     }
146 
147     public String getValues() {
148         return GetterUtil.getString(_values);
149     }
150 
151     public void setValues(String values) {
152         _values = values;
153     }
154 
155     public String getDescription() {
156         return GetterUtil.getString(_description);
157     }
158 
159     public void setDescription(String description) {
160         _description = description;
161     }
162 
163     public ShoppingItemField toEscapedModel() {
164         if (isEscapedModel()) {
165             return (ShoppingItemField)this;
166         }
167         else {
168             ShoppingItemField model = new ShoppingItemFieldImpl();
169 
170             model.setNew(isNew());
171             model.setEscapedModel(true);
172 
173             model.setItemFieldId(getItemFieldId());
174             model.setItemId(getItemId());
175             model.setName(HtmlUtil.escape(getName()));
176             model.setValues(HtmlUtil.escape(getValues()));
177             model.setDescription(HtmlUtil.escape(getDescription()));
178 
179             model = (ShoppingItemField)Proxy.newProxyInstance(ShoppingItemField.class.getClassLoader(),
180                     new Class[] { ShoppingItemField.class },
181                     new ReadOnlyBeanHandler(model));
182 
183             return model;
184         }
185     }
186 
187     public Object clone() {
188         ShoppingItemFieldImpl clone = new ShoppingItemFieldImpl();
189 
190         clone.setItemFieldId(getItemFieldId());
191         clone.setItemId(getItemId());
192         clone.setName(getName());
193         clone.setValues(getValues());
194         clone.setDescription(getDescription());
195 
196         return clone;
197     }
198 
199     public int compareTo(ShoppingItemField shoppingItemField) {
200         int value = 0;
201 
202         if (getItemId() < shoppingItemField.getItemId()) {
203             value = -1;
204         }
205         else if (getItemId() > shoppingItemField.getItemId()) {
206             value = 1;
207         }
208         else {
209             value = 0;
210         }
211 
212         if (value != 0) {
213             return value;
214         }
215 
216         value = getName().toLowerCase()
217                     .compareTo(shoppingItemField.getName().toLowerCase());
218 
219         if (value != 0) {
220             return value;
221         }
222 
223         return 0;
224     }
225 
226     public boolean equals(Object obj) {
227         if (obj == null) {
228             return false;
229         }
230 
231         ShoppingItemField shoppingItemField = null;
232 
233         try {
234             shoppingItemField = (ShoppingItemField)obj;
235         }
236         catch (ClassCastException cce) {
237             return false;
238         }
239 
240         long pk = shoppingItemField.getPrimaryKey();
241 
242         if (getPrimaryKey() == pk) {
243             return true;
244         }
245         else {
246             return false;
247         }
248     }
249 
250     public int hashCode() {
251         return (int)getPrimaryKey();
252     }
253 
254     public String toString() {
255         StringBuilder sb = new StringBuilder();
256 
257         sb.append("{itemFieldId=");
258         sb.append(getItemFieldId());
259         sb.append(", itemId=");
260         sb.append(getItemId());
261         sb.append(", name=");
262         sb.append(getName());
263         sb.append(", values=");
264         sb.append(getValues());
265         sb.append(", description=");
266         sb.append(getDescription());
267         sb.append("}");
268 
269         return sb.toString();
270     }
271 
272     public String toXmlString() {
273         StringBuilder sb = new StringBuilder();
274 
275         sb.append("<model><model-name>");
276         sb.append("com.liferay.portlet.shopping.model.ShoppingItemField");
277         sb.append("</model-name>");
278 
279         sb.append(
280             "<column><column-name>itemFieldId</column-name><column-value><![CDATA[");
281         sb.append(getItemFieldId());
282         sb.append("]]></column-value></column>");
283         sb.append(
284             "<column><column-name>itemId</column-name><column-value><![CDATA[");
285         sb.append(getItemId());
286         sb.append("]]></column-value></column>");
287         sb.append(
288             "<column><column-name>name</column-name><column-value><![CDATA[");
289         sb.append(getName());
290         sb.append("]]></column-value></column>");
291         sb.append(
292             "<column><column-name>values</column-name><column-value><![CDATA[");
293         sb.append(getValues());
294         sb.append("]]></column-value></column>");
295         sb.append(
296             "<column><column-name>description</column-name><column-value><![CDATA[");
297         sb.append(getDescription());
298         sb.append("]]></column-value></column>");
299 
300         sb.append("</model>");
301 
302         return sb.toString();
303     }
304 
305     private long _itemFieldId;
306     private long _itemId;
307     private String _name;
308     private String _values;
309     private String _description;
310 }