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 |= PARENTCATEGORYID_COLUMN_BITMASK;
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 _name = name;
332 }
333
334 @JSON
335 public String getDescription() {
336 if (_description == null) {
337 return StringPool.BLANK;
338 }
339 else {
340 return _description;
341 }
342 }
343
344 public void setDescription(String description) {
345 _description = description;
346 }
347
348 @JSON
349 public String getDisplayStyle() {
350 if (_displayStyle == null) {
351 return StringPool.BLANK;
352 }
353 else {
354 return _displayStyle;
355 }
356 }
357
358 public void setDisplayStyle(String displayStyle) {
359 _displayStyle = displayStyle;
360 }
361
362 @JSON
363 public int getThreadCount() {
364 return _threadCount;
365 }
366
367 public void setThreadCount(int threadCount) {
368 _threadCount = threadCount;
369 }
370
371 @JSON
372 public int getMessageCount() {
373 return _messageCount;
374 }
375
376 public void setMessageCount(int messageCount) {
377 _messageCount = messageCount;
378 }
379
380 @JSON
381 public Date getLastPostDate() {
382 return _lastPostDate;
383 }
384
385 public void setLastPostDate(Date lastPostDate) {
386 _lastPostDate = lastPostDate;
387 }
388
389 public long getColumnBitmask() {
390 return _columnBitmask;
391 }
392
393 @Override
394 public MBCategory toEscapedModel() {
395 if (_escapedModelProxy == null) {
396 _escapedModelProxy = (MBCategory)ProxyUtil.newProxyInstance(_classLoader,
397 _escapedModelProxyInterfaces,
398 new AutoEscapeBeanHandler(this));
399 }
400
401 return _escapedModelProxy;
402 }
403
404 @Override
405 public ExpandoBridge getExpandoBridge() {
406 if (_expandoBridge == null) {
407 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
408 MBCategory.class.getName(), getPrimaryKey());
409 }
410
411 return _expandoBridge;
412 }
413
414 @Override
415 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
416 getExpandoBridge().setAttributes(serviceContext);
417 }
418
419 @Override
420 public Object clone() {
421 MBCategoryImpl mbCategoryImpl = new MBCategoryImpl();
422
423 mbCategoryImpl.setUuid(getUuid());
424 mbCategoryImpl.setCategoryId(getCategoryId());
425 mbCategoryImpl.setGroupId(getGroupId());
426 mbCategoryImpl.setCompanyId(getCompanyId());
427 mbCategoryImpl.setUserId(getUserId());
428 mbCategoryImpl.setUserName(getUserName());
429 mbCategoryImpl.setCreateDate(getCreateDate());
430 mbCategoryImpl.setModifiedDate(getModifiedDate());
431 mbCategoryImpl.setParentCategoryId(getParentCategoryId());
432 mbCategoryImpl.setName(getName());
433 mbCategoryImpl.setDescription(getDescription());
434 mbCategoryImpl.setDisplayStyle(getDisplayStyle());
435 mbCategoryImpl.setThreadCount(getThreadCount());
436 mbCategoryImpl.setMessageCount(getMessageCount());
437 mbCategoryImpl.setLastPostDate(getLastPostDate());
438
439 mbCategoryImpl.resetOriginalValues();
440
441 return mbCategoryImpl;
442 }
443
444 public int compareTo(MBCategory mbCategory) {
445 int value = 0;
446
447 if (getParentCategoryId() < mbCategory.getParentCategoryId()) {
448 value = -1;
449 }
450 else if (getParentCategoryId() > mbCategory.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(mbCategory.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 MBCategory mbCategory = null;
478
479 try {
480 mbCategory = (MBCategory)obj;
481 }
482 catch (ClassCastException cce) {
483 return false;
484 }
485
486 long primaryKey = mbCategory.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 MBCategoryModelImpl mbCategoryModelImpl = this;
504
505 mbCategoryModelImpl._originalUuid = mbCategoryModelImpl._uuid;
506
507 mbCategoryModelImpl._originalGroupId = mbCategoryModelImpl._groupId;
508
509 mbCategoryModelImpl._setOriginalGroupId = false;
510
511 mbCategoryModelImpl._originalCompanyId = mbCategoryModelImpl._companyId;
512
513 mbCategoryModelImpl._setOriginalCompanyId = false;
514
515 mbCategoryModelImpl._originalParentCategoryId = mbCategoryModelImpl._parentCategoryId;
516
517 mbCategoryModelImpl._setOriginalParentCategoryId = false;
518
519 mbCategoryModelImpl._columnBitmask = 0;
520 }
521
522 @Override
523 public CacheModel<MBCategory> toCacheModel() {
524 MBCategoryCacheModel mbCategoryCacheModel = new MBCategoryCacheModel();
525
526 mbCategoryCacheModel.uuid = getUuid();
527
528 String uuid = mbCategoryCacheModel.uuid;
529
530 if ((uuid != null) && (uuid.length() == 0)) {
531 mbCategoryCacheModel.uuid = null;
532 }
533
534 mbCategoryCacheModel.categoryId = getCategoryId();
535
536 mbCategoryCacheModel.groupId = getGroupId();
537
538 mbCategoryCacheModel.companyId = getCompanyId();
539
540 mbCategoryCacheModel.userId = getUserId();
541
542 mbCategoryCacheModel.userName = getUserName();
543
544 String userName = mbCategoryCacheModel.userName;
545
546 if ((userName != null) && (userName.length() == 0)) {
547 mbCategoryCacheModel.userName = null;
548 }
549
550 Date createDate = getCreateDate();
551
552 if (createDate != null) {
553 mbCategoryCacheModel.createDate = createDate.getTime();
554 }
555 else {
556 mbCategoryCacheModel.createDate = Long.MIN_VALUE;
557 }
558
559 Date modifiedDate = getModifiedDate();
560
561 if (modifiedDate != null) {
562 mbCategoryCacheModel.modifiedDate = modifiedDate.getTime();
563 }
564 else {
565 mbCategoryCacheModel.modifiedDate = Long.MIN_VALUE;
566 }
567
568 mbCategoryCacheModel.parentCategoryId = getParentCategoryId();
569
570 mbCategoryCacheModel.name = getName();
571
572 String name = mbCategoryCacheModel.name;
573
574 if ((name != null) && (name.length() == 0)) {
575 mbCategoryCacheModel.name = null;
576 }
577
578 mbCategoryCacheModel.description = getDescription();
579
580 String description = mbCategoryCacheModel.description;
581
582 if ((description != null) && (description.length() == 0)) {
583 mbCategoryCacheModel.description = null;
584 }
585
586 mbCategoryCacheModel.displayStyle = getDisplayStyle();
587
588 String displayStyle = mbCategoryCacheModel.displayStyle;
589
590 if ((displayStyle != null) && (displayStyle.length() == 0)) {
591 mbCategoryCacheModel.displayStyle = null;
592 }
593
594 mbCategoryCacheModel.threadCount = getThreadCount();
595
596 mbCategoryCacheModel.messageCount = getMessageCount();
597
598 Date lastPostDate = getLastPostDate();
599
600 if (lastPostDate != null) {
601 mbCategoryCacheModel.lastPostDate = lastPostDate.getTime();
602 }
603 else {
604 mbCategoryCacheModel.lastPostDate = Long.MIN_VALUE;
605 }
606
607 return mbCategoryCacheModel;
608 }
609
610 @Override
611 public String toString() {
612 StringBundler sb = new StringBundler(31);
613
614 sb.append("{uuid=");
615 sb.append(getUuid());
616 sb.append(", categoryId=");
617 sb.append(getCategoryId());
618 sb.append(", groupId=");
619 sb.append(getGroupId());
620 sb.append(", companyId=");
621 sb.append(getCompanyId());
622 sb.append(", userId=");
623 sb.append(getUserId());
624 sb.append(", userName=");
625 sb.append(getUserName());
626 sb.append(", createDate=");
627 sb.append(getCreateDate());
628 sb.append(", modifiedDate=");
629 sb.append(getModifiedDate());
630 sb.append(", parentCategoryId=");
631 sb.append(getParentCategoryId());
632 sb.append(", name=");
633 sb.append(getName());
634 sb.append(", description=");
635 sb.append(getDescription());
636 sb.append(", displayStyle=");
637 sb.append(getDisplayStyle());
638 sb.append(", threadCount=");
639 sb.append(getThreadCount());
640 sb.append(", messageCount=");
641 sb.append(getMessageCount());
642 sb.append(", lastPostDate=");
643 sb.append(getLastPostDate());
644 sb.append("}");
645
646 return sb.toString();
647 }
648
649 public String toXmlString() {
650 StringBundler sb = new StringBundler(49);
651
652 sb.append("<model><model-name>");
653 sb.append("com.liferay.portlet.messageboards.model.MBCategory");
654 sb.append("</model-name>");
655
656 sb.append(
657 "<column><column-name>uuid</column-name><column-value><![CDATA[");
658 sb.append(getUuid());
659 sb.append("]]></column-value></column>");
660 sb.append(
661 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
662 sb.append(getCategoryId());
663 sb.append("]]></column-value></column>");
664 sb.append(
665 "<column><column-name>groupId</column-name><column-value><![CDATA[");
666 sb.append(getGroupId());
667 sb.append("]]></column-value></column>");
668 sb.append(
669 "<column><column-name>companyId</column-name><column-value><![CDATA[");
670 sb.append(getCompanyId());
671 sb.append("]]></column-value></column>");
672 sb.append(
673 "<column><column-name>userId</column-name><column-value><![CDATA[");
674 sb.append(getUserId());
675 sb.append("]]></column-value></column>");
676 sb.append(
677 "<column><column-name>userName</column-name><column-value><![CDATA[");
678 sb.append(getUserName());
679 sb.append("]]></column-value></column>");
680 sb.append(
681 "<column><column-name>createDate</column-name><column-value><![CDATA[");
682 sb.append(getCreateDate());
683 sb.append("]]></column-value></column>");
684 sb.append(
685 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
686 sb.append(getModifiedDate());
687 sb.append("]]></column-value></column>");
688 sb.append(
689 "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
690 sb.append(getParentCategoryId());
691 sb.append("]]></column-value></column>");
692 sb.append(
693 "<column><column-name>name</column-name><column-value><![CDATA[");
694 sb.append(getName());
695 sb.append("]]></column-value></column>");
696 sb.append(
697 "<column><column-name>description</column-name><column-value><![CDATA[");
698 sb.append(getDescription());
699 sb.append("]]></column-value></column>");
700 sb.append(
701 "<column><column-name>displayStyle</column-name><column-value><![CDATA[");
702 sb.append(getDisplayStyle());
703 sb.append("]]></column-value></column>");
704 sb.append(
705 "<column><column-name>threadCount</column-name><column-value><![CDATA[");
706 sb.append(getThreadCount());
707 sb.append("]]></column-value></column>");
708 sb.append(
709 "<column><column-name>messageCount</column-name><column-value><![CDATA[");
710 sb.append(getMessageCount());
711 sb.append("]]></column-value></column>");
712 sb.append(
713 "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
714 sb.append(getLastPostDate());
715 sb.append("]]></column-value></column>");
716
717 sb.append("</model>");
718
719 return sb.toString();
720 }
721
722 private static ClassLoader _classLoader = MBCategory.class.getClassLoader();
723 private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
724 MBCategory.class
725 };
726 private String _uuid;
727 private String _originalUuid;
728 private long _categoryId;
729 private long _groupId;
730 private long _originalGroupId;
731 private boolean _setOriginalGroupId;
732 private long _companyId;
733 private long _originalCompanyId;
734 private boolean _setOriginalCompanyId;
735 private long _userId;
736 private String _userUuid;
737 private String _userName;
738 private Date _createDate;
739 private Date _modifiedDate;
740 private long _parentCategoryId;
741 private long _originalParentCategoryId;
742 private boolean _setOriginalParentCategoryId;
743 private String _name;
744 private String _description;
745 private String _displayStyle;
746 private int _threadCount;
747 private int _messageCount;
748 private Date _lastPostDate;
749 private transient ExpandoBridge _expandoBridge;
750 private long _columnBitmask;
751 private MBCategory _escapedModelProxy;
752 }