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