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
30 import com.liferay.portlet.expando.model.ExpandoBridge;
31 import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
32 import com.liferay.portlet.shopping.model.ShoppingCategory;
33 import com.liferay.portlet.shopping.model.ShoppingCategorySoap;
34
35 import java.io.Serializable;
36
37 import java.lang.reflect.Proxy;
38
39 import java.sql.Types;
40
41 import java.util.ArrayList;
42 import java.util.Date;
43 import java.util.List;
44
45
65 public class ShoppingCategoryModelImpl extends BaseModelImpl<ShoppingCategory> {
66 public static final String TABLE_NAME = "ShoppingCategory";
67 public static final Object[][] TABLE_COLUMNS = {
68 { "categoryId", new Integer(Types.BIGINT) },
69
70
71 { "groupId", new Integer(Types.BIGINT) },
72
73
74 { "companyId", new Integer(Types.BIGINT) },
75
76
77 { "userId", new Integer(Types.BIGINT) },
78
79
80 { "userName", new Integer(Types.VARCHAR) },
81
82
83 { "createDate", new Integer(Types.TIMESTAMP) },
84
85
86 { "modifiedDate", new Integer(Types.TIMESTAMP) },
87
88
89 { "parentCategoryId", new Integer(Types.BIGINT) },
90
91
92 { "name", new Integer(Types.VARCHAR) },
93
94
95 { "description", new Integer(Types.VARCHAR) }
96 };
97 public static final String TABLE_SQL_CREATE = "create table ShoppingCategory (categoryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,parentCategoryId LONG,name VARCHAR(75) null,description STRING null)";
98 public static final String TABLE_SQL_DROP = "drop table ShoppingCategory";
99 public static final String DATA_SOURCE = "liferayDataSource";
100 public static final String SESSION_FACTORY = "liferaySessionFactory";
101 public static final String TX_MANAGER = "liferayTransactionManager";
102 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
103 "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
104 true);
105 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
106 "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
107 true);
108
109 public static ShoppingCategory toModel(ShoppingCategorySoap soapModel) {
110 ShoppingCategory model = new ShoppingCategoryImpl();
111
112 model.setCategoryId(soapModel.getCategoryId());
113 model.setGroupId(soapModel.getGroupId());
114 model.setCompanyId(soapModel.getCompanyId());
115 model.setUserId(soapModel.getUserId());
116 model.setUserName(soapModel.getUserName());
117 model.setCreateDate(soapModel.getCreateDate());
118 model.setModifiedDate(soapModel.getModifiedDate());
119 model.setParentCategoryId(soapModel.getParentCategoryId());
120 model.setName(soapModel.getName());
121 model.setDescription(soapModel.getDescription());
122
123 return model;
124 }
125
126 public static List<ShoppingCategory> toModels(
127 ShoppingCategorySoap[] soapModels) {
128 List<ShoppingCategory> models = new ArrayList<ShoppingCategory>(soapModels.length);
129
130 for (ShoppingCategorySoap soapModel : soapModels) {
131 models.add(toModel(soapModel));
132 }
133
134 return models;
135 }
136
137 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
138 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingCategory"));
139
140 public ShoppingCategoryModelImpl() {
141 }
142
143 public long getPrimaryKey() {
144 return _categoryId;
145 }
146
147 public void setPrimaryKey(long pk) {
148 setCategoryId(pk);
149 }
150
151 public Serializable getPrimaryKeyObj() {
152 return new Long(_categoryId);
153 }
154
155 public long getCategoryId() {
156 return _categoryId;
157 }
158
159 public void setCategoryId(long categoryId) {
160 _categoryId = categoryId;
161 }
162
163 public long getGroupId() {
164 return _groupId;
165 }
166
167 public void setGroupId(long groupId) {
168 _groupId = groupId;
169 }
170
171 public long getCompanyId() {
172 return _companyId;
173 }
174
175 public void setCompanyId(long companyId) {
176 _companyId = companyId;
177 }
178
179 public long getUserId() {
180 return _userId;
181 }
182
183 public void setUserId(long userId) {
184 _userId = userId;
185 }
186
187 public String getUserName() {
188 return GetterUtil.getString(_userName);
189 }
190
191 public void setUserName(String userName) {
192 _userName = userName;
193 }
194
195 public Date getCreateDate() {
196 return _createDate;
197 }
198
199 public void setCreateDate(Date createDate) {
200 _createDate = createDate;
201 }
202
203 public Date getModifiedDate() {
204 return _modifiedDate;
205 }
206
207 public void setModifiedDate(Date modifiedDate) {
208 _modifiedDate = modifiedDate;
209 }
210
211 public long getParentCategoryId() {
212 return _parentCategoryId;
213 }
214
215 public void setParentCategoryId(long parentCategoryId) {
216 _parentCategoryId = parentCategoryId;
217 }
218
219 public String getName() {
220 return GetterUtil.getString(_name);
221 }
222
223 public void setName(String name) {
224 _name = name;
225 }
226
227 public String getDescription() {
228 return GetterUtil.getString(_description);
229 }
230
231 public void setDescription(String description) {
232 _description = description;
233 }
234
235 public ShoppingCategory toEscapedModel() {
236 if (isEscapedModel()) {
237 return (ShoppingCategory)this;
238 }
239 else {
240 ShoppingCategory model = new ShoppingCategoryImpl();
241
242 model.setNew(isNew());
243 model.setEscapedModel(true);
244
245 model.setCategoryId(getCategoryId());
246 model.setGroupId(getGroupId());
247 model.setCompanyId(getCompanyId());
248 model.setUserId(getUserId());
249 model.setUserName(HtmlUtil.escape(getUserName()));
250 model.setCreateDate(getCreateDate());
251 model.setModifiedDate(getModifiedDate());
252 model.setParentCategoryId(getParentCategoryId());
253 model.setName(HtmlUtil.escape(getName()));
254 model.setDescription(HtmlUtil.escape(getDescription()));
255
256 model = (ShoppingCategory)Proxy.newProxyInstance(ShoppingCategory.class.getClassLoader(),
257 new Class[] { ShoppingCategory.class },
258 new ReadOnlyBeanHandler(model));
259
260 return model;
261 }
262 }
263
264 public ExpandoBridge getExpandoBridge() {
265 if (_expandoBridge == null) {
266 _expandoBridge = new ExpandoBridgeImpl(ShoppingCategory.class.getName(),
267 getPrimaryKey());
268 }
269
270 return _expandoBridge;
271 }
272
273 public Object clone() {
274 ShoppingCategoryImpl clone = new ShoppingCategoryImpl();
275
276 clone.setCategoryId(getCategoryId());
277 clone.setGroupId(getGroupId());
278 clone.setCompanyId(getCompanyId());
279 clone.setUserId(getUserId());
280 clone.setUserName(getUserName());
281 clone.setCreateDate(getCreateDate());
282 clone.setModifiedDate(getModifiedDate());
283 clone.setParentCategoryId(getParentCategoryId());
284 clone.setName(getName());
285 clone.setDescription(getDescription());
286
287 return clone;
288 }
289
290 public int compareTo(ShoppingCategory shoppingCategory) {
291 int value = 0;
292
293 if (getParentCategoryId() < shoppingCategory.getParentCategoryId()) {
294 value = -1;
295 }
296 else if (getParentCategoryId() > shoppingCategory.getParentCategoryId()) {
297 value = 1;
298 }
299 else {
300 value = 0;
301 }
302
303 if (value != 0) {
304 return value;
305 }
306
307 value = getName().toLowerCase()
308 .compareTo(shoppingCategory.getName().toLowerCase());
309
310 if (value != 0) {
311 return value;
312 }
313
314 return 0;
315 }
316
317 public boolean equals(Object obj) {
318 if (obj == null) {
319 return false;
320 }
321
322 ShoppingCategory shoppingCategory = null;
323
324 try {
325 shoppingCategory = (ShoppingCategory)obj;
326 }
327 catch (ClassCastException cce) {
328 return false;
329 }
330
331 long pk = shoppingCategory.getPrimaryKey();
332
333 if (getPrimaryKey() == pk) {
334 return true;
335 }
336 else {
337 return false;
338 }
339 }
340
341 public int hashCode() {
342 return (int)getPrimaryKey();
343 }
344
345 public String toString() {
346 StringBuilder sb = new StringBuilder();
347
348 sb.append("{categoryId=");
349 sb.append(getCategoryId());
350 sb.append(", groupId=");
351 sb.append(getGroupId());
352 sb.append(", companyId=");
353 sb.append(getCompanyId());
354 sb.append(", userId=");
355 sb.append(getUserId());
356 sb.append(", userName=");
357 sb.append(getUserName());
358 sb.append(", createDate=");
359 sb.append(getCreateDate());
360 sb.append(", modifiedDate=");
361 sb.append(getModifiedDate());
362 sb.append(", parentCategoryId=");
363 sb.append(getParentCategoryId());
364 sb.append(", name=");
365 sb.append(getName());
366 sb.append(", description=");
367 sb.append(getDescription());
368 sb.append("}");
369
370 return sb.toString();
371 }
372
373 public String toXmlString() {
374 StringBuilder sb = new StringBuilder();
375
376 sb.append("<model><model-name>");
377 sb.append("com.liferay.portlet.shopping.model.ShoppingCategory");
378 sb.append("</model-name>");
379
380 sb.append(
381 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
382 sb.append(getCategoryId());
383 sb.append("]]></column-value></column>");
384 sb.append(
385 "<column><column-name>groupId</column-name><column-value><![CDATA[");
386 sb.append(getGroupId());
387 sb.append("]]></column-value></column>");
388 sb.append(
389 "<column><column-name>companyId</column-name><column-value><![CDATA[");
390 sb.append(getCompanyId());
391 sb.append("]]></column-value></column>");
392 sb.append(
393 "<column><column-name>userId</column-name><column-value><![CDATA[");
394 sb.append(getUserId());
395 sb.append("]]></column-value></column>");
396 sb.append(
397 "<column><column-name>userName</column-name><column-value><![CDATA[");
398 sb.append(getUserName());
399 sb.append("]]></column-value></column>");
400 sb.append(
401 "<column><column-name>createDate</column-name><column-value><![CDATA[");
402 sb.append(getCreateDate());
403 sb.append("]]></column-value></column>");
404 sb.append(
405 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
406 sb.append(getModifiedDate());
407 sb.append("]]></column-value></column>");
408 sb.append(
409 "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
410 sb.append(getParentCategoryId());
411 sb.append("]]></column-value></column>");
412 sb.append(
413 "<column><column-name>name</column-name><column-value><![CDATA[");
414 sb.append(getName());
415 sb.append("]]></column-value></column>");
416 sb.append(
417 "<column><column-name>description</column-name><column-value><![CDATA[");
418 sb.append(getDescription());
419 sb.append("]]></column-value></column>");
420
421 sb.append("</model>");
422
423 return sb.toString();
424 }
425
426 private long _categoryId;
427 private long _groupId;
428 private long _companyId;
429 private long _userId;
430 private String _userName;
431 private Date _createDate;
432 private Date _modifiedDate;
433 private long _parentCategoryId;
434 private String _name;
435 private String _description;
436 private transient ExpandoBridge _expandoBridge;
437 }