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 NAME_COLUMN_BITMASK = 2L;
097 public static long PARENTCATEGORYID_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 @Override
154 public long getPrimaryKey() {
155 return _categoryId;
156 }
157
158 @Override
159 public void setPrimaryKey(long primaryKey) {
160 setCategoryId(primaryKey);
161 }
162
163 @Override
164 public Serializable getPrimaryKeyObj() {
165 return _categoryId;
166 }
167
168 @Override
169 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
170 setPrimaryKey(((Long)primaryKeyObj).longValue());
171 }
172
173 @Override
174 public Class<?> getModelClass() {
175 return ShoppingCategory.class;
176 }
177
178 @Override
179 public String getModelClassName() {
180 return ShoppingCategory.class.getName();
181 }
182
183 @Override
184 public Map<String, Object> getModelAttributes() {
185 Map<String, Object> attributes = new HashMap<String, Object>();
186
187 attributes.put("categoryId", getCategoryId());
188 attributes.put("groupId", getGroupId());
189 attributes.put("companyId", getCompanyId());
190 attributes.put("userId", getUserId());
191 attributes.put("userName", getUserName());
192 attributes.put("createDate", getCreateDate());
193 attributes.put("modifiedDate", getModifiedDate());
194 attributes.put("parentCategoryId", getParentCategoryId());
195 attributes.put("name", getName());
196 attributes.put("description", getDescription());
197
198 return attributes;
199 }
200
201 @Override
202 public void setModelAttributes(Map<String, Object> attributes) {
203 Long categoryId = (Long)attributes.get("categoryId");
204
205 if (categoryId != null) {
206 setCategoryId(categoryId);
207 }
208
209 Long groupId = (Long)attributes.get("groupId");
210
211 if (groupId != null) {
212 setGroupId(groupId);
213 }
214
215 Long companyId = (Long)attributes.get("companyId");
216
217 if (companyId != null) {
218 setCompanyId(companyId);
219 }
220
221 Long userId = (Long)attributes.get("userId");
222
223 if (userId != null) {
224 setUserId(userId);
225 }
226
227 String userName = (String)attributes.get("userName");
228
229 if (userName != null) {
230 setUserName(userName);
231 }
232
233 Date createDate = (Date)attributes.get("createDate");
234
235 if (createDate != null) {
236 setCreateDate(createDate);
237 }
238
239 Date modifiedDate = (Date)attributes.get("modifiedDate");
240
241 if (modifiedDate != null) {
242 setModifiedDate(modifiedDate);
243 }
244
245 Long parentCategoryId = (Long)attributes.get("parentCategoryId");
246
247 if (parentCategoryId != null) {
248 setParentCategoryId(parentCategoryId);
249 }
250
251 String name = (String)attributes.get("name");
252
253 if (name != null) {
254 setName(name);
255 }
256
257 String description = (String)attributes.get("description");
258
259 if (description != null) {
260 setDescription(description);
261 }
262 }
263
264 @JSON
265 @Override
266 public long getCategoryId() {
267 return _categoryId;
268 }
269
270 @Override
271 public void setCategoryId(long categoryId) {
272 _categoryId = categoryId;
273 }
274
275 @JSON
276 @Override
277 public long getGroupId() {
278 return _groupId;
279 }
280
281 @Override
282 public void setGroupId(long groupId) {
283 _columnBitmask |= GROUPID_COLUMN_BITMASK;
284
285 if (!_setOriginalGroupId) {
286 _setOriginalGroupId = true;
287
288 _originalGroupId = _groupId;
289 }
290
291 _groupId = groupId;
292 }
293
294 public long getOriginalGroupId() {
295 return _originalGroupId;
296 }
297
298 @JSON
299 @Override
300 public long getCompanyId() {
301 return _companyId;
302 }
303
304 @Override
305 public void setCompanyId(long companyId) {
306 _companyId = companyId;
307 }
308
309 @JSON
310 @Override
311 public long getUserId() {
312 return _userId;
313 }
314
315 @Override
316 public void setUserId(long userId) {
317 _userId = userId;
318 }
319
320 @Override
321 public String getUserUuid() throws SystemException {
322 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
323 }
324
325 @Override
326 public void setUserUuid(String userUuid) {
327 _userUuid = userUuid;
328 }
329
330 @JSON
331 @Override
332 public String getUserName() {
333 if (_userName == null) {
334 return StringPool.BLANK;
335 }
336 else {
337 return _userName;
338 }
339 }
340
341 @Override
342 public void setUserName(String userName) {
343 _userName = userName;
344 }
345
346 @JSON
347 @Override
348 public Date getCreateDate() {
349 return _createDate;
350 }
351
352 @Override
353 public void setCreateDate(Date createDate) {
354 _createDate = createDate;
355 }
356
357 @JSON
358 @Override
359 public Date getModifiedDate() {
360 return _modifiedDate;
361 }
362
363 @Override
364 public void setModifiedDate(Date modifiedDate) {
365 _modifiedDate = modifiedDate;
366 }
367
368 @JSON
369 @Override
370 public long getParentCategoryId() {
371 return _parentCategoryId;
372 }
373
374 @Override
375 public void setParentCategoryId(long parentCategoryId) {
376 _columnBitmask = -1L;
377
378 if (!_setOriginalParentCategoryId) {
379 _setOriginalParentCategoryId = true;
380
381 _originalParentCategoryId = _parentCategoryId;
382 }
383
384 _parentCategoryId = parentCategoryId;
385 }
386
387 public long getOriginalParentCategoryId() {
388 return _originalParentCategoryId;
389 }
390
391 @JSON
392 @Override
393 public String getName() {
394 if (_name == null) {
395 return StringPool.BLANK;
396 }
397 else {
398 return _name;
399 }
400 }
401
402 @Override
403 public void setName(String name) {
404 _columnBitmask = -1L;
405
406 if (_originalName == null) {
407 _originalName = _name;
408 }
409
410 _name = name;
411 }
412
413 public String getOriginalName() {
414 return GetterUtil.getString(_originalName);
415 }
416
417 @JSON
418 @Override
419 public String getDescription() {
420 if (_description == null) {
421 return StringPool.BLANK;
422 }
423 else {
424 return _description;
425 }
426 }
427
428 @Override
429 public void setDescription(String description) {
430 _description = description;
431 }
432
433 public long getColumnBitmask() {
434 return _columnBitmask;
435 }
436
437 @Override
438 public ExpandoBridge getExpandoBridge() {
439 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
440 ShoppingCategory.class.getName(), getPrimaryKey());
441 }
442
443 @Override
444 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
445 ExpandoBridge expandoBridge = getExpandoBridge();
446
447 expandoBridge.setAttributes(serviceContext);
448 }
449
450 @Override
451 public ShoppingCategory toEscapedModel() {
452 if (_escapedModel == null) {
453 _escapedModel = (ShoppingCategory)ProxyUtil.newProxyInstance(_classLoader,
454 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
455 }
456
457 return _escapedModel;
458 }
459
460 @Override
461 public Object clone() {
462 ShoppingCategoryImpl shoppingCategoryImpl = new ShoppingCategoryImpl();
463
464 shoppingCategoryImpl.setCategoryId(getCategoryId());
465 shoppingCategoryImpl.setGroupId(getGroupId());
466 shoppingCategoryImpl.setCompanyId(getCompanyId());
467 shoppingCategoryImpl.setUserId(getUserId());
468 shoppingCategoryImpl.setUserName(getUserName());
469 shoppingCategoryImpl.setCreateDate(getCreateDate());
470 shoppingCategoryImpl.setModifiedDate(getModifiedDate());
471 shoppingCategoryImpl.setParentCategoryId(getParentCategoryId());
472 shoppingCategoryImpl.setName(getName());
473 shoppingCategoryImpl.setDescription(getDescription());
474
475 shoppingCategoryImpl.resetOriginalValues();
476
477 return shoppingCategoryImpl;
478 }
479
480 @Override
481 public int compareTo(ShoppingCategory shoppingCategory) {
482 int value = 0;
483
484 if (getParentCategoryId() < shoppingCategory.getParentCategoryId()) {
485 value = -1;
486 }
487 else if (getParentCategoryId() > shoppingCategory.getParentCategoryId()) {
488 value = 1;
489 }
490 else {
491 value = 0;
492 }
493
494 if (value != 0) {
495 return value;
496 }
497
498 value = getName().compareToIgnoreCase(shoppingCategory.getName());
499
500 if (value != 0) {
501 return value;
502 }
503
504 return 0;
505 }
506
507 @Override
508 public boolean equals(Object obj) {
509 if (this == obj) {
510 return true;
511 }
512
513 if (!(obj instanceof ShoppingCategory)) {
514 return false;
515 }
516
517 ShoppingCategory shoppingCategory = (ShoppingCategory)obj;
518
519 long primaryKey = shoppingCategory.getPrimaryKey();
520
521 if (getPrimaryKey() == primaryKey) {
522 return true;
523 }
524 else {
525 return false;
526 }
527 }
528
529 @Override
530 public int hashCode() {
531 return (int)getPrimaryKey();
532 }
533
534 @Override
535 public void resetOriginalValues() {
536 ShoppingCategoryModelImpl shoppingCategoryModelImpl = this;
537
538 shoppingCategoryModelImpl._originalGroupId = shoppingCategoryModelImpl._groupId;
539
540 shoppingCategoryModelImpl._setOriginalGroupId = false;
541
542 shoppingCategoryModelImpl._originalParentCategoryId = shoppingCategoryModelImpl._parentCategoryId;
543
544 shoppingCategoryModelImpl._setOriginalParentCategoryId = false;
545
546 shoppingCategoryModelImpl._originalName = shoppingCategoryModelImpl._name;
547
548 shoppingCategoryModelImpl._columnBitmask = 0;
549 }
550
551 @Override
552 public CacheModel<ShoppingCategory> toCacheModel() {
553 ShoppingCategoryCacheModel shoppingCategoryCacheModel = new ShoppingCategoryCacheModel();
554
555 shoppingCategoryCacheModel.categoryId = getCategoryId();
556
557 shoppingCategoryCacheModel.groupId = getGroupId();
558
559 shoppingCategoryCacheModel.companyId = getCompanyId();
560
561 shoppingCategoryCacheModel.userId = getUserId();
562
563 shoppingCategoryCacheModel.userName = getUserName();
564
565 String userName = shoppingCategoryCacheModel.userName;
566
567 if ((userName != null) && (userName.length() == 0)) {
568 shoppingCategoryCacheModel.userName = null;
569 }
570
571 Date createDate = getCreateDate();
572
573 if (createDate != null) {
574 shoppingCategoryCacheModel.createDate = createDate.getTime();
575 }
576 else {
577 shoppingCategoryCacheModel.createDate = Long.MIN_VALUE;
578 }
579
580 Date modifiedDate = getModifiedDate();
581
582 if (modifiedDate != null) {
583 shoppingCategoryCacheModel.modifiedDate = modifiedDate.getTime();
584 }
585 else {
586 shoppingCategoryCacheModel.modifiedDate = Long.MIN_VALUE;
587 }
588
589 shoppingCategoryCacheModel.parentCategoryId = getParentCategoryId();
590
591 shoppingCategoryCacheModel.name = getName();
592
593 String name = shoppingCategoryCacheModel.name;
594
595 if ((name != null) && (name.length() == 0)) {
596 shoppingCategoryCacheModel.name = null;
597 }
598
599 shoppingCategoryCacheModel.description = getDescription();
600
601 String description = shoppingCategoryCacheModel.description;
602
603 if ((description != null) && (description.length() == 0)) {
604 shoppingCategoryCacheModel.description = null;
605 }
606
607 return shoppingCategoryCacheModel;
608 }
609
610 @Override
611 public String toString() {
612 StringBundler sb = new StringBundler(21);
613
614 sb.append("{categoryId=");
615 sb.append(getCategoryId());
616 sb.append(", groupId=");
617 sb.append(getGroupId());
618 sb.append(", companyId=");
619 sb.append(getCompanyId());
620 sb.append(", userId=");
621 sb.append(getUserId());
622 sb.append(", userName=");
623 sb.append(getUserName());
624 sb.append(", createDate=");
625 sb.append(getCreateDate());
626 sb.append(", modifiedDate=");
627 sb.append(getModifiedDate());
628 sb.append(", parentCategoryId=");
629 sb.append(getParentCategoryId());
630 sb.append(", name=");
631 sb.append(getName());
632 sb.append(", description=");
633 sb.append(getDescription());
634 sb.append("}");
635
636 return sb.toString();
637 }
638
639 @Override
640 public String toXmlString() {
641 StringBundler sb = new StringBundler(34);
642
643 sb.append("<model><model-name>");
644 sb.append("com.liferay.portlet.shopping.model.ShoppingCategory");
645 sb.append("</model-name>");
646
647 sb.append(
648 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
649 sb.append(getCategoryId());
650 sb.append("]]></column-value></column>");
651 sb.append(
652 "<column><column-name>groupId</column-name><column-value><![CDATA[");
653 sb.append(getGroupId());
654 sb.append("]]></column-value></column>");
655 sb.append(
656 "<column><column-name>companyId</column-name><column-value><![CDATA[");
657 sb.append(getCompanyId());
658 sb.append("]]></column-value></column>");
659 sb.append(
660 "<column><column-name>userId</column-name><column-value><![CDATA[");
661 sb.append(getUserId());
662 sb.append("]]></column-value></column>");
663 sb.append(
664 "<column><column-name>userName</column-name><column-value><![CDATA[");
665 sb.append(getUserName());
666 sb.append("]]></column-value></column>");
667 sb.append(
668 "<column><column-name>createDate</column-name><column-value><![CDATA[");
669 sb.append(getCreateDate());
670 sb.append("]]></column-value></column>");
671 sb.append(
672 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
673 sb.append(getModifiedDate());
674 sb.append("]]></column-value></column>");
675 sb.append(
676 "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
677 sb.append(getParentCategoryId());
678 sb.append("]]></column-value></column>");
679 sb.append(
680 "<column><column-name>name</column-name><column-value><![CDATA[");
681 sb.append(getName());
682 sb.append("]]></column-value></column>");
683 sb.append(
684 "<column><column-name>description</column-name><column-value><![CDATA[");
685 sb.append(getDescription());
686 sb.append("]]></column-value></column>");
687
688 sb.append("</model>");
689
690 return sb.toString();
691 }
692
693 private static ClassLoader _classLoader = ShoppingCategory.class.getClassLoader();
694 private static Class<?>[] _escapedModelInterfaces = new Class[] {
695 ShoppingCategory.class
696 };
697 private long _categoryId;
698 private long _groupId;
699 private long _originalGroupId;
700 private boolean _setOriginalGroupId;
701 private long _companyId;
702 private long _userId;
703 private String _userUuid;
704 private String _userName;
705 private Date _createDate;
706 private Date _modifiedDate;
707 private long _parentCategoryId;
708 private long _originalParentCategoryId;
709 private boolean _setOriginalParentCategoryId;
710 private String _name;
711 private String _originalName;
712 private String _description;
713 private long _columnBitmask;
714 private ShoppingCategory _escapedModel;
715 }