001
014
015 package com.liferay.portlet.shopping.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.json.JSON;
020 import com.liferay.portal.kernel.util.GetterUtil;
021 import com.liferay.portal.kernel.util.ProxyUtil;
022 import com.liferay.portal.kernel.util.StringBundler;
023 import com.liferay.portal.kernel.util.StringPool;
024 import com.liferay.portal.model.CacheModel;
025 import com.liferay.portal.model.impl.BaseModelImpl;
026 import com.liferay.portal.service.ServiceContext;
027 import com.liferay.portal.util.PortalUtil;
028
029 import com.liferay.portlet.expando.model.ExpandoBridge;
030 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031 import com.liferay.portlet.shopping.model.ShoppingCategory;
032 import com.liferay.portlet.shopping.model.ShoppingCategoryModel;
033 import com.liferay.portlet.shopping.model.ShoppingCategorySoap;
034
035 import java.io.Serializable;
036
037 import java.sql.Types;
038
039 import java.util.ArrayList;
040 import java.util.Date;
041 import java.util.HashMap;
042 import java.util.List;
043 import java.util.Map;
044
045
058 @JSON(strict = true)
059 public class ShoppingCategoryModelImpl extends BaseModelImpl<ShoppingCategory>
060 implements ShoppingCategoryModel {
061
066 public static final String TABLE_NAME = "ShoppingCategory";
067 public static final Object[][] TABLE_COLUMNS = {
068 { "categoryId", Types.BIGINT },
069 { "groupId", Types.BIGINT },
070 { "companyId", Types.BIGINT },
071 { "userId", Types.BIGINT },
072 { "userName", Types.VARCHAR },
073 { "createDate", Types.TIMESTAMP },
074 { "modifiedDate", Types.TIMESTAMP },
075 { "parentCategoryId", Types.BIGINT },
076 { "name", Types.VARCHAR },
077 { "description", Types.VARCHAR }
078 };
079 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)";
080 public static final String TABLE_SQL_DROP = "drop table ShoppingCategory";
081 public static final String ORDER_BY_JPQL = " ORDER BY shoppingCategory.parentCategoryId ASC, shoppingCategory.name ASC";
082 public static final String ORDER_BY_SQL = " ORDER BY ShoppingCategory.parentCategoryId ASC, ShoppingCategory.name ASC";
083 public static final String DATA_SOURCE = "liferayDataSource";
084 public static final String SESSION_FACTORY = "liferaySessionFactory";
085 public static final String TX_MANAGER = "liferayTransactionManager";
086 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
087 "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
088 true);
089 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
090 "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
091 true);
092 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
093 "value.object.column.bitmask.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
094 true);
095 public static long GROUPID_COLUMN_BITMASK = 1L;
096 public static long PARENTCATEGORYID_COLUMN_BITMASK = 2L;
097 public static long NAME_COLUMN_BITMASK = 4L;
098
099
105 public static ShoppingCategory toModel(ShoppingCategorySoap soapModel) {
106 if (soapModel == null) {
107 return null;
108 }
109
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
132 public static List<ShoppingCategory> toModels(
133 ShoppingCategorySoap[] soapModels) {
134 if (soapModels == null) {
135 return null;
136 }
137
138 List<ShoppingCategory> models = new ArrayList<ShoppingCategory>(soapModels.length);
139
140 for (ShoppingCategorySoap soapModel : soapModels) {
141 models.add(toModel(soapModel));
142 }
143
144 return models;
145 }
146
147 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
148 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingCategory"));
149
150 public ShoppingCategoryModelImpl() {
151 }
152
153 public long getPrimaryKey() {
154 return _categoryId;
155 }
156
157 public void setPrimaryKey(long primaryKey) {
158 setCategoryId(primaryKey);
159 }
160
161 public Serializable getPrimaryKeyObj() {
162 return new Long(_categoryId);
163 }
164
165 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
166 setPrimaryKey(((Long)primaryKeyObj).longValue());
167 }
168
169 public Class<?> getModelClass() {
170 return ShoppingCategory.class;
171 }
172
173 public String getModelClassName() {
174 return ShoppingCategory.class.getName();
175 }
176
177 @Override
178 public Map<String, Object> getModelAttributes() {
179 Map<String, Object> attributes = new HashMap<String, Object>();
180
181 attributes.put("categoryId", getCategoryId());
182 attributes.put("groupId", getGroupId());
183 attributes.put("companyId", getCompanyId());
184 attributes.put("userId", getUserId());
185 attributes.put("userName", getUserName());
186 attributes.put("createDate", getCreateDate());
187 attributes.put("modifiedDate", getModifiedDate());
188 attributes.put("parentCategoryId", getParentCategoryId());
189 attributes.put("name", getName());
190 attributes.put("description", getDescription());
191
192 return attributes;
193 }
194
195 @Override
196 public void setModelAttributes(Map<String, Object> attributes) {
197 Long categoryId = (Long)attributes.get("categoryId");
198
199 if (categoryId != null) {
200 setCategoryId(categoryId);
201 }
202
203 Long groupId = (Long)attributes.get("groupId");
204
205 if (groupId != null) {
206 setGroupId(groupId);
207 }
208
209 Long companyId = (Long)attributes.get("companyId");
210
211 if (companyId != null) {
212 setCompanyId(companyId);
213 }
214
215 Long userId = (Long)attributes.get("userId");
216
217 if (userId != null) {
218 setUserId(userId);
219 }
220
221 String userName = (String)attributes.get("userName");
222
223 if (userName != null) {
224 setUserName(userName);
225 }
226
227 Date createDate = (Date)attributes.get("createDate");
228
229 if (createDate != null) {
230 setCreateDate(createDate);
231 }
232
233 Date modifiedDate = (Date)attributes.get("modifiedDate");
234
235 if (modifiedDate != null) {
236 setModifiedDate(modifiedDate);
237 }
238
239 Long parentCategoryId = (Long)attributes.get("parentCategoryId");
240
241 if (parentCategoryId != null) {
242 setParentCategoryId(parentCategoryId);
243 }
244
245 String name = (String)attributes.get("name");
246
247 if (name != null) {
248 setName(name);
249 }
250
251 String description = (String)attributes.get("description");
252
253 if (description != null) {
254 setDescription(description);
255 }
256 }
257
258 @JSON
259 public long getCategoryId() {
260 return _categoryId;
261 }
262
263 public void setCategoryId(long categoryId) {
264 _categoryId = categoryId;
265 }
266
267 @JSON
268 public long getGroupId() {
269 return _groupId;
270 }
271
272 public void setGroupId(long groupId) {
273 _columnBitmask |= GROUPID_COLUMN_BITMASK;
274
275 if (!_setOriginalGroupId) {
276 _setOriginalGroupId = true;
277
278 _originalGroupId = _groupId;
279 }
280
281 _groupId = groupId;
282 }
283
284 public long getOriginalGroupId() {
285 return _originalGroupId;
286 }
287
288 @JSON
289 public long getCompanyId() {
290 return _companyId;
291 }
292
293 public void setCompanyId(long companyId) {
294 _companyId = companyId;
295 }
296
297 @JSON
298 public long getUserId() {
299 return _userId;
300 }
301
302 public void setUserId(long userId) {
303 _userId = userId;
304 }
305
306 public String getUserUuid() throws SystemException {
307 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
308 }
309
310 public void setUserUuid(String userUuid) {
311 _userUuid = userUuid;
312 }
313
314 @JSON
315 public String getUserName() {
316 if (_userName == null) {
317 return StringPool.BLANK;
318 }
319 else {
320 return _userName;
321 }
322 }
323
324 public void setUserName(String userName) {
325 _userName = userName;
326 }
327
328 @JSON
329 public Date getCreateDate() {
330 return _createDate;
331 }
332
333 public void setCreateDate(Date createDate) {
334 _createDate = createDate;
335 }
336
337 @JSON
338 public Date getModifiedDate() {
339 return _modifiedDate;
340 }
341
342 public void setModifiedDate(Date modifiedDate) {
343 _modifiedDate = modifiedDate;
344 }
345
346 @JSON
347 public long getParentCategoryId() {
348 return _parentCategoryId;
349 }
350
351 public void setParentCategoryId(long parentCategoryId) {
352 _columnBitmask = -1L;
353
354 if (!_setOriginalParentCategoryId) {
355 _setOriginalParentCategoryId = true;
356
357 _originalParentCategoryId = _parentCategoryId;
358 }
359
360 _parentCategoryId = parentCategoryId;
361 }
362
363 public long getOriginalParentCategoryId() {
364 return _originalParentCategoryId;
365 }
366
367 @JSON
368 public String getName() {
369 if (_name == null) {
370 return StringPool.BLANK;
371 }
372 else {
373 return _name;
374 }
375 }
376
377 public void setName(String name) {
378 _columnBitmask = -1L;
379
380 _name = name;
381 }
382
383 @JSON
384 public String getDescription() {
385 if (_description == null) {
386 return StringPool.BLANK;
387 }
388 else {
389 return _description;
390 }
391 }
392
393 public void setDescription(String description) {
394 _description = description;
395 }
396
397 public long getColumnBitmask() {
398 return _columnBitmask;
399 }
400
401 @Override
402 public ExpandoBridge getExpandoBridge() {
403 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
404 ShoppingCategory.class.getName(), getPrimaryKey());
405 }
406
407 @Override
408 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
409 ExpandoBridge expandoBridge = getExpandoBridge();
410
411 expandoBridge.setAttributes(serviceContext);
412 }
413
414 @Override
415 public ShoppingCategory toEscapedModel() {
416 if (_escapedModel == null) {
417 _escapedModel = (ShoppingCategory)ProxyUtil.newProxyInstance(_classLoader,
418 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
419 }
420
421 return _escapedModel;
422 }
423
424 @Override
425 public Object clone() {
426 ShoppingCategoryImpl shoppingCategoryImpl = new ShoppingCategoryImpl();
427
428 shoppingCategoryImpl.setCategoryId(getCategoryId());
429 shoppingCategoryImpl.setGroupId(getGroupId());
430 shoppingCategoryImpl.setCompanyId(getCompanyId());
431 shoppingCategoryImpl.setUserId(getUserId());
432 shoppingCategoryImpl.setUserName(getUserName());
433 shoppingCategoryImpl.setCreateDate(getCreateDate());
434 shoppingCategoryImpl.setModifiedDate(getModifiedDate());
435 shoppingCategoryImpl.setParentCategoryId(getParentCategoryId());
436 shoppingCategoryImpl.setName(getName());
437 shoppingCategoryImpl.setDescription(getDescription());
438
439 shoppingCategoryImpl.resetOriginalValues();
440
441 return shoppingCategoryImpl;
442 }
443
444 public int compareTo(ShoppingCategory shoppingCategory) {
445 int value = 0;
446
447 if (getParentCategoryId() < shoppingCategory.getParentCategoryId()) {
448 value = -1;
449 }
450 else if (getParentCategoryId() > shoppingCategory.getParentCategoryId()) {
451 value = 1;
452 }
453 else {
454 value = 0;
455 }
456
457 if (value != 0) {
458 return value;
459 }
460
461 value = getName().toLowerCase()
462 .compareTo(shoppingCategory.getName().toLowerCase());
463
464 if (value != 0) {
465 return value;
466 }
467
468 return 0;
469 }
470
471 @Override
472 public boolean equals(Object obj) {
473 if (obj == null) {
474 return false;
475 }
476
477 ShoppingCategory shoppingCategory = null;
478
479 try {
480 shoppingCategory = (ShoppingCategory)obj;
481 }
482 catch (ClassCastException cce) {
483 return false;
484 }
485
486 long primaryKey = shoppingCategory.getPrimaryKey();
487
488 if (getPrimaryKey() == primaryKey) {
489 return true;
490 }
491 else {
492 return false;
493 }
494 }
495
496 @Override
497 public int hashCode() {
498 return (int)getPrimaryKey();
499 }
500
501 @Override
502 public void resetOriginalValues() {
503 ShoppingCategoryModelImpl shoppingCategoryModelImpl = this;
504
505 shoppingCategoryModelImpl._originalGroupId = shoppingCategoryModelImpl._groupId;
506
507 shoppingCategoryModelImpl._setOriginalGroupId = false;
508
509 shoppingCategoryModelImpl._originalParentCategoryId = shoppingCategoryModelImpl._parentCategoryId;
510
511 shoppingCategoryModelImpl._setOriginalParentCategoryId = false;
512
513 shoppingCategoryModelImpl._columnBitmask = 0;
514 }
515
516 @Override
517 public CacheModel<ShoppingCategory> toCacheModel() {
518 ShoppingCategoryCacheModel shoppingCategoryCacheModel = new ShoppingCategoryCacheModel();
519
520 shoppingCategoryCacheModel.categoryId = getCategoryId();
521
522 shoppingCategoryCacheModel.groupId = getGroupId();
523
524 shoppingCategoryCacheModel.companyId = getCompanyId();
525
526 shoppingCategoryCacheModel.userId = getUserId();
527
528 shoppingCategoryCacheModel.userName = getUserName();
529
530 String userName = shoppingCategoryCacheModel.userName;
531
532 if ((userName != null) && (userName.length() == 0)) {
533 shoppingCategoryCacheModel.userName = null;
534 }
535
536 Date createDate = getCreateDate();
537
538 if (createDate != null) {
539 shoppingCategoryCacheModel.createDate = createDate.getTime();
540 }
541 else {
542 shoppingCategoryCacheModel.createDate = Long.MIN_VALUE;
543 }
544
545 Date modifiedDate = getModifiedDate();
546
547 if (modifiedDate != null) {
548 shoppingCategoryCacheModel.modifiedDate = modifiedDate.getTime();
549 }
550 else {
551 shoppingCategoryCacheModel.modifiedDate = Long.MIN_VALUE;
552 }
553
554 shoppingCategoryCacheModel.parentCategoryId = getParentCategoryId();
555
556 shoppingCategoryCacheModel.name = getName();
557
558 String name = shoppingCategoryCacheModel.name;
559
560 if ((name != null) && (name.length() == 0)) {
561 shoppingCategoryCacheModel.name = null;
562 }
563
564 shoppingCategoryCacheModel.description = getDescription();
565
566 String description = shoppingCategoryCacheModel.description;
567
568 if ((description != null) && (description.length() == 0)) {
569 shoppingCategoryCacheModel.description = null;
570 }
571
572 return shoppingCategoryCacheModel;
573 }
574
575 @Override
576 public String toString() {
577 StringBundler sb = new StringBundler(21);
578
579 sb.append("{categoryId=");
580 sb.append(getCategoryId());
581 sb.append(", groupId=");
582 sb.append(getGroupId());
583 sb.append(", companyId=");
584 sb.append(getCompanyId());
585 sb.append(", userId=");
586 sb.append(getUserId());
587 sb.append(", userName=");
588 sb.append(getUserName());
589 sb.append(", createDate=");
590 sb.append(getCreateDate());
591 sb.append(", modifiedDate=");
592 sb.append(getModifiedDate());
593 sb.append(", parentCategoryId=");
594 sb.append(getParentCategoryId());
595 sb.append(", name=");
596 sb.append(getName());
597 sb.append(", description=");
598 sb.append(getDescription());
599 sb.append("}");
600
601 return sb.toString();
602 }
603
604 public String toXmlString() {
605 StringBundler sb = new StringBundler(34);
606
607 sb.append("<model><model-name>");
608 sb.append("com.liferay.portlet.shopping.model.ShoppingCategory");
609 sb.append("</model-name>");
610
611 sb.append(
612 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
613 sb.append(getCategoryId());
614 sb.append("]]></column-value></column>");
615 sb.append(
616 "<column><column-name>groupId</column-name><column-value><![CDATA[");
617 sb.append(getGroupId());
618 sb.append("]]></column-value></column>");
619 sb.append(
620 "<column><column-name>companyId</column-name><column-value><![CDATA[");
621 sb.append(getCompanyId());
622 sb.append("]]></column-value></column>");
623 sb.append(
624 "<column><column-name>userId</column-name><column-value><![CDATA[");
625 sb.append(getUserId());
626 sb.append("]]></column-value></column>");
627 sb.append(
628 "<column><column-name>userName</column-name><column-value><![CDATA[");
629 sb.append(getUserName());
630 sb.append("]]></column-value></column>");
631 sb.append(
632 "<column><column-name>createDate</column-name><column-value><![CDATA[");
633 sb.append(getCreateDate());
634 sb.append("]]></column-value></column>");
635 sb.append(
636 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
637 sb.append(getModifiedDate());
638 sb.append("]]></column-value></column>");
639 sb.append(
640 "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
641 sb.append(getParentCategoryId());
642 sb.append("]]></column-value></column>");
643 sb.append(
644 "<column><column-name>name</column-name><column-value><![CDATA[");
645 sb.append(getName());
646 sb.append("]]></column-value></column>");
647 sb.append(
648 "<column><column-name>description</column-name><column-value><![CDATA[");
649 sb.append(getDescription());
650 sb.append("]]></column-value></column>");
651
652 sb.append("</model>");
653
654 return sb.toString();
655 }
656
657 private static ClassLoader _classLoader = ShoppingCategory.class.getClassLoader();
658 private static Class<?>[] _escapedModelInterfaces = new Class[] {
659 ShoppingCategory.class
660 };
661 private long _categoryId;
662 private long _groupId;
663 private long _originalGroupId;
664 private boolean _setOriginalGroupId;
665 private long _companyId;
666 private long _userId;
667 private String _userUuid;
668 private String _userName;
669 private Date _createDate;
670 private Date _modifiedDate;
671 private long _parentCategoryId;
672 private long _originalParentCategoryId;
673 private boolean _setOriginalParentCategoryId;
674 private String _name;
675 private String _description;
676 private long _columnBitmask;
677 private ShoppingCategory _escapedModel;
678 }