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            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 _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().compareToIgnoreCase(shoppingItemField.getName());
289    
290                    if (value != 0) {
291                            return value;
292                    }
293    
294                    return 0;
295            }
296    
297            @Override
298            public boolean equals(Object obj) {
299                    if (obj == null) {
300                            return false;
301                    }
302    
303                    ShoppingItemField shoppingItemField = null;
304    
305                    try {
306                            shoppingItemField = (ShoppingItemField)obj;
307                    }
308                    catch (ClassCastException cce) {
309                            return false;
310                    }
311    
312                    long primaryKey = shoppingItemField.getPrimaryKey();
313    
314                    if (getPrimaryKey() == primaryKey) {
315                            return true;
316                    }
317                    else {
318                            return false;
319                    }
320            }
321    
322            @Override
323            public int hashCode() {
324                    return (int)getPrimaryKey();
325            }
326    
327            @Override
328            public void resetOriginalValues() {
329                    ShoppingItemFieldModelImpl shoppingItemFieldModelImpl = this;
330    
331                    shoppingItemFieldModelImpl._originalItemId = shoppingItemFieldModelImpl._itemId;
332    
333                    shoppingItemFieldModelImpl._setOriginalItemId = false;
334    
335                    shoppingItemFieldModelImpl._columnBitmask = 0;
336            }
337    
338            @Override
339            public CacheModel<ShoppingItemField> toCacheModel() {
340                    ShoppingItemFieldCacheModel shoppingItemFieldCacheModel = new ShoppingItemFieldCacheModel();
341    
342                    shoppingItemFieldCacheModel.itemFieldId = getItemFieldId();
343    
344                    shoppingItemFieldCacheModel.itemId = getItemId();
345    
346                    shoppingItemFieldCacheModel.name = getName();
347    
348                    String name = shoppingItemFieldCacheModel.name;
349    
350                    if ((name != null) && (name.length() == 0)) {
351                            shoppingItemFieldCacheModel.name = null;
352                    }
353    
354                    shoppingItemFieldCacheModel.values = getValues();
355    
356                    String values = shoppingItemFieldCacheModel.values;
357    
358                    if ((values != null) && (values.length() == 0)) {
359                            shoppingItemFieldCacheModel.values = null;
360                    }
361    
362                    shoppingItemFieldCacheModel.description = getDescription();
363    
364                    String description = shoppingItemFieldCacheModel.description;
365    
366                    if ((description != null) && (description.length() == 0)) {
367                            shoppingItemFieldCacheModel.description = null;
368                    }
369    
370                    return shoppingItemFieldCacheModel;
371            }
372    
373            @Override
374            public String toString() {
375                    StringBundler sb = new StringBundler(11);
376    
377                    sb.append("{itemFieldId=");
378                    sb.append(getItemFieldId());
379                    sb.append(", itemId=");
380                    sb.append(getItemId());
381                    sb.append(", name=");
382                    sb.append(getName());
383                    sb.append(", values=");
384                    sb.append(getValues());
385                    sb.append(", description=");
386                    sb.append(getDescription());
387                    sb.append("}");
388    
389                    return sb.toString();
390            }
391    
392            public String toXmlString() {
393                    StringBundler sb = new StringBundler(19);
394    
395                    sb.append("<model><model-name>");
396                    sb.append("com.liferay.portlet.shopping.model.ShoppingItemField");
397                    sb.append("</model-name>");
398    
399                    sb.append(
400                            "<column><column-name>itemFieldId</column-name><column-value><![CDATA[");
401                    sb.append(getItemFieldId());
402                    sb.append("]]></column-value></column>");
403                    sb.append(
404                            "<column><column-name>itemId</column-name><column-value><![CDATA[");
405                    sb.append(getItemId());
406                    sb.append("]]></column-value></column>");
407                    sb.append(
408                            "<column><column-name>name</column-name><column-value><![CDATA[");
409                    sb.append(getName());
410                    sb.append("]]></column-value></column>");
411                    sb.append(
412                            "<column><column-name>values</column-name><column-value><![CDATA[");
413                    sb.append(getValues());
414                    sb.append("]]></column-value></column>");
415                    sb.append(
416                            "<column><column-name>description</column-name><column-value><![CDATA[");
417                    sb.append(getDescription());
418                    sb.append("]]></column-value></column>");
419    
420                    sb.append("</model>");
421    
422                    return sb.toString();
423            }
424    
425            private static ClassLoader _classLoader = ShoppingItemField.class.getClassLoader();
426            private static Class<?>[] _escapedModelInterfaces = new Class[] {
427                            ShoppingItemField.class
428                    };
429            private long _itemFieldId;
430            private long _itemId;
431            private long _originalItemId;
432            private boolean _setOriginalItemId;
433            private String _name;
434            private String _values;
435            private String _description;
436            private long _columnBitmask;
437            private ShoppingItemField _escapedModel;
438    }