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.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 getUserUuid() throws SystemException {
188 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
189 }
190
191 public void setUserUuid(String userUuid) {
192 _userUuid = userUuid;
193 }
194
195 public String getUserName() {
196 return GetterUtil.getString(_userName);
197 }
198
199 public void setUserName(String userName) {
200 _userName = userName;
201 }
202
203 public Date getCreateDate() {
204 return _createDate;
205 }
206
207 public void setCreateDate(Date createDate) {
208 _createDate = createDate;
209 }
210
211 public Date getModifiedDate() {
212 return _modifiedDate;
213 }
214
215 public void setModifiedDate(Date modifiedDate) {
216 _modifiedDate = modifiedDate;
217 }
218
219 public long getParentCategoryId() {
220 return _parentCategoryId;
221 }
222
223 public void setParentCategoryId(long parentCategoryId) {
224 _parentCategoryId = parentCategoryId;
225 }
226
227 public String getName() {
228 return GetterUtil.getString(_name);
229 }
230
231 public void setName(String name) {
232 _name = name;
233 }
234
235 public String getDescription() {
236 return GetterUtil.getString(_description);
237 }
238
239 public void setDescription(String description) {
240 _description = description;
241 }
242
243 public ShoppingCategory toEscapedModel() {
244 if (isEscapedModel()) {
245 return (ShoppingCategory)this;
246 }
247 else {
248 ShoppingCategory model = new ShoppingCategoryImpl();
249
250 model.setNew(isNew());
251 model.setEscapedModel(true);
252
253 model.setCategoryId(getCategoryId());
254 model.setGroupId(getGroupId());
255 model.setCompanyId(getCompanyId());
256 model.setUserId(getUserId());
257 model.setUserName(HtmlUtil.escape(getUserName()));
258 model.setCreateDate(getCreateDate());
259 model.setModifiedDate(getModifiedDate());
260 model.setParentCategoryId(getParentCategoryId());
261 model.setName(HtmlUtil.escape(getName()));
262 model.setDescription(HtmlUtil.escape(getDescription()));
263
264 model = (ShoppingCategory)Proxy.newProxyInstance(ShoppingCategory.class.getClassLoader(),
265 new Class[] { ShoppingCategory.class },
266 new ReadOnlyBeanHandler(model));
267
268 return model;
269 }
270 }
271
272 public Object clone() {
273 ShoppingCategoryImpl clone = new ShoppingCategoryImpl();
274
275 clone.setCategoryId(getCategoryId());
276 clone.setGroupId(getGroupId());
277 clone.setCompanyId(getCompanyId());
278 clone.setUserId(getUserId());
279 clone.setUserName(getUserName());
280 clone.setCreateDate(getCreateDate());
281 clone.setModifiedDate(getModifiedDate());
282 clone.setParentCategoryId(getParentCategoryId());
283 clone.setName(getName());
284 clone.setDescription(getDescription());
285
286 return clone;
287 }
288
289 public int compareTo(ShoppingCategory shoppingCategory) {
290 int value = 0;
291
292 if (getParentCategoryId() < shoppingCategory.getParentCategoryId()) {
293 value = -1;
294 }
295 else if (getParentCategoryId() > shoppingCategory.getParentCategoryId()) {
296 value = 1;
297 }
298 else {
299 value = 0;
300 }
301
302 if (value != 0) {
303 return value;
304 }
305
306 value = getName().toLowerCase()
307 .compareTo(shoppingCategory.getName().toLowerCase());
308
309 if (value != 0) {
310 return value;
311 }
312
313 return 0;
314 }
315
316 public boolean equals(Object obj) {
317 if (obj == null) {
318 return false;
319 }
320
321 ShoppingCategory shoppingCategory = null;
322
323 try {
324 shoppingCategory = (ShoppingCategory)obj;
325 }
326 catch (ClassCastException cce) {
327 return false;
328 }
329
330 long pk = shoppingCategory.getPrimaryKey();
331
332 if (getPrimaryKey() == pk) {
333 return true;
334 }
335 else {
336 return false;
337 }
338 }
339
340 public int hashCode() {
341 return (int)getPrimaryKey();
342 }
343
344 public String toString() {
345 StringBuilder sb = new StringBuilder();
346
347 sb.append("{categoryId=");
348 sb.append(getCategoryId());
349 sb.append(", groupId=");
350 sb.append(getGroupId());
351 sb.append(", companyId=");
352 sb.append(getCompanyId());
353 sb.append(", userId=");
354 sb.append(getUserId());
355 sb.append(", userName=");
356 sb.append(getUserName());
357 sb.append(", createDate=");
358 sb.append(getCreateDate());
359 sb.append(", modifiedDate=");
360 sb.append(getModifiedDate());
361 sb.append(", parentCategoryId=");
362 sb.append(getParentCategoryId());
363 sb.append(", name=");
364 sb.append(getName());
365 sb.append(", description=");
366 sb.append(getDescription());
367 sb.append("}");
368
369 return sb.toString();
370 }
371
372 public String toXmlString() {
373 StringBuilder sb = new StringBuilder();
374
375 sb.append("<model><model-name>");
376 sb.append("com.liferay.portlet.shopping.model.ShoppingCategory");
377 sb.append("</model-name>");
378
379 sb.append(
380 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
381 sb.append(getCategoryId());
382 sb.append("]]></column-value></column>");
383 sb.append(
384 "<column><column-name>groupId</column-name><column-value><![CDATA[");
385 sb.append(getGroupId());
386 sb.append("]]></column-value></column>");
387 sb.append(
388 "<column><column-name>companyId</column-name><column-value><![CDATA[");
389 sb.append(getCompanyId());
390 sb.append("]]></column-value></column>");
391 sb.append(
392 "<column><column-name>userId</column-name><column-value><![CDATA[");
393 sb.append(getUserId());
394 sb.append("]]></column-value></column>");
395 sb.append(
396 "<column><column-name>userName</column-name><column-value><![CDATA[");
397 sb.append(getUserName());
398 sb.append("]]></column-value></column>");
399 sb.append(
400 "<column><column-name>createDate</column-name><column-value><![CDATA[");
401 sb.append(getCreateDate());
402 sb.append("]]></column-value></column>");
403 sb.append(
404 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
405 sb.append(getModifiedDate());
406 sb.append("]]></column-value></column>");
407 sb.append(
408 "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
409 sb.append(getParentCategoryId());
410 sb.append("]]></column-value></column>");
411 sb.append(
412 "<column><column-name>name</column-name><column-value><![CDATA[");
413 sb.append(getName());
414 sb.append("]]></column-value></column>");
415 sb.append(
416 "<column><column-name>description</column-name><column-value><![CDATA[");
417 sb.append(getDescription());
418 sb.append("]]></column-value></column>");
419
420 sb.append("</model>");
421
422 return sb.toString();
423 }
424
425 private long _categoryId;
426 private long _groupId;
427 private long _companyId;
428 private long _userId;
429 private String _userUuid;
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 }