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