001    /**
002     * Copyright (c) 2000-2011 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 |= ITEMID_COLUMN_BITMASK;
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                    _name = name;
149            }
150    
151            public String getValues() {
152                    if (_values == null) {
153                            return StringPool.BLANK;
154                    }
155                    else {
156                            return _values;
157                    }
158            }
159    
160            public void setValues(String values) {
161                    _values = values;
162            }
163    
164            public String getDescription() {
165                    if (_description == null) {
166                            return StringPool.BLANK;
167                    }
168                    else {
169                            return _description;
170                    }
171            }
172    
173            public void setDescription(String description) {
174                    _description = description;
175            }
176    
177            public long getColumnBitmask() {
178                    return _columnBitmask;
179            }
180    
181            @Override
182            public ShoppingItemField toEscapedModel() {
183                    if (_escapedModelProxy == null) {
184                            _escapedModelProxy = (ShoppingItemField)ProxyUtil.newProxyInstance(_classLoader,
185                                            _escapedModelProxyInterfaces,
186                                            new AutoEscapeBeanHandler(this));
187                    }
188    
189                    return _escapedModelProxy;
190            }
191    
192            @Override
193            public ExpandoBridge getExpandoBridge() {
194                    if (_expandoBridge == null) {
195                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
196                                            ShoppingItemField.class.getName(), getPrimaryKey());
197                    }
198    
199                    return _expandoBridge;
200            }
201    
202            @Override
203            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
204                    getExpandoBridge().setAttributes(serviceContext);
205            }
206    
207            @Override
208            public Object clone() {
209                    ShoppingItemFieldImpl shoppingItemFieldImpl = new ShoppingItemFieldImpl();
210    
211                    shoppingItemFieldImpl.setItemFieldId(getItemFieldId());
212                    shoppingItemFieldImpl.setItemId(getItemId());
213                    shoppingItemFieldImpl.setName(getName());
214                    shoppingItemFieldImpl.setValues(getValues());
215                    shoppingItemFieldImpl.setDescription(getDescription());
216    
217                    shoppingItemFieldImpl.resetOriginalValues();
218    
219                    return shoppingItemFieldImpl;
220            }
221    
222            public int compareTo(ShoppingItemField shoppingItemField) {
223                    int value = 0;
224    
225                    if (getItemId() < shoppingItemField.getItemId()) {
226                            value = -1;
227                    }
228                    else if (getItemId() > shoppingItemField.getItemId()) {
229                            value = 1;
230                    }
231                    else {
232                            value = 0;
233                    }
234    
235                    if (value != 0) {
236                            return value;
237                    }
238    
239                    value = getName().toLowerCase()
240                                            .compareTo(shoppingItemField.getName().toLowerCase());
241    
242                    if (value != 0) {
243                            return value;
244                    }
245    
246                    return 0;
247            }
248    
249            @Override
250            public boolean equals(Object obj) {
251                    if (obj == null) {
252                            return false;
253                    }
254    
255                    ShoppingItemField shoppingItemField = null;
256    
257                    try {
258                            shoppingItemField = (ShoppingItemField)obj;
259                    }
260                    catch (ClassCastException cce) {
261                            return false;
262                    }
263    
264                    long primaryKey = shoppingItemField.getPrimaryKey();
265    
266                    if (getPrimaryKey() == primaryKey) {
267                            return true;
268                    }
269                    else {
270                            return false;
271                    }
272            }
273    
274            @Override
275            public int hashCode() {
276                    return (int)getPrimaryKey();
277            }
278    
279            @Override
280            public void resetOriginalValues() {
281                    ShoppingItemFieldModelImpl shoppingItemFieldModelImpl = this;
282    
283                    shoppingItemFieldModelImpl._originalItemId = shoppingItemFieldModelImpl._itemId;
284    
285                    shoppingItemFieldModelImpl._setOriginalItemId = false;
286    
287                    shoppingItemFieldModelImpl._columnBitmask = 0;
288            }
289    
290            @Override
291            public CacheModel<ShoppingItemField> toCacheModel() {
292                    ShoppingItemFieldCacheModel shoppingItemFieldCacheModel = new ShoppingItemFieldCacheModel();
293    
294                    shoppingItemFieldCacheModel.itemFieldId = getItemFieldId();
295    
296                    shoppingItemFieldCacheModel.itemId = getItemId();
297    
298                    shoppingItemFieldCacheModel.name = getName();
299    
300                    String name = shoppingItemFieldCacheModel.name;
301    
302                    if ((name != null) && (name.length() == 0)) {
303                            shoppingItemFieldCacheModel.name = null;
304                    }
305    
306                    shoppingItemFieldCacheModel.values = getValues();
307    
308                    String values = shoppingItemFieldCacheModel.values;
309    
310                    if ((values != null) && (values.length() == 0)) {
311                            shoppingItemFieldCacheModel.values = null;
312                    }
313    
314                    shoppingItemFieldCacheModel.description = getDescription();
315    
316                    String description = shoppingItemFieldCacheModel.description;
317    
318                    if ((description != null) && (description.length() == 0)) {
319                            shoppingItemFieldCacheModel.description = null;
320                    }
321    
322                    return shoppingItemFieldCacheModel;
323            }
324    
325            @Override
326            public String toString() {
327                    StringBundler sb = new StringBundler(11);
328    
329                    sb.append("{itemFieldId=");
330                    sb.append(getItemFieldId());
331                    sb.append(", itemId=");
332                    sb.append(getItemId());
333                    sb.append(", name=");
334                    sb.append(getName());
335                    sb.append(", values=");
336                    sb.append(getValues());
337                    sb.append(", description=");
338                    sb.append(getDescription());
339                    sb.append("}");
340    
341                    return sb.toString();
342            }
343    
344            public String toXmlString() {
345                    StringBundler sb = new StringBundler(19);
346    
347                    sb.append("<model><model-name>");
348                    sb.append("com.liferay.portlet.shopping.model.ShoppingItemField");
349                    sb.append("</model-name>");
350    
351                    sb.append(
352                            "<column><column-name>itemFieldId</column-name><column-value><![CDATA[");
353                    sb.append(getItemFieldId());
354                    sb.append("]]></column-value></column>");
355                    sb.append(
356                            "<column><column-name>itemId</column-name><column-value><![CDATA[");
357                    sb.append(getItemId());
358                    sb.append("]]></column-value></column>");
359                    sb.append(
360                            "<column><column-name>name</column-name><column-value><![CDATA[");
361                    sb.append(getName());
362                    sb.append("]]></column-value></column>");
363                    sb.append(
364                            "<column><column-name>values</column-name><column-value><![CDATA[");
365                    sb.append(getValues());
366                    sb.append("]]></column-value></column>");
367                    sb.append(
368                            "<column><column-name>description</column-name><column-value><![CDATA[");
369                    sb.append(getDescription());
370                    sb.append("]]></column-value></column>");
371    
372                    sb.append("</model>");
373    
374                    return sb.toString();
375            }
376    
377            private static ClassLoader _classLoader = ShoppingItemField.class.getClassLoader();
378            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
379                            ShoppingItemField.class
380                    };
381            private long _itemFieldId;
382            private long _itemId;
383            private long _originalItemId;
384            private boolean _setOriginalItemId;
385            private String _name;
386            private String _values;
387            private String _description;
388            private transient ExpandoBridge _expandoBridge;
389            private long _columnBitmask;
390            private ShoppingItemField _escapedModelProxy;
391    }