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