1
19
20 package com.liferay.portlet.shopping.model.impl;
21
22 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23 import com.liferay.portal.kernel.util.GetterUtil;
24 import com.liferay.portal.kernel.util.HtmlUtil;
25 import com.liferay.portal.model.impl.BaseModelImpl;
26
27 import com.liferay.portlet.shopping.model.ShoppingItemField;
28 import com.liferay.portlet.shopping.model.ShoppingItemFieldSoap;
29
30 import java.io.Serializable;
31
32 import java.lang.reflect.Proxy;
33
34 import java.sql.Types;
35
36 import java.util.ArrayList;
37 import java.util.List;
38
39
59 public class ShoppingItemFieldModelImpl extends BaseModelImpl {
60 public static final String TABLE_NAME = "ShoppingItemField";
61 public static final Object[][] TABLE_COLUMNS = {
62 { "itemFieldId", new Integer(Types.BIGINT) },
63
64
65 { "itemId", new Integer(Types.BIGINT) },
66
67
68 { "name", new Integer(Types.VARCHAR) },
69
70
71 { "values_", new Integer(Types.VARCHAR) },
72
73
74 { "description", new Integer(Types.VARCHAR) }
75 };
76 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)";
77 public static final String TABLE_SQL_DROP = "drop table ShoppingItemField";
78 public static final String DATA_SOURCE = "liferayDataSource";
79 public static final String SESSION_FACTORY = "liferaySessionFactory";
80 public static final String TX_MANAGER = "liferayTransactionManager";
81 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
82 "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingItemField"),
83 true);
84
85 public static ShoppingItemField toModel(ShoppingItemFieldSoap soapModel) {
86 ShoppingItemField model = new ShoppingItemFieldImpl();
87
88 model.setItemFieldId(soapModel.getItemFieldId());
89 model.setItemId(soapModel.getItemId());
90 model.setName(soapModel.getName());
91 model.setValues(soapModel.getValues());
92 model.setDescription(soapModel.getDescription());
93
94 return model;
95 }
96
97 public static List<ShoppingItemField> toModels(
98 ShoppingItemFieldSoap[] soapModels) {
99 List<ShoppingItemField> models = new ArrayList<ShoppingItemField>(soapModels.length);
100
101 for (ShoppingItemFieldSoap soapModel : soapModels) {
102 models.add(toModel(soapModel));
103 }
104
105 return models;
106 }
107
108 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
109 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingItemField"));
110
111 public ShoppingItemFieldModelImpl() {
112 }
113
114 public long getPrimaryKey() {
115 return _itemFieldId;
116 }
117
118 public void setPrimaryKey(long pk) {
119 setItemFieldId(pk);
120 }
121
122 public Serializable getPrimaryKeyObj() {
123 return new Long(_itemFieldId);
124 }
125
126 public long getItemFieldId() {
127 return _itemFieldId;
128 }
129
130 public void setItemFieldId(long itemFieldId) {
131 if (itemFieldId != _itemFieldId) {
132 _itemFieldId = itemFieldId;
133 }
134 }
135
136 public long getItemId() {
137 return _itemId;
138 }
139
140 public void setItemId(long itemId) {
141 if (itemId != _itemId) {
142 _itemId = itemId;
143 }
144 }
145
146 public String getName() {
147 return GetterUtil.getString(_name);
148 }
149
150 public void setName(String name) {
151 if (((name == null) && (_name != null)) ||
152 ((name != null) && (_name == null)) ||
153 ((name != null) && (_name != null) && !name.equals(_name))) {
154 _name = name;
155 }
156 }
157
158 public String getValues() {
159 return GetterUtil.getString(_values);
160 }
161
162 public void setValues(String values) {
163 if (((values == null) && (_values != null)) ||
164 ((values != null) && (_values == null)) ||
165 ((values != null) && (_values != null) &&
166 !values.equals(_values))) {
167 _values = values;
168 }
169 }
170
171 public String getDescription() {
172 return GetterUtil.getString(_description);
173 }
174
175 public void setDescription(String description) {
176 if (((description == null) && (_description != null)) ||
177 ((description != null) && (_description == null)) ||
178 ((description != null) && (_description != null) &&
179 !description.equals(_description))) {
180 _description = description;
181 }
182 }
183
184 public ShoppingItemField toEscapedModel() {
185 if (isEscapedModel()) {
186 return (ShoppingItemField)this;
187 }
188 else {
189 ShoppingItemField model = new ShoppingItemFieldImpl();
190
191 model.setNew(isNew());
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 }