1
22
23 package com.liferay.portlet.shopping.model.impl;
24
25 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26 import com.liferay.portal.kernel.util.GetterUtil;
27 import com.liferay.portal.kernel.util.HtmlUtil;
28 import com.liferay.portal.model.impl.BaseModelImpl;
29 import com.liferay.portal.util.PropsUtil;
30
31 import com.liferay.portlet.shopping.model.ShoppingItemField;
32 import com.liferay.portlet.shopping.model.ShoppingItemFieldSoap;
33
34 import java.io.Serializable;
35
36 import java.lang.reflect.Proxy;
37
38 import java.sql.Types;
39
40 import java.util.ArrayList;
41 import java.util.List;
42
43
63 public class ShoppingItemFieldModelImpl extends BaseModelImpl {
64 public static final String TABLE_NAME = "ShoppingItemField";
65 public static final Object[][] TABLE_COLUMNS = {
66 { "itemFieldId", new Integer(Types.BIGINT) },
67
68
69 { "itemId", new Integer(Types.BIGINT) },
70
71
72 { "name", new Integer(Types.VARCHAR) },
73
74
75 { "values_", new Integer(Types.VARCHAR) },
76
77
78 { "description", new Integer(Types.VARCHAR) }
79 };
80 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)";
81 public static final String TABLE_SQL_DROP = "drop table ShoppingItemField";
82 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
83 "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
84 true);
85
86 public static ShoppingItemField toModel(ShoppingItemFieldSoap soapModel) {
87 ShoppingItemField model = new ShoppingItemFieldImpl();
88
89 model.setItemFieldId(soapModel.getItemFieldId());
90 model.setItemId(soapModel.getItemId());
91 model.setName(soapModel.getName());
92 model.setValues(soapModel.getValues());
93 model.setDescription(soapModel.getDescription());
94
95 return model;
96 }
97
98 public static List<ShoppingItemField> toModels(
99 ShoppingItemFieldSoap[] soapModels) {
100 List<ShoppingItemField> models = new ArrayList<ShoppingItemField>(soapModels.length);
101
102 for (ShoppingItemFieldSoap soapModel : soapModels) {
103 models.add(toModel(soapModel));
104 }
105
106 return models;
107 }
108
109 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
110 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemField"));
111
112 public ShoppingItemFieldModelImpl() {
113 }
114
115 public long getPrimaryKey() {
116 return _itemFieldId;
117 }
118
119 public void setPrimaryKey(long pk) {
120 setItemFieldId(pk);
121 }
122
123 public Serializable getPrimaryKeyObj() {
124 return new Long(_itemFieldId);
125 }
126
127 public long getItemFieldId() {
128 return _itemFieldId;
129 }
130
131 public void setItemFieldId(long itemFieldId) {
132 if (itemFieldId != _itemFieldId) {
133 _itemFieldId = itemFieldId;
134 }
135 }
136
137 public long getItemId() {
138 return _itemId;
139 }
140
141 public void setItemId(long itemId) {
142 if (itemId != _itemId) {
143 _itemId = itemId;
144 }
145 }
146
147 public String getName() {
148 return GetterUtil.getString(_name);
149 }
150
151 public void setName(String name) {
152 if (((name == null) && (_name != null)) ||
153 ((name != null) && (_name == null)) ||
154 ((name != null) && (_name != null) && !name.equals(_name))) {
155 _name = name;
156 }
157 }
158
159 public String getValues() {
160 return GetterUtil.getString(_values);
161 }
162
163 public void setValues(String values) {
164 if (((values == null) && (_values != null)) ||
165 ((values != null) && (_values == null)) ||
166 ((values != null) && (_values != null) &&
167 !values.equals(_values))) {
168 _values = values;
169 }
170 }
171
172 public String getDescription() {
173 return GetterUtil.getString(_description);
174 }
175
176 public void setDescription(String description) {
177 if (((description == null) && (_description != null)) ||
178 ((description != null) && (_description == null)) ||
179 ((description != null) && (_description != null) &&
180 !description.equals(_description))) {
181 _description = description;
182 }
183 }
184
185 public ShoppingItemField toEscapedModel() {
186 if (isEscapedModel()) {
187 return (ShoppingItemField)this;
188 }
189 else {
190 ShoppingItemField model = new ShoppingItemFieldImpl();
191
192 model.setEscapedModel(true);
193
194 model.setItemFieldId(getItemFieldId());
195 model.setItemId(getItemId());
196 model.setName(HtmlUtil.escape(getName()));
197 model.setValues(HtmlUtil.escape(getValues()));
198 model.setDescription(HtmlUtil.escape(getDescription()));
199
200 model = (ShoppingItemField)Proxy.newProxyInstance(ShoppingItemField.class.getClassLoader(),
201 new Class[] { ShoppingItemField.class },
202 new ReadOnlyBeanHandler(model));
203
204 return model;
205 }
206 }
207
208 public Object clone() {
209 ShoppingItemFieldImpl clone = new ShoppingItemFieldImpl();
210
211 clone.setItemFieldId(getItemFieldId());
212 clone.setItemId(getItemId());
213 clone.setName(getName());
214 clone.setValues(getValues());
215 clone.setDescription(getDescription());
216
217 return clone;
218 }
219
220 public int compareTo(Object obj) {
221 if (obj == null) {
222 return -1;
223 }
224
225 ShoppingItemFieldImpl shoppingItemField = (ShoppingItemFieldImpl)obj;
226
227 int value = 0;
228
229 if (getItemId() < shoppingItemField.getItemId()) {
230 value = -1;
231 }
232 else if (getItemId() > shoppingItemField.getItemId()) {
233 value = 1;
234 }
235 else {
236 value = 0;
237 }
238
239 if (value != 0) {
240 return value;
241 }
242
243 value = getName().toLowerCase()
244 .compareTo(shoppingItemField.getName().toLowerCase());
245
246 if (value != 0) {
247 return value;
248 }
249
250 return 0;
251 }
252
253 public boolean equals(Object obj) {
254 if (obj == null) {
255 return false;
256 }
257
258 ShoppingItemFieldImpl shoppingItemField = null;
259
260 try {
261 shoppingItemField = (ShoppingItemFieldImpl)obj;
262 }
263 catch (ClassCastException cce) {
264 return false;
265 }
266
267 long pk = shoppingItemField.getPrimaryKey();
268
269 if (getPrimaryKey() == pk) {
270 return true;
271 }
272 else {
273 return false;
274 }
275 }
276
277 public int hashCode() {
278 return (int)getPrimaryKey();
279 }
280
281 private long _itemFieldId;
282 private long _itemId;
283 private String _name;
284 private String _values;
285 private String _description;
286 }