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