001
014
015 package com.liferay.portlet.shopping.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.util.GetterUtil;
019 import com.liferay.portal.kernel.util.ProxyUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.model.CacheModel;
023 import com.liferay.portal.model.impl.BaseModelImpl;
024 import com.liferay.portal.service.ServiceContext;
025
026 import com.liferay.portlet.expando.model.ExpandoBridge;
027 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028 import com.liferay.portlet.shopping.model.ShoppingItemField;
029 import com.liferay.portlet.shopping.model.ShoppingItemFieldModel;
030
031 import java.io.Serializable;
032
033 import java.sql.Types;
034
035 import java.util.HashMap;
036 import java.util.Map;
037
038
051 public class ShoppingItemFieldModelImpl extends BaseModelImpl<ShoppingItemField>
052 implements ShoppingItemFieldModel {
053
058 public static final String TABLE_NAME = "ShoppingItemField";
059 public static final Object[][] TABLE_COLUMNS = {
060 { "itemFieldId", Types.BIGINT },
061 { "itemId", Types.BIGINT },
062 { "name", Types.VARCHAR },
063 { "values_", Types.VARCHAR },
064 { "description", Types.VARCHAR }
065 };
066 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)";
067 public static final String TABLE_SQL_DROP = "drop table ShoppingItemField";
068 public static final String ORDER_BY_JPQL = " ORDER BY shoppingItemField.itemId ASC, shoppingItemField.name ASC";
069 public static final String ORDER_BY_SQL = " ORDER BY ShoppingItemField.itemId ASC, ShoppingItemField.name ASC";
070 public static final String DATA_SOURCE = "liferayDataSource";
071 public static final String SESSION_FACTORY = "liferaySessionFactory";
072 public static final String TX_MANAGER = "liferayTransactionManager";
073 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074 "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
075 true);
076 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077 "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
078 true);
079 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080 "value.object.column.bitmask.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
081 true);
082 public static long ITEMID_COLUMN_BITMASK = 1L;
083 public static long NAME_COLUMN_BITMASK = 2L;
084 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
085 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemField"));
086
087 public ShoppingItemFieldModelImpl() {
088 }
089
090 public long getPrimaryKey() {
091 return _itemFieldId;
092 }
093
094 public void setPrimaryKey(long primaryKey) {
095 setItemFieldId(primaryKey);
096 }
097
098 public Serializable getPrimaryKeyObj() {
099 return new Long(_itemFieldId);
100 }
101
102 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
103 setPrimaryKey(((Long)primaryKeyObj).longValue());
104 }
105
106 public Class<?> getModelClass() {
107 return ShoppingItemField.class;
108 }
109
110 public String getModelClassName() {
111 return ShoppingItemField.class.getName();
112 }
113
114 @Override
115 public Map<String, Object> getModelAttributes() {
116 Map<String, Object> attributes = new HashMap<String, Object>();
117
118 attributes.put("itemFieldId", getItemFieldId());
119 attributes.put("itemId", getItemId());
120 attributes.put("name", getName());
121 attributes.put("values", getValues());
122 attributes.put("description", getDescription());
123
124 return attributes;
125 }
126
127 @Override
128 public void setModelAttributes(Map<String, Object> attributes) {
129 Long itemFieldId = (Long)attributes.get("itemFieldId");
130
131 if (itemFieldId != null) {
132 setItemFieldId(itemFieldId);
133 }
134
135 Long itemId = (Long)attributes.get("itemId");
136
137 if (itemId != null) {
138 setItemId(itemId);
139 }
140
141 String name = (String)attributes.get("name");
142
143 if (name != null) {
144 setName(name);
145 }
146
147 String values = (String)attributes.get("values");
148
149 if (values != null) {
150 setValues(values);
151 }
152
153 String description = (String)attributes.get("description");
154
155 if (description != null) {
156 setDescription(description);
157 }
158 }
159
160 public long getItemFieldId() {
161 return _itemFieldId;
162 }
163
164 public void setItemFieldId(long itemFieldId) {
165 _itemFieldId = itemFieldId;
166 }
167
168 public long getItemId() {
169 return _itemId;
170 }
171
172 public void setItemId(long itemId) {
173 _columnBitmask = -1L;
174
175 if (!_setOriginalItemId) {
176 _setOriginalItemId = true;
177
178 _originalItemId = _itemId;
179 }
180
181 _itemId = itemId;
182 }
183
184 public long getOriginalItemId() {
185 return _originalItemId;
186 }
187
188 public String getName() {
189 if (_name == null) {
190 return StringPool.BLANK;
191 }
192 else {
193 return _name;
194 }
195 }
196
197 public void setName(String name) {
198 _columnBitmask = -1L;
199
200 _name = name;
201 }
202
203 public String getValues() {
204 if (_values == null) {
205 return StringPool.BLANK;
206 }
207 else {
208 return _values;
209 }
210 }
211
212 public void setValues(String values) {
213 _values = values;
214 }
215
216 public String getDescription() {
217 if (_description == null) {
218 return StringPool.BLANK;
219 }
220 else {
221 return _description;
222 }
223 }
224
225 public void setDescription(String description) {
226 _description = description;
227 }
228
229 public long getColumnBitmask() {
230 return _columnBitmask;
231 }
232
233 @Override
234 public ExpandoBridge getExpandoBridge() {
235 return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
236 ShoppingItemField.class.getName(), getPrimaryKey());
237 }
238
239 @Override
240 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
241 ExpandoBridge expandoBridge = getExpandoBridge();
242
243 expandoBridge.setAttributes(serviceContext);
244 }
245
246 @Override
247 public ShoppingItemField toEscapedModel() {
248 if (_escapedModel == null) {
249 _escapedModel = (ShoppingItemField)ProxyUtil.newProxyInstance(_classLoader,
250 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
251 }
252
253 return _escapedModel;
254 }
255
256 @Override
257 public Object clone() {
258 ShoppingItemFieldImpl shoppingItemFieldImpl = new ShoppingItemFieldImpl();
259
260 shoppingItemFieldImpl.setItemFieldId(getItemFieldId());
261 shoppingItemFieldImpl.setItemId(getItemId());
262 shoppingItemFieldImpl.setName(getName());
263 shoppingItemFieldImpl.setValues(getValues());
264 shoppingItemFieldImpl.setDescription(getDescription());
265
266 shoppingItemFieldImpl.resetOriginalValues();
267
268 return shoppingItemFieldImpl;
269 }
270
271 public int compareTo(ShoppingItemField shoppingItemField) {
272 int value = 0;
273
274 if (getItemId() < shoppingItemField.getItemId()) {
275 value = -1;
276 }
277 else if (getItemId() > shoppingItemField.getItemId()) {
278 value = 1;
279 }
280 else {
281 value = 0;
282 }
283
284 if (value != 0) {
285 return value;
286 }
287
288 value = getName().toLowerCase()
289 .compareTo(shoppingItemField.getName().toLowerCase());
290
291 if (value != 0) {
292 return value;
293 }
294
295 return 0;
296 }
297
298 @Override
299 public boolean equals(Object obj) {
300 if (obj == null) {
301 return false;
302 }
303
304 ShoppingItemField shoppingItemField = null;
305
306 try {
307 shoppingItemField = (ShoppingItemField)obj;
308 }
309 catch (ClassCastException cce) {
310 return false;
311 }
312
313 long primaryKey = shoppingItemField.getPrimaryKey();
314
315 if (getPrimaryKey() == primaryKey) {
316 return true;
317 }
318 else {
319 return false;
320 }
321 }
322
323 @Override
324 public int hashCode() {
325 return (int)getPrimaryKey();
326 }
327
328 @Override
329 public void resetOriginalValues() {
330 ShoppingItemFieldModelImpl shoppingItemFieldModelImpl = this;
331
332 shoppingItemFieldModelImpl._originalItemId = shoppingItemFieldModelImpl._itemId;
333
334 shoppingItemFieldModelImpl._setOriginalItemId = false;
335
336 shoppingItemFieldModelImpl._columnBitmask = 0;
337 }
338
339 @Override
340 public CacheModel<ShoppingItemField> toCacheModel() {
341 ShoppingItemFieldCacheModel shoppingItemFieldCacheModel = new ShoppingItemFieldCacheModel();
342
343 shoppingItemFieldCacheModel.itemFieldId = getItemFieldId();
344
345 shoppingItemFieldCacheModel.itemId = getItemId();
346
347 shoppingItemFieldCacheModel.name = getName();
348
349 String name = shoppingItemFieldCacheModel.name;
350
351 if ((name != null) && (name.length() == 0)) {
352 shoppingItemFieldCacheModel.name = null;
353 }
354
355 shoppingItemFieldCacheModel.values = getValues();
356
357 String values = shoppingItemFieldCacheModel.values;
358
359 if ((values != null) && (values.length() == 0)) {
360 shoppingItemFieldCacheModel.values = null;
361 }
362
363 shoppingItemFieldCacheModel.description = getDescription();
364
365 String description = shoppingItemFieldCacheModel.description;
366
367 if ((description != null) && (description.length() == 0)) {
368 shoppingItemFieldCacheModel.description = null;
369 }
370
371 return shoppingItemFieldCacheModel;
372 }
373
374 @Override
375 public String toString() {
376 StringBundler sb = new StringBundler(11);
377
378 sb.append("{itemFieldId=");
379 sb.append(getItemFieldId());
380 sb.append(", itemId=");
381 sb.append(getItemId());
382 sb.append(", name=");
383 sb.append(getName());
384 sb.append(", values=");
385 sb.append(getValues());
386 sb.append(", description=");
387 sb.append(getDescription());
388 sb.append("}");
389
390 return sb.toString();
391 }
392
393 public String toXmlString() {
394 StringBundler sb = new StringBundler(19);
395
396 sb.append("<model><model-name>");
397 sb.append("com.liferay.portlet.shopping.model.ShoppingItemField");
398 sb.append("</model-name>");
399
400 sb.append(
401 "<column><column-name>itemFieldId</column-name><column-value><![CDATA[");
402 sb.append(getItemFieldId());
403 sb.append("]]></column-value></column>");
404 sb.append(
405 "<column><column-name>itemId</column-name><column-value><![CDATA[");
406 sb.append(getItemId());
407 sb.append("]]></column-value></column>");
408 sb.append(
409 "<column><column-name>name</column-name><column-value><![CDATA[");
410 sb.append(getName());
411 sb.append("]]></column-value></column>");
412 sb.append(
413 "<column><column-name>values</column-name><column-value><![CDATA[");
414 sb.append(getValues());
415 sb.append("]]></column-value></column>");
416 sb.append(
417 "<column><column-name>description</column-name><column-value><![CDATA[");
418 sb.append(getDescription());
419 sb.append("]]></column-value></column>");
420
421 sb.append("</model>");
422
423 return sb.toString();
424 }
425
426 private static ClassLoader _classLoader = ShoppingItemField.class.getClassLoader();
427 private static Class<?>[] _escapedModelInterfaces = new Class[] {
428 ShoppingItemField.class
429 };
430 private long _itemFieldId;
431 private long _itemId;
432 private long _originalItemId;
433 private boolean _setOriginalItemId;
434 private String _name;
435 private String _values;
436 private String _description;
437 private long _columnBitmask;
438 private ShoppingItemField _escapedModel;
439 }