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