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 final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
084 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemField"));
085
086 public ShoppingItemFieldModelImpl() {
087 }
088
089 public long getPrimaryKey() {
090 return _itemFieldId;
091 }
092
093 public void setPrimaryKey(long primaryKey) {
094 setItemFieldId(primaryKey);
095 }
096
097 public Serializable getPrimaryKeyObj() {
098 return new Long(_itemFieldId);
099 }
100
101 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
102 setPrimaryKey(((Long)primaryKeyObj).longValue());
103 }
104
105 public Class<?> getModelClass() {
106 return ShoppingItemField.class;
107 }
108
109 public String getModelClassName() {
110 return ShoppingItemField.class.getName();
111 }
112
113 @Override
114 public Map<String, Object> getModelAttributes() {
115 Map<String, Object> attributes = new HashMap<String, Object>();
116
117 attributes.put("itemFieldId", getItemFieldId());
118 attributes.put("itemId", getItemId());
119 attributes.put("name", getName());
120 attributes.put("values", getValues());
121 attributes.put("description", getDescription());
122
123 return attributes;
124 }
125
126 @Override
127 public void setModelAttributes(Map<String, Object> attributes) {
128 Long itemFieldId = (Long)attributes.get("itemFieldId");
129
130 if (itemFieldId != null) {
131 setItemFieldId(itemFieldId);
132 }
133
134 Long itemId = (Long)attributes.get("itemId");
135
136 if (itemId != null) {
137 setItemId(itemId);
138 }
139
140 String name = (String)attributes.get("name");
141
142 if (name != null) {
143 setName(name);
144 }
145
146 String values = (String)attributes.get("values");
147
148 if (values != null) {
149 setValues(values);
150 }
151
152 String description = (String)attributes.get("description");
153
154 if (description != null) {
155 setDescription(description);
156 }
157 }
158
159 public long getItemFieldId() {
160 return _itemFieldId;
161 }
162
163 public void setItemFieldId(long itemFieldId) {
164 _itemFieldId = itemFieldId;
165 }
166
167 public long getItemId() {
168 return _itemId;
169 }
170
171 public void setItemId(long itemId) {
172 _columnBitmask = -1L;
173
174 if (!_setOriginalItemId) {
175 _setOriginalItemId = true;
176
177 _originalItemId = _itemId;
178 }
179
180 _itemId = itemId;
181 }
182
183 public long getOriginalItemId() {
184 return _originalItemId;
185 }
186
187 public String getName() {
188 if (_name == null) {
189 return StringPool.BLANK;
190 }
191 else {
192 return _name;
193 }
194 }
195
196 public void setName(String name) {
197 _columnBitmask = -1L;
198
199 _name = name;
200 }
201
202 public String getValues() {
203 if (_values == null) {
204 return StringPool.BLANK;
205 }
206 else {
207 return _values;
208 }
209 }
210
211 public void setValues(String values) {
212 _values = values;
213 }
214
215 public String getDescription() {
216 if (_description == null) {
217 return StringPool.BLANK;
218 }
219 else {
220 return _description;
221 }
222 }
223
224 public void setDescription(String description) {
225 _description = description;
226 }
227
228 public long getColumnBitmask() {
229 return _columnBitmask;
230 }
231
232 @Override
233 public ExpandoBridge getExpandoBridge() {
234 return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
235 ShoppingItemField.class.getName(), getPrimaryKey());
236 }
237
238 @Override
239 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
240 ExpandoBridge expandoBridge = getExpandoBridge();
241
242 expandoBridge.setAttributes(serviceContext);
243 }
244
245 @Override
246 public ShoppingItemField toEscapedModel() {
247 if (_escapedModel == null) {
248 _escapedModel = (ShoppingItemField)ProxyUtil.newProxyInstance(_classLoader,
249 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
250 }
251
252 return _escapedModel;
253 }
254
255 public ShoppingItemField toUnescapedModel() {
256 return (ShoppingItemField)this;
257 }
258
259 @Override
260 public Object clone() {
261 ShoppingItemFieldImpl shoppingItemFieldImpl = new ShoppingItemFieldImpl();
262
263 shoppingItemFieldImpl.setItemFieldId(getItemFieldId());
264 shoppingItemFieldImpl.setItemId(getItemId());
265 shoppingItemFieldImpl.setName(getName());
266 shoppingItemFieldImpl.setValues(getValues());
267 shoppingItemFieldImpl.setDescription(getDescription());
268
269 shoppingItemFieldImpl.resetOriginalValues();
270
271 return shoppingItemFieldImpl;
272 }
273
274 public int compareTo(ShoppingItemField shoppingItemField) {
275 int value = 0;
276
277 if (getItemId() < shoppingItemField.getItemId()) {
278 value = -1;
279 }
280 else if (getItemId() > shoppingItemField.getItemId()) {
281 value = 1;
282 }
283 else {
284 value = 0;
285 }
286
287 if (value != 0) {
288 return value;
289 }
290
291 value = getName().toLowerCase()
292 .compareTo(shoppingItemField.getName().toLowerCase());
293
294 if (value != 0) {
295 return value;
296 }
297
298 return 0;
299 }
300
301 @Override
302 public boolean equals(Object obj) {
303 if (this == obj) {
304 return true;
305 }
306
307 if (!(obj instanceof ShoppingItemField)) {
308 return false;
309 }
310
311 ShoppingItemField shoppingItemField = (ShoppingItemField)obj;
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 }