1
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.kernel.util.StringBundler;
29 import com.liferay.portal.model.impl.BaseModelImpl;
30 import com.liferay.portal.service.ServiceContext;
31
32 import com.liferay.portlet.expando.model.ExpandoBridge;
33 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
34 import com.liferay.portlet.shopping.model.ShoppingItemField;
35 import com.liferay.portlet.shopping.model.ShoppingItemFieldSoap;
36
37 import java.io.Serializable;
38
39 import java.lang.reflect.Proxy;
40
41 import java.sql.Types;
42
43 import java.util.ArrayList;
44 import java.util.List;
45
46
65 public class ShoppingItemFieldModelImpl extends BaseModelImpl<ShoppingItemField> {
66 public static final String TABLE_NAME = "ShoppingItemField";
67 public static final Object[][] TABLE_COLUMNS = {
68 { "itemFieldId", new Integer(Types.BIGINT) },
69 { "itemId", new Integer(Types.BIGINT) },
70 { "name", new Integer(Types.VARCHAR) },
71 { "values_", new Integer(Types.VARCHAR) },
72 { "description", new Integer(Types.VARCHAR) }
73 };
74 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)";
75 public static final String TABLE_SQL_DROP = "drop table ShoppingItemField";
76 public static final String ORDER_BY_JPQL = " ORDER BY shoppingItemField.itemId ASC, shoppingItemField.name ASC";
77 public static final String ORDER_BY_SQL = " ORDER BY ShoppingItemField.itemId ASC, ShoppingItemField.name ASC";
78 public static final String DATA_SOURCE = "liferayDataSource";
79 public static final String SESSION_FACTORY = "liferaySessionFactory";
80 public static final String TX_MANAGER = "liferayTransactionManager";
81 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
82 "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
83 true);
84 public static final boolean FINDER_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 _itemFieldId = itemFieldId;
135 }
136
137 public long getItemId() {
138 return _itemId;
139 }
140
141 public void setItemId(long itemId) {
142 _itemId = itemId;
143 }
144
145 public String getName() {
146 return GetterUtil.getString(_name);
147 }
148
149 public void setName(String name) {
150 _name = name;
151 }
152
153 public String getValues() {
154 return GetterUtil.getString(_values);
155 }
156
157 public void setValues(String values) {
158 _values = values;
159 }
160
161 public String getDescription() {
162 return GetterUtil.getString(_description);
163 }
164
165 public void setDescription(String description) {
166 _description = description;
167 }
168
169 public ShoppingItemField toEscapedModel() {
170 if (isEscapedModel()) {
171 return (ShoppingItemField)this;
172 }
173 else {
174 ShoppingItemField model = new ShoppingItemFieldImpl();
175
176 model.setNew(isNew());
177 model.setEscapedModel(true);
178
179 model.setItemFieldId(getItemFieldId());
180 model.setItemId(getItemId());
181 model.setName(HtmlUtil.escape(getName()));
182 model.setValues(HtmlUtil.escape(getValues()));
183 model.setDescription(HtmlUtil.escape(getDescription()));
184
185 model = (ShoppingItemField)Proxy.newProxyInstance(ShoppingItemField.class.getClassLoader(),
186 new Class[] { ShoppingItemField.class },
187 new ReadOnlyBeanHandler(model));
188
189 return model;
190 }
191 }
192
193 public ExpandoBridge getExpandoBridge() {
194 if (_expandoBridge == null) {
195 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(ShoppingItemField.class.getName(),
196 getPrimaryKey());
197 }
198
199 return _expandoBridge;
200 }
201
202 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
203 getExpandoBridge().setAttributes(serviceContext);
204 }
205
206 public Object clone() {
207 ShoppingItemFieldImpl clone = new ShoppingItemFieldImpl();
208
209 clone.setItemFieldId(getItemFieldId());
210 clone.setItemId(getItemId());
211 clone.setName(getName());
212 clone.setValues(getValues());
213 clone.setDescription(getDescription());
214
215 return clone;
216 }
217
218 public int compareTo(ShoppingItemField shoppingItemField) {
219 int value = 0;
220
221 if (getItemId() < shoppingItemField.getItemId()) {
222 value = -1;
223 }
224 else if (getItemId() > shoppingItemField.getItemId()) {
225 value = 1;
226 }
227 else {
228 value = 0;
229 }
230
231 if (value != 0) {
232 return value;
233 }
234
235 value = getName().toLowerCase()
236 .compareTo(shoppingItemField.getName().toLowerCase());
237
238 if (value != 0) {
239 return value;
240 }
241
242 return 0;
243 }
244
245 public boolean equals(Object obj) {
246 if (obj == null) {
247 return false;
248 }
249
250 ShoppingItemField shoppingItemField = null;
251
252 try {
253 shoppingItemField = (ShoppingItemField)obj;
254 }
255 catch (ClassCastException cce) {
256 return false;
257 }
258
259 long pk = shoppingItemField.getPrimaryKey();
260
261 if (getPrimaryKey() == pk) {
262 return true;
263 }
264 else {
265 return false;
266 }
267 }
268
269 public int hashCode() {
270 return (int)getPrimaryKey();
271 }
272
273 public String toString() {
274 StringBundler sb = new StringBundler(11);
275
276 sb.append("{itemFieldId=");
277 sb.append(getItemFieldId());
278 sb.append(", itemId=");
279 sb.append(getItemId());
280 sb.append(", name=");
281 sb.append(getName());
282 sb.append(", values=");
283 sb.append(getValues());
284 sb.append(", description=");
285 sb.append(getDescription());
286 sb.append("}");
287
288 return sb.toString();
289 }
290
291 public String toXmlString() {
292 StringBundler sb = new StringBundler(19);
293
294 sb.append("<model><model-name>");
295 sb.append("com.liferay.portlet.shopping.model.ShoppingItemField");
296 sb.append("</model-name>");
297
298 sb.append(
299 "<column><column-name>itemFieldId</column-name><column-value><![CDATA[");
300 sb.append(getItemFieldId());
301 sb.append("]]></column-value></column>");
302 sb.append(
303 "<column><column-name>itemId</column-name><column-value><![CDATA[");
304 sb.append(getItemId());
305 sb.append("]]></column-value></column>");
306 sb.append(
307 "<column><column-name>name</column-name><column-value><![CDATA[");
308 sb.append(getName());
309 sb.append("]]></column-value></column>");
310 sb.append(
311 "<column><column-name>values</column-name><column-value><![CDATA[");
312 sb.append(getValues());
313 sb.append("]]></column-value></column>");
314 sb.append(
315 "<column><column-name>description</column-name><column-value><![CDATA[");
316 sb.append(getDescription());
317 sb.append("]]></column-value></column>");
318
319 sb.append("</model>");
320
321 return sb.toString();
322 }
323
324 private long _itemFieldId;
325 private long _itemId;
326 private String _name;
327 private String _values;
328 private String _description;
329 private transient ExpandoBridge _expandoBridge;
330 }