001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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    /**
039     * The base model implementation for the ShoppingItemField service. Represents a row in the "ShoppingItemField" database table, with each column mapped to a property of this class.
040     *
041     * <p>
042     * This implementation and its corresponding interface {@link com.liferay.portlet.shopping.model.ShoppingItemFieldModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ShoppingItemFieldImpl}.
043     * </p>
044     *
045     * @author Brian Wing Shun Chan
046     * @see ShoppingItemFieldImpl
047     * @see com.liferay.portlet.shopping.model.ShoppingItemField
048     * @see com.liferay.portlet.shopping.model.ShoppingItemFieldModel
049     * @generated
050     */
051    public class ShoppingItemFieldModelImpl extends BaseModelImpl<ShoppingItemField>
052            implements ShoppingItemFieldModel {
053            /*
054             * NOTE FOR DEVELOPERS:
055             *
056             * Never modify or reference this class directly. All methods that expect a shopping item field model instance should use the {@link com.liferay.portlet.shopping.model.ShoppingItemField} interface instead.
057             */
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            @Override
091            public long getPrimaryKey() {
092                    return _itemFieldId;
093            }
094    
095            @Override
096            public void setPrimaryKey(long primaryKey) {
097                    setItemFieldId(primaryKey);
098            }
099    
100            @Override
101            public Serializable getPrimaryKeyObj() {
102                    return _itemFieldId;
103            }
104    
105            @Override
106            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
107                    setPrimaryKey(((Long)primaryKeyObj).longValue());
108            }
109    
110            @Override
111            public Class<?> getModelClass() {
112                    return ShoppingItemField.class;
113            }
114    
115            @Override
116            public String getModelClassName() {
117                    return ShoppingItemField.class.getName();
118            }
119    
120            @Override
121            public Map<String, Object> getModelAttributes() {
122                    Map<String, Object> attributes = new HashMap<String, Object>();
123    
124                    attributes.put("itemFieldId", getItemFieldId());
125                    attributes.put("itemId", getItemId());
126                    attributes.put("name", getName());
127                    attributes.put("values", getValues());
128                    attributes.put("description", getDescription());
129    
130                    return attributes;
131            }
132    
133            @Override
134            public void setModelAttributes(Map<String, Object> attributes) {
135                    Long itemFieldId = (Long)attributes.get("itemFieldId");
136    
137                    if (itemFieldId != null) {
138                            setItemFieldId(itemFieldId);
139                    }
140    
141                    Long itemId = (Long)attributes.get("itemId");
142    
143                    if (itemId != null) {
144                            setItemId(itemId);
145                    }
146    
147                    String name = (String)attributes.get("name");
148    
149                    if (name != null) {
150                            setName(name);
151                    }
152    
153                    String values = (String)attributes.get("values");
154    
155                    if (values != null) {
156                            setValues(values);
157                    }
158    
159                    String description = (String)attributes.get("description");
160    
161                    if (description != null) {
162                            setDescription(description);
163                    }
164            }
165    
166            @Override
167            public long getItemFieldId() {
168                    return _itemFieldId;
169            }
170    
171            @Override
172            public void setItemFieldId(long itemFieldId) {
173                    _itemFieldId = itemFieldId;
174            }
175    
176            @Override
177            public long getItemId() {
178                    return _itemId;
179            }
180    
181            @Override
182            public void setItemId(long itemId) {
183                    _columnBitmask = -1L;
184    
185                    if (!_setOriginalItemId) {
186                            _setOriginalItemId = true;
187    
188                            _originalItemId = _itemId;
189                    }
190    
191                    _itemId = itemId;
192            }
193    
194            public long getOriginalItemId() {
195                    return _originalItemId;
196            }
197    
198            @Override
199            public String getName() {
200                    if (_name == null) {
201                            return StringPool.BLANK;
202                    }
203                    else {
204                            return _name;
205                    }
206            }
207    
208            @Override
209            public void setName(String name) {
210                    _columnBitmask = -1L;
211    
212                    _name = name;
213            }
214    
215            @Override
216            public String getValues() {
217                    if (_values == null) {
218                            return StringPool.BLANK;
219                    }
220                    else {
221                            return _values;
222                    }
223            }
224    
225            @Override
226            public void setValues(String values) {
227                    _values = values;
228            }
229    
230            @Override
231            public String getDescription() {
232                    if (_description == null) {
233                            return StringPool.BLANK;
234                    }
235                    else {
236                            return _description;
237                    }
238            }
239    
240            @Override
241            public void setDescription(String description) {
242                    _description = description;
243            }
244    
245            public long getColumnBitmask() {
246                    return _columnBitmask;
247            }
248    
249            @Override
250            public ExpandoBridge getExpandoBridge() {
251                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
252                            ShoppingItemField.class.getName(), getPrimaryKey());
253            }
254    
255            @Override
256            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
257                    ExpandoBridge expandoBridge = getExpandoBridge();
258    
259                    expandoBridge.setAttributes(serviceContext);
260            }
261    
262            @Override
263            public ShoppingItemField toEscapedModel() {
264                    if (_escapedModel == null) {
265                            _escapedModel = (ShoppingItemField)ProxyUtil.newProxyInstance(_classLoader,
266                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
267                    }
268    
269                    return _escapedModel;
270            }
271    
272            @Override
273            public Object clone() {
274                    ShoppingItemFieldImpl shoppingItemFieldImpl = new ShoppingItemFieldImpl();
275    
276                    shoppingItemFieldImpl.setItemFieldId(getItemFieldId());
277                    shoppingItemFieldImpl.setItemId(getItemId());
278                    shoppingItemFieldImpl.setName(getName());
279                    shoppingItemFieldImpl.setValues(getValues());
280                    shoppingItemFieldImpl.setDescription(getDescription());
281    
282                    shoppingItemFieldImpl.resetOriginalValues();
283    
284                    return shoppingItemFieldImpl;
285            }
286    
287            @Override
288            public int compareTo(ShoppingItemField shoppingItemField) {
289                    int value = 0;
290    
291                    if (getItemId() < shoppingItemField.getItemId()) {
292                            value = -1;
293                    }
294                    else if (getItemId() > shoppingItemField.getItemId()) {
295                            value = 1;
296                    }
297                    else {
298                            value = 0;
299                    }
300    
301                    if (value != 0) {
302                            return value;
303                    }
304    
305                    value = getName().compareToIgnoreCase(shoppingItemField.getName());
306    
307                    if (value != 0) {
308                            return value;
309                    }
310    
311                    return 0;
312            }
313    
314            @Override
315            public boolean equals(Object obj) {
316                    if (this == obj) {
317                            return true;
318                    }
319    
320                    if (!(obj instanceof ShoppingItemField)) {
321                            return false;
322                    }
323    
324                    ShoppingItemField shoppingItemField = (ShoppingItemField)obj;
325    
326                    long primaryKey = shoppingItemField.getPrimaryKey();
327    
328                    if (getPrimaryKey() == primaryKey) {
329                            return true;
330                    }
331                    else {
332                            return false;
333                    }
334            }
335    
336            @Override
337            public int hashCode() {
338                    return (int)getPrimaryKey();
339            }
340    
341            @Override
342            public void resetOriginalValues() {
343                    ShoppingItemFieldModelImpl shoppingItemFieldModelImpl = this;
344    
345                    shoppingItemFieldModelImpl._originalItemId = shoppingItemFieldModelImpl._itemId;
346    
347                    shoppingItemFieldModelImpl._setOriginalItemId = false;
348    
349                    shoppingItemFieldModelImpl._columnBitmask = 0;
350            }
351    
352            @Override
353            public CacheModel<ShoppingItemField> toCacheModel() {
354                    ShoppingItemFieldCacheModel shoppingItemFieldCacheModel = new ShoppingItemFieldCacheModel();
355    
356                    shoppingItemFieldCacheModel.itemFieldId = getItemFieldId();
357    
358                    shoppingItemFieldCacheModel.itemId = getItemId();
359    
360                    shoppingItemFieldCacheModel.name = getName();
361    
362                    String name = shoppingItemFieldCacheModel.name;
363    
364                    if ((name != null) && (name.length() == 0)) {
365                            shoppingItemFieldCacheModel.name = null;
366                    }
367    
368                    shoppingItemFieldCacheModel.values = getValues();
369    
370                    String values = shoppingItemFieldCacheModel.values;
371    
372                    if ((values != null) && (values.length() == 0)) {
373                            shoppingItemFieldCacheModel.values = null;
374                    }
375    
376                    shoppingItemFieldCacheModel.description = getDescription();
377    
378                    String description = shoppingItemFieldCacheModel.description;
379    
380                    if ((description != null) && (description.length() == 0)) {
381                            shoppingItemFieldCacheModel.description = null;
382                    }
383    
384                    return shoppingItemFieldCacheModel;
385            }
386    
387            @Override
388            public String toString() {
389                    StringBundler sb = new StringBundler(11);
390    
391                    sb.append("{itemFieldId=");
392                    sb.append(getItemFieldId());
393                    sb.append(", itemId=");
394                    sb.append(getItemId());
395                    sb.append(", name=");
396                    sb.append(getName());
397                    sb.append(", values=");
398                    sb.append(getValues());
399                    sb.append(", description=");
400                    sb.append(getDescription());
401                    sb.append("}");
402    
403                    return sb.toString();
404            }
405    
406            @Override
407            public String toXmlString() {
408                    StringBundler sb = new StringBundler(19);
409    
410                    sb.append("<model><model-name>");
411                    sb.append("com.liferay.portlet.shopping.model.ShoppingItemField");
412                    sb.append("</model-name>");
413    
414                    sb.append(
415                            "<column><column-name>itemFieldId</column-name><column-value><![CDATA[");
416                    sb.append(getItemFieldId());
417                    sb.append("]]></column-value></column>");
418                    sb.append(
419                            "<column><column-name>itemId</column-name><column-value><![CDATA[");
420                    sb.append(getItemId());
421                    sb.append("]]></column-value></column>");
422                    sb.append(
423                            "<column><column-name>name</column-name><column-value><![CDATA[");
424                    sb.append(getName());
425                    sb.append("]]></column-value></column>");
426                    sb.append(
427                            "<column><column-name>values</column-name><column-value><![CDATA[");
428                    sb.append(getValues());
429                    sb.append("]]></column-value></column>");
430                    sb.append(
431                            "<column><column-name>description</column-name><column-value><![CDATA[");
432                    sb.append(getDescription());
433                    sb.append("]]></column-value></column>");
434    
435                    sb.append("</model>");
436    
437                    return sb.toString();
438            }
439    
440            private static ClassLoader _classLoader = ShoppingItemField.class.getClassLoader();
441            private static Class<?>[] _escapedModelInterfaces = new Class[] {
442                            ShoppingItemField.class
443                    };
444            private long _itemFieldId;
445            private long _itemId;
446            private long _originalItemId;
447            private boolean _setOriginalItemId;
448            private String _name;
449            private String _values;
450            private String _description;
451            private long _columnBitmask;
452            private ShoppingItemField _escapedModel;
453    }