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