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