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