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
098
104 public static ShoppingCategory toModel(ShoppingCategorySoap soapModel) {
105 if (soapModel == null) {
106 return null;
107 }
108
109 ShoppingCategory model = new ShoppingCategoryImpl();
110
111 model.setCategoryId(soapModel.getCategoryId());
112 model.setGroupId(soapModel.getGroupId());
113 model.setCompanyId(soapModel.getCompanyId());
114 model.setUserId(soapModel.getUserId());
115 model.setUserName(soapModel.getUserName());
116 model.setCreateDate(soapModel.getCreateDate());
117 model.setModifiedDate(soapModel.getModifiedDate());
118 model.setParentCategoryId(soapModel.getParentCategoryId());
119 model.setName(soapModel.getName());
120 model.setDescription(soapModel.getDescription());
121
122 return model;
123 }
124
125
131 public static List<ShoppingCategory> toModels(
132 ShoppingCategorySoap[] soapModels) {
133 if (soapModels == null) {
134 return null;
135 }
136
137 List<ShoppingCategory> models = new ArrayList<ShoppingCategory>(soapModels.length);
138
139 for (ShoppingCategorySoap soapModel : soapModels) {
140 models.add(toModel(soapModel));
141 }
142
143 return models;
144 }
145
146 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
147 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingCategory"));
148
149 public ShoppingCategoryModelImpl() {
150 }
151
152 public long getPrimaryKey() {
153 return _categoryId;
154 }
155
156 public void setPrimaryKey(long primaryKey) {
157 setCategoryId(primaryKey);
158 }
159
160 public Serializable getPrimaryKeyObj() {
161 return new Long(_categoryId);
162 }
163
164 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
165 setPrimaryKey(((Long)primaryKeyObj).longValue());
166 }
167
168 public Class<?> getModelClass() {
169 return ShoppingCategory.class;
170 }
171
172 public String getModelClassName() {
173 return ShoppingCategory.class.getName();
174 }
175
176 @Override
177 public Map<String, Object> getModelAttributes() {
178 Map<String, Object> attributes = new HashMap<String, Object>();
179
180 attributes.put("categoryId", getCategoryId());
181 attributes.put("groupId", getGroupId());
182 attributes.put("companyId", getCompanyId());
183 attributes.put("userId", getUserId());
184 attributes.put("userName", getUserName());
185 attributes.put("createDate", getCreateDate());
186 attributes.put("modifiedDate", getModifiedDate());
187 attributes.put("parentCategoryId", getParentCategoryId());
188 attributes.put("name", getName());
189 attributes.put("description", getDescription());
190
191 return attributes;
192 }
193
194 @Override
195 public void setModelAttributes(Map<String, Object> attributes) {
196 Long categoryId = (Long)attributes.get("categoryId");
197
198 if (categoryId != null) {
199 setCategoryId(categoryId);
200 }
201
202 Long groupId = (Long)attributes.get("groupId");
203
204 if (groupId != null) {
205 setGroupId(groupId);
206 }
207
208 Long companyId = (Long)attributes.get("companyId");
209
210 if (companyId != null) {
211 setCompanyId(companyId);
212 }
213
214 Long userId = (Long)attributes.get("userId");
215
216 if (userId != null) {
217 setUserId(userId);
218 }
219
220 String userName = (String)attributes.get("userName");
221
222 if (userName != null) {
223 setUserName(userName);
224 }
225
226 Date createDate = (Date)attributes.get("createDate");
227
228 if (createDate != null) {
229 setCreateDate(createDate);
230 }
231
232 Date modifiedDate = (Date)attributes.get("modifiedDate");
233
234 if (modifiedDate != null) {
235 setModifiedDate(modifiedDate);
236 }
237
238 Long parentCategoryId = (Long)attributes.get("parentCategoryId");
239
240 if (parentCategoryId != null) {
241 setParentCategoryId(parentCategoryId);
242 }
243
244 String name = (String)attributes.get("name");
245
246 if (name != null) {
247 setName(name);
248 }
249
250 String description = (String)attributes.get("description");
251
252 if (description != null) {
253 setDescription(description);
254 }
255 }
256
257 @JSON
258 public long getCategoryId() {
259 return _categoryId;
260 }
261
262 public void setCategoryId(long categoryId) {
263 _categoryId = categoryId;
264 }
265
266 @JSON
267 public long getGroupId() {
268 return _groupId;
269 }
270
271 public void setGroupId(long groupId) {
272 _columnBitmask |= GROUPID_COLUMN_BITMASK;
273
274 if (!_setOriginalGroupId) {
275 _setOriginalGroupId = true;
276
277 _originalGroupId = _groupId;
278 }
279
280 _groupId = groupId;
281 }
282
283 public long getOriginalGroupId() {
284 return _originalGroupId;
285 }
286
287 @JSON
288 public long getCompanyId() {
289 return _companyId;
290 }
291
292 public void setCompanyId(long companyId) {
293 _companyId = companyId;
294 }
295
296 @JSON
297 public long getUserId() {
298 return _userId;
299 }
300
301 public void setUserId(long userId) {
302 _userId = userId;
303 }
304
305 public String getUserUuid() throws SystemException {
306 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
307 }
308
309 public void setUserUuid(String userUuid) {
310 _userUuid = userUuid;
311 }
312
313 @JSON
314 public String getUserName() {
315 if (_userName == null) {
316 return StringPool.BLANK;
317 }
318 else {
319 return _userName;
320 }
321 }
322
323 public void setUserName(String userName) {
324 _userName = userName;
325 }
326
327 @JSON
328 public Date getCreateDate() {
329 return _createDate;
330 }
331
332 public void setCreateDate(Date createDate) {
333 _createDate = createDate;
334 }
335
336 @JSON
337 public Date getModifiedDate() {
338 return _modifiedDate;
339 }
340
341 public void setModifiedDate(Date modifiedDate) {
342 _modifiedDate = modifiedDate;
343 }
344
345 @JSON
346 public long getParentCategoryId() {
347 return _parentCategoryId;
348 }
349
350 public void setParentCategoryId(long parentCategoryId) {
351 _columnBitmask = -1L;
352
353 if (!_setOriginalParentCategoryId) {
354 _setOriginalParentCategoryId = true;
355
356 _originalParentCategoryId = _parentCategoryId;
357 }
358
359 _parentCategoryId = parentCategoryId;
360 }
361
362 public long getOriginalParentCategoryId() {
363 return _originalParentCategoryId;
364 }
365
366 @JSON
367 public String getName() {
368 if (_name == null) {
369 return StringPool.BLANK;
370 }
371 else {
372 return _name;
373 }
374 }
375
376 public void setName(String name) {
377 _columnBitmask = -1L;
378
379 _name = name;
380 }
381
382 @JSON
383 public String getDescription() {
384 if (_description == null) {
385 return StringPool.BLANK;
386 }
387 else {
388 return _description;
389 }
390 }
391
392 public void setDescription(String description) {
393 _description = description;
394 }
395
396 public long getColumnBitmask() {
397 return _columnBitmask;
398 }
399
400 @Override
401 public ExpandoBridge getExpandoBridge() {
402 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
403 ShoppingCategory.class.getName(), getPrimaryKey());
404 }
405
406 @Override
407 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
408 ExpandoBridge expandoBridge = getExpandoBridge();
409
410 expandoBridge.setAttributes(serviceContext);
411 }
412
413 @Override
414 public ShoppingCategory toEscapedModel() {
415 if (_escapedModel == null) {
416 _escapedModel = (ShoppingCategory)ProxyUtil.newProxyInstance(_classLoader,
417 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
418 }
419
420 return _escapedModel;
421 }
422
423 public ShoppingCategory toUnescapedModel() {
424 return (ShoppingCategory)this;
425 }
426
427 @Override
428 public Object clone() {
429 ShoppingCategoryImpl shoppingCategoryImpl = new ShoppingCategoryImpl();
430
431 shoppingCategoryImpl.setCategoryId(getCategoryId());
432 shoppingCategoryImpl.setGroupId(getGroupId());
433 shoppingCategoryImpl.setCompanyId(getCompanyId());
434 shoppingCategoryImpl.setUserId(getUserId());
435 shoppingCategoryImpl.setUserName(getUserName());
436 shoppingCategoryImpl.setCreateDate(getCreateDate());
437 shoppingCategoryImpl.setModifiedDate(getModifiedDate());
438 shoppingCategoryImpl.setParentCategoryId(getParentCategoryId());
439 shoppingCategoryImpl.setName(getName());
440 shoppingCategoryImpl.setDescription(getDescription());
441
442 shoppingCategoryImpl.resetOriginalValues();
443
444 return shoppingCategoryImpl;
445 }
446
447 public int compareTo(ShoppingCategory shoppingCategory) {
448 int value = 0;
449
450 if (getParentCategoryId() < shoppingCategory.getParentCategoryId()) {
451 value = -1;
452 }
453 else if (getParentCategoryId() > shoppingCategory.getParentCategoryId()) {
454 value = 1;
455 }
456 else {
457 value = 0;
458 }
459
460 if (value != 0) {
461 return value;
462 }
463
464 value = getName().toLowerCase()
465 .compareTo(shoppingCategory.getName().toLowerCase());
466
467 if (value != 0) {
468 return value;
469 }
470
471 return 0;
472 }
473
474 @Override
475 public boolean equals(Object obj) {
476 if (this == obj) {
477 return true;
478 }
479
480 if (!(obj instanceof ShoppingCategory)) {
481 return false;
482 }
483
484 ShoppingCategory shoppingCategory = (ShoppingCategory)obj;
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 }