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.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.impl.BaseModelImpl;
022    import com.liferay.portal.service.ServiceContext;
023    
024    import com.liferay.portlet.expando.model.ExpandoBridge;
025    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
026    import com.liferay.portlet.shopping.model.ShoppingItemField;
027    import com.liferay.portlet.shopping.model.ShoppingItemFieldModel;
028    
029    import java.io.Serializable;
030    
031    import java.lang.reflect.Proxy;
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     * <p>
043     * 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.
044     * </p>
045     *
046     * @author Brian Wing Shun Chan
047     * @see ShoppingItemFieldImpl
048     * @see com.liferay.portlet.shopping.model.ShoppingItemField
049     * @see com.liferay.portlet.shopping.model.ShoppingItemFieldModel
050     * @generated
051     */
052    public class ShoppingItemFieldModelImpl extends BaseModelImpl<ShoppingItemField>
053            implements ShoppingItemFieldModel {
054            public static final String TABLE_NAME = "ShoppingItemField";
055            public static final Object[][] TABLE_COLUMNS = {
056                            { "itemFieldId", new Integer(Types.BIGINT) },
057                            { "itemId", new Integer(Types.BIGINT) },
058                            { "name", new Integer(Types.VARCHAR) },
059                            { "values_", new Integer(Types.VARCHAR) },
060                            { "description", new Integer(Types.VARCHAR) }
061                    };
062            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)";
063            public static final String TABLE_SQL_DROP = "drop table ShoppingItemField";
064            public static final String ORDER_BY_JPQL = " ORDER BY shoppingItemField.itemId ASC, shoppingItemField.name ASC";
065            public static final String ORDER_BY_SQL = " ORDER BY ShoppingItemField.itemId ASC, ShoppingItemField.name ASC";
066            public static final String DATA_SOURCE = "liferayDataSource";
067            public static final String SESSION_FACTORY = "liferaySessionFactory";
068            public static final String TX_MANAGER = "liferayTransactionManager";
069            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
070                                    "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
071                            true);
072            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
073                                    "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
074                            true);
075            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
076                                    "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemField"));
077    
078            public ShoppingItemFieldModelImpl() {
079            }
080    
081            public long getPrimaryKey() {
082                    return _itemFieldId;
083            }
084    
085            public void setPrimaryKey(long pk) {
086                    setItemFieldId(pk);
087            }
088    
089            public Serializable getPrimaryKeyObj() {
090                    return new Long(_itemFieldId);
091            }
092    
093            public long getItemFieldId() {
094                    return _itemFieldId;
095            }
096    
097            public void setItemFieldId(long itemFieldId) {
098                    _itemFieldId = itemFieldId;
099            }
100    
101            public long getItemId() {
102                    return _itemId;
103            }
104    
105            public void setItemId(long itemId) {
106                    _itemId = itemId;
107            }
108    
109            public String getName() {
110                    if (_name == null) {
111                            return StringPool.BLANK;
112                    }
113                    else {
114                            return _name;
115                    }
116            }
117    
118            public void setName(String name) {
119                    _name = name;
120            }
121    
122            public String getValues() {
123                    if (_values == null) {
124                            return StringPool.BLANK;
125                    }
126                    else {
127                            return _values;
128                    }
129            }
130    
131            public void setValues(String values) {
132                    _values = values;
133            }
134    
135            public String getDescription() {
136                    if (_description == null) {
137                            return StringPool.BLANK;
138                    }
139                    else {
140                            return _description;
141                    }
142            }
143    
144            public void setDescription(String description) {
145                    _description = description;
146            }
147    
148            public ShoppingItemField toEscapedModel() {
149                    if (isEscapedModel()) {
150                            return (ShoppingItemField)this;
151                    }
152                    else {
153                            return (ShoppingItemField)Proxy.newProxyInstance(ShoppingItemField.class.getClassLoader(),
154                                    new Class[] { ShoppingItemField.class },
155                                    new AutoEscapeBeanHandler(this));
156                    }
157            }
158    
159            public ExpandoBridge getExpandoBridge() {
160                    if (_expandoBridge == null) {
161                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
162                                            ShoppingItemField.class.getName(), getPrimaryKey());
163                    }
164    
165                    return _expandoBridge;
166            }
167    
168            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
169                    getExpandoBridge().setAttributes(serviceContext);
170            }
171    
172            public Object clone() {
173                    ShoppingItemFieldImpl shoppingItemFieldImpl = new ShoppingItemFieldImpl();
174    
175                    shoppingItemFieldImpl.setItemFieldId(getItemFieldId());
176    
177                    shoppingItemFieldImpl.setItemId(getItemId());
178    
179                    shoppingItemFieldImpl.setName(getName());
180    
181                    shoppingItemFieldImpl.setValues(getValues());
182    
183                    shoppingItemFieldImpl.setDescription(getDescription());
184    
185                    return shoppingItemFieldImpl;
186            }
187    
188            public int compareTo(ShoppingItemField shoppingItemField) {
189                    int value = 0;
190    
191                    if (getItemId() < shoppingItemField.getItemId()) {
192                            value = -1;
193                    }
194                    else if (getItemId() > shoppingItemField.getItemId()) {
195                            value = 1;
196                    }
197                    else {
198                            value = 0;
199                    }
200    
201                    if (value != 0) {
202                            return value;
203                    }
204    
205                    value = getName().toLowerCase()
206                                            .compareTo(shoppingItemField.getName().toLowerCase());
207    
208                    if (value != 0) {
209                            return value;
210                    }
211    
212                    return 0;
213            }
214    
215            public boolean equals(Object obj) {
216                    if (obj == null) {
217                            return false;
218                    }
219    
220                    ShoppingItemField shoppingItemField = null;
221    
222                    try {
223                            shoppingItemField = (ShoppingItemField)obj;
224                    }
225                    catch (ClassCastException cce) {
226                            return false;
227                    }
228    
229                    long pk = shoppingItemField.getPrimaryKey();
230    
231                    if (getPrimaryKey() == pk) {
232                            return true;
233                    }
234                    else {
235                            return false;
236                    }
237            }
238    
239            public int hashCode() {
240                    return (int)getPrimaryKey();
241            }
242    
243            public String toString() {
244                    StringBundler sb = new StringBundler(11);
245    
246                    sb.append("{itemFieldId=");
247                    sb.append(getItemFieldId());
248                    sb.append(", itemId=");
249                    sb.append(getItemId());
250                    sb.append(", name=");
251                    sb.append(getName());
252                    sb.append(", values=");
253                    sb.append(getValues());
254                    sb.append(", description=");
255                    sb.append(getDescription());
256                    sb.append("}");
257    
258                    return sb.toString();
259            }
260    
261            public String toXmlString() {
262                    StringBundler sb = new StringBundler(19);
263    
264                    sb.append("<model><model-name>");
265                    sb.append("com.liferay.portlet.shopping.model.ShoppingItemField");
266                    sb.append("</model-name>");
267    
268                    sb.append(
269                            "<column><column-name>itemFieldId</column-name><column-value><![CDATA[");
270                    sb.append(getItemFieldId());
271                    sb.append("]]></column-value></column>");
272                    sb.append(
273                            "<column><column-name>itemId</column-name><column-value><![CDATA[");
274                    sb.append(getItemId());
275                    sb.append("]]></column-value></column>");
276                    sb.append(
277                            "<column><column-name>name</column-name><column-value><![CDATA[");
278                    sb.append(getName());
279                    sb.append("]]></column-value></column>");
280                    sb.append(
281                            "<column><column-name>values</column-name><column-value><![CDATA[");
282                    sb.append(getValues());
283                    sb.append("]]></column-value></column>");
284                    sb.append(
285                            "<column><column-name>description</column-name><column-value><![CDATA[");
286                    sb.append(getDescription());
287                    sb.append("]]></column-value></column>");
288    
289                    sb.append("</model>");
290    
291                    return sb.toString();
292            }
293    
294            private long _itemFieldId;
295            private long _itemId;
296            private String _name;
297            private String _values;
298            private String _description;
299            private transient ExpandoBridge _expandoBridge;
300    }