1
22
23 package com.liferay.portlet.wiki.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
27 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
28 import com.liferay.portal.kernel.dao.orm.Query;
29 import com.liferay.portal.kernel.dao.orm.QueryPos;
30 import com.liferay.portal.kernel.dao.orm.QueryUtil;
31 import com.liferay.portal.kernel.dao.orm.Session;
32 import com.liferay.portal.kernel.util.GetterUtil;
33 import com.liferay.portal.kernel.util.ListUtil;
34 import com.liferay.portal.kernel.util.OrderByComparator;
35 import com.liferay.portal.kernel.util.StringPool;
36 import com.liferay.portal.kernel.util.StringUtil;
37 import com.liferay.portal.kernel.util.Validator;
38 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
39 import com.liferay.portal.model.ModelListener;
40 import com.liferay.portal.service.persistence.BatchSessionUtil;
41 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42
43 import com.liferay.portlet.wiki.NoSuchPageException;
44 import com.liferay.portlet.wiki.model.WikiPage;
45 import com.liferay.portlet.wiki.model.impl.WikiPageImpl;
46 import com.liferay.portlet.wiki.model.impl.WikiPageModelImpl;
47
48 import org.apache.commons.logging.Log;
49 import org.apache.commons.logging.LogFactory;
50
51 import java.util.ArrayList;
52 import java.util.Collections;
53 import java.util.Iterator;
54 import java.util.List;
55
56
62 public class WikiPagePersistenceImpl extends BasePersistenceImpl
63 implements WikiPagePersistence {
64 public WikiPage create(long pageId) {
65 WikiPage wikiPage = new WikiPageImpl();
66
67 wikiPage.setNew(true);
68 wikiPage.setPrimaryKey(pageId);
69
70 String uuid = PortalUUIDUtil.generate();
71
72 wikiPage.setUuid(uuid);
73
74 return wikiPage;
75 }
76
77 public WikiPage remove(long pageId)
78 throws NoSuchPageException, SystemException {
79 Session session = null;
80
81 try {
82 session = openSession();
83
84 WikiPage wikiPage = (WikiPage)session.get(WikiPageImpl.class,
85 new Long(pageId));
86
87 if (wikiPage == null) {
88 if (_log.isWarnEnabled()) {
89 _log.warn("No WikiPage exists with the primary key " +
90 pageId);
91 }
92
93 throw new NoSuchPageException(
94 "No WikiPage exists with the primary key " + pageId);
95 }
96
97 return remove(wikiPage);
98 }
99 catch (NoSuchPageException nsee) {
100 throw nsee;
101 }
102 catch (Exception e) {
103 throw processException(e);
104 }
105 finally {
106 closeSession(session);
107 }
108 }
109
110 public WikiPage remove(WikiPage wikiPage) throws SystemException {
111 if (_listeners.length > 0) {
112 for (ModelListener listener : _listeners) {
113 listener.onBeforeRemove(wikiPage);
114 }
115 }
116
117 wikiPage = removeImpl(wikiPage);
118
119 if (_listeners.length > 0) {
120 for (ModelListener listener : _listeners) {
121 listener.onAfterRemove(wikiPage);
122 }
123 }
124
125 return wikiPage;
126 }
127
128 protected WikiPage removeImpl(WikiPage wikiPage) throws SystemException {
129 Session session = null;
130
131 try {
132 session = openSession();
133
134 if (BatchSessionUtil.isEnabled()) {
135 Object staleObject = session.get(WikiPageImpl.class,
136 wikiPage.getPrimaryKeyObj());
137
138 if (staleObject != null) {
139 session.evict(staleObject);
140 }
141 }
142
143 session.delete(wikiPage);
144
145 session.flush();
146
147 return wikiPage;
148 }
149 catch (Exception e) {
150 throw processException(e);
151 }
152 finally {
153 closeSession(session);
154
155 FinderCacheUtil.clearCache(WikiPage.class.getName());
156 }
157 }
158
159
162 public WikiPage update(WikiPage wikiPage) throws SystemException {
163 if (_log.isWarnEnabled()) {
164 _log.warn(
165 "Using the deprecated update(WikiPage wikiPage) method. Use update(WikiPage wikiPage, boolean merge) instead.");
166 }
167
168 return update(wikiPage, false);
169 }
170
171
184 public WikiPage update(WikiPage wikiPage, boolean merge)
185 throws SystemException {
186 boolean isNew = wikiPage.isNew();
187
188 if (_listeners.length > 0) {
189 for (ModelListener listener : _listeners) {
190 if (isNew) {
191 listener.onBeforeCreate(wikiPage);
192 }
193 else {
194 listener.onBeforeUpdate(wikiPage);
195 }
196 }
197 }
198
199 wikiPage = updateImpl(wikiPage, merge);
200
201 if (_listeners.length > 0) {
202 for (ModelListener listener : _listeners) {
203 if (isNew) {
204 listener.onAfterCreate(wikiPage);
205 }
206 else {
207 listener.onAfterUpdate(wikiPage);
208 }
209 }
210 }
211
212 return wikiPage;
213 }
214
215 public WikiPage updateImpl(
216 com.liferay.portlet.wiki.model.WikiPage wikiPage, boolean merge)
217 throws SystemException {
218 if (Validator.isNull(wikiPage.getUuid())) {
219 String uuid = PortalUUIDUtil.generate();
220
221 wikiPage.setUuid(uuid);
222 }
223
224 Session session = null;
225
226 try {
227 session = openSession();
228
229 BatchSessionUtil.update(session, wikiPage, merge);
230
231 wikiPage.setNew(false);
232
233 return wikiPage;
234 }
235 catch (Exception e) {
236 throw processException(e);
237 }
238 finally {
239 closeSession(session);
240
241 FinderCacheUtil.clearCache(WikiPage.class.getName());
242 }
243 }
244
245 public WikiPage findByPrimaryKey(long pageId)
246 throws NoSuchPageException, SystemException {
247 WikiPage wikiPage = fetchByPrimaryKey(pageId);
248
249 if (wikiPage == null) {
250 if (_log.isWarnEnabled()) {
251 _log.warn("No WikiPage exists with the primary key " + pageId);
252 }
253
254 throw new NoSuchPageException(
255 "No WikiPage exists with the primary key " + pageId);
256 }
257
258 return wikiPage;
259 }
260
261 public WikiPage fetchByPrimaryKey(long pageId) throws SystemException {
262 Session session = null;
263
264 try {
265 session = openSession();
266
267 return (WikiPage)session.get(WikiPageImpl.class, new Long(pageId));
268 }
269 catch (Exception e) {
270 throw processException(e);
271 }
272 finally {
273 closeSession(session);
274 }
275 }
276
277 public List<WikiPage> findByUuid(String uuid) throws SystemException {
278 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
279 String finderClassName = WikiPage.class.getName();
280 String finderMethodName = "findByUuid";
281 String[] finderParams = new String[] { String.class.getName() };
282 Object[] finderArgs = new Object[] { uuid };
283
284 Object result = null;
285
286 if (finderClassNameCacheEnabled) {
287 result = FinderCacheUtil.getResult(finderClassName,
288 finderMethodName, finderParams, finderArgs, this);
289 }
290
291 if (result == null) {
292 Session session = null;
293
294 try {
295 session = openSession();
296
297 StringBuilder query = new StringBuilder();
298
299 query.append(
300 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
301
302 if (uuid == null) {
303 query.append("uuid_ IS NULL");
304 }
305 else {
306 query.append("uuid_ = ?");
307 }
308
309 query.append(" ");
310
311 query.append("ORDER BY ");
312
313 query.append("nodeId ASC, ");
314 query.append("title ASC, ");
315 query.append("version ASC");
316
317 Query q = session.createQuery(query.toString());
318
319 QueryPos qPos = QueryPos.getInstance(q);
320
321 if (uuid != null) {
322 qPos.add(uuid);
323 }
324
325 List<WikiPage> list = q.list();
326
327 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
328 finderClassName, finderMethodName, finderParams,
329 finderArgs, list);
330
331 return list;
332 }
333 catch (Exception e) {
334 throw processException(e);
335 }
336 finally {
337 closeSession(session);
338 }
339 }
340 else {
341 return (List<WikiPage>)result;
342 }
343 }
344
345 public List<WikiPage> findByUuid(String uuid, int start, int end)
346 throws SystemException {
347 return findByUuid(uuid, start, end, null);
348 }
349
350 public List<WikiPage> findByUuid(String uuid, int start, int end,
351 OrderByComparator obc) throws SystemException {
352 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
353 String finderClassName = WikiPage.class.getName();
354 String finderMethodName = "findByUuid";
355 String[] finderParams = new String[] {
356 String.class.getName(),
357
358 "java.lang.Integer", "java.lang.Integer",
359 "com.liferay.portal.kernel.util.OrderByComparator"
360 };
361 Object[] finderArgs = new Object[] {
362 uuid,
363
364 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
365 };
366
367 Object result = null;
368
369 if (finderClassNameCacheEnabled) {
370 result = FinderCacheUtil.getResult(finderClassName,
371 finderMethodName, finderParams, finderArgs, this);
372 }
373
374 if (result == null) {
375 Session session = null;
376
377 try {
378 session = openSession();
379
380 StringBuilder query = new StringBuilder();
381
382 query.append(
383 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
384
385 if (uuid == null) {
386 query.append("uuid_ IS NULL");
387 }
388 else {
389 query.append("uuid_ = ?");
390 }
391
392 query.append(" ");
393
394 if (obc != null) {
395 query.append("ORDER BY ");
396 query.append(obc.getOrderBy());
397 }
398
399 else {
400 query.append("ORDER BY ");
401
402 query.append("nodeId ASC, ");
403 query.append("title ASC, ");
404 query.append("version ASC");
405 }
406
407 Query q = session.createQuery(query.toString());
408
409 QueryPos qPos = QueryPos.getInstance(q);
410
411 if (uuid != null) {
412 qPos.add(uuid);
413 }
414
415 List<WikiPage> list = (List<WikiPage>)QueryUtil.list(q,
416 getDialect(), start, end);
417
418 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
419 finderClassName, finderMethodName, finderParams,
420 finderArgs, list);
421
422 return list;
423 }
424 catch (Exception e) {
425 throw processException(e);
426 }
427 finally {
428 closeSession(session);
429 }
430 }
431 else {
432 return (List<WikiPage>)result;
433 }
434 }
435
436 public WikiPage findByUuid_First(String uuid, OrderByComparator obc)
437 throws NoSuchPageException, SystemException {
438 List<WikiPage> list = findByUuid(uuid, 0, 1, obc);
439
440 if (list.size() == 0) {
441 StringBuilder msg = new StringBuilder();
442
443 msg.append("No WikiPage exists with the key {");
444
445 msg.append("uuid=" + uuid);
446
447 msg.append(StringPool.CLOSE_CURLY_BRACE);
448
449 throw new NoSuchPageException(msg.toString());
450 }
451 else {
452 return list.get(0);
453 }
454 }
455
456 public WikiPage findByUuid_Last(String uuid, OrderByComparator obc)
457 throws NoSuchPageException, SystemException {
458 int count = countByUuid(uuid);
459
460 List<WikiPage> list = findByUuid(uuid, count - 1, count, obc);
461
462 if (list.size() == 0) {
463 StringBuilder msg = new StringBuilder();
464
465 msg.append("No WikiPage exists with the key {");
466
467 msg.append("uuid=" + uuid);
468
469 msg.append(StringPool.CLOSE_CURLY_BRACE);
470
471 throw new NoSuchPageException(msg.toString());
472 }
473 else {
474 return list.get(0);
475 }
476 }
477
478 public WikiPage[] findByUuid_PrevAndNext(long pageId, String uuid,
479 OrderByComparator obc) throws NoSuchPageException, SystemException {
480 WikiPage wikiPage = findByPrimaryKey(pageId);
481
482 int count = countByUuid(uuid);
483
484 Session session = null;
485
486 try {
487 session = openSession();
488
489 StringBuilder query = new StringBuilder();
490
491 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
492
493 if (uuid == null) {
494 query.append("uuid_ IS NULL");
495 }
496 else {
497 query.append("uuid_ = ?");
498 }
499
500 query.append(" ");
501
502 if (obc != null) {
503 query.append("ORDER BY ");
504 query.append(obc.getOrderBy());
505 }
506
507 else {
508 query.append("ORDER BY ");
509
510 query.append("nodeId ASC, ");
511 query.append("title ASC, ");
512 query.append("version ASC");
513 }
514
515 Query q = session.createQuery(query.toString());
516
517 QueryPos qPos = QueryPos.getInstance(q);
518
519 if (uuid != null) {
520 qPos.add(uuid);
521 }
522
523 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
524
525 WikiPage[] array = new WikiPageImpl[3];
526
527 array[0] = (WikiPage)objArray[0];
528 array[1] = (WikiPage)objArray[1];
529 array[2] = (WikiPage)objArray[2];
530
531 return array;
532 }
533 catch (Exception e) {
534 throw processException(e);
535 }
536 finally {
537 closeSession(session);
538 }
539 }
540
541 public List<WikiPage> findByNodeId(long nodeId) throws SystemException {
542 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
543 String finderClassName = WikiPage.class.getName();
544 String finderMethodName = "findByNodeId";
545 String[] finderParams = new String[] { Long.class.getName() };
546 Object[] finderArgs = new Object[] { new Long(nodeId) };
547
548 Object result = null;
549
550 if (finderClassNameCacheEnabled) {
551 result = FinderCacheUtil.getResult(finderClassName,
552 finderMethodName, finderParams, finderArgs, this);
553 }
554
555 if (result == null) {
556 Session session = null;
557
558 try {
559 session = openSession();
560
561 StringBuilder query = new StringBuilder();
562
563 query.append(
564 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
565
566 query.append("nodeId = ?");
567
568 query.append(" ");
569
570 query.append("ORDER BY ");
571
572 query.append("nodeId ASC, ");
573 query.append("title ASC, ");
574 query.append("version ASC");
575
576 Query q = session.createQuery(query.toString());
577
578 QueryPos qPos = QueryPos.getInstance(q);
579
580 qPos.add(nodeId);
581
582 List<WikiPage> list = q.list();
583
584 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
585 finderClassName, finderMethodName, finderParams,
586 finderArgs, list);
587
588 return list;
589 }
590 catch (Exception e) {
591 throw processException(e);
592 }
593 finally {
594 closeSession(session);
595 }
596 }
597 else {
598 return (List<WikiPage>)result;
599 }
600 }
601
602 public List<WikiPage> findByNodeId(long nodeId, int start, int end)
603 throws SystemException {
604 return findByNodeId(nodeId, start, end, null);
605 }
606
607 public List<WikiPage> findByNodeId(long nodeId, int start, int end,
608 OrderByComparator obc) throws SystemException {
609 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
610 String finderClassName = WikiPage.class.getName();
611 String finderMethodName = "findByNodeId";
612 String[] finderParams = new String[] {
613 Long.class.getName(),
614
615 "java.lang.Integer", "java.lang.Integer",
616 "com.liferay.portal.kernel.util.OrderByComparator"
617 };
618 Object[] finderArgs = new Object[] {
619 new Long(nodeId),
620
621 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
622 };
623
624 Object result = null;
625
626 if (finderClassNameCacheEnabled) {
627 result = FinderCacheUtil.getResult(finderClassName,
628 finderMethodName, finderParams, finderArgs, this);
629 }
630
631 if (result == null) {
632 Session session = null;
633
634 try {
635 session = openSession();
636
637 StringBuilder query = new StringBuilder();
638
639 query.append(
640 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
641
642 query.append("nodeId = ?");
643
644 query.append(" ");
645
646 if (obc != null) {
647 query.append("ORDER BY ");
648 query.append(obc.getOrderBy());
649 }
650
651 else {
652 query.append("ORDER BY ");
653
654 query.append("nodeId ASC, ");
655 query.append("title ASC, ");
656 query.append("version ASC");
657 }
658
659 Query q = session.createQuery(query.toString());
660
661 QueryPos qPos = QueryPos.getInstance(q);
662
663 qPos.add(nodeId);
664
665 List<WikiPage> list = (List<WikiPage>)QueryUtil.list(q,
666 getDialect(), start, end);
667
668 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
669 finderClassName, finderMethodName, finderParams,
670 finderArgs, list);
671
672 return list;
673 }
674 catch (Exception e) {
675 throw processException(e);
676 }
677 finally {
678 closeSession(session);
679 }
680 }
681 else {
682 return (List<WikiPage>)result;
683 }
684 }
685
686 public WikiPage findByNodeId_First(long nodeId, OrderByComparator obc)
687 throws NoSuchPageException, SystemException {
688 List<WikiPage> list = findByNodeId(nodeId, 0, 1, obc);
689
690 if (list.size() == 0) {
691 StringBuilder msg = new StringBuilder();
692
693 msg.append("No WikiPage exists with the key {");
694
695 msg.append("nodeId=" + nodeId);
696
697 msg.append(StringPool.CLOSE_CURLY_BRACE);
698
699 throw new NoSuchPageException(msg.toString());
700 }
701 else {
702 return list.get(0);
703 }
704 }
705
706 public WikiPage findByNodeId_Last(long nodeId, OrderByComparator obc)
707 throws NoSuchPageException, SystemException {
708 int count = countByNodeId(nodeId);
709
710 List<WikiPage> list = findByNodeId(nodeId, count - 1, count, obc);
711
712 if (list.size() == 0) {
713 StringBuilder msg = new StringBuilder();
714
715 msg.append("No WikiPage exists with the key {");
716
717 msg.append("nodeId=" + nodeId);
718
719 msg.append(StringPool.CLOSE_CURLY_BRACE);
720
721 throw new NoSuchPageException(msg.toString());
722 }
723 else {
724 return list.get(0);
725 }
726 }
727
728 public WikiPage[] findByNodeId_PrevAndNext(long pageId, long nodeId,
729 OrderByComparator obc) throws NoSuchPageException, SystemException {
730 WikiPage wikiPage = findByPrimaryKey(pageId);
731
732 int count = countByNodeId(nodeId);
733
734 Session session = null;
735
736 try {
737 session = openSession();
738
739 StringBuilder query = new StringBuilder();
740
741 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
742
743 query.append("nodeId = ?");
744
745 query.append(" ");
746
747 if (obc != null) {
748 query.append("ORDER BY ");
749 query.append(obc.getOrderBy());
750 }
751
752 else {
753 query.append("ORDER BY ");
754
755 query.append("nodeId ASC, ");
756 query.append("title ASC, ");
757 query.append("version ASC");
758 }
759
760 Query q = session.createQuery(query.toString());
761
762 QueryPos qPos = QueryPos.getInstance(q);
763
764 qPos.add(nodeId);
765
766 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
767
768 WikiPage[] array = new WikiPageImpl[3];
769
770 array[0] = (WikiPage)objArray[0];
771 array[1] = (WikiPage)objArray[1];
772 array[2] = (WikiPage)objArray[2];
773
774 return array;
775 }
776 catch (Exception e) {
777 throw processException(e);
778 }
779 finally {
780 closeSession(session);
781 }
782 }
783
784 public List<WikiPage> findByFormat(String format) throws SystemException {
785 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
786 String finderClassName = WikiPage.class.getName();
787 String finderMethodName = "findByFormat";
788 String[] finderParams = new String[] { String.class.getName() };
789 Object[] finderArgs = new Object[] { format };
790
791 Object result = null;
792
793 if (finderClassNameCacheEnabled) {
794 result = FinderCacheUtil.getResult(finderClassName,
795 finderMethodName, finderParams, finderArgs, this);
796 }
797
798 if (result == null) {
799 Session session = null;
800
801 try {
802 session = openSession();
803
804 StringBuilder query = new StringBuilder();
805
806 query.append(
807 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
808
809 if (format == null) {
810 query.append("format IS NULL");
811 }
812 else {
813 query.append("format = ?");
814 }
815
816 query.append(" ");
817
818 query.append("ORDER BY ");
819
820 query.append("nodeId ASC, ");
821 query.append("title ASC, ");
822 query.append("version ASC");
823
824 Query q = session.createQuery(query.toString());
825
826 QueryPos qPos = QueryPos.getInstance(q);
827
828 if (format != null) {
829 qPos.add(format);
830 }
831
832 List<WikiPage> list = q.list();
833
834 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
835 finderClassName, finderMethodName, finderParams,
836 finderArgs, list);
837
838 return list;
839 }
840 catch (Exception e) {
841 throw processException(e);
842 }
843 finally {
844 closeSession(session);
845 }
846 }
847 else {
848 return (List<WikiPage>)result;
849 }
850 }
851
852 public List<WikiPage> findByFormat(String format, int start, int end)
853 throws SystemException {
854 return findByFormat(format, start, end, null);
855 }
856
857 public List<WikiPage> findByFormat(String format, int start, int end,
858 OrderByComparator obc) throws SystemException {
859 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
860 String finderClassName = WikiPage.class.getName();
861 String finderMethodName = "findByFormat";
862 String[] finderParams = new String[] {
863 String.class.getName(),
864
865 "java.lang.Integer", "java.lang.Integer",
866 "com.liferay.portal.kernel.util.OrderByComparator"
867 };
868 Object[] finderArgs = new Object[] {
869 format,
870
871 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
872 };
873
874 Object result = null;
875
876 if (finderClassNameCacheEnabled) {
877 result = FinderCacheUtil.getResult(finderClassName,
878 finderMethodName, finderParams, finderArgs, this);
879 }
880
881 if (result == null) {
882 Session session = null;
883
884 try {
885 session = openSession();
886
887 StringBuilder query = new StringBuilder();
888
889 query.append(
890 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
891
892 if (format == null) {
893 query.append("format IS NULL");
894 }
895 else {
896 query.append("format = ?");
897 }
898
899 query.append(" ");
900
901 if (obc != null) {
902 query.append("ORDER BY ");
903 query.append(obc.getOrderBy());
904 }
905
906 else {
907 query.append("ORDER BY ");
908
909 query.append("nodeId ASC, ");
910 query.append("title ASC, ");
911 query.append("version ASC");
912 }
913
914 Query q = session.createQuery(query.toString());
915
916 QueryPos qPos = QueryPos.getInstance(q);
917
918 if (format != null) {
919 qPos.add(format);
920 }
921
922 List<WikiPage> list = (List<WikiPage>)QueryUtil.list(q,
923 getDialect(), start, end);
924
925 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
926 finderClassName, finderMethodName, finderParams,
927 finderArgs, list);
928
929 return list;
930 }
931 catch (Exception e) {
932 throw processException(e);
933 }
934 finally {
935 closeSession(session);
936 }
937 }
938 else {
939 return (List<WikiPage>)result;
940 }
941 }
942
943 public WikiPage findByFormat_First(String format, OrderByComparator obc)
944 throws NoSuchPageException, SystemException {
945 List<WikiPage> list = findByFormat(format, 0, 1, obc);
946
947 if (list.size() == 0) {
948 StringBuilder msg = new StringBuilder();
949
950 msg.append("No WikiPage exists with the key {");
951
952 msg.append("format=" + format);
953
954 msg.append(StringPool.CLOSE_CURLY_BRACE);
955
956 throw new NoSuchPageException(msg.toString());
957 }
958 else {
959 return list.get(0);
960 }
961 }
962
963 public WikiPage findByFormat_Last(String format, OrderByComparator obc)
964 throws NoSuchPageException, SystemException {
965 int count = countByFormat(format);
966
967 List<WikiPage> list = findByFormat(format, count - 1, count, obc);
968
969 if (list.size() == 0) {
970 StringBuilder msg = new StringBuilder();
971
972 msg.append("No WikiPage exists with the key {");
973
974 msg.append("format=" + format);
975
976 msg.append(StringPool.CLOSE_CURLY_BRACE);
977
978 throw new NoSuchPageException(msg.toString());
979 }
980 else {
981 return list.get(0);
982 }
983 }
984
985 public WikiPage[] findByFormat_PrevAndNext(long pageId, String format,
986 OrderByComparator obc) throws NoSuchPageException, SystemException {
987 WikiPage wikiPage = findByPrimaryKey(pageId);
988
989 int count = countByFormat(format);
990
991 Session session = null;
992
993 try {
994 session = openSession();
995
996 StringBuilder query = new StringBuilder();
997
998 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
999
1000 if (format == null) {
1001 query.append("format IS NULL");
1002 }
1003 else {
1004 query.append("format = ?");
1005 }
1006
1007 query.append(" ");
1008
1009 if (obc != null) {
1010 query.append("ORDER BY ");
1011 query.append(obc.getOrderBy());
1012 }
1013
1014 else {
1015 query.append("ORDER BY ");
1016
1017 query.append("nodeId ASC, ");
1018 query.append("title ASC, ");
1019 query.append("version ASC");
1020 }
1021
1022 Query q = session.createQuery(query.toString());
1023
1024 QueryPos qPos = QueryPos.getInstance(q);
1025
1026 if (format != null) {
1027 qPos.add(format);
1028 }
1029
1030 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1031
1032 WikiPage[] array = new WikiPageImpl[3];
1033
1034 array[0] = (WikiPage)objArray[0];
1035 array[1] = (WikiPage)objArray[1];
1036 array[2] = (WikiPage)objArray[2];
1037
1038 return array;
1039 }
1040 catch (Exception e) {
1041 throw processException(e);
1042 }
1043 finally {
1044 closeSession(session);
1045 }
1046 }
1047
1048 public List<WikiPage> findByN_T(long nodeId, String title)
1049 throws SystemException {
1050 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1051 String finderClassName = WikiPage.class.getName();
1052 String finderMethodName = "findByN_T";
1053 String[] finderParams = new String[] {
1054 Long.class.getName(), String.class.getName()
1055 };
1056 Object[] finderArgs = new Object[] { new Long(nodeId), title };
1057
1058 Object result = null;
1059
1060 if (finderClassNameCacheEnabled) {
1061 result = FinderCacheUtil.getResult(finderClassName,
1062 finderMethodName, finderParams, finderArgs, this);
1063 }
1064
1065 if (result == null) {
1066 Session session = null;
1067
1068 try {
1069 session = openSession();
1070
1071 StringBuilder query = new StringBuilder();
1072
1073 query.append(
1074 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1075
1076 query.append("nodeId = ?");
1077
1078 query.append(" AND ");
1079
1080 if (title == null) {
1081 query.append("title IS NULL");
1082 }
1083 else {
1084 query.append("title = ?");
1085 }
1086
1087 query.append(" ");
1088
1089 query.append("ORDER BY ");
1090
1091 query.append("nodeId ASC, ");
1092 query.append("title ASC, ");
1093 query.append("version ASC");
1094
1095 Query q = session.createQuery(query.toString());
1096
1097 QueryPos qPos = QueryPos.getInstance(q);
1098
1099 qPos.add(nodeId);
1100
1101 if (title != null) {
1102 qPos.add(title);
1103 }
1104
1105 List<WikiPage> list = q.list();
1106
1107 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1108 finderClassName, finderMethodName, finderParams,
1109 finderArgs, list);
1110
1111 return list;
1112 }
1113 catch (Exception e) {
1114 throw processException(e);
1115 }
1116 finally {
1117 closeSession(session);
1118 }
1119 }
1120 else {
1121 return (List<WikiPage>)result;
1122 }
1123 }
1124
1125 public List<WikiPage> findByN_T(long nodeId, String title, int start,
1126 int end) throws SystemException {
1127 return findByN_T(nodeId, title, start, end, null);
1128 }
1129
1130 public List<WikiPage> findByN_T(long nodeId, String title, int start,
1131 int end, OrderByComparator obc) throws SystemException {
1132 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1133 String finderClassName = WikiPage.class.getName();
1134 String finderMethodName = "findByN_T";
1135 String[] finderParams = new String[] {
1136 Long.class.getName(), String.class.getName(),
1137
1138 "java.lang.Integer", "java.lang.Integer",
1139 "com.liferay.portal.kernel.util.OrderByComparator"
1140 };
1141 Object[] finderArgs = new Object[] {
1142 new Long(nodeId),
1143
1144 title,
1145
1146 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1147 };
1148
1149 Object result = null;
1150
1151 if (finderClassNameCacheEnabled) {
1152 result = FinderCacheUtil.getResult(finderClassName,
1153 finderMethodName, finderParams, finderArgs, this);
1154 }
1155
1156 if (result == null) {
1157 Session session = null;
1158
1159 try {
1160 session = openSession();
1161
1162 StringBuilder query = new StringBuilder();
1163
1164 query.append(
1165 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1166
1167 query.append("nodeId = ?");
1168
1169 query.append(" AND ");
1170
1171 if (title == null) {
1172 query.append("title IS NULL");
1173 }
1174 else {
1175 query.append("title = ?");
1176 }
1177
1178 query.append(" ");
1179
1180 if (obc != null) {
1181 query.append("ORDER BY ");
1182 query.append(obc.getOrderBy());
1183 }
1184
1185 else {
1186 query.append("ORDER BY ");
1187
1188 query.append("nodeId ASC, ");
1189 query.append("title ASC, ");
1190 query.append("version ASC");
1191 }
1192
1193 Query q = session.createQuery(query.toString());
1194
1195 QueryPos qPos = QueryPos.getInstance(q);
1196
1197 qPos.add(nodeId);
1198
1199 if (title != null) {
1200 qPos.add(title);
1201 }
1202
1203 List<WikiPage> list = (List<WikiPage>)QueryUtil.list(q,
1204 getDialect(), start, end);
1205
1206 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1207 finderClassName, finderMethodName, finderParams,
1208 finderArgs, list);
1209
1210 return list;
1211 }
1212 catch (Exception e) {
1213 throw processException(e);
1214 }
1215 finally {
1216 closeSession(session);
1217 }
1218 }
1219 else {
1220 return (List<WikiPage>)result;
1221 }
1222 }
1223
1224 public WikiPage findByN_T_First(long nodeId, String title,
1225 OrderByComparator obc) throws NoSuchPageException, SystemException {
1226 List<WikiPage> list = findByN_T(nodeId, title, 0, 1, obc);
1227
1228 if (list.size() == 0) {
1229 StringBuilder msg = new StringBuilder();
1230
1231 msg.append("No WikiPage exists with the key {");
1232
1233 msg.append("nodeId=" + nodeId);
1234
1235 msg.append(", ");
1236 msg.append("title=" + title);
1237
1238 msg.append(StringPool.CLOSE_CURLY_BRACE);
1239
1240 throw new NoSuchPageException(msg.toString());
1241 }
1242 else {
1243 return list.get(0);
1244 }
1245 }
1246
1247 public WikiPage findByN_T_Last(long nodeId, String title,
1248 OrderByComparator obc) throws NoSuchPageException, SystemException {
1249 int count = countByN_T(nodeId, title);
1250
1251 List<WikiPage> list = findByN_T(nodeId, title, count - 1, count, obc);
1252
1253 if (list.size() == 0) {
1254 StringBuilder msg = new StringBuilder();
1255
1256 msg.append("No WikiPage exists with the key {");
1257
1258 msg.append("nodeId=" + nodeId);
1259
1260 msg.append(", ");
1261 msg.append("title=" + title);
1262
1263 msg.append(StringPool.CLOSE_CURLY_BRACE);
1264
1265 throw new NoSuchPageException(msg.toString());
1266 }
1267 else {
1268 return list.get(0);
1269 }
1270 }
1271
1272 public WikiPage[] findByN_T_PrevAndNext(long pageId, long nodeId,
1273 String title, OrderByComparator obc)
1274 throws NoSuchPageException, SystemException {
1275 WikiPage wikiPage = findByPrimaryKey(pageId);
1276
1277 int count = countByN_T(nodeId, title);
1278
1279 Session session = null;
1280
1281 try {
1282 session = openSession();
1283
1284 StringBuilder query = new StringBuilder();
1285
1286 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1287
1288 query.append("nodeId = ?");
1289
1290 query.append(" AND ");
1291
1292 if (title == null) {
1293 query.append("title IS NULL");
1294 }
1295 else {
1296 query.append("title = ?");
1297 }
1298
1299 query.append(" ");
1300
1301 if (obc != null) {
1302 query.append("ORDER BY ");
1303 query.append(obc.getOrderBy());
1304 }
1305
1306 else {
1307 query.append("ORDER BY ");
1308
1309 query.append("nodeId ASC, ");
1310 query.append("title ASC, ");
1311 query.append("version ASC");
1312 }
1313
1314 Query q = session.createQuery(query.toString());
1315
1316 QueryPos qPos = QueryPos.getInstance(q);
1317
1318 qPos.add(nodeId);
1319
1320 if (title != null) {
1321 qPos.add(title);
1322 }
1323
1324 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1325
1326 WikiPage[] array = new WikiPageImpl[3];
1327
1328 array[0] = (WikiPage)objArray[0];
1329 array[1] = (WikiPage)objArray[1];
1330 array[2] = (WikiPage)objArray[2];
1331
1332 return array;
1333 }
1334 catch (Exception e) {
1335 throw processException(e);
1336 }
1337 finally {
1338 closeSession(session);
1339 }
1340 }
1341
1342 public List<WikiPage> findByN_H(long nodeId, boolean head)
1343 throws SystemException {
1344 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1345 String finderClassName = WikiPage.class.getName();
1346 String finderMethodName = "findByN_H";
1347 String[] finderParams = new String[] {
1348 Long.class.getName(), Boolean.class.getName()
1349 };
1350 Object[] finderArgs = new Object[] {
1351 new Long(nodeId), Boolean.valueOf(head)
1352 };
1353
1354 Object result = null;
1355
1356 if (finderClassNameCacheEnabled) {
1357 result = FinderCacheUtil.getResult(finderClassName,
1358 finderMethodName, finderParams, finderArgs, this);
1359 }
1360
1361 if (result == null) {
1362 Session session = null;
1363
1364 try {
1365 session = openSession();
1366
1367 StringBuilder query = new StringBuilder();
1368
1369 query.append(
1370 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1371
1372 query.append("nodeId = ?");
1373
1374 query.append(" AND ");
1375
1376 query.append("head = ?");
1377
1378 query.append(" ");
1379
1380 query.append("ORDER BY ");
1381
1382 query.append("nodeId ASC, ");
1383 query.append("title ASC, ");
1384 query.append("version ASC");
1385
1386 Query q = session.createQuery(query.toString());
1387
1388 QueryPos qPos = QueryPos.getInstance(q);
1389
1390 qPos.add(nodeId);
1391
1392 qPos.add(head);
1393
1394 List<WikiPage> list = q.list();
1395
1396 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1397 finderClassName, finderMethodName, finderParams,
1398 finderArgs, list);
1399
1400 return list;
1401 }
1402 catch (Exception e) {
1403 throw processException(e);
1404 }
1405 finally {
1406 closeSession(session);
1407 }
1408 }
1409 else {
1410 return (List<WikiPage>)result;
1411 }
1412 }
1413
1414 public List<WikiPage> findByN_H(long nodeId, boolean head, int start,
1415 int end) throws SystemException {
1416 return findByN_H(nodeId, head, start, end, null);
1417 }
1418
1419 public List<WikiPage> findByN_H(long nodeId, boolean head, int start,
1420 int end, OrderByComparator obc) throws SystemException {
1421 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1422 String finderClassName = WikiPage.class.getName();
1423 String finderMethodName = "findByN_H";
1424 String[] finderParams = new String[] {
1425 Long.class.getName(), Boolean.class.getName(),
1426
1427 "java.lang.Integer", "java.lang.Integer",
1428 "com.liferay.portal.kernel.util.OrderByComparator"
1429 };
1430 Object[] finderArgs = new Object[] {
1431 new Long(nodeId), Boolean.valueOf(head),
1432
1433 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1434 };
1435
1436 Object result = null;
1437
1438 if (finderClassNameCacheEnabled) {
1439 result = FinderCacheUtil.getResult(finderClassName,
1440 finderMethodName, finderParams, finderArgs, this);
1441 }
1442
1443 if (result == null) {
1444 Session session = null;
1445
1446 try {
1447 session = openSession();
1448
1449 StringBuilder query = new StringBuilder();
1450
1451 query.append(
1452 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1453
1454 query.append("nodeId = ?");
1455
1456 query.append(" AND ");
1457
1458 query.append("head = ?");
1459
1460 query.append(" ");
1461
1462 if (obc != null) {
1463 query.append("ORDER BY ");
1464 query.append(obc.getOrderBy());
1465 }
1466
1467 else {
1468 query.append("ORDER BY ");
1469
1470 query.append("nodeId ASC, ");
1471 query.append("title ASC, ");
1472 query.append("version ASC");
1473 }
1474
1475 Query q = session.createQuery(query.toString());
1476
1477 QueryPos qPos = QueryPos.getInstance(q);
1478
1479 qPos.add(nodeId);
1480
1481 qPos.add(head);
1482
1483 List<WikiPage> list = (List<WikiPage>)QueryUtil.list(q,
1484 getDialect(), start, end);
1485
1486 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1487 finderClassName, finderMethodName, finderParams,
1488 finderArgs, list);
1489
1490 return list;
1491 }
1492 catch (Exception e) {
1493 throw processException(e);
1494 }
1495 finally {
1496 closeSession(session);
1497 }
1498 }
1499 else {
1500 return (List<WikiPage>)result;
1501 }
1502 }
1503
1504 public WikiPage findByN_H_First(long nodeId, boolean head,
1505 OrderByComparator obc) throws NoSuchPageException, SystemException {
1506 List<WikiPage> list = findByN_H(nodeId, head, 0, 1, obc);
1507
1508 if (list.size() == 0) {
1509 StringBuilder msg = new StringBuilder();
1510
1511 msg.append("No WikiPage exists with the key {");
1512
1513 msg.append("nodeId=" + nodeId);
1514
1515 msg.append(", ");
1516 msg.append("head=" + head);
1517
1518 msg.append(StringPool.CLOSE_CURLY_BRACE);
1519
1520 throw new NoSuchPageException(msg.toString());
1521 }
1522 else {
1523 return list.get(0);
1524 }
1525 }
1526
1527 public WikiPage findByN_H_Last(long nodeId, boolean head,
1528 OrderByComparator obc) throws NoSuchPageException, SystemException {
1529 int count = countByN_H(nodeId, head);
1530
1531 List<WikiPage> list = findByN_H(nodeId, head, count - 1, count, obc);
1532
1533 if (list.size() == 0) {
1534 StringBuilder msg = new StringBuilder();
1535
1536 msg.append("No WikiPage exists with the key {");
1537
1538 msg.append("nodeId=" + nodeId);
1539
1540 msg.append(", ");
1541 msg.append("head=" + head);
1542
1543 msg.append(StringPool.CLOSE_CURLY_BRACE);
1544
1545 throw new NoSuchPageException(msg.toString());
1546 }
1547 else {
1548 return list.get(0);
1549 }
1550 }
1551
1552 public WikiPage[] findByN_H_PrevAndNext(long pageId, long nodeId,
1553 boolean head, OrderByComparator obc)
1554 throws NoSuchPageException, SystemException {
1555 WikiPage wikiPage = findByPrimaryKey(pageId);
1556
1557 int count = countByN_H(nodeId, head);
1558
1559 Session session = null;
1560
1561 try {
1562 session = openSession();
1563
1564 StringBuilder query = new StringBuilder();
1565
1566 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1567
1568 query.append("nodeId = ?");
1569
1570 query.append(" AND ");
1571
1572 query.append("head = ?");
1573
1574 query.append(" ");
1575
1576 if (obc != null) {
1577 query.append("ORDER BY ");
1578 query.append(obc.getOrderBy());
1579 }
1580
1581 else {
1582 query.append("ORDER BY ");
1583
1584 query.append("nodeId ASC, ");
1585 query.append("title ASC, ");
1586 query.append("version ASC");
1587 }
1588
1589 Query q = session.createQuery(query.toString());
1590
1591 QueryPos qPos = QueryPos.getInstance(q);
1592
1593 qPos.add(nodeId);
1594
1595 qPos.add(head);
1596
1597 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1598
1599 WikiPage[] array = new WikiPageImpl[3];
1600
1601 array[0] = (WikiPage)objArray[0];
1602 array[1] = (WikiPage)objArray[1];
1603 array[2] = (WikiPage)objArray[2];
1604
1605 return array;
1606 }
1607 catch (Exception e) {
1608 throw processException(e);
1609 }
1610 finally {
1611 closeSession(session);
1612 }
1613 }
1614
1615 public List<WikiPage> findByN_P(long nodeId, String parentTitle)
1616 throws SystemException {
1617 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1618 String finderClassName = WikiPage.class.getName();
1619 String finderMethodName = "findByN_P";
1620 String[] finderParams = new String[] {
1621 Long.class.getName(), String.class.getName()
1622 };
1623 Object[] finderArgs = new Object[] { new Long(nodeId), parentTitle };
1624
1625 Object result = null;
1626
1627 if (finderClassNameCacheEnabled) {
1628 result = FinderCacheUtil.getResult(finderClassName,
1629 finderMethodName, finderParams, finderArgs, this);
1630 }
1631
1632 if (result == null) {
1633 Session session = null;
1634
1635 try {
1636 session = openSession();
1637
1638 StringBuilder query = new StringBuilder();
1639
1640 query.append(
1641 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1642
1643 query.append("nodeId = ?");
1644
1645 query.append(" AND ");
1646
1647 if (parentTitle == null) {
1648 query.append("parentTitle IS NULL");
1649 }
1650 else {
1651 query.append("parentTitle = ?");
1652 }
1653
1654 query.append(" ");
1655
1656 query.append("ORDER BY ");
1657
1658 query.append("nodeId ASC, ");
1659 query.append("title ASC, ");
1660 query.append("version ASC");
1661
1662 Query q = session.createQuery(query.toString());
1663
1664 QueryPos qPos = QueryPos.getInstance(q);
1665
1666 qPos.add(nodeId);
1667
1668 if (parentTitle != null) {
1669 qPos.add(parentTitle);
1670 }
1671
1672 List<WikiPage> list = q.list();
1673
1674 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1675 finderClassName, finderMethodName, finderParams,
1676 finderArgs, list);
1677
1678 return list;
1679 }
1680 catch (Exception e) {
1681 throw processException(e);
1682 }
1683 finally {
1684 closeSession(session);
1685 }
1686 }
1687 else {
1688 return (List<WikiPage>)result;
1689 }
1690 }
1691
1692 public List<WikiPage> findByN_P(long nodeId, String parentTitle, int start,
1693 int end) throws SystemException {
1694 return findByN_P(nodeId, parentTitle, start, end, null);
1695 }
1696
1697 public List<WikiPage> findByN_P(long nodeId, String parentTitle, int start,
1698 int end, OrderByComparator obc) throws SystemException {
1699 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1700 String finderClassName = WikiPage.class.getName();
1701 String finderMethodName = "findByN_P";
1702 String[] finderParams = new String[] {
1703 Long.class.getName(), String.class.getName(),
1704
1705 "java.lang.Integer", "java.lang.Integer",
1706 "com.liferay.portal.kernel.util.OrderByComparator"
1707 };
1708 Object[] finderArgs = new Object[] {
1709 new Long(nodeId),
1710
1711 parentTitle,
1712
1713 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1714 };
1715
1716 Object result = null;
1717
1718 if (finderClassNameCacheEnabled) {
1719 result = FinderCacheUtil.getResult(finderClassName,
1720 finderMethodName, finderParams, finderArgs, this);
1721 }
1722
1723 if (result == null) {
1724 Session session = null;
1725
1726 try {
1727 session = openSession();
1728
1729 StringBuilder query = new StringBuilder();
1730
1731 query.append(
1732 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1733
1734 query.append("nodeId = ?");
1735
1736 query.append(" AND ");
1737
1738 if (parentTitle == null) {
1739 query.append("parentTitle IS NULL");
1740 }
1741 else {
1742 query.append("parentTitle = ?");
1743 }
1744
1745 query.append(" ");
1746
1747 if (obc != null) {
1748 query.append("ORDER BY ");
1749 query.append(obc.getOrderBy());
1750 }
1751
1752 else {
1753 query.append("ORDER BY ");
1754
1755 query.append("nodeId ASC, ");
1756 query.append("title ASC, ");
1757 query.append("version ASC");
1758 }
1759
1760 Query q = session.createQuery(query.toString());
1761
1762 QueryPos qPos = QueryPos.getInstance(q);
1763
1764 qPos.add(nodeId);
1765
1766 if (parentTitle != null) {
1767 qPos.add(parentTitle);
1768 }
1769
1770 List<WikiPage> list = (List<WikiPage>)QueryUtil.list(q,
1771 getDialect(), start, end);
1772
1773 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1774 finderClassName, finderMethodName, finderParams,
1775 finderArgs, list);
1776
1777 return list;
1778 }
1779 catch (Exception e) {
1780 throw processException(e);
1781 }
1782 finally {
1783 closeSession(session);
1784 }
1785 }
1786 else {
1787 return (List<WikiPage>)result;
1788 }
1789 }
1790
1791 public WikiPage findByN_P_First(long nodeId, String parentTitle,
1792 OrderByComparator obc) throws NoSuchPageException, SystemException {
1793 List<WikiPage> list = findByN_P(nodeId, parentTitle, 0, 1, obc);
1794
1795 if (list.size() == 0) {
1796 StringBuilder msg = new StringBuilder();
1797
1798 msg.append("No WikiPage exists with the key {");
1799
1800 msg.append("nodeId=" + nodeId);
1801
1802 msg.append(", ");
1803 msg.append("parentTitle=" + parentTitle);
1804
1805 msg.append(StringPool.CLOSE_CURLY_BRACE);
1806
1807 throw new NoSuchPageException(msg.toString());
1808 }
1809 else {
1810 return list.get(0);
1811 }
1812 }
1813
1814 public WikiPage findByN_P_Last(long nodeId, String parentTitle,
1815 OrderByComparator obc) throws NoSuchPageException, SystemException {
1816 int count = countByN_P(nodeId, parentTitle);
1817
1818 List<WikiPage> list = findByN_P(nodeId, parentTitle, count - 1, count,
1819 obc);
1820
1821 if (list.size() == 0) {
1822 StringBuilder msg = new StringBuilder();
1823
1824 msg.append("No WikiPage exists with the key {");
1825
1826 msg.append("nodeId=" + nodeId);
1827
1828 msg.append(", ");
1829 msg.append("parentTitle=" + parentTitle);
1830
1831 msg.append(StringPool.CLOSE_CURLY_BRACE);
1832
1833 throw new NoSuchPageException(msg.toString());
1834 }
1835 else {
1836 return list.get(0);
1837 }
1838 }
1839
1840 public WikiPage[] findByN_P_PrevAndNext(long pageId, long nodeId,
1841 String parentTitle, OrderByComparator obc)
1842 throws NoSuchPageException, SystemException {
1843 WikiPage wikiPage = findByPrimaryKey(pageId);
1844
1845 int count = countByN_P(nodeId, parentTitle);
1846
1847 Session session = null;
1848
1849 try {
1850 session = openSession();
1851
1852 StringBuilder query = new StringBuilder();
1853
1854 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1855
1856 query.append("nodeId = ?");
1857
1858 query.append(" AND ");
1859
1860 if (parentTitle == null) {
1861 query.append("parentTitle IS NULL");
1862 }
1863 else {
1864 query.append("parentTitle = ?");
1865 }
1866
1867 query.append(" ");
1868
1869 if (obc != null) {
1870 query.append("ORDER BY ");
1871 query.append(obc.getOrderBy());
1872 }
1873
1874 else {
1875 query.append("ORDER BY ");
1876
1877 query.append("nodeId ASC, ");
1878 query.append("title ASC, ");
1879 query.append("version ASC");
1880 }
1881
1882 Query q = session.createQuery(query.toString());
1883
1884 QueryPos qPos = QueryPos.getInstance(q);
1885
1886 qPos.add(nodeId);
1887
1888 if (parentTitle != null) {
1889 qPos.add(parentTitle);
1890 }
1891
1892 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1893
1894 WikiPage[] array = new WikiPageImpl[3];
1895
1896 array[0] = (WikiPage)objArray[0];
1897 array[1] = (WikiPage)objArray[1];
1898 array[2] = (WikiPage)objArray[2];
1899
1900 return array;
1901 }
1902 catch (Exception e) {
1903 throw processException(e);
1904 }
1905 finally {
1906 closeSession(session);
1907 }
1908 }
1909
1910 public List<WikiPage> findByN_R(long nodeId, String redirectTitle)
1911 throws SystemException {
1912 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1913 String finderClassName = WikiPage.class.getName();
1914 String finderMethodName = "findByN_R";
1915 String[] finderParams = new String[] {
1916 Long.class.getName(), String.class.getName()
1917 };
1918 Object[] finderArgs = new Object[] { new Long(nodeId), redirectTitle };
1919
1920 Object result = null;
1921
1922 if (finderClassNameCacheEnabled) {
1923 result = FinderCacheUtil.getResult(finderClassName,
1924 finderMethodName, finderParams, finderArgs, this);
1925 }
1926
1927 if (result == null) {
1928 Session session = null;
1929
1930 try {
1931 session = openSession();
1932
1933 StringBuilder query = new StringBuilder();
1934
1935 query.append(
1936 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
1937
1938 query.append("nodeId = ?");
1939
1940 query.append(" AND ");
1941
1942 if (redirectTitle == null) {
1943 query.append("redirectTitle IS NULL");
1944 }
1945 else {
1946 query.append("redirectTitle = ?");
1947 }
1948
1949 query.append(" ");
1950
1951 query.append("ORDER BY ");
1952
1953 query.append("nodeId ASC, ");
1954 query.append("title ASC, ");
1955 query.append("version ASC");
1956
1957 Query q = session.createQuery(query.toString());
1958
1959 QueryPos qPos = QueryPos.getInstance(q);
1960
1961 qPos.add(nodeId);
1962
1963 if (redirectTitle != null) {
1964 qPos.add(redirectTitle);
1965 }
1966
1967 List<WikiPage> list = q.list();
1968
1969 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1970 finderClassName, finderMethodName, finderParams,
1971 finderArgs, list);
1972
1973 return list;
1974 }
1975 catch (Exception e) {
1976 throw processException(e);
1977 }
1978 finally {
1979 closeSession(session);
1980 }
1981 }
1982 else {
1983 return (List<WikiPage>)result;
1984 }
1985 }
1986
1987 public List<WikiPage> findByN_R(long nodeId, String redirectTitle,
1988 int start, int end) throws SystemException {
1989 return findByN_R(nodeId, redirectTitle, start, end, null);
1990 }
1991
1992 public List<WikiPage> findByN_R(long nodeId, String redirectTitle,
1993 int start, int end, OrderByComparator obc) throws SystemException {
1994 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
1995 String finderClassName = WikiPage.class.getName();
1996 String finderMethodName = "findByN_R";
1997 String[] finderParams = new String[] {
1998 Long.class.getName(), String.class.getName(),
1999
2000 "java.lang.Integer", "java.lang.Integer",
2001 "com.liferay.portal.kernel.util.OrderByComparator"
2002 };
2003 Object[] finderArgs = new Object[] {
2004 new Long(nodeId),
2005
2006 redirectTitle,
2007
2008 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2009 };
2010
2011 Object result = null;
2012
2013 if (finderClassNameCacheEnabled) {
2014 result = FinderCacheUtil.getResult(finderClassName,
2015 finderMethodName, finderParams, finderArgs, this);
2016 }
2017
2018 if (result == null) {
2019 Session session = null;
2020
2021 try {
2022 session = openSession();
2023
2024 StringBuilder query = new StringBuilder();
2025
2026 query.append(
2027 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
2028
2029 query.append("nodeId = ?");
2030
2031 query.append(" AND ");
2032
2033 if (redirectTitle == null) {
2034 query.append("redirectTitle IS NULL");
2035 }
2036 else {
2037 query.append("redirectTitle = ?");
2038 }
2039
2040 query.append(" ");
2041
2042 if (obc != null) {
2043 query.append("ORDER BY ");
2044 query.append(obc.getOrderBy());
2045 }
2046
2047 else {
2048 query.append("ORDER BY ");
2049
2050 query.append("nodeId ASC, ");
2051 query.append("title ASC, ");
2052 query.append("version ASC");
2053 }
2054
2055 Query q = session.createQuery(query.toString());
2056
2057 QueryPos qPos = QueryPos.getInstance(q);
2058
2059 qPos.add(nodeId);
2060
2061 if (redirectTitle != null) {
2062 qPos.add(redirectTitle);
2063 }
2064
2065 List<WikiPage> list = (List<WikiPage>)QueryUtil.list(q,
2066 getDialect(), start, end);
2067
2068 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2069 finderClassName, finderMethodName, finderParams,
2070 finderArgs, list);
2071
2072 return list;
2073 }
2074 catch (Exception e) {
2075 throw processException(e);
2076 }
2077 finally {
2078 closeSession(session);
2079 }
2080 }
2081 else {
2082 return (List<WikiPage>)result;
2083 }
2084 }
2085
2086 public WikiPage findByN_R_First(long nodeId, String redirectTitle,
2087 OrderByComparator obc) throws NoSuchPageException, SystemException {
2088 List<WikiPage> list = findByN_R(nodeId, redirectTitle, 0, 1, obc);
2089
2090 if (list.size() == 0) {
2091 StringBuilder msg = new StringBuilder();
2092
2093 msg.append("No WikiPage exists with the key {");
2094
2095 msg.append("nodeId=" + nodeId);
2096
2097 msg.append(", ");
2098 msg.append("redirectTitle=" + redirectTitle);
2099
2100 msg.append(StringPool.CLOSE_CURLY_BRACE);
2101
2102 throw new NoSuchPageException(msg.toString());
2103 }
2104 else {
2105 return list.get(0);
2106 }
2107 }
2108
2109 public WikiPage findByN_R_Last(long nodeId, String redirectTitle,
2110 OrderByComparator obc) throws NoSuchPageException, SystemException {
2111 int count = countByN_R(nodeId, redirectTitle);
2112
2113 List<WikiPage> list = findByN_R(nodeId, redirectTitle, count - 1,
2114 count, obc);
2115
2116 if (list.size() == 0) {
2117 StringBuilder msg = new StringBuilder();
2118
2119 msg.append("No WikiPage exists with the key {");
2120
2121 msg.append("nodeId=" + nodeId);
2122
2123 msg.append(", ");
2124 msg.append("redirectTitle=" + redirectTitle);
2125
2126 msg.append(StringPool.CLOSE_CURLY_BRACE);
2127
2128 throw new NoSuchPageException(msg.toString());
2129 }
2130 else {
2131 return list.get(0);
2132 }
2133 }
2134
2135 public WikiPage[] findByN_R_PrevAndNext(long pageId, long nodeId,
2136 String redirectTitle, OrderByComparator obc)
2137 throws NoSuchPageException, SystemException {
2138 WikiPage wikiPage = findByPrimaryKey(pageId);
2139
2140 int count = countByN_R(nodeId, redirectTitle);
2141
2142 Session session = null;
2143
2144 try {
2145 session = openSession();
2146
2147 StringBuilder query = new StringBuilder();
2148
2149 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
2150
2151 query.append("nodeId = ?");
2152
2153 query.append(" AND ");
2154
2155 if (redirectTitle == null) {
2156 query.append("redirectTitle IS NULL");
2157 }
2158 else {
2159 query.append("redirectTitle = ?");
2160 }
2161
2162 query.append(" ");
2163
2164 if (obc != null) {
2165 query.append("ORDER BY ");
2166 query.append(obc.getOrderBy());
2167 }
2168
2169 else {
2170 query.append("ORDER BY ");
2171
2172 query.append("nodeId ASC, ");
2173 query.append("title ASC, ");
2174 query.append("version ASC");
2175 }
2176
2177 Query q = session.createQuery(query.toString());
2178
2179 QueryPos qPos = QueryPos.getInstance(q);
2180
2181 qPos.add(nodeId);
2182
2183 if (redirectTitle != null) {
2184 qPos.add(redirectTitle);
2185 }
2186
2187 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
2188
2189 WikiPage[] array = new WikiPageImpl[3];
2190
2191 array[0] = (WikiPage)objArray[0];
2192 array[1] = (WikiPage)objArray[1];
2193 array[2] = (WikiPage)objArray[2];
2194
2195 return array;
2196 }
2197 catch (Exception e) {
2198 throw processException(e);
2199 }
2200 finally {
2201 closeSession(session);
2202 }
2203 }
2204
2205 public WikiPage findByN_T_V(long nodeId, String title, double version)
2206 throws NoSuchPageException, SystemException {
2207 WikiPage wikiPage = fetchByN_T_V(nodeId, title, version);
2208
2209 if (wikiPage == null) {
2210 StringBuilder msg = new StringBuilder();
2211
2212 msg.append("No WikiPage exists with the key {");
2213
2214 msg.append("nodeId=" + nodeId);
2215
2216 msg.append(", ");
2217 msg.append("title=" + title);
2218
2219 msg.append(", ");
2220 msg.append("version=" + version);
2221
2222 msg.append(StringPool.CLOSE_CURLY_BRACE);
2223
2224 if (_log.isWarnEnabled()) {
2225 _log.warn(msg.toString());
2226 }
2227
2228 throw new NoSuchPageException(msg.toString());
2229 }
2230
2231 return wikiPage;
2232 }
2233
2234 public WikiPage fetchByN_T_V(long nodeId, String title, double version)
2235 throws SystemException {
2236 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
2237 String finderClassName = WikiPage.class.getName();
2238 String finderMethodName = "fetchByN_T_V";
2239 String[] finderParams = new String[] {
2240 Long.class.getName(), String.class.getName(),
2241 Double.class.getName()
2242 };
2243 Object[] finderArgs = new Object[] {
2244 new Long(nodeId),
2245
2246 title, new Double(version)
2247 };
2248
2249 Object result = null;
2250
2251 if (finderClassNameCacheEnabled) {
2252 result = FinderCacheUtil.getResult(finderClassName,
2253 finderMethodName, finderParams, finderArgs, this);
2254 }
2255
2256 if (result == null) {
2257 Session session = null;
2258
2259 try {
2260 session = openSession();
2261
2262 StringBuilder query = new StringBuilder();
2263
2264 query.append(
2265 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
2266
2267 query.append("nodeId = ?");
2268
2269 query.append(" AND ");
2270
2271 if (title == null) {
2272 query.append("title IS NULL");
2273 }
2274 else {
2275 query.append("title = ?");
2276 }
2277
2278 query.append(" AND ");
2279
2280 query.append("version = ?");
2281
2282 query.append(" ");
2283
2284 query.append("ORDER BY ");
2285
2286 query.append("nodeId ASC, ");
2287 query.append("title ASC, ");
2288 query.append("version ASC");
2289
2290 Query q = session.createQuery(query.toString());
2291
2292 QueryPos qPos = QueryPos.getInstance(q);
2293
2294 qPos.add(nodeId);
2295
2296 if (title != null) {
2297 qPos.add(title);
2298 }
2299
2300 qPos.add(version);
2301
2302 List<WikiPage> list = q.list();
2303
2304 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2305 finderClassName, finderMethodName, finderParams,
2306 finderArgs, list);
2307
2308 if (list.size() == 0) {
2309 return null;
2310 }
2311 else {
2312 return list.get(0);
2313 }
2314 }
2315 catch (Exception e) {
2316 throw processException(e);
2317 }
2318 finally {
2319 closeSession(session);
2320 }
2321 }
2322 else {
2323 List<WikiPage> list = (List<WikiPage>)result;
2324
2325 if (list.size() == 0) {
2326 return null;
2327 }
2328 else {
2329 return list.get(0);
2330 }
2331 }
2332 }
2333
2334 public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head)
2335 throws SystemException {
2336 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
2337 String finderClassName = WikiPage.class.getName();
2338 String finderMethodName = "findByN_T_H";
2339 String[] finderParams = new String[] {
2340 Long.class.getName(), String.class.getName(),
2341 Boolean.class.getName()
2342 };
2343 Object[] finderArgs = new Object[] {
2344 new Long(nodeId),
2345
2346 title, Boolean.valueOf(head)
2347 };
2348
2349 Object result = null;
2350
2351 if (finderClassNameCacheEnabled) {
2352 result = FinderCacheUtil.getResult(finderClassName,
2353 finderMethodName, finderParams, finderArgs, this);
2354 }
2355
2356 if (result == null) {
2357 Session session = null;
2358
2359 try {
2360 session = openSession();
2361
2362 StringBuilder query = new StringBuilder();
2363
2364 query.append(
2365 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
2366
2367 query.append("nodeId = ?");
2368
2369 query.append(" AND ");
2370
2371 if (title == null) {
2372 query.append("title IS NULL");
2373 }
2374 else {
2375 query.append("title = ?");
2376 }
2377
2378 query.append(" AND ");
2379
2380 query.append("head = ?");
2381
2382 query.append(" ");
2383
2384 query.append("ORDER BY ");
2385
2386 query.append("nodeId ASC, ");
2387 query.append("title ASC, ");
2388 query.append("version ASC");
2389
2390 Query q = session.createQuery(query.toString());
2391
2392 QueryPos qPos = QueryPos.getInstance(q);
2393
2394 qPos.add(nodeId);
2395
2396 if (title != null) {
2397 qPos.add(title);
2398 }
2399
2400 qPos.add(head);
2401
2402 List<WikiPage> list = q.list();
2403
2404 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2405 finderClassName, finderMethodName, finderParams,
2406 finderArgs, list);
2407
2408 return list;
2409 }
2410 catch (Exception e) {
2411 throw processException(e);
2412 }
2413 finally {
2414 closeSession(session);
2415 }
2416 }
2417 else {
2418 return (List<WikiPage>)result;
2419 }
2420 }
2421
2422 public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head,
2423 int start, int end) throws SystemException {
2424 return findByN_T_H(nodeId, title, head, start, end, null);
2425 }
2426
2427 public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head,
2428 int start, int end, OrderByComparator obc) throws SystemException {
2429 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
2430 String finderClassName = WikiPage.class.getName();
2431 String finderMethodName = "findByN_T_H";
2432 String[] finderParams = new String[] {
2433 Long.class.getName(), String.class.getName(),
2434 Boolean.class.getName(),
2435
2436 "java.lang.Integer", "java.lang.Integer",
2437 "com.liferay.portal.kernel.util.OrderByComparator"
2438 };
2439 Object[] finderArgs = new Object[] {
2440 new Long(nodeId),
2441
2442 title, Boolean.valueOf(head),
2443
2444 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2445 };
2446
2447 Object result = null;
2448
2449 if (finderClassNameCacheEnabled) {
2450 result = FinderCacheUtil.getResult(finderClassName,
2451 finderMethodName, finderParams, finderArgs, this);
2452 }
2453
2454 if (result == null) {
2455 Session session = null;
2456
2457 try {
2458 session = openSession();
2459
2460 StringBuilder query = new StringBuilder();
2461
2462 query.append(
2463 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
2464
2465 query.append("nodeId = ?");
2466
2467 query.append(" AND ");
2468
2469 if (title == null) {
2470 query.append("title IS NULL");
2471 }
2472 else {
2473 query.append("title = ?");
2474 }
2475
2476 query.append(" AND ");
2477
2478 query.append("head = ?");
2479
2480 query.append(" ");
2481
2482 if (obc != null) {
2483 query.append("ORDER BY ");
2484 query.append(obc.getOrderBy());
2485 }
2486
2487 else {
2488 query.append("ORDER BY ");
2489
2490 query.append("nodeId ASC, ");
2491 query.append("title ASC, ");
2492 query.append("version ASC");
2493 }
2494
2495 Query q = session.createQuery(query.toString());
2496
2497 QueryPos qPos = QueryPos.getInstance(q);
2498
2499 qPos.add(nodeId);
2500
2501 if (title != null) {
2502 qPos.add(title);
2503 }
2504
2505 qPos.add(head);
2506
2507 List<WikiPage> list = (List<WikiPage>)QueryUtil.list(q,
2508 getDialect(), start, end);
2509
2510 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2511 finderClassName, finderMethodName, finderParams,
2512 finderArgs, list);
2513
2514 return list;
2515 }
2516 catch (Exception e) {
2517 throw processException(e);
2518 }
2519 finally {
2520 closeSession(session);
2521 }
2522 }
2523 else {
2524 return (List<WikiPage>)result;
2525 }
2526 }
2527
2528 public WikiPage findByN_T_H_First(long nodeId, String title, boolean head,
2529 OrderByComparator obc) throws NoSuchPageException, SystemException {
2530 List<WikiPage> list = findByN_T_H(nodeId, title, head, 0, 1, obc);
2531
2532 if (list.size() == 0) {
2533 StringBuilder msg = new StringBuilder();
2534
2535 msg.append("No WikiPage exists with the key {");
2536
2537 msg.append("nodeId=" + nodeId);
2538
2539 msg.append(", ");
2540 msg.append("title=" + title);
2541
2542 msg.append(", ");
2543 msg.append("head=" + head);
2544
2545 msg.append(StringPool.CLOSE_CURLY_BRACE);
2546
2547 throw new NoSuchPageException(msg.toString());
2548 }
2549 else {
2550 return list.get(0);
2551 }
2552 }
2553
2554 public WikiPage findByN_T_H_Last(long nodeId, String title, boolean head,
2555 OrderByComparator obc) throws NoSuchPageException, SystemException {
2556 int count = countByN_T_H(nodeId, title, head);
2557
2558 List<WikiPage> list = findByN_T_H(nodeId, title, head, count - 1,
2559 count, obc);
2560
2561 if (list.size() == 0) {
2562 StringBuilder msg = new StringBuilder();
2563
2564 msg.append("No WikiPage exists with the key {");
2565
2566 msg.append("nodeId=" + nodeId);
2567
2568 msg.append(", ");
2569 msg.append("title=" + title);
2570
2571 msg.append(", ");
2572 msg.append("head=" + head);
2573
2574 msg.append(StringPool.CLOSE_CURLY_BRACE);
2575
2576 throw new NoSuchPageException(msg.toString());
2577 }
2578 else {
2579 return list.get(0);
2580 }
2581 }
2582
2583 public WikiPage[] findByN_T_H_PrevAndNext(long pageId, long nodeId,
2584 String title, boolean head, OrderByComparator obc)
2585 throws NoSuchPageException, SystemException {
2586 WikiPage wikiPage = findByPrimaryKey(pageId);
2587
2588 int count = countByN_T_H(nodeId, title, head);
2589
2590 Session session = null;
2591
2592 try {
2593 session = openSession();
2594
2595 StringBuilder query = new StringBuilder();
2596
2597 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
2598
2599 query.append("nodeId = ?");
2600
2601 query.append(" AND ");
2602
2603 if (title == null) {
2604 query.append("title IS NULL");
2605 }
2606 else {
2607 query.append("title = ?");
2608 }
2609
2610 query.append(" AND ");
2611
2612 query.append("head = ?");
2613
2614 query.append(" ");
2615
2616 if (obc != null) {
2617 query.append("ORDER BY ");
2618 query.append(obc.getOrderBy());
2619 }
2620
2621 else {
2622 query.append("ORDER BY ");
2623
2624 query.append("nodeId ASC, ");
2625 query.append("title ASC, ");
2626 query.append("version ASC");
2627 }
2628
2629 Query q = session.createQuery(query.toString());
2630
2631 QueryPos qPos = QueryPos.getInstance(q);
2632
2633 qPos.add(nodeId);
2634
2635 if (title != null) {
2636 qPos.add(title);
2637 }
2638
2639 qPos.add(head);
2640
2641 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
2642
2643 WikiPage[] array = new WikiPageImpl[3];
2644
2645 array[0] = (WikiPage)objArray[0];
2646 array[1] = (WikiPage)objArray[1];
2647 array[2] = (WikiPage)objArray[2];
2648
2649 return array;
2650 }
2651 catch (Exception e) {
2652 throw processException(e);
2653 }
2654 finally {
2655 closeSession(session);
2656 }
2657 }
2658
2659 public List<WikiPage> findByN_H_P(long nodeId, boolean head,
2660 String parentTitle) throws SystemException {
2661 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
2662 String finderClassName = WikiPage.class.getName();
2663 String finderMethodName = "findByN_H_P";
2664 String[] finderParams = new String[] {
2665 Long.class.getName(), Boolean.class.getName(),
2666 String.class.getName()
2667 };
2668 Object[] finderArgs = new Object[] {
2669 new Long(nodeId), Boolean.valueOf(head),
2670
2671 parentTitle
2672 };
2673
2674 Object result = null;
2675
2676 if (finderClassNameCacheEnabled) {
2677 result = FinderCacheUtil.getResult(finderClassName,
2678 finderMethodName, finderParams, finderArgs, this);
2679 }
2680
2681 if (result == null) {
2682 Session session = null;
2683
2684 try {
2685 session = openSession();
2686
2687 StringBuilder query = new StringBuilder();
2688
2689 query.append(
2690 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
2691
2692 query.append("nodeId = ?");
2693
2694 query.append(" AND ");
2695
2696 query.append("head = ?");
2697
2698 query.append(" AND ");
2699
2700 if (parentTitle == null) {
2701 query.append("parentTitle IS NULL");
2702 }
2703 else {
2704 query.append("parentTitle = ?");
2705 }
2706
2707 query.append(" ");
2708
2709 query.append("ORDER BY ");
2710
2711 query.append("nodeId ASC, ");
2712 query.append("title ASC, ");
2713 query.append("version ASC");
2714
2715 Query q = session.createQuery(query.toString());
2716
2717 QueryPos qPos = QueryPos.getInstance(q);
2718
2719 qPos.add(nodeId);
2720
2721 qPos.add(head);
2722
2723 if (parentTitle != null) {
2724 qPos.add(parentTitle);
2725 }
2726
2727 List<WikiPage> list = q.list();
2728
2729 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2730 finderClassName, finderMethodName, finderParams,
2731 finderArgs, list);
2732
2733 return list;
2734 }
2735 catch (Exception e) {
2736 throw processException(e);
2737 }
2738 finally {
2739 closeSession(session);
2740 }
2741 }
2742 else {
2743 return (List<WikiPage>)result;
2744 }
2745 }
2746
2747 public List<WikiPage> findByN_H_P(long nodeId, boolean head,
2748 String parentTitle, int start, int end) throws SystemException {
2749 return findByN_H_P(nodeId, head, parentTitle, start, end, null);
2750 }
2751
2752 public List<WikiPage> findByN_H_P(long nodeId, boolean head,
2753 String parentTitle, int start, int end, OrderByComparator obc)
2754 throws SystemException {
2755 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
2756 String finderClassName = WikiPage.class.getName();
2757 String finderMethodName = "findByN_H_P";
2758 String[] finderParams = new String[] {
2759 Long.class.getName(), Boolean.class.getName(),
2760 String.class.getName(),
2761
2762 "java.lang.Integer", "java.lang.Integer",
2763 "com.liferay.portal.kernel.util.OrderByComparator"
2764 };
2765 Object[] finderArgs = new Object[] {
2766 new Long(nodeId), Boolean.valueOf(head),
2767
2768 parentTitle,
2769
2770 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2771 };
2772
2773 Object result = null;
2774
2775 if (finderClassNameCacheEnabled) {
2776 result = FinderCacheUtil.getResult(finderClassName,
2777 finderMethodName, finderParams, finderArgs, this);
2778 }
2779
2780 if (result == null) {
2781 Session session = null;
2782
2783 try {
2784 session = openSession();
2785
2786 StringBuilder query = new StringBuilder();
2787
2788 query.append(
2789 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
2790
2791 query.append("nodeId = ?");
2792
2793 query.append(" AND ");
2794
2795 query.append("head = ?");
2796
2797 query.append(" AND ");
2798
2799 if (parentTitle == null) {
2800 query.append("parentTitle IS NULL");
2801 }
2802 else {
2803 query.append("parentTitle = ?");
2804 }
2805
2806 query.append(" ");
2807
2808 if (obc != null) {
2809 query.append("ORDER BY ");
2810 query.append(obc.getOrderBy());
2811 }
2812
2813 else {
2814 query.append("ORDER BY ");
2815
2816 query.append("nodeId ASC, ");
2817 query.append("title ASC, ");
2818 query.append("version ASC");
2819 }
2820
2821 Query q = session.createQuery(query.toString());
2822
2823 QueryPos qPos = QueryPos.getInstance(q);
2824
2825 qPos.add(nodeId);
2826
2827 qPos.add(head);
2828
2829 if (parentTitle != null) {
2830 qPos.add(parentTitle);
2831 }
2832
2833 List<WikiPage> list = (List<WikiPage>)QueryUtil.list(q,
2834 getDialect(), start, end);
2835
2836 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2837 finderClassName, finderMethodName, finderParams,
2838 finderArgs, list);
2839
2840 return list;
2841 }
2842 catch (Exception e) {
2843 throw processException(e);
2844 }
2845 finally {
2846 closeSession(session);
2847 }
2848 }
2849 else {
2850 return (List<WikiPage>)result;
2851 }
2852 }
2853
2854 public WikiPage findByN_H_P_First(long nodeId, boolean head,
2855 String parentTitle, OrderByComparator obc)
2856 throws NoSuchPageException, SystemException {
2857 List<WikiPage> list = findByN_H_P(nodeId, head, parentTitle, 0, 1, obc);
2858
2859 if (list.size() == 0) {
2860 StringBuilder msg = new StringBuilder();
2861
2862 msg.append("No WikiPage exists with the key {");
2863
2864 msg.append("nodeId=" + nodeId);
2865
2866 msg.append(", ");
2867 msg.append("head=" + head);
2868
2869 msg.append(", ");
2870 msg.append("parentTitle=" + parentTitle);
2871
2872 msg.append(StringPool.CLOSE_CURLY_BRACE);
2873
2874 throw new NoSuchPageException(msg.toString());
2875 }
2876 else {
2877 return list.get(0);
2878 }
2879 }
2880
2881 public WikiPage findByN_H_P_Last(long nodeId, boolean head,
2882 String parentTitle, OrderByComparator obc)
2883 throws NoSuchPageException, SystemException {
2884 int count = countByN_H_P(nodeId, head, parentTitle);
2885
2886 List<WikiPage> list = findByN_H_P(nodeId, head, parentTitle, count - 1,
2887 count, obc);
2888
2889 if (list.size() == 0) {
2890 StringBuilder msg = new StringBuilder();
2891
2892 msg.append("No WikiPage exists with the key {");
2893
2894 msg.append("nodeId=" + nodeId);
2895
2896 msg.append(", ");
2897 msg.append("head=" + head);
2898
2899 msg.append(", ");
2900 msg.append("parentTitle=" + parentTitle);
2901
2902 msg.append(StringPool.CLOSE_CURLY_BRACE);
2903
2904 throw new NoSuchPageException(msg.toString());
2905 }
2906 else {
2907 return list.get(0);
2908 }
2909 }
2910
2911 public WikiPage[] findByN_H_P_PrevAndNext(long pageId, long nodeId,
2912 boolean head, String parentTitle, OrderByComparator obc)
2913 throws NoSuchPageException, SystemException {
2914 WikiPage wikiPage = findByPrimaryKey(pageId);
2915
2916 int count = countByN_H_P(nodeId, head, parentTitle);
2917
2918 Session session = null;
2919
2920 try {
2921 session = openSession();
2922
2923 StringBuilder query = new StringBuilder();
2924
2925 query.append("FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
2926
2927 query.append("nodeId = ?");
2928
2929 query.append(" AND ");
2930
2931 query.append("head = ?");
2932
2933 query.append(" AND ");
2934
2935 if (parentTitle == null) {
2936 query.append("parentTitle IS NULL");
2937 }
2938 else {
2939 query.append("parentTitle = ?");
2940 }
2941
2942 query.append(" ");
2943
2944 if (obc != null) {
2945 query.append("ORDER BY ");
2946 query.append(obc.getOrderBy());
2947 }
2948
2949 else {
2950 query.append("ORDER BY ");
2951
2952 query.append("nodeId ASC, ");
2953 query.append("title ASC, ");
2954 query.append("version ASC");
2955 }
2956
2957 Query q = session.createQuery(query.toString());
2958
2959 QueryPos qPos = QueryPos.getInstance(q);
2960
2961 qPos.add(nodeId);
2962
2963 qPos.add(head);
2964
2965 if (parentTitle != null) {
2966 qPos.add(parentTitle);
2967 }
2968
2969 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
2970
2971 WikiPage[] array = new WikiPageImpl[3];
2972
2973 array[0] = (WikiPage)objArray[0];
2974 array[1] = (WikiPage)objArray[1];
2975 array[2] = (WikiPage)objArray[2];
2976
2977 return array;
2978 }
2979 catch (Exception e) {
2980 throw processException(e);
2981 }
2982 finally {
2983 closeSession(session);
2984 }
2985 }
2986
2987 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
2988 throws SystemException {
2989 Session session = null;
2990
2991 try {
2992 session = openSession();
2993
2994 dynamicQuery.compile(session);
2995
2996 return dynamicQuery.list();
2997 }
2998 catch (Exception e) {
2999 throw processException(e);
3000 }
3001 finally {
3002 closeSession(session);
3003 }
3004 }
3005
3006 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
3007 int start, int end) throws SystemException {
3008 Session session = null;
3009
3010 try {
3011 session = openSession();
3012
3013 dynamicQuery.setLimit(start, end);
3014
3015 dynamicQuery.compile(session);
3016
3017 return dynamicQuery.list();
3018 }
3019 catch (Exception e) {
3020 throw processException(e);
3021 }
3022 finally {
3023 closeSession(session);
3024 }
3025 }
3026
3027 public List<WikiPage> findAll() throws SystemException {
3028 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3029 }
3030
3031 public List<WikiPage> findAll(int start, int end) throws SystemException {
3032 return findAll(start, end, null);
3033 }
3034
3035 public List<WikiPage> findAll(int start, int end, OrderByComparator obc)
3036 throws SystemException {
3037 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
3038 String finderClassName = WikiPage.class.getName();
3039 String finderMethodName = "findAll";
3040 String[] finderParams = new String[] {
3041 "java.lang.Integer", "java.lang.Integer",
3042 "com.liferay.portal.kernel.util.OrderByComparator"
3043 };
3044 Object[] finderArgs = new Object[] {
3045 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
3046 };
3047
3048 Object result = null;
3049
3050 if (finderClassNameCacheEnabled) {
3051 result = FinderCacheUtil.getResult(finderClassName,
3052 finderMethodName, finderParams, finderArgs, this);
3053 }
3054
3055 if (result == null) {
3056 Session session = null;
3057
3058 try {
3059 session = openSession();
3060
3061 StringBuilder query = new StringBuilder();
3062
3063 query.append("FROM com.liferay.portlet.wiki.model.WikiPage ");
3064
3065 if (obc != null) {
3066 query.append("ORDER BY ");
3067 query.append(obc.getOrderBy());
3068 }
3069
3070 else {
3071 query.append("ORDER BY ");
3072
3073 query.append("nodeId ASC, ");
3074 query.append("title ASC, ");
3075 query.append("version ASC");
3076 }
3077
3078 Query q = session.createQuery(query.toString());
3079
3080 List<WikiPage> list = null;
3081
3082 if (obc == null) {
3083 list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
3084 start, end, false);
3085
3086 Collections.sort(list);
3087 }
3088 else {
3089 list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
3090 start, end);
3091 }
3092
3093 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3094 finderClassName, finderMethodName, finderParams,
3095 finderArgs, list);
3096
3097 return list;
3098 }
3099 catch (Exception e) {
3100 throw processException(e);
3101 }
3102 finally {
3103 closeSession(session);
3104 }
3105 }
3106 else {
3107 return (List<WikiPage>)result;
3108 }
3109 }
3110
3111 public void removeByUuid(String uuid) throws SystemException {
3112 for (WikiPage wikiPage : findByUuid(uuid)) {
3113 remove(wikiPage);
3114 }
3115 }
3116
3117 public void removeByNodeId(long nodeId) throws SystemException {
3118 for (WikiPage wikiPage : findByNodeId(nodeId)) {
3119 remove(wikiPage);
3120 }
3121 }
3122
3123 public void removeByFormat(String format) throws SystemException {
3124 for (WikiPage wikiPage : findByFormat(format)) {
3125 remove(wikiPage);
3126 }
3127 }
3128
3129 public void removeByN_T(long nodeId, String title)
3130 throws SystemException {
3131 for (WikiPage wikiPage : findByN_T(nodeId, title)) {
3132 remove(wikiPage);
3133 }
3134 }
3135
3136 public void removeByN_H(long nodeId, boolean head)
3137 throws SystemException {
3138 for (WikiPage wikiPage : findByN_H(nodeId, head)) {
3139 remove(wikiPage);
3140 }
3141 }
3142
3143 public void removeByN_P(long nodeId, String parentTitle)
3144 throws SystemException {
3145 for (WikiPage wikiPage : findByN_P(nodeId, parentTitle)) {
3146 remove(wikiPage);
3147 }
3148 }
3149
3150 public void removeByN_R(long nodeId, String redirectTitle)
3151 throws SystemException {
3152 for (WikiPage wikiPage : findByN_R(nodeId, redirectTitle)) {
3153 remove(wikiPage);
3154 }
3155 }
3156
3157 public void removeByN_T_V(long nodeId, String title, double version)
3158 throws NoSuchPageException, SystemException {
3159 WikiPage wikiPage = findByN_T_V(nodeId, title, version);
3160
3161 remove(wikiPage);
3162 }
3163
3164 public void removeByN_T_H(long nodeId, String title, boolean head)
3165 throws SystemException {
3166 for (WikiPage wikiPage : findByN_T_H(nodeId, title, head)) {
3167 remove(wikiPage);
3168 }
3169 }
3170
3171 public void removeByN_H_P(long nodeId, boolean head, String parentTitle)
3172 throws SystemException {
3173 for (WikiPage wikiPage : findByN_H_P(nodeId, head, parentTitle)) {
3174 remove(wikiPage);
3175 }
3176 }
3177
3178 public void removeAll() throws SystemException {
3179 for (WikiPage wikiPage : findAll()) {
3180 remove(wikiPage);
3181 }
3182 }
3183
3184 public int countByUuid(String uuid) throws SystemException {
3185 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
3186 String finderClassName = WikiPage.class.getName();
3187 String finderMethodName = "countByUuid";
3188 String[] finderParams = new String[] { String.class.getName() };
3189 Object[] finderArgs = new Object[] { uuid };
3190
3191 Object result = null;
3192
3193 if (finderClassNameCacheEnabled) {
3194 result = FinderCacheUtil.getResult(finderClassName,
3195 finderMethodName, finderParams, finderArgs, this);
3196 }
3197
3198 if (result == null) {
3199 Session session = null;
3200
3201 try {
3202 session = openSession();
3203
3204 StringBuilder query = new StringBuilder();
3205
3206 query.append("SELECT COUNT(*) ");
3207 query.append(
3208 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
3209
3210 if (uuid == null) {
3211 query.append("uuid_ IS NULL");
3212 }
3213 else {
3214 query.append("uuid_ = ?");
3215 }
3216
3217 query.append(" ");
3218
3219 Query q = session.createQuery(query.toString());
3220
3221 QueryPos qPos = QueryPos.getInstance(q);
3222
3223 if (uuid != null) {
3224 qPos.add(uuid);
3225 }
3226
3227 Long count = null;
3228
3229 Iterator<Long> itr = q.list().iterator();
3230
3231 if (itr.hasNext()) {
3232 count = itr.next();
3233 }
3234
3235 if (count == null) {
3236 count = new Long(0);
3237 }
3238
3239 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3240 finderClassName, finderMethodName, finderParams,
3241 finderArgs, count);
3242
3243 return count.intValue();
3244 }
3245 catch (Exception e) {
3246 throw processException(e);
3247 }
3248 finally {
3249 closeSession(session);
3250 }
3251 }
3252 else {
3253 return ((Long)result).intValue();
3254 }
3255 }
3256
3257 public int countByNodeId(long nodeId) throws SystemException {
3258 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
3259 String finderClassName = WikiPage.class.getName();
3260 String finderMethodName = "countByNodeId";
3261 String[] finderParams = new String[] { Long.class.getName() };
3262 Object[] finderArgs = new Object[] { new Long(nodeId) };
3263
3264 Object result = null;
3265
3266 if (finderClassNameCacheEnabled) {
3267 result = FinderCacheUtil.getResult(finderClassName,
3268 finderMethodName, finderParams, finderArgs, this);
3269 }
3270
3271 if (result == null) {
3272 Session session = null;
3273
3274 try {
3275 session = openSession();
3276
3277 StringBuilder query = new StringBuilder();
3278
3279 query.append("SELECT COUNT(*) ");
3280 query.append(
3281 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
3282
3283 query.append("nodeId = ?");
3284
3285 query.append(" ");
3286
3287 Query q = session.createQuery(query.toString());
3288
3289 QueryPos qPos = QueryPos.getInstance(q);
3290
3291 qPos.add(nodeId);
3292
3293 Long count = null;
3294
3295 Iterator<Long> itr = q.list().iterator();
3296
3297 if (itr.hasNext()) {
3298 count = itr.next();
3299 }
3300
3301 if (count == null) {
3302 count = new Long(0);
3303 }
3304
3305 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3306 finderClassName, finderMethodName, finderParams,
3307 finderArgs, count);
3308
3309 return count.intValue();
3310 }
3311 catch (Exception e) {
3312 throw processException(e);
3313 }
3314 finally {
3315 closeSession(session);
3316 }
3317 }
3318 else {
3319 return ((Long)result).intValue();
3320 }
3321 }
3322
3323 public int countByFormat(String format) throws SystemException {
3324 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
3325 String finderClassName = WikiPage.class.getName();
3326 String finderMethodName = "countByFormat";
3327 String[] finderParams = new String[] { String.class.getName() };
3328 Object[] finderArgs = new Object[] { format };
3329
3330 Object result = null;
3331
3332 if (finderClassNameCacheEnabled) {
3333 result = FinderCacheUtil.getResult(finderClassName,
3334 finderMethodName, finderParams, finderArgs, this);
3335 }
3336
3337 if (result == null) {
3338 Session session = null;
3339
3340 try {
3341 session = openSession();
3342
3343 StringBuilder query = new StringBuilder();
3344
3345 query.append("SELECT COUNT(*) ");
3346 query.append(
3347 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
3348
3349 if (format == null) {
3350 query.append("format IS NULL");
3351 }
3352 else {
3353 query.append("format = ?");
3354 }
3355
3356 query.append(" ");
3357
3358 Query q = session.createQuery(query.toString());
3359
3360 QueryPos qPos = QueryPos.getInstance(q);
3361
3362 if (format != null) {
3363 qPos.add(format);
3364 }
3365
3366 Long count = null;
3367
3368 Iterator<Long> itr = q.list().iterator();
3369
3370 if (itr.hasNext()) {
3371 count = itr.next();
3372 }
3373
3374 if (count == null) {
3375 count = new Long(0);
3376 }
3377
3378 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3379 finderClassName, finderMethodName, finderParams,
3380 finderArgs, count);
3381
3382 return count.intValue();
3383 }
3384 catch (Exception e) {
3385 throw processException(e);
3386 }
3387 finally {
3388 closeSession(session);
3389 }
3390 }
3391 else {
3392 return ((Long)result).intValue();
3393 }
3394 }
3395
3396 public int countByN_T(long nodeId, String title) throws SystemException {
3397 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
3398 String finderClassName = WikiPage.class.getName();
3399 String finderMethodName = "countByN_T";
3400 String[] finderParams = new String[] {
3401 Long.class.getName(), String.class.getName()
3402 };
3403 Object[] finderArgs = new Object[] { new Long(nodeId), title };
3404
3405 Object result = null;
3406
3407 if (finderClassNameCacheEnabled) {
3408 result = FinderCacheUtil.getResult(finderClassName,
3409 finderMethodName, finderParams, finderArgs, this);
3410 }
3411
3412 if (result == null) {
3413 Session session = null;
3414
3415 try {
3416 session = openSession();
3417
3418 StringBuilder query = new StringBuilder();
3419
3420 query.append("SELECT COUNT(*) ");
3421 query.append(
3422 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
3423
3424 query.append("nodeId = ?");
3425
3426 query.append(" AND ");
3427
3428 if (title == null) {
3429 query.append("title IS NULL");
3430 }
3431 else {
3432 query.append("title = ?");
3433 }
3434
3435 query.append(" ");
3436
3437 Query q = session.createQuery(query.toString());
3438
3439 QueryPos qPos = QueryPos.getInstance(q);
3440
3441 qPos.add(nodeId);
3442
3443 if (title != null) {
3444 qPos.add(title);
3445 }
3446
3447 Long count = null;
3448
3449 Iterator<Long> itr = q.list().iterator();
3450
3451 if (itr.hasNext()) {
3452 count = itr.next();
3453 }
3454
3455 if (count == null) {
3456 count = new Long(0);
3457 }
3458
3459 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3460 finderClassName, finderMethodName, finderParams,
3461 finderArgs, count);
3462
3463 return count.intValue();
3464 }
3465 catch (Exception e) {
3466 throw processException(e);
3467 }
3468 finally {
3469 closeSession(session);
3470 }
3471 }
3472 else {
3473 return ((Long)result).intValue();
3474 }
3475 }
3476
3477 public int countByN_H(long nodeId, boolean head) throws SystemException {
3478 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
3479 String finderClassName = WikiPage.class.getName();
3480 String finderMethodName = "countByN_H";
3481 String[] finderParams = new String[] {
3482 Long.class.getName(), Boolean.class.getName()
3483 };
3484 Object[] finderArgs = new Object[] {
3485 new Long(nodeId), Boolean.valueOf(head)
3486 };
3487
3488 Object result = null;
3489
3490 if (finderClassNameCacheEnabled) {
3491 result = FinderCacheUtil.getResult(finderClassName,
3492 finderMethodName, finderParams, finderArgs, this);
3493 }
3494
3495 if (result == null) {
3496 Session session = null;
3497
3498 try {
3499 session = openSession();
3500
3501 StringBuilder query = new StringBuilder();
3502
3503 query.append("SELECT COUNT(*) ");
3504 query.append(
3505 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
3506
3507 query.append("nodeId = ?");
3508
3509 query.append(" AND ");
3510
3511 query.append("head = ?");
3512
3513 query.append(" ");
3514
3515 Query q = session.createQuery(query.toString());
3516
3517 QueryPos qPos = QueryPos.getInstance(q);
3518
3519 qPos.add(nodeId);
3520
3521 qPos.add(head);
3522
3523 Long count = null;
3524
3525 Iterator<Long> itr = q.list().iterator();
3526
3527 if (itr.hasNext()) {
3528 count = itr.next();
3529 }
3530
3531 if (count == null) {
3532 count = new Long(0);
3533 }
3534
3535 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3536 finderClassName, finderMethodName, finderParams,
3537 finderArgs, count);
3538
3539 return count.intValue();
3540 }
3541 catch (Exception e) {
3542 throw processException(e);
3543 }
3544 finally {
3545 closeSession(session);
3546 }
3547 }
3548 else {
3549 return ((Long)result).intValue();
3550 }
3551 }
3552
3553 public int countByN_P(long nodeId, String parentTitle)
3554 throws SystemException {
3555 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
3556 String finderClassName = WikiPage.class.getName();
3557 String finderMethodName = "countByN_P";
3558 String[] finderParams = new String[] {
3559 Long.class.getName(), String.class.getName()
3560 };
3561 Object[] finderArgs = new Object[] { new Long(nodeId), parentTitle };
3562
3563 Object result = null;
3564
3565 if (finderClassNameCacheEnabled) {
3566 result = FinderCacheUtil.getResult(finderClassName,
3567 finderMethodName, finderParams, finderArgs, this);
3568 }
3569
3570 if (result == null) {
3571 Session session = null;
3572
3573 try {
3574 session = openSession();
3575
3576 StringBuilder query = new StringBuilder();
3577
3578 query.append("SELECT COUNT(*) ");
3579 query.append(
3580 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
3581
3582 query.append("nodeId = ?");
3583
3584 query.append(" AND ");
3585
3586 if (parentTitle == null) {
3587 query.append("parentTitle IS NULL");
3588 }
3589 else {
3590 query.append("parentTitle = ?");
3591 }
3592
3593 query.append(" ");
3594
3595 Query q = session.createQuery(query.toString());
3596
3597 QueryPos qPos = QueryPos.getInstance(q);
3598
3599 qPos.add(nodeId);
3600
3601 if (parentTitle != null) {
3602 qPos.add(parentTitle);
3603 }
3604
3605 Long count = null;
3606
3607 Iterator<Long> itr = q.list().iterator();
3608
3609 if (itr.hasNext()) {
3610 count = itr.next();
3611 }
3612
3613 if (count == null) {
3614 count = new Long(0);
3615 }
3616
3617 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3618 finderClassName, finderMethodName, finderParams,
3619 finderArgs, count);
3620
3621 return count.intValue();
3622 }
3623 catch (Exception e) {
3624 throw processException(e);
3625 }
3626 finally {
3627 closeSession(session);
3628 }
3629 }
3630 else {
3631 return ((Long)result).intValue();
3632 }
3633 }
3634
3635 public int countByN_R(long nodeId, String redirectTitle)
3636 throws SystemException {
3637 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
3638 String finderClassName = WikiPage.class.getName();
3639 String finderMethodName = "countByN_R";
3640 String[] finderParams = new String[] {
3641 Long.class.getName(), String.class.getName()
3642 };
3643 Object[] finderArgs = new Object[] { new Long(nodeId), redirectTitle };
3644
3645 Object result = null;
3646
3647 if (finderClassNameCacheEnabled) {
3648 result = FinderCacheUtil.getResult(finderClassName,
3649 finderMethodName, finderParams, finderArgs, this);
3650 }
3651
3652 if (result == null) {
3653 Session session = null;
3654
3655 try {
3656 session = openSession();
3657
3658 StringBuilder query = new StringBuilder();
3659
3660 query.append("SELECT COUNT(*) ");
3661 query.append(
3662 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
3663
3664 query.append("nodeId = ?");
3665
3666 query.append(" AND ");
3667
3668 if (redirectTitle == null) {
3669 query.append("redirectTitle IS NULL");
3670 }
3671 else {
3672 query.append("redirectTitle = ?");
3673 }
3674
3675 query.append(" ");
3676
3677 Query q = session.createQuery(query.toString());
3678
3679 QueryPos qPos = QueryPos.getInstance(q);
3680
3681 qPos.add(nodeId);
3682
3683 if (redirectTitle != null) {
3684 qPos.add(redirectTitle);
3685 }
3686
3687 Long count = null;
3688
3689 Iterator<Long> itr = q.list().iterator();
3690
3691 if (itr.hasNext()) {
3692 count = itr.next();
3693 }
3694
3695 if (count == null) {
3696 count = new Long(0);
3697 }
3698
3699 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3700 finderClassName, finderMethodName, finderParams,
3701 finderArgs, count);
3702
3703 return count.intValue();
3704 }
3705 catch (Exception e) {
3706 throw processException(e);
3707 }
3708 finally {
3709 closeSession(session);
3710 }
3711 }
3712 else {
3713 return ((Long)result).intValue();
3714 }
3715 }
3716
3717 public int countByN_T_V(long nodeId, String title, double version)
3718 throws SystemException {
3719 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
3720 String finderClassName = WikiPage.class.getName();
3721 String finderMethodName = "countByN_T_V";
3722 String[] finderParams = new String[] {
3723 Long.class.getName(), String.class.getName(),
3724 Double.class.getName()
3725 };
3726 Object[] finderArgs = new Object[] {
3727 new Long(nodeId),
3728
3729 title, new Double(version)
3730 };
3731
3732 Object result = null;
3733
3734 if (finderClassNameCacheEnabled) {
3735 result = FinderCacheUtil.getResult(finderClassName,
3736 finderMethodName, finderParams, finderArgs, this);
3737 }
3738
3739 if (result == null) {
3740 Session session = null;
3741
3742 try {
3743 session = openSession();
3744
3745 StringBuilder query = new StringBuilder();
3746
3747 query.append("SELECT COUNT(*) ");
3748 query.append(
3749 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
3750
3751 query.append("nodeId = ?");
3752
3753 query.append(" AND ");
3754
3755 if (title == null) {
3756 query.append("title IS NULL");
3757 }
3758 else {
3759 query.append("title = ?");
3760 }
3761
3762 query.append(" AND ");
3763
3764 query.append("version = ?");
3765
3766 query.append(" ");
3767
3768 Query q = session.createQuery(query.toString());
3769
3770 QueryPos qPos = QueryPos.getInstance(q);
3771
3772 qPos.add(nodeId);
3773
3774 if (title != null) {
3775 qPos.add(title);
3776 }
3777
3778 qPos.add(version);
3779
3780 Long count = null;
3781
3782 Iterator<Long> itr = q.list().iterator();
3783
3784 if (itr.hasNext()) {
3785 count = itr.next();
3786 }
3787
3788 if (count == null) {
3789 count = new Long(0);
3790 }
3791
3792 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3793 finderClassName, finderMethodName, finderParams,
3794 finderArgs, count);
3795
3796 return count.intValue();
3797 }
3798 catch (Exception e) {
3799 throw processException(e);
3800 }
3801 finally {
3802 closeSession(session);
3803 }
3804 }
3805 else {
3806 return ((Long)result).intValue();
3807 }
3808 }
3809
3810 public int countByN_T_H(long nodeId, String title, boolean head)
3811 throws SystemException {
3812 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
3813 String finderClassName = WikiPage.class.getName();
3814 String finderMethodName = "countByN_T_H";
3815 String[] finderParams = new String[] {
3816 Long.class.getName(), String.class.getName(),
3817 Boolean.class.getName()
3818 };
3819 Object[] finderArgs = new Object[] {
3820 new Long(nodeId),
3821
3822 title, Boolean.valueOf(head)
3823 };
3824
3825 Object result = null;
3826
3827 if (finderClassNameCacheEnabled) {
3828 result = FinderCacheUtil.getResult(finderClassName,
3829 finderMethodName, finderParams, finderArgs, this);
3830 }
3831
3832 if (result == null) {
3833 Session session = null;
3834
3835 try {
3836 session = openSession();
3837
3838 StringBuilder query = new StringBuilder();
3839
3840 query.append("SELECT COUNT(*) ");
3841 query.append(
3842 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
3843
3844 query.append("nodeId = ?");
3845
3846 query.append(" AND ");
3847
3848 if (title == null) {
3849 query.append("title IS NULL");
3850 }
3851 else {
3852 query.append("title = ?");
3853 }
3854
3855 query.append(" AND ");
3856
3857 query.append("head = ?");
3858
3859 query.append(" ");
3860
3861 Query q = session.createQuery(query.toString());
3862
3863 QueryPos qPos = QueryPos.getInstance(q);
3864
3865 qPos.add(nodeId);
3866
3867 if (title != null) {
3868 qPos.add(title);
3869 }
3870
3871 qPos.add(head);
3872
3873 Long count = null;
3874
3875 Iterator<Long> itr = q.list().iterator();
3876
3877 if (itr.hasNext()) {
3878 count = itr.next();
3879 }
3880
3881 if (count == null) {
3882 count = new Long(0);
3883 }
3884
3885 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3886 finderClassName, finderMethodName, finderParams,
3887 finderArgs, count);
3888
3889 return count.intValue();
3890 }
3891 catch (Exception e) {
3892 throw processException(e);
3893 }
3894 finally {
3895 closeSession(session);
3896 }
3897 }
3898 else {
3899 return ((Long)result).intValue();
3900 }
3901 }
3902
3903 public int countByN_H_P(long nodeId, boolean head, String parentTitle)
3904 throws SystemException {
3905 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
3906 String finderClassName = WikiPage.class.getName();
3907 String finderMethodName = "countByN_H_P";
3908 String[] finderParams = new String[] {
3909 Long.class.getName(), Boolean.class.getName(),
3910 String.class.getName()
3911 };
3912 Object[] finderArgs = new Object[] {
3913 new Long(nodeId), Boolean.valueOf(head),
3914
3915 parentTitle
3916 };
3917
3918 Object result = null;
3919
3920 if (finderClassNameCacheEnabled) {
3921 result = FinderCacheUtil.getResult(finderClassName,
3922 finderMethodName, finderParams, finderArgs, this);
3923 }
3924
3925 if (result == null) {
3926 Session session = null;
3927
3928 try {
3929 session = openSession();
3930
3931 StringBuilder query = new StringBuilder();
3932
3933 query.append("SELECT COUNT(*) ");
3934 query.append(
3935 "FROM com.liferay.portlet.wiki.model.WikiPage WHERE ");
3936
3937 query.append("nodeId = ?");
3938
3939 query.append(" AND ");
3940
3941 query.append("head = ?");
3942
3943 query.append(" AND ");
3944
3945 if (parentTitle == null) {
3946 query.append("parentTitle IS NULL");
3947 }
3948 else {
3949 query.append("parentTitle = ?");
3950 }
3951
3952 query.append(" ");
3953
3954 Query q = session.createQuery(query.toString());
3955
3956 QueryPos qPos = QueryPos.getInstance(q);
3957
3958 qPos.add(nodeId);
3959
3960 qPos.add(head);
3961
3962 if (parentTitle != null) {
3963 qPos.add(parentTitle);
3964 }
3965
3966 Long count = null;
3967
3968 Iterator<Long> itr = q.list().iterator();
3969
3970 if (itr.hasNext()) {
3971 count = itr.next();
3972 }
3973
3974 if (count == null) {
3975 count = new Long(0);
3976 }
3977
3978 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3979 finderClassName, finderMethodName, finderParams,
3980 finderArgs, count);
3981
3982 return count.intValue();
3983 }
3984 catch (Exception e) {
3985 throw processException(e);
3986 }
3987 finally {
3988 closeSession(session);
3989 }
3990 }
3991 else {
3992 return ((Long)result).intValue();
3993 }
3994 }
3995
3996 public int countAll() throws SystemException {
3997 boolean finderClassNameCacheEnabled = WikiPageModelImpl.CACHE_ENABLED;
3998 String finderClassName = WikiPage.class.getName();
3999 String finderMethodName = "countAll";
4000 String[] finderParams = new String[] { };
4001 Object[] finderArgs = new Object[] { };
4002
4003 Object result = null;
4004
4005 if (finderClassNameCacheEnabled) {
4006 result = FinderCacheUtil.getResult(finderClassName,
4007 finderMethodName, finderParams, finderArgs, this);
4008 }
4009
4010 if (result == null) {
4011 Session session = null;
4012
4013 try {
4014 session = openSession();
4015
4016 Query q = session.createQuery(
4017 "SELECT COUNT(*) FROM com.liferay.portlet.wiki.model.WikiPage");
4018
4019 Long count = null;
4020
4021 Iterator<Long> itr = q.list().iterator();
4022
4023 if (itr.hasNext()) {
4024 count = itr.next();
4025 }
4026
4027 if (count == null) {
4028 count = new Long(0);
4029 }
4030
4031 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
4032 finderClassName, finderMethodName, finderParams,
4033 finderArgs, count);
4034
4035 return count.intValue();
4036 }
4037 catch (Exception e) {
4038 throw processException(e);
4039 }
4040 finally {
4041 closeSession(session);
4042 }
4043 }
4044 else {
4045 return ((Long)result).intValue();
4046 }
4047 }
4048
4049 public void registerListener(ModelListener listener) {
4050 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
4051
4052 listeners.add(listener);
4053
4054 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
4055 }
4056
4057 public void unregisterListener(ModelListener listener) {
4058 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
4059
4060 listeners.remove(listener);
4061
4062 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
4063 }
4064
4065 public void afterPropertiesSet() {
4066 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4067 com.liferay.portal.util.PropsUtil.get(
4068 "value.object.listener.com.liferay.portlet.wiki.model.WikiPage")));
4069
4070 if (listenerClassNames.length > 0) {
4071 try {
4072 List<ModelListener> listeners = new ArrayList<ModelListener>();
4073
4074 for (String listenerClassName : listenerClassNames) {
4075 listeners.add((ModelListener)Class.forName(
4076 listenerClassName).newInstance());
4077 }
4078
4079 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
4080 }
4081 catch (Exception e) {
4082 _log.error(e);
4083 }
4084 }
4085 }
4086
4087 private static Log _log = LogFactory.getLog(WikiPagePersistenceImpl.class);
4088 private ModelListener[] _listeners = new ModelListener[0];
4089}