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.util.GetterUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.kernel.workflow.WorkflowConstants;
023 import com.liferay.portal.model.impl.BaseModelImpl;
024 import com.liferay.portal.service.ServiceContext;
025 import com.liferay.portal.util.PortalUtil;
026
027 import com.liferay.portlet.expando.model.ExpandoBridge;
028 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
029 import com.liferay.portlet.wiki.model.WikiPage;
030 import com.liferay.portlet.wiki.model.WikiPageModel;
031 import com.liferay.portlet.wiki.model.WikiPageSoap;
032
033 import java.io.Serializable;
034
035 import java.lang.reflect.Proxy;
036
037 import java.sql.Types;
038
039 import java.util.ArrayList;
040 import java.util.Date;
041 import java.util.List;
042
043
060 public class WikiPageModelImpl extends BaseModelImpl<WikiPage>
061 implements WikiPageModel {
062 public static final String TABLE_NAME = "WikiPage";
063 public static final Object[][] TABLE_COLUMNS = {
064 { "uuid_", new Integer(Types.VARCHAR) },
065 { "pageId", new Integer(Types.BIGINT) },
066 { "resourcePrimKey", new Integer(Types.BIGINT) },
067 { "groupId", new Integer(Types.BIGINT) },
068 { "companyId", new Integer(Types.BIGINT) },
069 { "userId", new Integer(Types.BIGINT) },
070 { "userName", new Integer(Types.VARCHAR) },
071 { "createDate", new Integer(Types.TIMESTAMP) },
072 { "modifiedDate", new Integer(Types.TIMESTAMP) },
073 { "nodeId", new Integer(Types.BIGINT) },
074 { "title", new Integer(Types.VARCHAR) },
075 { "version", new Integer(Types.DOUBLE) },
076 { "minorEdit", new Integer(Types.BOOLEAN) },
077 { "content", new Integer(Types.CLOB) },
078 { "summary", new Integer(Types.VARCHAR) },
079 { "format", new Integer(Types.VARCHAR) },
080 { "head", new Integer(Types.BOOLEAN) },
081 { "parentTitle", new Integer(Types.VARCHAR) },
082 { "redirectTitle", new Integer(Types.VARCHAR) },
083 { "status", new Integer(Types.INTEGER) },
084 { "statusByUserId", new Integer(Types.BIGINT) },
085 { "statusByUserName", new Integer(Types.VARCHAR) },
086 { "statusDate", new Integer(Types.TIMESTAMP) }
087 };
088 public static final String TABLE_SQL_CREATE = "create table WikiPage (uuid_ VARCHAR(75) null,pageId LONG not null primary key,resourcePrimKey LONG,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,nodeId LONG,title VARCHAR(255) null,version DOUBLE,minorEdit BOOLEAN,content TEXT null,summary STRING null,format VARCHAR(75) null,head BOOLEAN,parentTitle VARCHAR(255) null,redirectTitle VARCHAR(255) null,status INTEGER,statusByUserId LONG,statusByUserName VARCHAR(75) null,statusDate DATE null)";
089 public static final String TABLE_SQL_DROP = "drop table WikiPage";
090 public static final String ORDER_BY_JPQL = " ORDER BY wikiPage.nodeId ASC, wikiPage.title ASC, wikiPage.version DESC";
091 public static final String ORDER_BY_SQL = " ORDER BY WikiPage.nodeId ASC, WikiPage.title ASC, WikiPage.version DESC";
092 public static final String DATA_SOURCE = "liferayDataSource";
093 public static final String SESSION_FACTORY = "liferaySessionFactory";
094 public static final String TX_MANAGER = "liferayTransactionManager";
095 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
096 "value.object.entity.cache.enabled.com.liferay.portlet.wiki.model.WikiPage"),
097 true);
098 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
099 "value.object.finder.cache.enabled.com.liferay.portlet.wiki.model.WikiPage"),
100 true);
101
102
108 public static WikiPage toModel(WikiPageSoap soapModel) {
109 WikiPage model = new WikiPageImpl();
110
111 model.setUuid(soapModel.getUuid());
112 model.setPageId(soapModel.getPageId());
113 model.setResourcePrimKey(soapModel.getResourcePrimKey());
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.setNodeId(soapModel.getNodeId());
121 model.setTitle(soapModel.getTitle());
122 model.setVersion(soapModel.getVersion());
123 model.setMinorEdit(soapModel.getMinorEdit());
124 model.setContent(soapModel.getContent());
125 model.setSummary(soapModel.getSummary());
126 model.setFormat(soapModel.getFormat());
127 model.setHead(soapModel.getHead());
128 model.setParentTitle(soapModel.getParentTitle());
129 model.setRedirectTitle(soapModel.getRedirectTitle());
130 model.setStatus(soapModel.getStatus());
131 model.setStatusByUserId(soapModel.getStatusByUserId());
132 model.setStatusByUserName(soapModel.getStatusByUserName());
133 model.setStatusDate(soapModel.getStatusDate());
134
135 return model;
136 }
137
138
144 public static List<WikiPage> toModels(WikiPageSoap[] soapModels) {
145 List<WikiPage> models = new ArrayList<WikiPage>(soapModels.length);
146
147 for (WikiPageSoap soapModel : soapModels) {
148 models.add(toModel(soapModel));
149 }
150
151 return models;
152 }
153
154 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
155 "lock.expiration.time.com.liferay.portlet.wiki.model.WikiPage"));
156
157 public WikiPageModelImpl() {
158 }
159
160 public long getPrimaryKey() {
161 return _pageId;
162 }
163
164 public void setPrimaryKey(long pk) {
165 setPageId(pk);
166 }
167
168 public Serializable getPrimaryKeyObj() {
169 return new Long(_pageId);
170 }
171
172 public String getUuid() {
173 if (_uuid == null) {
174 return StringPool.BLANK;
175 }
176 else {
177 return _uuid;
178 }
179 }
180
181 public void setUuid(String uuid) {
182 _uuid = uuid;
183
184 if (_originalUuid == null) {
185 _originalUuid = uuid;
186 }
187 }
188
189 public String getOriginalUuid() {
190 return GetterUtil.getString(_originalUuid);
191 }
192
193 public long getPageId() {
194 return _pageId;
195 }
196
197 public void setPageId(long pageId) {
198 _pageId = pageId;
199 }
200
201 public long getResourcePrimKey() {
202 return _resourcePrimKey;
203 }
204
205 public void setResourcePrimKey(long resourcePrimKey) {
206 _resourcePrimKey = resourcePrimKey;
207
208 if (!_setOriginalResourcePrimKey) {
209 _setOriginalResourcePrimKey = true;
210
211 _originalResourcePrimKey = resourcePrimKey;
212 }
213 }
214
215 public long getOriginalResourcePrimKey() {
216 return _originalResourcePrimKey;
217 }
218
219 public long getGroupId() {
220 return _groupId;
221 }
222
223 public void setGroupId(long groupId) {
224 _groupId = groupId;
225
226 if (!_setOriginalGroupId) {
227 _setOriginalGroupId = true;
228
229 _originalGroupId = groupId;
230 }
231 }
232
233 public long getOriginalGroupId() {
234 return _originalGroupId;
235 }
236
237 public long getCompanyId() {
238 return _companyId;
239 }
240
241 public void setCompanyId(long companyId) {
242 _companyId = companyId;
243 }
244
245 public long getUserId() {
246 return _userId;
247 }
248
249 public void setUserId(long userId) {
250 _userId = userId;
251 }
252
253 public String getUserUuid() throws SystemException {
254 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
255 }
256
257 public void setUserUuid(String userUuid) {
258 _userUuid = userUuid;
259 }
260
261 public String getUserName() {
262 if (_userName == null) {
263 return StringPool.BLANK;
264 }
265 else {
266 return _userName;
267 }
268 }
269
270 public void setUserName(String userName) {
271 _userName = userName;
272 }
273
274 public Date getCreateDate() {
275 return _createDate;
276 }
277
278 public void setCreateDate(Date createDate) {
279 _createDate = createDate;
280 }
281
282 public Date getModifiedDate() {
283 return _modifiedDate;
284 }
285
286 public void setModifiedDate(Date modifiedDate) {
287 _modifiedDate = modifiedDate;
288 }
289
290 public long getNodeId() {
291 return _nodeId;
292 }
293
294 public void setNodeId(long nodeId) {
295 _nodeId = nodeId;
296
297 if (!_setOriginalNodeId) {
298 _setOriginalNodeId = true;
299
300 _originalNodeId = nodeId;
301 }
302 }
303
304 public long getOriginalNodeId() {
305 return _originalNodeId;
306 }
307
308 public String getTitle() {
309 if (_title == null) {
310 return StringPool.BLANK;
311 }
312 else {
313 return _title;
314 }
315 }
316
317 public void setTitle(String title) {
318 _title = title;
319
320 if (_originalTitle == null) {
321 _originalTitle = title;
322 }
323 }
324
325 public String getOriginalTitle() {
326 return GetterUtil.getString(_originalTitle);
327 }
328
329 public double getVersion() {
330 return _version;
331 }
332
333 public void setVersion(double version) {
334 _version = version;
335
336 if (!_setOriginalVersion) {
337 _setOriginalVersion = true;
338
339 _originalVersion = version;
340 }
341 }
342
343 public double getOriginalVersion() {
344 return _originalVersion;
345 }
346
347 public boolean getMinorEdit() {
348 return _minorEdit;
349 }
350
351 public boolean isMinorEdit() {
352 return _minorEdit;
353 }
354
355 public void setMinorEdit(boolean minorEdit) {
356 _minorEdit = minorEdit;
357 }
358
359 public String getContent() {
360 if (_content == null) {
361 return StringPool.BLANK;
362 }
363 else {
364 return _content;
365 }
366 }
367
368 public void setContent(String content) {
369 _content = content;
370 }
371
372 public String getSummary() {
373 if (_summary == null) {
374 return StringPool.BLANK;
375 }
376 else {
377 return _summary;
378 }
379 }
380
381 public void setSummary(String summary) {
382 _summary = summary;
383 }
384
385 public String getFormat() {
386 if (_format == null) {
387 return StringPool.BLANK;
388 }
389 else {
390 return _format;
391 }
392 }
393
394 public void setFormat(String format) {
395 _format = format;
396 }
397
398 public boolean getHead() {
399 return _head;
400 }
401
402 public boolean isHead() {
403 return _head;
404 }
405
406 public void setHead(boolean head) {
407 _head = head;
408 }
409
410 public String getParentTitle() {
411 if (_parentTitle == null) {
412 return StringPool.BLANK;
413 }
414 else {
415 return _parentTitle;
416 }
417 }
418
419 public void setParentTitle(String parentTitle) {
420 _parentTitle = parentTitle;
421 }
422
423 public String getRedirectTitle() {
424 if (_redirectTitle == null) {
425 return StringPool.BLANK;
426 }
427 else {
428 return _redirectTitle;
429 }
430 }
431
432 public void setRedirectTitle(String redirectTitle) {
433 _redirectTitle = redirectTitle;
434 }
435
436 public int getStatus() {
437 return _status;
438 }
439
440 public void setStatus(int status) {
441 _status = status;
442 }
443
444 public long getStatusByUserId() {
445 return _statusByUserId;
446 }
447
448 public void setStatusByUserId(long statusByUserId) {
449 _statusByUserId = statusByUserId;
450 }
451
452 public String getStatusByUserUuid() throws SystemException {
453 return PortalUtil.getUserValue(getStatusByUserId(), "uuid",
454 _statusByUserUuid);
455 }
456
457 public void setStatusByUserUuid(String statusByUserUuid) {
458 _statusByUserUuid = statusByUserUuid;
459 }
460
461 public String getStatusByUserName() {
462 if (_statusByUserName == null) {
463 return StringPool.BLANK;
464 }
465 else {
466 return _statusByUserName;
467 }
468 }
469
470 public void setStatusByUserName(String statusByUserName) {
471 _statusByUserName = statusByUserName;
472 }
473
474 public Date getStatusDate() {
475 return _statusDate;
476 }
477
478 public void setStatusDate(Date statusDate) {
479 _statusDate = statusDate;
480 }
481
482 public boolean isApproved() {
483 if (getStatus() == WorkflowConstants.STATUS_APPROVED) {
484 return true;
485 }
486 else {
487 return false;
488 }
489 }
490
491 public boolean isDraft() {
492 if (getStatus() == WorkflowConstants.STATUS_DRAFT) {
493 return true;
494 }
495 else {
496 return false;
497 }
498 }
499
500 public boolean isExpired() {
501 if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
502 return true;
503 }
504 else {
505 return false;
506 }
507 }
508
509 public boolean isPending() {
510 if (getStatus() == WorkflowConstants.STATUS_PENDING) {
511 return true;
512 }
513 else {
514 return false;
515 }
516 }
517
518 public WikiPage toEscapedModel() {
519 if (isEscapedModel()) {
520 return (WikiPage)this;
521 }
522 else {
523 return (WikiPage)Proxy.newProxyInstance(WikiPage.class.getClassLoader(),
524 new Class[] { WikiPage.class }, new AutoEscapeBeanHandler(this));
525 }
526 }
527
528 public ExpandoBridge getExpandoBridge() {
529 if (_expandoBridge == null) {
530 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
531 WikiPage.class.getName(), getPrimaryKey());
532 }
533
534 return _expandoBridge;
535 }
536
537 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
538 getExpandoBridge().setAttributes(serviceContext);
539 }
540
541 public Object clone() {
542 WikiPageImpl clone = new WikiPageImpl();
543
544 clone.setUuid(getUuid());
545 clone.setPageId(getPageId());
546 clone.setResourcePrimKey(getResourcePrimKey());
547 clone.setGroupId(getGroupId());
548 clone.setCompanyId(getCompanyId());
549 clone.setUserId(getUserId());
550 clone.setUserName(getUserName());
551 clone.setCreateDate(getCreateDate());
552 clone.setModifiedDate(getModifiedDate());
553 clone.setNodeId(getNodeId());
554 clone.setTitle(getTitle());
555 clone.setVersion(getVersion());
556 clone.setMinorEdit(getMinorEdit());
557 clone.setContent(getContent());
558 clone.setSummary(getSummary());
559 clone.setFormat(getFormat());
560 clone.setHead(getHead());
561 clone.setParentTitle(getParentTitle());
562 clone.setRedirectTitle(getRedirectTitle());
563 clone.setStatus(getStatus());
564 clone.setStatusByUserId(getStatusByUserId());
565 clone.setStatusByUserName(getStatusByUserName());
566 clone.setStatusDate(getStatusDate());
567
568 return clone;
569 }
570
571 public int compareTo(WikiPage wikiPage) {
572 int value = 0;
573
574 if (getNodeId() < wikiPage.getNodeId()) {
575 value = -1;
576 }
577 else if (getNodeId() > wikiPage.getNodeId()) {
578 value = 1;
579 }
580 else {
581 value = 0;
582 }
583
584 if (value != 0) {
585 return value;
586 }
587
588 value = getTitle().toLowerCase()
589 .compareTo(wikiPage.getTitle().toLowerCase());
590
591 if (value != 0) {
592 return value;
593 }
594
595 if (getVersion() < wikiPage.getVersion()) {
596 value = -1;
597 }
598 else if (getVersion() > wikiPage.getVersion()) {
599 value = 1;
600 }
601 else {
602 value = 0;
603 }
604
605 value = value * -1;
606
607 if (value != 0) {
608 return value;
609 }
610
611 return 0;
612 }
613
614 public boolean equals(Object obj) {
615 if (obj == null) {
616 return false;
617 }
618
619 WikiPage wikiPage = null;
620
621 try {
622 wikiPage = (WikiPage)obj;
623 }
624 catch (ClassCastException cce) {
625 return false;
626 }
627
628 long pk = wikiPage.getPrimaryKey();
629
630 if (getPrimaryKey() == pk) {
631 return true;
632 }
633 else {
634 return false;
635 }
636 }
637
638 public int hashCode() {
639 return (int)getPrimaryKey();
640 }
641
642 public String toString() {
643 StringBundler sb = new StringBundler(47);
644
645 sb.append("{uuid=");
646 sb.append(getUuid());
647 sb.append(", pageId=");
648 sb.append(getPageId());
649 sb.append(", resourcePrimKey=");
650 sb.append(getResourcePrimKey());
651 sb.append(", groupId=");
652 sb.append(getGroupId());
653 sb.append(", companyId=");
654 sb.append(getCompanyId());
655 sb.append(", userId=");
656 sb.append(getUserId());
657 sb.append(", userName=");
658 sb.append(getUserName());
659 sb.append(", createDate=");
660 sb.append(getCreateDate());
661 sb.append(", modifiedDate=");
662 sb.append(getModifiedDate());
663 sb.append(", nodeId=");
664 sb.append(getNodeId());
665 sb.append(", title=");
666 sb.append(getTitle());
667 sb.append(", version=");
668 sb.append(getVersion());
669 sb.append(", minorEdit=");
670 sb.append(getMinorEdit());
671 sb.append(", content=");
672 sb.append(getContent());
673 sb.append(", summary=");
674 sb.append(getSummary());
675 sb.append(", format=");
676 sb.append(getFormat());
677 sb.append(", head=");
678 sb.append(getHead());
679 sb.append(", parentTitle=");
680 sb.append(getParentTitle());
681 sb.append(", redirectTitle=");
682 sb.append(getRedirectTitle());
683 sb.append(", status=");
684 sb.append(getStatus());
685 sb.append(", statusByUserId=");
686 sb.append(getStatusByUserId());
687 sb.append(", statusByUserName=");
688 sb.append(getStatusByUserName());
689 sb.append(", statusDate=");
690 sb.append(getStatusDate());
691 sb.append("}");
692
693 return sb.toString();
694 }
695
696 public String toXmlString() {
697 StringBundler sb = new StringBundler(73);
698
699 sb.append("<model><model-name>");
700 sb.append("com.liferay.portlet.wiki.model.WikiPage");
701 sb.append("</model-name>");
702
703 sb.append(
704 "<column><column-name>uuid</column-name><column-value><![CDATA[");
705 sb.append(getUuid());
706 sb.append("]]></column-value></column>");
707 sb.append(
708 "<column><column-name>pageId</column-name><column-value><![CDATA[");
709 sb.append(getPageId());
710 sb.append("]]></column-value></column>");
711 sb.append(
712 "<column><column-name>resourcePrimKey</column-name><column-value><![CDATA[");
713 sb.append(getResourcePrimKey());
714 sb.append("]]></column-value></column>");
715 sb.append(
716 "<column><column-name>groupId</column-name><column-value><![CDATA[");
717 sb.append(getGroupId());
718 sb.append("]]></column-value></column>");
719 sb.append(
720 "<column><column-name>companyId</column-name><column-value><![CDATA[");
721 sb.append(getCompanyId());
722 sb.append("]]></column-value></column>");
723 sb.append(
724 "<column><column-name>userId</column-name><column-value><![CDATA[");
725 sb.append(getUserId());
726 sb.append("]]></column-value></column>");
727 sb.append(
728 "<column><column-name>userName</column-name><column-value><![CDATA[");
729 sb.append(getUserName());
730 sb.append("]]></column-value></column>");
731 sb.append(
732 "<column><column-name>createDate</column-name><column-value><![CDATA[");
733 sb.append(getCreateDate());
734 sb.append("]]></column-value></column>");
735 sb.append(
736 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
737 sb.append(getModifiedDate());
738 sb.append("]]></column-value></column>");
739 sb.append(
740 "<column><column-name>nodeId</column-name><column-value><![CDATA[");
741 sb.append(getNodeId());
742 sb.append("]]></column-value></column>");
743 sb.append(
744 "<column><column-name>title</column-name><column-value><![CDATA[");
745 sb.append(getTitle());
746 sb.append("]]></column-value></column>");
747 sb.append(
748 "<column><column-name>version</column-name><column-value><![CDATA[");
749 sb.append(getVersion());
750 sb.append("]]></column-value></column>");
751 sb.append(
752 "<column><column-name>minorEdit</column-name><column-value><![CDATA[");
753 sb.append(getMinorEdit());
754 sb.append("]]></column-value></column>");
755 sb.append(
756 "<column><column-name>content</column-name><column-value><![CDATA[");
757 sb.append(getContent());
758 sb.append("]]></column-value></column>");
759 sb.append(
760 "<column><column-name>summary</column-name><column-value><![CDATA[");
761 sb.append(getSummary());
762 sb.append("]]></column-value></column>");
763 sb.append(
764 "<column><column-name>format</column-name><column-value><![CDATA[");
765 sb.append(getFormat());
766 sb.append("]]></column-value></column>");
767 sb.append(
768 "<column><column-name>head</column-name><column-value><![CDATA[");
769 sb.append(getHead());
770 sb.append("]]></column-value></column>");
771 sb.append(
772 "<column><column-name>parentTitle</column-name><column-value><![CDATA[");
773 sb.append(getParentTitle());
774 sb.append("]]></column-value></column>");
775 sb.append(
776 "<column><column-name>redirectTitle</column-name><column-value><![CDATA[");
777 sb.append(getRedirectTitle());
778 sb.append("]]></column-value></column>");
779 sb.append(
780 "<column><column-name>status</column-name><column-value><![CDATA[");
781 sb.append(getStatus());
782 sb.append("]]></column-value></column>");
783 sb.append(
784 "<column><column-name>statusByUserId</column-name><column-value><![CDATA[");
785 sb.append(getStatusByUserId());
786 sb.append("]]></column-value></column>");
787 sb.append(
788 "<column><column-name>statusByUserName</column-name><column-value><![CDATA[");
789 sb.append(getStatusByUserName());
790 sb.append("]]></column-value></column>");
791 sb.append(
792 "<column><column-name>statusDate</column-name><column-value><![CDATA[");
793 sb.append(getStatusDate());
794 sb.append("]]></column-value></column>");
795
796 sb.append("</model>");
797
798 return sb.toString();
799 }
800
801 private String _uuid;
802 private String _originalUuid;
803 private long _pageId;
804 private long _resourcePrimKey;
805 private long _originalResourcePrimKey;
806 private boolean _setOriginalResourcePrimKey;
807 private long _groupId;
808 private long _originalGroupId;
809 private boolean _setOriginalGroupId;
810 private long _companyId;
811 private long _userId;
812 private String _userUuid;
813 private String _userName;
814 private Date _createDate;
815 private Date _modifiedDate;
816 private long _nodeId;
817 private long _originalNodeId;
818 private boolean _setOriginalNodeId;
819 private String _title;
820 private String _originalTitle;
821 private double _version;
822 private double _originalVersion;
823 private boolean _setOriginalVersion;
824 private boolean _minorEdit;
825 private String _content;
826 private String _summary;
827 private String _format;
828 private boolean _head;
829 private String _parentTitle;
830 private String _redirectTitle;
831 private int _status;
832 private long _statusByUserId;
833 private String _statusByUserUuid;
834 private String _statusByUserName;
835 private Date _statusDate;
836 private transient ExpandoBridge _expandoBridge;
837 }