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