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