1
22
23 package com.liferay.portlet.wiki.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.annotation.BeanReference;
27 import com.liferay.portal.kernel.cache.CacheRegistry;
28 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
29 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
30 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderPath;
32 import com.liferay.portal.kernel.dao.orm.Query;
33 import com.liferay.portal.kernel.dao.orm.QueryPos;
34 import com.liferay.portal.kernel.dao.orm.QueryUtil;
35 import com.liferay.portal.kernel.dao.orm.Session;
36 import com.liferay.portal.kernel.log.Log;
37 import com.liferay.portal.kernel.log.LogFactoryUtil;
38 import com.liferay.portal.kernel.util.GetterUtil;
39 import com.liferay.portal.kernel.util.OrderByComparator;
40 import com.liferay.portal.kernel.util.StringPool;
41 import com.liferay.portal.kernel.util.StringUtil;
42 import com.liferay.portal.kernel.util.Validator;
43 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
44 import com.liferay.portal.model.ModelListener;
45 import com.liferay.portal.service.persistence.BatchSessionUtil;
46 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
47
48 import com.liferay.portlet.wiki.NoSuchNodeException;
49 import com.liferay.portlet.wiki.model.WikiNode;
50 import com.liferay.portlet.wiki.model.impl.WikiNodeImpl;
51 import com.liferay.portlet.wiki.model.impl.WikiNodeModelImpl;
52
53 import java.util.ArrayList;
54 import java.util.Collections;
55 import java.util.List;
56
57
70 public class WikiNodePersistenceImpl extends BasePersistenceImpl
71 implements WikiNodePersistence {
72 public static final String FINDER_CLASS_NAME_ENTITY = WikiNodeImpl.class.getName();
73 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
74 ".List";
75 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
76 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
77 "findByUuid", new String[] { String.class.getName() });
78 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
79 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
80 "findByUuid",
81 new String[] {
82 String.class.getName(),
83
84 "java.lang.Integer", "java.lang.Integer",
85 "com.liferay.portal.kernel.util.OrderByComparator"
86 });
87 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
88 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
89 "countByUuid", new String[] { String.class.getName() });
90 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
91 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
92 "fetchByUUID_G",
93 new String[] { String.class.getName(), Long.class.getName() });
94 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
95 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
96 "countByUUID_G",
97 new String[] { String.class.getName(), Long.class.getName() });
98 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
99 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
100 "findByGroupId", new String[] { Long.class.getName() });
101 public static final FinderPath FINDER_PATH_FIND_BY_OBC_GROUPID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
102 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
103 "findByGroupId",
104 new String[] {
105 Long.class.getName(),
106
107 "java.lang.Integer", "java.lang.Integer",
108 "com.liferay.portal.kernel.util.OrderByComparator"
109 });
110 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
111 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
112 "countByGroupId", new String[] { Long.class.getName() });
113 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
114 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
115 "findByCompanyId", new String[] { Long.class.getName() });
116 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
117 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
118 "findByCompanyId",
119 new String[] {
120 Long.class.getName(),
121
122 "java.lang.Integer", "java.lang.Integer",
123 "com.liferay.portal.kernel.util.OrderByComparator"
124 });
125 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
126 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
127 "countByCompanyId", new String[] { Long.class.getName() });
128 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
129 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
130 "fetchByG_N",
131 new String[] { Long.class.getName(), String.class.getName() });
132 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
133 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
134 "countByG_N",
135 new String[] { Long.class.getName(), String.class.getName() });
136 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
137 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
138 "findAll", new String[0]);
139 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
140 WikiNodeModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
141 "countAll", new String[0]);
142
143 public void cacheResult(WikiNode wikiNode) {
144 EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
145 WikiNodeImpl.class, wikiNode.getPrimaryKey(), wikiNode);
146
147 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
148 new Object[] { wikiNode.getUuid(), new Long(wikiNode.getGroupId()) },
149 wikiNode);
150
151 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
152 new Object[] { new Long(wikiNode.getGroupId()), wikiNode.getName() },
153 wikiNode);
154 }
155
156 public void cacheResult(List<WikiNode> wikiNodes) {
157 for (WikiNode wikiNode : wikiNodes) {
158 if (EntityCacheUtil.getResult(
159 WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
160 WikiNodeImpl.class, wikiNode.getPrimaryKey(), this) == null) {
161 cacheResult(wikiNode);
162 }
163 }
164 }
165
166 public void clearCache() {
167 CacheRegistry.clear(WikiNodeImpl.class.getName());
168 EntityCacheUtil.clearCache(WikiNodeImpl.class.getName());
169 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
170 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
171 }
172
173 public WikiNode create(long nodeId) {
174 WikiNode wikiNode = new WikiNodeImpl();
175
176 wikiNode.setNew(true);
177 wikiNode.setPrimaryKey(nodeId);
178
179 String uuid = PortalUUIDUtil.generate();
180
181 wikiNode.setUuid(uuid);
182
183 return wikiNode;
184 }
185
186 public WikiNode remove(long nodeId)
187 throws NoSuchNodeException, SystemException {
188 Session session = null;
189
190 try {
191 session = openSession();
192
193 WikiNode wikiNode = (WikiNode)session.get(WikiNodeImpl.class,
194 new Long(nodeId));
195
196 if (wikiNode == null) {
197 if (_log.isWarnEnabled()) {
198 _log.warn("No WikiNode exists with the primary key " +
199 nodeId);
200 }
201
202 throw new NoSuchNodeException(
203 "No WikiNode exists with the primary key " + nodeId);
204 }
205
206 return remove(wikiNode);
207 }
208 catch (NoSuchNodeException nsee) {
209 throw nsee;
210 }
211 catch (Exception e) {
212 throw processException(e);
213 }
214 finally {
215 closeSession(session);
216 }
217 }
218
219 public WikiNode remove(WikiNode wikiNode) throws SystemException {
220 for (ModelListener<WikiNode> listener : listeners) {
221 listener.onBeforeRemove(wikiNode);
222 }
223
224 wikiNode = removeImpl(wikiNode);
225
226 for (ModelListener<WikiNode> listener : listeners) {
227 listener.onAfterRemove(wikiNode);
228 }
229
230 return wikiNode;
231 }
232
233 protected WikiNode removeImpl(WikiNode wikiNode) throws SystemException {
234 Session session = null;
235
236 try {
237 session = openSession();
238
239 if (wikiNode.isCachedModel() || BatchSessionUtil.isEnabled()) {
240 Object staleObject = session.get(WikiNodeImpl.class,
241 wikiNode.getPrimaryKeyObj());
242
243 if (staleObject != null) {
244 session.evict(staleObject);
245 }
246 }
247
248 session.delete(wikiNode);
249
250 session.flush();
251 }
252 catch (Exception e) {
253 throw processException(e);
254 }
255 finally {
256 closeSession(session);
257 }
258
259 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
260
261 WikiNodeModelImpl wikiNodeModelImpl = (WikiNodeModelImpl)wikiNode;
262
263 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
264 new Object[] {
265 wikiNodeModelImpl.getOriginalUuid(),
266 new Long(wikiNodeModelImpl.getOriginalGroupId())
267 });
268
269 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
270 new Object[] {
271 new Long(wikiNodeModelImpl.getOriginalGroupId()),
272
273 wikiNodeModelImpl.getOriginalName()
274 });
275
276 EntityCacheUtil.removeResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
277 WikiNodeImpl.class, wikiNode.getPrimaryKey());
278
279 return wikiNode;
280 }
281
282
285 public WikiNode update(WikiNode wikiNode) throws SystemException {
286 if (_log.isWarnEnabled()) {
287 _log.warn(
288 "Using the deprecated update(WikiNode wikiNode) method. Use update(WikiNode wikiNode, boolean merge) instead.");
289 }
290
291 return update(wikiNode, false);
292 }
293
294
306 public WikiNode update(WikiNode wikiNode, boolean merge)
307 throws SystemException {
308 boolean isNew = wikiNode.isNew();
309
310 for (ModelListener<WikiNode> listener : listeners) {
311 if (isNew) {
312 listener.onBeforeCreate(wikiNode);
313 }
314 else {
315 listener.onBeforeUpdate(wikiNode);
316 }
317 }
318
319 wikiNode = updateImpl(wikiNode, merge);
320
321 for (ModelListener<WikiNode> listener : listeners) {
322 if (isNew) {
323 listener.onAfterCreate(wikiNode);
324 }
325 else {
326 listener.onAfterUpdate(wikiNode);
327 }
328 }
329
330 return wikiNode;
331 }
332
333 public WikiNode updateImpl(
334 com.liferay.portlet.wiki.model.WikiNode wikiNode, boolean merge)
335 throws SystemException {
336 boolean isNew = wikiNode.isNew();
337
338 WikiNodeModelImpl wikiNodeModelImpl = (WikiNodeModelImpl)wikiNode;
339
340 if (Validator.isNull(wikiNode.getUuid())) {
341 String uuid = PortalUUIDUtil.generate();
342
343 wikiNode.setUuid(uuid);
344 }
345
346 Session session = null;
347
348 try {
349 session = openSession();
350
351 BatchSessionUtil.update(session, wikiNode, merge);
352
353 wikiNode.setNew(false);
354 }
355 catch (Exception e) {
356 throw processException(e);
357 }
358 finally {
359 closeSession(session);
360 }
361
362 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
363
364 EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
365 WikiNodeImpl.class, wikiNode.getPrimaryKey(), wikiNode);
366
367 if (!isNew &&
368 (!Validator.equals(wikiNode.getUuid(),
369 wikiNodeModelImpl.getOriginalUuid()) ||
370 (wikiNode.getGroupId() != wikiNodeModelImpl.getOriginalGroupId()))) {
371 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
372 new Object[] {
373 wikiNodeModelImpl.getOriginalUuid(),
374 new Long(wikiNodeModelImpl.getOriginalGroupId())
375 });
376 }
377
378 if (isNew ||
379 (!Validator.equals(wikiNode.getUuid(),
380 wikiNodeModelImpl.getOriginalUuid()) ||
381 (wikiNode.getGroupId() != wikiNodeModelImpl.getOriginalGroupId()))) {
382 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
383 new Object[] { wikiNode.getUuid(), new Long(
384 wikiNode.getGroupId()) }, wikiNode);
385 }
386
387 if (!isNew &&
388 ((wikiNode.getGroupId() != wikiNodeModelImpl.getOriginalGroupId()) ||
389 !Validator.equals(wikiNode.getName(),
390 wikiNodeModelImpl.getOriginalName()))) {
391 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
392 new Object[] {
393 new Long(wikiNodeModelImpl.getOriginalGroupId()),
394
395 wikiNodeModelImpl.getOriginalName()
396 });
397 }
398
399 if (isNew ||
400 ((wikiNode.getGroupId() != wikiNodeModelImpl.getOriginalGroupId()) ||
401 !Validator.equals(wikiNode.getName(),
402 wikiNodeModelImpl.getOriginalName()))) {
403 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
404 new Object[] { new Long(wikiNode.getGroupId()), wikiNode.getName() },
405 wikiNode);
406 }
407
408 return wikiNode;
409 }
410
411 public WikiNode findByPrimaryKey(long nodeId)
412 throws NoSuchNodeException, SystemException {
413 WikiNode wikiNode = fetchByPrimaryKey(nodeId);
414
415 if (wikiNode == null) {
416 if (_log.isWarnEnabled()) {
417 _log.warn("No WikiNode exists with the primary key " + nodeId);
418 }
419
420 throw new NoSuchNodeException(
421 "No WikiNode exists with the primary key " + nodeId);
422 }
423
424 return wikiNode;
425 }
426
427 public WikiNode fetchByPrimaryKey(long nodeId) throws SystemException {
428 WikiNode wikiNode = (WikiNode)EntityCacheUtil.getResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED,
429 WikiNodeImpl.class, nodeId, this);
430
431 if (wikiNode == null) {
432 Session session = null;
433
434 try {
435 session = openSession();
436
437 wikiNode = (WikiNode)session.get(WikiNodeImpl.class,
438 new Long(nodeId));
439 }
440 catch (Exception e) {
441 throw processException(e);
442 }
443 finally {
444 if (wikiNode != null) {
445 cacheResult(wikiNode);
446 }
447
448 closeSession(session);
449 }
450 }
451
452 return wikiNode;
453 }
454
455 public List<WikiNode> findByUuid(String uuid) throws SystemException {
456 Object[] finderArgs = new Object[] { uuid };
457
458 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
459 finderArgs, this);
460
461 if (list == null) {
462 Session session = null;
463
464 try {
465 session = openSession();
466
467 StringBuilder query = new StringBuilder();
468
469 query.append("SELECT wikiNode FROM WikiNode wikiNode WHERE ");
470
471 if (uuid == null) {
472 query.append("wikiNode.uuid IS NULL");
473 }
474 else {
475 query.append("wikiNode.uuid = ?");
476 }
477
478 query.append(" ");
479
480 query.append("ORDER BY ");
481
482 query.append("wikiNode.name ASC");
483
484 Query q = session.createQuery(query.toString());
485
486 QueryPos qPos = QueryPos.getInstance(q);
487
488 if (uuid != null) {
489 qPos.add(uuid);
490 }
491
492 list = q.list();
493 }
494 catch (Exception e) {
495 throw processException(e);
496 }
497 finally {
498 if (list == null) {
499 list = new ArrayList<WikiNode>();
500 }
501
502 cacheResult(list);
503
504 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
505 list);
506
507 closeSession(session);
508 }
509 }
510
511 return list;
512 }
513
514 public List<WikiNode> findByUuid(String uuid, int start, int end)
515 throws SystemException {
516 return findByUuid(uuid, start, end, null);
517 }
518
519 public List<WikiNode> findByUuid(String uuid, int start, int end,
520 OrderByComparator obc) throws SystemException {
521 Object[] finderArgs = new Object[] {
522 uuid,
523
524 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
525 };
526
527 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
528 finderArgs, this);
529
530 if (list == null) {
531 Session session = null;
532
533 try {
534 session = openSession();
535
536 StringBuilder query = new StringBuilder();
537
538 query.append("SELECT wikiNode FROM WikiNode wikiNode WHERE ");
539
540 if (uuid == null) {
541 query.append("wikiNode.uuid IS NULL");
542 }
543 else {
544 query.append("wikiNode.uuid = ?");
545 }
546
547 query.append(" ");
548
549 if (obc != null) {
550 query.append("ORDER BY ");
551
552 String[] orderByFields = obc.getOrderByFields();
553
554 for (int i = 0; i < orderByFields.length; i++) {
555 query.append("wikiNode.");
556 query.append(orderByFields[i]);
557
558 if (obc.isAscending()) {
559 query.append(" ASC");
560 }
561 else {
562 query.append(" DESC");
563 }
564
565 if ((i + 1) < orderByFields.length) {
566 query.append(", ");
567 }
568 }
569 }
570
571 else {
572 query.append("ORDER BY ");
573
574 query.append("wikiNode.name ASC");
575 }
576
577 Query q = session.createQuery(query.toString());
578
579 QueryPos qPos = QueryPos.getInstance(q);
580
581 if (uuid != null) {
582 qPos.add(uuid);
583 }
584
585 list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
586 end);
587 }
588 catch (Exception e) {
589 throw processException(e);
590 }
591 finally {
592 if (list == null) {
593 list = new ArrayList<WikiNode>();
594 }
595
596 cacheResult(list);
597
598 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
599 finderArgs, list);
600
601 closeSession(session);
602 }
603 }
604
605 return list;
606 }
607
608 public WikiNode findByUuid_First(String uuid, OrderByComparator obc)
609 throws NoSuchNodeException, SystemException {
610 List<WikiNode> list = findByUuid(uuid, 0, 1, obc);
611
612 if (list.isEmpty()) {
613 StringBuilder msg = new StringBuilder();
614
615 msg.append("No WikiNode exists with the key {");
616
617 msg.append("uuid=" + uuid);
618
619 msg.append(StringPool.CLOSE_CURLY_BRACE);
620
621 throw new NoSuchNodeException(msg.toString());
622 }
623 else {
624 return list.get(0);
625 }
626 }
627
628 public WikiNode findByUuid_Last(String uuid, OrderByComparator obc)
629 throws NoSuchNodeException, SystemException {
630 int count = countByUuid(uuid);
631
632 List<WikiNode> list = findByUuid(uuid, count - 1, count, obc);
633
634 if (list.isEmpty()) {
635 StringBuilder msg = new StringBuilder();
636
637 msg.append("No WikiNode exists with the key {");
638
639 msg.append("uuid=" + uuid);
640
641 msg.append(StringPool.CLOSE_CURLY_BRACE);
642
643 throw new NoSuchNodeException(msg.toString());
644 }
645 else {
646 return list.get(0);
647 }
648 }
649
650 public WikiNode[] findByUuid_PrevAndNext(long nodeId, String uuid,
651 OrderByComparator obc) throws NoSuchNodeException, SystemException {
652 WikiNode wikiNode = findByPrimaryKey(nodeId);
653
654 int count = countByUuid(uuid);
655
656 Session session = null;
657
658 try {
659 session = openSession();
660
661 StringBuilder query = new StringBuilder();
662
663 query.append("SELECT wikiNode FROM WikiNode wikiNode WHERE ");
664
665 if (uuid == null) {
666 query.append("wikiNode.uuid IS NULL");
667 }
668 else {
669 query.append("wikiNode.uuid = ?");
670 }
671
672 query.append(" ");
673
674 if (obc != null) {
675 query.append("ORDER BY ");
676
677 String[] orderByFields = obc.getOrderByFields();
678
679 for (int i = 0; i < orderByFields.length; i++) {
680 query.append("wikiNode.");
681 query.append(orderByFields[i]);
682
683 if (obc.isAscending()) {
684 query.append(" ASC");
685 }
686 else {
687 query.append(" DESC");
688 }
689
690 if ((i + 1) < orderByFields.length) {
691 query.append(", ");
692 }
693 }
694 }
695
696 else {
697 query.append("ORDER BY ");
698
699 query.append("wikiNode.name ASC");
700 }
701
702 Query q = session.createQuery(query.toString());
703
704 QueryPos qPos = QueryPos.getInstance(q);
705
706 if (uuid != null) {
707 qPos.add(uuid);
708 }
709
710 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiNode);
711
712 WikiNode[] array = new WikiNodeImpl[3];
713
714 array[0] = (WikiNode)objArray[0];
715 array[1] = (WikiNode)objArray[1];
716 array[2] = (WikiNode)objArray[2];
717
718 return array;
719 }
720 catch (Exception e) {
721 throw processException(e);
722 }
723 finally {
724 closeSession(session);
725 }
726 }
727
728 public WikiNode findByUUID_G(String uuid, long groupId)
729 throws NoSuchNodeException, SystemException {
730 WikiNode wikiNode = fetchByUUID_G(uuid, groupId);
731
732 if (wikiNode == null) {
733 StringBuilder msg = new StringBuilder();
734
735 msg.append("No WikiNode exists with the key {");
736
737 msg.append("uuid=" + uuid);
738
739 msg.append(", ");
740 msg.append("groupId=" + groupId);
741
742 msg.append(StringPool.CLOSE_CURLY_BRACE);
743
744 if (_log.isWarnEnabled()) {
745 _log.warn(msg.toString());
746 }
747
748 throw new NoSuchNodeException(msg.toString());
749 }
750
751 return wikiNode;
752 }
753
754 public WikiNode fetchByUUID_G(String uuid, long groupId)
755 throws SystemException {
756 return fetchByUUID_G(uuid, groupId, true);
757 }
758
759 public WikiNode fetchByUUID_G(String uuid, long groupId,
760 boolean retrieveFromCache) throws SystemException {
761 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
762
763 Object result = null;
764
765 if (retrieveFromCache) {
766 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
767 finderArgs, this);
768 }
769
770 if (result == null) {
771 Session session = null;
772
773 try {
774 session = openSession();
775
776 StringBuilder query = new StringBuilder();
777
778 query.append("SELECT wikiNode FROM WikiNode wikiNode WHERE ");
779
780 if (uuid == null) {
781 query.append("wikiNode.uuid IS NULL");
782 }
783 else {
784 query.append("wikiNode.uuid = ?");
785 }
786
787 query.append(" AND ");
788
789 query.append("wikiNode.groupId = ?");
790
791 query.append(" ");
792
793 query.append("ORDER BY ");
794
795 query.append("wikiNode.name ASC");
796
797 Query q = session.createQuery(query.toString());
798
799 QueryPos qPos = QueryPos.getInstance(q);
800
801 if (uuid != null) {
802 qPos.add(uuid);
803 }
804
805 qPos.add(groupId);
806
807 List<WikiNode> list = q.list();
808
809 result = list;
810
811 WikiNode wikiNode = null;
812
813 if (list.isEmpty()) {
814 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
815 finderArgs, list);
816 }
817 else {
818 wikiNode = list.get(0);
819
820 cacheResult(wikiNode);
821
822 if ((wikiNode.getUuid() == null) ||
823 !wikiNode.getUuid().equals(uuid) ||
824 (wikiNode.getGroupId() != groupId)) {
825 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
826 finderArgs, wikiNode);
827 }
828 }
829
830 return wikiNode;
831 }
832 catch (Exception e) {
833 throw processException(e);
834 }
835 finally {
836 if (result == null) {
837 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
838 finderArgs, new ArrayList<WikiNode>());
839 }
840
841 closeSession(session);
842 }
843 }
844 else {
845 if (result instanceof List<?>) {
846 return null;
847 }
848 else {
849 return (WikiNode)result;
850 }
851 }
852 }
853
854 public List<WikiNode> findByGroupId(long groupId) throws SystemException {
855 Object[] finderArgs = new Object[] { new Long(groupId) };
856
857 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
858 finderArgs, this);
859
860 if (list == null) {
861 Session session = null;
862
863 try {
864 session = openSession();
865
866 StringBuilder query = new StringBuilder();
867
868 query.append("SELECT wikiNode FROM WikiNode wikiNode WHERE ");
869
870 query.append("wikiNode.groupId = ?");
871
872 query.append(" ");
873
874 query.append("ORDER BY ");
875
876 query.append("wikiNode.name ASC");
877
878 Query q = session.createQuery(query.toString());
879
880 QueryPos qPos = QueryPos.getInstance(q);
881
882 qPos.add(groupId);
883
884 list = q.list();
885 }
886 catch (Exception e) {
887 throw processException(e);
888 }
889 finally {
890 if (list == null) {
891 list = new ArrayList<WikiNode>();
892 }
893
894 cacheResult(list);
895
896 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
897 finderArgs, list);
898
899 closeSession(session);
900 }
901 }
902
903 return list;
904 }
905
906 public List<WikiNode> findByGroupId(long groupId, int start, int end)
907 throws SystemException {
908 return findByGroupId(groupId, start, end, null);
909 }
910
911 public List<WikiNode> findByGroupId(long groupId, int start, int end,
912 OrderByComparator obc) throws SystemException {
913 Object[] finderArgs = new Object[] {
914 new Long(groupId),
915
916 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
917 };
918
919 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
920 finderArgs, this);
921
922 if (list == null) {
923 Session session = null;
924
925 try {
926 session = openSession();
927
928 StringBuilder query = new StringBuilder();
929
930 query.append("SELECT wikiNode FROM WikiNode wikiNode WHERE ");
931
932 query.append("wikiNode.groupId = ?");
933
934 query.append(" ");
935
936 if (obc != null) {
937 query.append("ORDER BY ");
938
939 String[] orderByFields = obc.getOrderByFields();
940
941 for (int i = 0; i < orderByFields.length; i++) {
942 query.append("wikiNode.");
943 query.append(orderByFields[i]);
944
945 if (obc.isAscending()) {
946 query.append(" ASC");
947 }
948 else {
949 query.append(" DESC");
950 }
951
952 if ((i + 1) < orderByFields.length) {
953 query.append(", ");
954 }
955 }
956 }
957
958 else {
959 query.append("ORDER BY ");
960
961 query.append("wikiNode.name ASC");
962 }
963
964 Query q = session.createQuery(query.toString());
965
966 QueryPos qPos = QueryPos.getInstance(q);
967
968 qPos.add(groupId);
969
970 list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
971 end);
972 }
973 catch (Exception e) {
974 throw processException(e);
975 }
976 finally {
977 if (list == null) {
978 list = new ArrayList<WikiNode>();
979 }
980
981 cacheResult(list);
982
983 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_GROUPID,
984 finderArgs, list);
985
986 closeSession(session);
987 }
988 }
989
990 return list;
991 }
992
993 public WikiNode findByGroupId_First(long groupId, OrderByComparator obc)
994 throws NoSuchNodeException, SystemException {
995 List<WikiNode> list = findByGroupId(groupId, 0, 1, obc);
996
997 if (list.isEmpty()) {
998 StringBuilder msg = new StringBuilder();
999
1000 msg.append("No WikiNode exists with the key {");
1001
1002 msg.append("groupId=" + groupId);
1003
1004 msg.append(StringPool.CLOSE_CURLY_BRACE);
1005
1006 throw new NoSuchNodeException(msg.toString());
1007 }
1008 else {
1009 return list.get(0);
1010 }
1011 }
1012
1013 public WikiNode findByGroupId_Last(long groupId, OrderByComparator obc)
1014 throws NoSuchNodeException, SystemException {
1015 int count = countByGroupId(groupId);
1016
1017 List<WikiNode> list = findByGroupId(groupId, count - 1, count, obc);
1018
1019 if (list.isEmpty()) {
1020 StringBuilder msg = new StringBuilder();
1021
1022 msg.append("No WikiNode exists with the key {");
1023
1024 msg.append("groupId=" + groupId);
1025
1026 msg.append(StringPool.CLOSE_CURLY_BRACE);
1027
1028 throw new NoSuchNodeException(msg.toString());
1029 }
1030 else {
1031 return list.get(0);
1032 }
1033 }
1034
1035 public WikiNode[] findByGroupId_PrevAndNext(long nodeId, long groupId,
1036 OrderByComparator obc) throws NoSuchNodeException, SystemException {
1037 WikiNode wikiNode = findByPrimaryKey(nodeId);
1038
1039 int count = countByGroupId(groupId);
1040
1041 Session session = null;
1042
1043 try {
1044 session = openSession();
1045
1046 StringBuilder query = new StringBuilder();
1047
1048 query.append("SELECT wikiNode FROM WikiNode wikiNode WHERE ");
1049
1050 query.append("wikiNode.groupId = ?");
1051
1052 query.append(" ");
1053
1054 if (obc != null) {
1055 query.append("ORDER BY ");
1056
1057 String[] orderByFields = obc.getOrderByFields();
1058
1059 for (int i = 0; i < orderByFields.length; i++) {
1060 query.append("wikiNode.");
1061 query.append(orderByFields[i]);
1062
1063 if (obc.isAscending()) {
1064 query.append(" ASC");
1065 }
1066 else {
1067 query.append(" DESC");
1068 }
1069
1070 if ((i + 1) < orderByFields.length) {
1071 query.append(", ");
1072 }
1073 }
1074 }
1075
1076 else {
1077 query.append("ORDER BY ");
1078
1079 query.append("wikiNode.name ASC");
1080 }
1081
1082 Query q = session.createQuery(query.toString());
1083
1084 QueryPos qPos = QueryPos.getInstance(q);
1085
1086 qPos.add(groupId);
1087
1088 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiNode);
1089
1090 WikiNode[] array = new WikiNodeImpl[3];
1091
1092 array[0] = (WikiNode)objArray[0];
1093 array[1] = (WikiNode)objArray[1];
1094 array[2] = (WikiNode)objArray[2];
1095
1096 return array;
1097 }
1098 catch (Exception e) {
1099 throw processException(e);
1100 }
1101 finally {
1102 closeSession(session);
1103 }
1104 }
1105
1106 public List<WikiNode> findByCompanyId(long companyId)
1107 throws SystemException {
1108 Object[] finderArgs = new Object[] { new Long(companyId) };
1109
1110 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
1111 finderArgs, this);
1112
1113 if (list == null) {
1114 Session session = null;
1115
1116 try {
1117 session = openSession();
1118
1119 StringBuilder query = new StringBuilder();
1120
1121 query.append("SELECT wikiNode FROM WikiNode wikiNode WHERE ");
1122
1123 query.append("wikiNode.companyId = ?");
1124
1125 query.append(" ");
1126
1127 query.append("ORDER BY ");
1128
1129 query.append("wikiNode.name ASC");
1130
1131 Query q = session.createQuery(query.toString());
1132
1133 QueryPos qPos = QueryPos.getInstance(q);
1134
1135 qPos.add(companyId);
1136
1137 list = q.list();
1138 }
1139 catch (Exception e) {
1140 throw processException(e);
1141 }
1142 finally {
1143 if (list == null) {
1144 list = new ArrayList<WikiNode>();
1145 }
1146
1147 cacheResult(list);
1148
1149 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1150 finderArgs, list);
1151
1152 closeSession(session);
1153 }
1154 }
1155
1156 return list;
1157 }
1158
1159 public List<WikiNode> findByCompanyId(long companyId, int start, int end)
1160 throws SystemException {
1161 return findByCompanyId(companyId, start, end, null);
1162 }
1163
1164 public List<WikiNode> findByCompanyId(long companyId, int start, int end,
1165 OrderByComparator obc) throws SystemException {
1166 Object[] finderArgs = new Object[] {
1167 new Long(companyId),
1168
1169 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1170 };
1171
1172 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1173 finderArgs, this);
1174
1175 if (list == null) {
1176 Session session = null;
1177
1178 try {
1179 session = openSession();
1180
1181 StringBuilder query = new StringBuilder();
1182
1183 query.append("SELECT wikiNode FROM WikiNode wikiNode WHERE ");
1184
1185 query.append("wikiNode.companyId = ?");
1186
1187 query.append(" ");
1188
1189 if (obc != null) {
1190 query.append("ORDER BY ");
1191
1192 String[] orderByFields = obc.getOrderByFields();
1193
1194 for (int i = 0; i < orderByFields.length; i++) {
1195 query.append("wikiNode.");
1196 query.append(orderByFields[i]);
1197
1198 if (obc.isAscending()) {
1199 query.append(" ASC");
1200 }
1201 else {
1202 query.append(" DESC");
1203 }
1204
1205 if ((i + 1) < orderByFields.length) {
1206 query.append(", ");
1207 }
1208 }
1209 }
1210
1211 else {
1212 query.append("ORDER BY ");
1213
1214 query.append("wikiNode.name ASC");
1215 }
1216
1217 Query q = session.createQuery(query.toString());
1218
1219 QueryPos qPos = QueryPos.getInstance(q);
1220
1221 qPos.add(companyId);
1222
1223 list = (List<WikiNode>)QueryUtil.list(q, getDialect(), start,
1224 end);
1225 }
1226 catch (Exception e) {
1227 throw processException(e);
1228 }
1229 finally {
1230 if (list == null) {
1231 list = new ArrayList<WikiNode>();
1232 }
1233
1234 cacheResult(list);
1235
1236 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1237 finderArgs, list);
1238
1239 closeSession(session);
1240 }
1241 }
1242
1243 return list;
1244 }
1245
1246 public WikiNode findByCompanyId_First(long companyId, OrderByComparator obc)
1247 throws NoSuchNodeException, SystemException {
1248 List<WikiNode> list = findByCompanyId(companyId, 0, 1, obc);
1249
1250 if (list.isEmpty()) {
1251 StringBuilder msg = new StringBuilder();
1252
1253 msg.append("No WikiNode exists with the key {");
1254
1255 msg.append("companyId=" + companyId);
1256
1257 msg.append(StringPool.CLOSE_CURLY_BRACE);
1258
1259 throw new NoSuchNodeException(msg.toString());
1260 }
1261 else {
1262 return list.get(0);
1263 }
1264 }
1265
1266 public WikiNode findByCompanyId_Last(long companyId, OrderByComparator obc)
1267 throws NoSuchNodeException, SystemException {
1268 int count = countByCompanyId(companyId);
1269
1270 List<WikiNode> list = findByCompanyId(companyId, count - 1, count, obc);
1271
1272 if (list.isEmpty()) {
1273 StringBuilder msg = new StringBuilder();
1274
1275 msg.append("No WikiNode exists with the key {");
1276
1277 msg.append("companyId=" + companyId);
1278
1279 msg.append(StringPool.CLOSE_CURLY_BRACE);
1280
1281 throw new NoSuchNodeException(msg.toString());
1282 }
1283 else {
1284 return list.get(0);
1285 }
1286 }
1287
1288 public WikiNode[] findByCompanyId_PrevAndNext(long nodeId, long companyId,
1289 OrderByComparator obc) throws NoSuchNodeException, SystemException {
1290 WikiNode wikiNode = findByPrimaryKey(nodeId);
1291
1292 int count = countByCompanyId(companyId);
1293
1294 Session session = null;
1295
1296 try {
1297 session = openSession();
1298
1299 StringBuilder query = new StringBuilder();
1300
1301 query.append("SELECT wikiNode FROM WikiNode wikiNode WHERE ");
1302
1303 query.append("wikiNode.companyId = ?");
1304
1305 query.append(" ");
1306
1307 if (obc != null) {
1308 query.append("ORDER BY ");
1309
1310 String[] orderByFields = obc.getOrderByFields();
1311
1312 for (int i = 0; i < orderByFields.length; i++) {
1313 query.append("wikiNode.");
1314 query.append(orderByFields[i]);
1315
1316 if (obc.isAscending()) {
1317 query.append(" ASC");
1318 }
1319 else {
1320 query.append(" DESC");
1321 }
1322
1323 if ((i + 1) < orderByFields.length) {
1324 query.append(", ");
1325 }
1326 }
1327 }
1328
1329 else {
1330 query.append("ORDER BY ");
1331
1332 query.append("wikiNode.name ASC");
1333 }
1334
1335 Query q = session.createQuery(query.toString());
1336
1337 QueryPos qPos = QueryPos.getInstance(q);
1338
1339 qPos.add(companyId);
1340
1341 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiNode);
1342
1343 WikiNode[] array = new WikiNodeImpl[3];
1344
1345 array[0] = (WikiNode)objArray[0];
1346 array[1] = (WikiNode)objArray[1];
1347 array[2] = (WikiNode)objArray[2];
1348
1349 return array;
1350 }
1351 catch (Exception e) {
1352 throw processException(e);
1353 }
1354 finally {
1355 closeSession(session);
1356 }
1357 }
1358
1359 public WikiNode findByG_N(long groupId, String name)
1360 throws NoSuchNodeException, SystemException {
1361 WikiNode wikiNode = fetchByG_N(groupId, name);
1362
1363 if (wikiNode == null) {
1364 StringBuilder msg = new StringBuilder();
1365
1366 msg.append("No WikiNode exists with the key {");
1367
1368 msg.append("groupId=" + groupId);
1369
1370 msg.append(", ");
1371 msg.append("name=" + name);
1372
1373 msg.append(StringPool.CLOSE_CURLY_BRACE);
1374
1375 if (_log.isWarnEnabled()) {
1376 _log.warn(msg.toString());
1377 }
1378
1379 throw new NoSuchNodeException(msg.toString());
1380 }
1381
1382 return wikiNode;
1383 }
1384
1385 public WikiNode fetchByG_N(long groupId, String name)
1386 throws SystemException {
1387 return fetchByG_N(groupId, name, true);
1388 }
1389
1390 public WikiNode fetchByG_N(long groupId, String name,
1391 boolean retrieveFromCache) throws SystemException {
1392 Object[] finderArgs = new Object[] { new Long(groupId), name };
1393
1394 Object result = null;
1395
1396 if (retrieveFromCache) {
1397 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
1398 finderArgs, this);
1399 }
1400
1401 if (result == null) {
1402 Session session = null;
1403
1404 try {
1405 session = openSession();
1406
1407 StringBuilder query = new StringBuilder();
1408
1409 query.append("SELECT wikiNode FROM WikiNode wikiNode WHERE ");
1410
1411 query.append("wikiNode.groupId = ?");
1412
1413 query.append(" AND ");
1414
1415 if (name == null) {
1416 query.append("wikiNode.name IS NULL");
1417 }
1418 else {
1419 query.append("wikiNode.name = ?");
1420 }
1421
1422 query.append(" ");
1423
1424 query.append("ORDER BY ");
1425
1426 query.append("wikiNode.name ASC");
1427
1428 Query q = session.createQuery(query.toString());
1429
1430 QueryPos qPos = QueryPos.getInstance(q);
1431
1432 qPos.add(groupId);
1433
1434 if (name != null) {
1435 qPos.add(name);
1436 }
1437
1438 List<WikiNode> list = q.list();
1439
1440 result = list;
1441
1442 WikiNode wikiNode = null;
1443
1444 if (list.isEmpty()) {
1445 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1446 finderArgs, list);
1447 }
1448 else {
1449 wikiNode = list.get(0);
1450
1451 cacheResult(wikiNode);
1452
1453 if ((wikiNode.getGroupId() != groupId) ||
1454 (wikiNode.getName() == null) ||
1455 !wikiNode.getName().equals(name)) {
1456 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1457 finderArgs, wikiNode);
1458 }
1459 }
1460
1461 return wikiNode;
1462 }
1463 catch (Exception e) {
1464 throw processException(e);
1465 }
1466 finally {
1467 if (result == null) {
1468 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1469 finderArgs, new ArrayList<WikiNode>());
1470 }
1471
1472 closeSession(session);
1473 }
1474 }
1475 else {
1476 if (result instanceof List<?>) {
1477 return null;
1478 }
1479 else {
1480 return (WikiNode)result;
1481 }
1482 }
1483 }
1484
1485 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1486 throws SystemException {
1487 Session session = null;
1488
1489 try {
1490 session = openSession();
1491
1492 dynamicQuery.compile(session);
1493
1494 return dynamicQuery.list();
1495 }
1496 catch (Exception e) {
1497 throw processException(e);
1498 }
1499 finally {
1500 closeSession(session);
1501 }
1502 }
1503
1504 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1505 int start, int end) throws SystemException {
1506 Session session = null;
1507
1508 try {
1509 session = openSession();
1510
1511 dynamicQuery.setLimit(start, end);
1512
1513 dynamicQuery.compile(session);
1514
1515 return dynamicQuery.list();
1516 }
1517 catch (Exception e) {
1518 throw processException(e);
1519 }
1520 finally {
1521 closeSession(session);
1522 }
1523 }
1524
1525 public List<WikiNode> findAll() throws SystemException {
1526 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1527 }
1528
1529 public List<WikiNode> findAll(int start, int end) throws SystemException {
1530 return findAll(start, end, null);
1531 }
1532
1533 public List<WikiNode> findAll(int start, int end, OrderByComparator obc)
1534 throws SystemException {
1535 Object[] finderArgs = new Object[] {
1536 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1537 };
1538
1539 List<WikiNode> list = (List<WikiNode>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1540 finderArgs, this);
1541
1542 if (list == null) {
1543 Session session = null;
1544
1545 try {
1546 session = openSession();
1547
1548 StringBuilder query = new StringBuilder();
1549
1550 query.append("SELECT wikiNode FROM WikiNode wikiNode ");
1551
1552 if (obc != null) {
1553 query.append("ORDER BY ");
1554
1555 String[] orderByFields = obc.getOrderByFields();
1556
1557 for (int i = 0; i < orderByFields.length; i++) {
1558 query.append("wikiNode.");
1559 query.append(orderByFields[i]);
1560
1561 if (obc.isAscending()) {
1562 query.append(" ASC");
1563 }
1564 else {
1565 query.append(" DESC");
1566 }
1567
1568 if ((i + 1) < orderByFields.length) {
1569 query.append(", ");
1570 }
1571 }
1572 }
1573
1574 else {
1575 query.append("ORDER BY ");
1576
1577 query.append("wikiNode.name ASC");
1578 }
1579
1580 Query q = session.createQuery(query.toString());
1581
1582 if (obc == null) {
1583 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
1584 start, end, false);
1585
1586 Collections.sort(list);
1587 }
1588 else {
1589 list = (List<WikiNode>)QueryUtil.list(q, getDialect(),
1590 start, end);
1591 }
1592 }
1593 catch (Exception e) {
1594 throw processException(e);
1595 }
1596 finally {
1597 if (list == null) {
1598 list = new ArrayList<WikiNode>();
1599 }
1600
1601 cacheResult(list);
1602
1603 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1604
1605 closeSession(session);
1606 }
1607 }
1608
1609 return list;
1610 }
1611
1612 public void removeByUuid(String uuid) throws SystemException {
1613 for (WikiNode wikiNode : findByUuid(uuid)) {
1614 remove(wikiNode);
1615 }
1616 }
1617
1618 public void removeByUUID_G(String uuid, long groupId)
1619 throws NoSuchNodeException, SystemException {
1620 WikiNode wikiNode = findByUUID_G(uuid, groupId);
1621
1622 remove(wikiNode);
1623 }
1624
1625 public void removeByGroupId(long groupId) throws SystemException {
1626 for (WikiNode wikiNode : findByGroupId(groupId)) {
1627 remove(wikiNode);
1628 }
1629 }
1630
1631 public void removeByCompanyId(long companyId) throws SystemException {
1632 for (WikiNode wikiNode : findByCompanyId(companyId)) {
1633 remove(wikiNode);
1634 }
1635 }
1636
1637 public void removeByG_N(long groupId, String name)
1638 throws NoSuchNodeException, SystemException {
1639 WikiNode wikiNode = findByG_N(groupId, name);
1640
1641 remove(wikiNode);
1642 }
1643
1644 public void removeAll() throws SystemException {
1645 for (WikiNode wikiNode : findAll()) {
1646 remove(wikiNode);
1647 }
1648 }
1649
1650 public int countByUuid(String uuid) throws SystemException {
1651 Object[] finderArgs = new Object[] { uuid };
1652
1653 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
1654 finderArgs, this);
1655
1656 if (count == null) {
1657 Session session = null;
1658
1659 try {
1660 session = openSession();
1661
1662 StringBuilder query = new StringBuilder();
1663
1664 query.append("SELECT COUNT(wikiNode) ");
1665 query.append("FROM WikiNode wikiNode WHERE ");
1666
1667 if (uuid == null) {
1668 query.append("wikiNode.uuid IS NULL");
1669 }
1670 else {
1671 query.append("wikiNode.uuid = ?");
1672 }
1673
1674 query.append(" ");
1675
1676 Query q = session.createQuery(query.toString());
1677
1678 QueryPos qPos = QueryPos.getInstance(q);
1679
1680 if (uuid != null) {
1681 qPos.add(uuid);
1682 }
1683
1684 count = (Long)q.uniqueResult();
1685 }
1686 catch (Exception e) {
1687 throw processException(e);
1688 }
1689 finally {
1690 if (count == null) {
1691 count = Long.valueOf(0);
1692 }
1693
1694 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
1695 finderArgs, count);
1696
1697 closeSession(session);
1698 }
1699 }
1700
1701 return count.intValue();
1702 }
1703
1704 public int countByUUID_G(String uuid, long groupId)
1705 throws SystemException {
1706 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1707
1708 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
1709 finderArgs, this);
1710
1711 if (count == null) {
1712 Session session = null;
1713
1714 try {
1715 session = openSession();
1716
1717 StringBuilder query = new StringBuilder();
1718
1719 query.append("SELECT COUNT(wikiNode) ");
1720 query.append("FROM WikiNode wikiNode WHERE ");
1721
1722 if (uuid == null) {
1723 query.append("wikiNode.uuid IS NULL");
1724 }
1725 else {
1726 query.append("wikiNode.uuid = ?");
1727 }
1728
1729 query.append(" AND ");
1730
1731 query.append("wikiNode.groupId = ?");
1732
1733 query.append(" ");
1734
1735 Query q = session.createQuery(query.toString());
1736
1737 QueryPos qPos = QueryPos.getInstance(q);
1738
1739 if (uuid != null) {
1740 qPos.add(uuid);
1741 }
1742
1743 qPos.add(groupId);
1744
1745 count = (Long)q.uniqueResult();
1746 }
1747 catch (Exception e) {
1748 throw processException(e);
1749 }
1750 finally {
1751 if (count == null) {
1752 count = Long.valueOf(0);
1753 }
1754
1755 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
1756 finderArgs, count);
1757
1758 closeSession(session);
1759 }
1760 }
1761
1762 return count.intValue();
1763 }
1764
1765 public int countByGroupId(long groupId) throws SystemException {
1766 Object[] finderArgs = new Object[] { new Long(groupId) };
1767
1768 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1769 finderArgs, this);
1770
1771 if (count == null) {
1772 Session session = null;
1773
1774 try {
1775 session = openSession();
1776
1777 StringBuilder query = new StringBuilder();
1778
1779 query.append("SELECT COUNT(wikiNode) ");
1780 query.append("FROM WikiNode wikiNode WHERE ");
1781
1782 query.append("wikiNode.groupId = ?");
1783
1784 query.append(" ");
1785
1786 Query q = session.createQuery(query.toString());
1787
1788 QueryPos qPos = QueryPos.getInstance(q);
1789
1790 qPos.add(groupId);
1791
1792 count = (Long)q.uniqueResult();
1793 }
1794 catch (Exception e) {
1795 throw processException(e);
1796 }
1797 finally {
1798 if (count == null) {
1799 count = Long.valueOf(0);
1800 }
1801
1802 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1803 finderArgs, count);
1804
1805 closeSession(session);
1806 }
1807 }
1808
1809 return count.intValue();
1810 }
1811
1812 public int countByCompanyId(long companyId) throws SystemException {
1813 Object[] finderArgs = new Object[] { new Long(companyId) };
1814
1815 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1816 finderArgs, this);
1817
1818 if (count == null) {
1819 Session session = null;
1820
1821 try {
1822 session = openSession();
1823
1824 StringBuilder query = new StringBuilder();
1825
1826 query.append("SELECT COUNT(wikiNode) ");
1827 query.append("FROM WikiNode wikiNode WHERE ");
1828
1829 query.append("wikiNode.companyId = ?");
1830
1831 query.append(" ");
1832
1833 Query q = session.createQuery(query.toString());
1834
1835 QueryPos qPos = QueryPos.getInstance(q);
1836
1837 qPos.add(companyId);
1838
1839 count = (Long)q.uniqueResult();
1840 }
1841 catch (Exception e) {
1842 throw processException(e);
1843 }
1844 finally {
1845 if (count == null) {
1846 count = Long.valueOf(0);
1847 }
1848
1849 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1850 finderArgs, count);
1851
1852 closeSession(session);
1853 }
1854 }
1855
1856 return count.intValue();
1857 }
1858
1859 public int countByG_N(long groupId, String name) throws SystemException {
1860 Object[] finderArgs = new Object[] { new Long(groupId), name };
1861
1862 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
1863 finderArgs, this);
1864
1865 if (count == null) {
1866 Session session = null;
1867
1868 try {
1869 session = openSession();
1870
1871 StringBuilder query = new StringBuilder();
1872
1873 query.append("SELECT COUNT(wikiNode) ");
1874 query.append("FROM WikiNode wikiNode WHERE ");
1875
1876 query.append("wikiNode.groupId = ?");
1877
1878 query.append(" AND ");
1879
1880 if (name == null) {
1881 query.append("wikiNode.name IS NULL");
1882 }
1883 else {
1884 query.append("wikiNode.name = ?");
1885 }
1886
1887 query.append(" ");
1888
1889 Query q = session.createQuery(query.toString());
1890
1891 QueryPos qPos = QueryPos.getInstance(q);
1892
1893 qPos.add(groupId);
1894
1895 if (name != null) {
1896 qPos.add(name);
1897 }
1898
1899 count = (Long)q.uniqueResult();
1900 }
1901 catch (Exception e) {
1902 throw processException(e);
1903 }
1904 finally {
1905 if (count == null) {
1906 count = Long.valueOf(0);
1907 }
1908
1909 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
1910 count);
1911
1912 closeSession(session);
1913 }
1914 }
1915
1916 return count.intValue();
1917 }
1918
1919 public int countAll() throws SystemException {
1920 Object[] finderArgs = new Object[0];
1921
1922 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1923 finderArgs, this);
1924
1925 if (count == null) {
1926 Session session = null;
1927
1928 try {
1929 session = openSession();
1930
1931 Query q = session.createQuery(
1932 "SELECT COUNT(wikiNode) FROM WikiNode wikiNode");
1933
1934 count = (Long)q.uniqueResult();
1935 }
1936 catch (Exception e) {
1937 throw processException(e);
1938 }
1939 finally {
1940 if (count == null) {
1941 count = Long.valueOf(0);
1942 }
1943
1944 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1945 count);
1946
1947 closeSession(session);
1948 }
1949 }
1950
1951 return count.intValue();
1952 }
1953
1954 public void afterPropertiesSet() {
1955 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1956 com.liferay.portal.util.PropsUtil.get(
1957 "value.object.listener.com.liferay.portlet.wiki.model.WikiNode")));
1958
1959 if (listenerClassNames.length > 0) {
1960 try {
1961 List<ModelListener<WikiNode>> listenersList = new ArrayList<ModelListener<WikiNode>>();
1962
1963 for (String listenerClassName : listenerClassNames) {
1964 listenersList.add((ModelListener<WikiNode>)Class.forName(
1965 listenerClassName).newInstance());
1966 }
1967
1968 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1969 }
1970 catch (Exception e) {
1971 _log.error(e);
1972 }
1973 }
1974 }
1975
1976 @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiNodePersistence.impl")
1977 protected com.liferay.portlet.wiki.service.persistence.WikiNodePersistence wikiNodePersistence;
1978 @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPagePersistence.impl")
1979 protected com.liferay.portlet.wiki.service.persistence.WikiPagePersistence wikiPagePersistence;
1980 @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence.impl")
1981 protected com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence wikiPageResourcePersistence;
1982 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1983 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1984 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
1985 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1986 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1987 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1988 private static Log _log = LogFactoryUtil.getLog(WikiNodePersistenceImpl.class);
1989}