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.DynamicQuery;
22 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
23 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
24 import com.liferay.portal.kernel.dao.orm.FinderPath;
25 import com.liferay.portal.kernel.dao.orm.Query;
26 import com.liferay.portal.kernel.dao.orm.QueryPos;
27 import com.liferay.portal.kernel.dao.orm.QueryUtil;
28 import com.liferay.portal.kernel.dao.orm.Session;
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.NoSuchPageException;
43 import com.liferay.portlet.wiki.model.WikiPage;
44 import com.liferay.portlet.wiki.model.impl.WikiPageImpl;
45 import com.liferay.portlet.wiki.model.impl.WikiPageModelImpl;
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 WikiPagePersistenceImpl extends BasePersistenceImpl<WikiPage>
67 implements WikiPagePersistence {
68 public static final String FINDER_CLASS_NAME_ENTITY = WikiPageImpl.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(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
72 WikiPageModelImpl.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(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
75 WikiPageModelImpl.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(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
84 WikiPageModelImpl.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(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
87 WikiPageModelImpl.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(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
91 WikiPageModelImpl.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_NODEID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
95 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
96 "findByNodeId", new String[] { Long.class.getName() });
97 public static final FinderPath FINDER_PATH_FIND_BY_OBC_NODEID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
98 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
99 "findByNodeId",
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_NODEID = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
107 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
108 "countByNodeId", new String[] { Long.class.getName() });
109 public static final FinderPath FINDER_PATH_FIND_BY_FORMAT = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
110 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
111 "findByFormat", new String[] { String.class.getName() });
112 public static final FinderPath FINDER_PATH_FIND_BY_OBC_FORMAT = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
113 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
114 "findByFormat",
115 new String[] {
116 String.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_FORMAT = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
122 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
123 "countByFormat", new String[] { String.class.getName() });
124 public static final FinderPath FINDER_PATH_FIND_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
125 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
126 "findByN_T",
127 new String[] { Long.class.getName(), String.class.getName() });
128 public static final FinderPath FINDER_PATH_FIND_BY_OBC_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
129 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
130 "findByN_T",
131 new String[] {
132 Long.class.getName(), String.class.getName(),
133
134 "java.lang.Integer", "java.lang.Integer",
135 "com.liferay.portal.kernel.util.OrderByComparator"
136 });
137 public static final FinderPath FINDER_PATH_COUNT_BY_N_T = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
138 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
139 "countByN_T",
140 new String[] { Long.class.getName(), String.class.getName() });
141 public static final FinderPath FINDER_PATH_FIND_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
142 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
143 "findByN_H",
144 new String[] { Long.class.getName(), Boolean.class.getName() });
145 public static final FinderPath FINDER_PATH_FIND_BY_OBC_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
146 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
147 "findByN_H",
148 new String[] {
149 Long.class.getName(), Boolean.class.getName(),
150
151 "java.lang.Integer", "java.lang.Integer",
152 "com.liferay.portal.kernel.util.OrderByComparator"
153 });
154 public static final FinderPath FINDER_PATH_COUNT_BY_N_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
155 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
156 "countByN_H",
157 new String[] { Long.class.getName(), Boolean.class.getName() });
158 public static final FinderPath FINDER_PATH_FIND_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
159 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
160 "findByN_P",
161 new String[] { Long.class.getName(), String.class.getName() });
162 public static final FinderPath FINDER_PATH_FIND_BY_OBC_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
163 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
164 "findByN_P",
165 new String[] {
166 Long.class.getName(), String.class.getName(),
167
168 "java.lang.Integer", "java.lang.Integer",
169 "com.liferay.portal.kernel.util.OrderByComparator"
170 });
171 public static final FinderPath FINDER_PATH_COUNT_BY_N_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
172 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
173 "countByN_P",
174 new String[] { Long.class.getName(), String.class.getName() });
175 public static final FinderPath FINDER_PATH_FIND_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
176 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
177 "findByN_R",
178 new String[] { Long.class.getName(), String.class.getName() });
179 public static final FinderPath FINDER_PATH_FIND_BY_OBC_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
180 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
181 "findByN_R",
182 new String[] {
183 Long.class.getName(), String.class.getName(),
184
185 "java.lang.Integer", "java.lang.Integer",
186 "com.liferay.portal.kernel.util.OrderByComparator"
187 });
188 public static final FinderPath FINDER_PATH_COUNT_BY_N_R = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
189 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
190 "countByN_R",
191 new String[] { Long.class.getName(), String.class.getName() });
192 public static final FinderPath FINDER_PATH_FETCH_BY_N_T_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
193 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
194 "fetchByN_T_V",
195 new String[] {
196 Long.class.getName(), String.class.getName(),
197 Double.class.getName()
198 });
199 public static final FinderPath FINDER_PATH_COUNT_BY_N_T_V = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
200 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
201 "countByN_T_V",
202 new String[] {
203 Long.class.getName(), String.class.getName(),
204 Double.class.getName()
205 });
206 public static final FinderPath FINDER_PATH_FIND_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
207 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
208 "findByN_T_H",
209 new String[] {
210 Long.class.getName(), String.class.getName(),
211 Boolean.class.getName()
212 });
213 public static final FinderPath FINDER_PATH_FIND_BY_OBC_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
214 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
215 "findByN_T_H",
216 new String[] {
217 Long.class.getName(), String.class.getName(),
218 Boolean.class.getName(),
219
220 "java.lang.Integer", "java.lang.Integer",
221 "com.liferay.portal.kernel.util.OrderByComparator"
222 });
223 public static final FinderPath FINDER_PATH_COUNT_BY_N_T_H = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
224 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
225 "countByN_T_H",
226 new String[] {
227 Long.class.getName(), String.class.getName(),
228 Boolean.class.getName()
229 });
230 public static final FinderPath FINDER_PATH_FIND_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
231 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
232 "findByN_H_P",
233 new String[] {
234 Long.class.getName(), Boolean.class.getName(),
235 String.class.getName()
236 });
237 public static final FinderPath FINDER_PATH_FIND_BY_OBC_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
238 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
239 "findByN_H_P",
240 new String[] {
241 Long.class.getName(), Boolean.class.getName(),
242 String.class.getName(),
243
244 "java.lang.Integer", "java.lang.Integer",
245 "com.liferay.portal.kernel.util.OrderByComparator"
246 });
247 public static final FinderPath FINDER_PATH_COUNT_BY_N_H_P = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
248 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
249 "countByN_H_P",
250 new String[] {
251 Long.class.getName(), Boolean.class.getName(),
252 String.class.getName()
253 });
254 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
255 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
256 "findAll", new String[0]);
257 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
258 WikiPageModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
259 "countAll", new String[0]);
260
261 public void cacheResult(WikiPage wikiPage) {
262 EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
263 WikiPageImpl.class, wikiPage.getPrimaryKey(), wikiPage);
264
265 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
266 new Object[] { wikiPage.getUuid(), new Long(wikiPage.getGroupId()) },
267 wikiPage);
268
269 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
270 new Object[] {
271 new Long(wikiPage.getNodeId()),
272
273 wikiPage.getTitle(), new Double(wikiPage.getVersion())
274 }, wikiPage);
275 }
276
277 public void cacheResult(List<WikiPage> wikiPages) {
278 for (WikiPage wikiPage : wikiPages) {
279 if (EntityCacheUtil.getResult(
280 WikiPageModelImpl.ENTITY_CACHE_ENABLED,
281 WikiPageImpl.class, wikiPage.getPrimaryKey(), this) == null) {
282 cacheResult(wikiPage);
283 }
284 }
285 }
286
287 public void clearCache() {
288 CacheRegistry.clear(WikiPageImpl.class.getName());
289 EntityCacheUtil.clearCache(WikiPageImpl.class.getName());
290 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
291 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
292 }
293
294 public WikiPage create(long pageId) {
295 WikiPage wikiPage = new WikiPageImpl();
296
297 wikiPage.setNew(true);
298 wikiPage.setPrimaryKey(pageId);
299
300 String uuid = PortalUUIDUtil.generate();
301
302 wikiPage.setUuid(uuid);
303
304 return wikiPage;
305 }
306
307 public WikiPage remove(Serializable primaryKey)
308 throws NoSuchModelException, SystemException {
309 return remove(((Long)primaryKey).longValue());
310 }
311
312 public WikiPage remove(long pageId)
313 throws NoSuchPageException, SystemException {
314 Session session = null;
315
316 try {
317 session = openSession();
318
319 WikiPage wikiPage = (WikiPage)session.get(WikiPageImpl.class,
320 new Long(pageId));
321
322 if (wikiPage == null) {
323 if (_log.isWarnEnabled()) {
324 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + pageId);
325 }
326
327 throw new NoSuchPageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
328 pageId);
329 }
330
331 return remove(wikiPage);
332 }
333 catch (NoSuchPageException nsee) {
334 throw nsee;
335 }
336 catch (Exception e) {
337 throw processException(e);
338 }
339 finally {
340 closeSession(session);
341 }
342 }
343
344 public WikiPage remove(WikiPage wikiPage) throws SystemException {
345 for (ModelListener<WikiPage> listener : listeners) {
346 listener.onBeforeRemove(wikiPage);
347 }
348
349 wikiPage = removeImpl(wikiPage);
350
351 for (ModelListener<WikiPage> listener : listeners) {
352 listener.onAfterRemove(wikiPage);
353 }
354
355 return wikiPage;
356 }
357
358 protected WikiPage removeImpl(WikiPage wikiPage) throws SystemException {
359 wikiPage = toUnwrappedModel(wikiPage);
360
361 Session session = null;
362
363 try {
364 session = openSession();
365
366 if (wikiPage.isCachedModel() || BatchSessionUtil.isEnabled()) {
367 Object staleObject = session.get(WikiPageImpl.class,
368 wikiPage.getPrimaryKeyObj());
369
370 if (staleObject != null) {
371 session.evict(staleObject);
372 }
373 }
374
375 session.delete(wikiPage);
376
377 session.flush();
378 }
379 catch (Exception e) {
380 throw processException(e);
381 }
382 finally {
383 closeSession(session);
384 }
385
386 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
387
388 WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
389
390 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
391 new Object[] {
392 wikiPageModelImpl.getOriginalUuid(),
393 new Long(wikiPageModelImpl.getOriginalGroupId())
394 });
395
396 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V,
397 new Object[] {
398 new Long(wikiPageModelImpl.getOriginalNodeId()),
399
400 wikiPageModelImpl.getOriginalTitle(),
401 new Double(wikiPageModelImpl.getOriginalVersion())
402 });
403
404 EntityCacheUtil.removeResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
405 WikiPageImpl.class, wikiPage.getPrimaryKey());
406
407 return wikiPage;
408 }
409
410
413 public WikiPage update(WikiPage wikiPage) throws SystemException {
414 if (_log.isWarnEnabled()) {
415 _log.warn(
416 "Using the deprecated update(WikiPage wikiPage) method. Use update(WikiPage wikiPage, boolean merge) instead.");
417 }
418
419 return update(wikiPage, false);
420 }
421
422 public WikiPage updateImpl(
423 com.liferay.portlet.wiki.model.WikiPage wikiPage, boolean merge)
424 throws SystemException {
425 wikiPage = toUnwrappedModel(wikiPage);
426
427 boolean isNew = wikiPage.isNew();
428
429 WikiPageModelImpl wikiPageModelImpl = (WikiPageModelImpl)wikiPage;
430
431 if (Validator.isNull(wikiPage.getUuid())) {
432 String uuid = PortalUUIDUtil.generate();
433
434 wikiPage.setUuid(uuid);
435 }
436
437 Session session = null;
438
439 try {
440 session = openSession();
441
442 BatchSessionUtil.update(session, wikiPage, merge);
443
444 wikiPage.setNew(false);
445 }
446 catch (Exception e) {
447 throw processException(e);
448 }
449 finally {
450 closeSession(session);
451 }
452
453 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
454
455 EntityCacheUtil.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
456 WikiPageImpl.class, wikiPage.getPrimaryKey(), wikiPage);
457
458 if (!isNew &&
459 (!Validator.equals(wikiPage.getUuid(),
460 wikiPageModelImpl.getOriginalUuid()) ||
461 (wikiPage.getGroupId() != wikiPageModelImpl.getOriginalGroupId()))) {
462 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
463 new Object[] {
464 wikiPageModelImpl.getOriginalUuid(),
465 new Long(wikiPageModelImpl.getOriginalGroupId())
466 });
467 }
468
469 if (isNew ||
470 (!Validator.equals(wikiPage.getUuid(),
471 wikiPageModelImpl.getOriginalUuid()) ||
472 (wikiPage.getGroupId() != wikiPageModelImpl.getOriginalGroupId()))) {
473 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
474 new Object[] { wikiPage.getUuid(), new Long(
475 wikiPage.getGroupId()) }, wikiPage);
476 }
477
478 if (!isNew &&
479 ((wikiPage.getNodeId() != wikiPageModelImpl.getOriginalNodeId()) ||
480 !Validator.equals(wikiPage.getTitle(),
481 wikiPageModelImpl.getOriginalTitle()) ||
482 (wikiPage.getVersion() != wikiPageModelImpl.getOriginalVersion()))) {
483 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_N_T_V,
484 new Object[] {
485 new Long(wikiPageModelImpl.getOriginalNodeId()),
486
487 wikiPageModelImpl.getOriginalTitle(),
488 new Double(wikiPageModelImpl.getOriginalVersion())
489 });
490 }
491
492 if (isNew ||
493 ((wikiPage.getNodeId() != wikiPageModelImpl.getOriginalNodeId()) ||
494 !Validator.equals(wikiPage.getTitle(),
495 wikiPageModelImpl.getOriginalTitle()) ||
496 (wikiPage.getVersion() != wikiPageModelImpl.getOriginalVersion()))) {
497 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
498 new Object[] {
499 new Long(wikiPage.getNodeId()),
500
501 wikiPage.getTitle(), new Double(wikiPage.getVersion())
502 }, wikiPage);
503 }
504
505 return wikiPage;
506 }
507
508 protected WikiPage toUnwrappedModel(WikiPage wikiPage) {
509 if (wikiPage instanceof WikiPageImpl) {
510 return wikiPage;
511 }
512
513 WikiPageImpl wikiPageImpl = new WikiPageImpl();
514
515 wikiPageImpl.setNew(wikiPage.isNew());
516 wikiPageImpl.setPrimaryKey(wikiPage.getPrimaryKey());
517
518 wikiPageImpl.setUuid(wikiPage.getUuid());
519 wikiPageImpl.setPageId(wikiPage.getPageId());
520 wikiPageImpl.setResourcePrimKey(wikiPage.getResourcePrimKey());
521 wikiPageImpl.setGroupId(wikiPage.getGroupId());
522 wikiPageImpl.setCompanyId(wikiPage.getCompanyId());
523 wikiPageImpl.setUserId(wikiPage.getUserId());
524 wikiPageImpl.setUserName(wikiPage.getUserName());
525 wikiPageImpl.setCreateDate(wikiPage.getCreateDate());
526 wikiPageImpl.setModifiedDate(wikiPage.getModifiedDate());
527 wikiPageImpl.setNodeId(wikiPage.getNodeId());
528 wikiPageImpl.setTitle(wikiPage.getTitle());
529 wikiPageImpl.setVersion(wikiPage.getVersion());
530 wikiPageImpl.setMinorEdit(wikiPage.isMinorEdit());
531 wikiPageImpl.setContent(wikiPage.getContent());
532 wikiPageImpl.setSummary(wikiPage.getSummary());
533 wikiPageImpl.setFormat(wikiPage.getFormat());
534 wikiPageImpl.setHead(wikiPage.isHead());
535 wikiPageImpl.setParentTitle(wikiPage.getParentTitle());
536 wikiPageImpl.setRedirectTitle(wikiPage.getRedirectTitle());
537
538 return wikiPageImpl;
539 }
540
541 public WikiPage findByPrimaryKey(Serializable primaryKey)
542 throws NoSuchModelException, SystemException {
543 return findByPrimaryKey(((Long)primaryKey).longValue());
544 }
545
546 public WikiPage findByPrimaryKey(long pageId)
547 throws NoSuchPageException, SystemException {
548 WikiPage wikiPage = fetchByPrimaryKey(pageId);
549
550 if (wikiPage == null) {
551 if (_log.isWarnEnabled()) {
552 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + pageId);
553 }
554
555 throw new NoSuchPageException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
556 pageId);
557 }
558
559 return wikiPage;
560 }
561
562 public WikiPage fetchByPrimaryKey(Serializable primaryKey)
563 throws SystemException {
564 return fetchByPrimaryKey(((Long)primaryKey).longValue());
565 }
566
567 public WikiPage fetchByPrimaryKey(long pageId) throws SystemException {
568 WikiPage wikiPage = (WikiPage)EntityCacheUtil.getResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED,
569 WikiPageImpl.class, pageId, this);
570
571 if (wikiPage == null) {
572 Session session = null;
573
574 try {
575 session = openSession();
576
577 wikiPage = (WikiPage)session.get(WikiPageImpl.class,
578 new Long(pageId));
579 }
580 catch (Exception e) {
581 throw processException(e);
582 }
583 finally {
584 if (wikiPage != null) {
585 cacheResult(wikiPage);
586 }
587
588 closeSession(session);
589 }
590 }
591
592 return wikiPage;
593 }
594
595 public List<WikiPage> findByUuid(String uuid) throws SystemException {
596 Object[] finderArgs = new Object[] { uuid };
597
598 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
599 finderArgs, this);
600
601 if (list == null) {
602 Session session = null;
603
604 try {
605 session = openSession();
606
607 StringBundler query = new StringBundler(3);
608
609 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
610
611 if (uuid == null) {
612 query.append(_FINDER_COLUMN_UUID_UUID_1);
613 }
614 else {
615 if (uuid.equals(StringPool.BLANK)) {
616 query.append(_FINDER_COLUMN_UUID_UUID_3);
617 }
618 else {
619 query.append(_FINDER_COLUMN_UUID_UUID_2);
620 }
621 }
622
623 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
624
625 String sql = query.toString();
626
627 Query q = session.createQuery(sql);
628
629 QueryPos qPos = QueryPos.getInstance(q);
630
631 if (uuid != null) {
632 qPos.add(uuid);
633 }
634
635 list = q.list();
636 }
637 catch (Exception e) {
638 throw processException(e);
639 }
640 finally {
641 if (list == null) {
642 list = new ArrayList<WikiPage>();
643 }
644
645 cacheResult(list);
646
647 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
648 list);
649
650 closeSession(session);
651 }
652 }
653
654 return list;
655 }
656
657 public List<WikiPage> findByUuid(String uuid, int start, int end)
658 throws SystemException {
659 return findByUuid(uuid, start, end, null);
660 }
661
662 public List<WikiPage> findByUuid(String uuid, int start, int end,
663 OrderByComparator obc) throws SystemException {
664 Object[] finderArgs = new Object[] {
665 uuid,
666
667 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
668 };
669
670 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
671 finderArgs, this);
672
673 if (list == null) {
674 Session session = null;
675
676 try {
677 session = openSession();
678
679 StringBundler query = null;
680
681 if (obc != null) {
682 query = new StringBundler(3 +
683 (obc.getOrderByFields().length * 3));
684 }
685 else {
686 query = new StringBundler(3);
687 }
688
689 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
690
691 if (uuid == null) {
692 query.append(_FINDER_COLUMN_UUID_UUID_1);
693 }
694 else {
695 if (uuid.equals(StringPool.BLANK)) {
696 query.append(_FINDER_COLUMN_UUID_UUID_3);
697 }
698 else {
699 query.append(_FINDER_COLUMN_UUID_UUID_2);
700 }
701 }
702
703 if (obc != null) {
704 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
705 }
706
707 else {
708 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
709 }
710
711 String sql = query.toString();
712
713 Query q = session.createQuery(sql);
714
715 QueryPos qPos = QueryPos.getInstance(q);
716
717 if (uuid != null) {
718 qPos.add(uuid);
719 }
720
721 list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
722 end);
723 }
724 catch (Exception e) {
725 throw processException(e);
726 }
727 finally {
728 if (list == null) {
729 list = new ArrayList<WikiPage>();
730 }
731
732 cacheResult(list);
733
734 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
735 finderArgs, list);
736
737 closeSession(session);
738 }
739 }
740
741 return list;
742 }
743
744 public WikiPage findByUuid_First(String uuid, OrderByComparator obc)
745 throws NoSuchPageException, SystemException {
746 List<WikiPage> list = findByUuid(uuid, 0, 1, obc);
747
748 if (list.isEmpty()) {
749 StringBundler msg = new StringBundler(4);
750
751 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
752
753 msg.append("uuid=");
754 msg.append(uuid);
755
756 msg.append(StringPool.CLOSE_CURLY_BRACE);
757
758 throw new NoSuchPageException(msg.toString());
759 }
760 else {
761 return list.get(0);
762 }
763 }
764
765 public WikiPage findByUuid_Last(String uuid, OrderByComparator obc)
766 throws NoSuchPageException, SystemException {
767 int count = countByUuid(uuid);
768
769 List<WikiPage> list = findByUuid(uuid, count - 1, count, obc);
770
771 if (list.isEmpty()) {
772 StringBundler msg = new StringBundler(4);
773
774 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
775
776 msg.append("uuid=");
777 msg.append(uuid);
778
779 msg.append(StringPool.CLOSE_CURLY_BRACE);
780
781 throw new NoSuchPageException(msg.toString());
782 }
783 else {
784 return list.get(0);
785 }
786 }
787
788 public WikiPage[] findByUuid_PrevAndNext(long pageId, String uuid,
789 OrderByComparator obc) throws NoSuchPageException, SystemException {
790 WikiPage wikiPage = findByPrimaryKey(pageId);
791
792 int count = countByUuid(uuid);
793
794 Session session = null;
795
796 try {
797 session = openSession();
798
799 StringBundler query = null;
800
801 if (obc != null) {
802 query = new StringBundler(3 +
803 (obc.getOrderByFields().length * 3));
804 }
805 else {
806 query = new StringBundler(3);
807 }
808
809 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
810
811 if (uuid == null) {
812 query.append(_FINDER_COLUMN_UUID_UUID_1);
813 }
814 else {
815 if (uuid.equals(StringPool.BLANK)) {
816 query.append(_FINDER_COLUMN_UUID_UUID_3);
817 }
818 else {
819 query.append(_FINDER_COLUMN_UUID_UUID_2);
820 }
821 }
822
823 if (obc != null) {
824 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
825 }
826
827 else {
828 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
829 }
830
831 String sql = query.toString();
832
833 Query q = session.createQuery(sql);
834
835 QueryPos qPos = QueryPos.getInstance(q);
836
837 if (uuid != null) {
838 qPos.add(uuid);
839 }
840
841 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
842
843 WikiPage[] array = new WikiPageImpl[3];
844
845 array[0] = (WikiPage)objArray[0];
846 array[1] = (WikiPage)objArray[1];
847 array[2] = (WikiPage)objArray[2];
848
849 return array;
850 }
851 catch (Exception e) {
852 throw processException(e);
853 }
854 finally {
855 closeSession(session);
856 }
857 }
858
859 public WikiPage findByUUID_G(String uuid, long groupId)
860 throws NoSuchPageException, SystemException {
861 WikiPage wikiPage = fetchByUUID_G(uuid, groupId);
862
863 if (wikiPage == null) {
864 StringBundler msg = new StringBundler(6);
865
866 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
867
868 msg.append("uuid=");
869 msg.append(uuid);
870
871 msg.append(", groupId=");
872 msg.append(groupId);
873
874 msg.append(StringPool.CLOSE_CURLY_BRACE);
875
876 if (_log.isWarnEnabled()) {
877 _log.warn(msg.toString());
878 }
879
880 throw new NoSuchPageException(msg.toString());
881 }
882
883 return wikiPage;
884 }
885
886 public WikiPage fetchByUUID_G(String uuid, long groupId)
887 throws SystemException {
888 return fetchByUUID_G(uuid, groupId, true);
889 }
890
891 public WikiPage fetchByUUID_G(String uuid, long groupId,
892 boolean retrieveFromCache) throws SystemException {
893 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
894
895 Object result = null;
896
897 if (retrieveFromCache) {
898 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
899 finderArgs, this);
900 }
901
902 if (result == null) {
903 Session session = null;
904
905 try {
906 session = openSession();
907
908 StringBundler query = new StringBundler(4);
909
910 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
911
912 if (uuid == null) {
913 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
914 }
915 else {
916 if (uuid.equals(StringPool.BLANK)) {
917 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
918 }
919 else {
920 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
921 }
922 }
923
924 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
925
926 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
927
928 String sql = query.toString();
929
930 Query q = session.createQuery(sql);
931
932 QueryPos qPos = QueryPos.getInstance(q);
933
934 if (uuid != null) {
935 qPos.add(uuid);
936 }
937
938 qPos.add(groupId);
939
940 List<WikiPage> list = q.list();
941
942 result = list;
943
944 WikiPage wikiPage = null;
945
946 if (list.isEmpty()) {
947 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
948 finderArgs, list);
949 }
950 else {
951 wikiPage = list.get(0);
952
953 cacheResult(wikiPage);
954
955 if ((wikiPage.getUuid() == null) ||
956 !wikiPage.getUuid().equals(uuid) ||
957 (wikiPage.getGroupId() != groupId)) {
958 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
959 finderArgs, wikiPage);
960 }
961 }
962
963 return wikiPage;
964 }
965 catch (Exception e) {
966 throw processException(e);
967 }
968 finally {
969 if (result == null) {
970 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
971 finderArgs, new ArrayList<WikiPage>());
972 }
973
974 closeSession(session);
975 }
976 }
977 else {
978 if (result instanceof List<?>) {
979 return null;
980 }
981 else {
982 return (WikiPage)result;
983 }
984 }
985 }
986
987 public List<WikiPage> findByNodeId(long nodeId) throws SystemException {
988 Object[] finderArgs = new Object[] { new Long(nodeId) };
989
990 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_NODEID,
991 finderArgs, this);
992
993 if (list == null) {
994 Session session = null;
995
996 try {
997 session = openSession();
998
999 StringBundler query = new StringBundler(3);
1000
1001 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1002
1003 query.append(_FINDER_COLUMN_NODEID_NODEID_2);
1004
1005 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1006
1007 String sql = query.toString();
1008
1009 Query q = session.createQuery(sql);
1010
1011 QueryPos qPos = QueryPos.getInstance(q);
1012
1013 qPos.add(nodeId);
1014
1015 list = q.list();
1016 }
1017 catch (Exception e) {
1018 throw processException(e);
1019 }
1020 finally {
1021 if (list == null) {
1022 list = new ArrayList<WikiPage>();
1023 }
1024
1025 cacheResult(list);
1026
1027 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_NODEID,
1028 finderArgs, list);
1029
1030 closeSession(session);
1031 }
1032 }
1033
1034 return list;
1035 }
1036
1037 public List<WikiPage> findByNodeId(long nodeId, int start, int end)
1038 throws SystemException {
1039 return findByNodeId(nodeId, start, end, null);
1040 }
1041
1042 public List<WikiPage> findByNodeId(long nodeId, int start, int end,
1043 OrderByComparator obc) throws SystemException {
1044 Object[] finderArgs = new Object[] {
1045 new Long(nodeId),
1046
1047 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1048 };
1049
1050 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_NODEID,
1051 finderArgs, this);
1052
1053 if (list == null) {
1054 Session session = null;
1055
1056 try {
1057 session = openSession();
1058
1059 StringBundler query = null;
1060
1061 if (obc != null) {
1062 query = new StringBundler(3 +
1063 (obc.getOrderByFields().length * 3));
1064 }
1065 else {
1066 query = new StringBundler(3);
1067 }
1068
1069 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1070
1071 query.append(_FINDER_COLUMN_NODEID_NODEID_2);
1072
1073 if (obc != null) {
1074 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1075 }
1076
1077 else {
1078 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1079 }
1080
1081 String sql = query.toString();
1082
1083 Query q = session.createQuery(sql);
1084
1085 QueryPos qPos = QueryPos.getInstance(q);
1086
1087 qPos.add(nodeId);
1088
1089 list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
1090 end);
1091 }
1092 catch (Exception e) {
1093 throw processException(e);
1094 }
1095 finally {
1096 if (list == null) {
1097 list = new ArrayList<WikiPage>();
1098 }
1099
1100 cacheResult(list);
1101
1102 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_NODEID,
1103 finderArgs, list);
1104
1105 closeSession(session);
1106 }
1107 }
1108
1109 return list;
1110 }
1111
1112 public WikiPage findByNodeId_First(long nodeId, OrderByComparator obc)
1113 throws NoSuchPageException, SystemException {
1114 List<WikiPage> list = findByNodeId(nodeId, 0, 1, obc);
1115
1116 if (list.isEmpty()) {
1117 StringBundler msg = new StringBundler(4);
1118
1119 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1120
1121 msg.append("nodeId=");
1122 msg.append(nodeId);
1123
1124 msg.append(StringPool.CLOSE_CURLY_BRACE);
1125
1126 throw new NoSuchPageException(msg.toString());
1127 }
1128 else {
1129 return list.get(0);
1130 }
1131 }
1132
1133 public WikiPage findByNodeId_Last(long nodeId, OrderByComparator obc)
1134 throws NoSuchPageException, SystemException {
1135 int count = countByNodeId(nodeId);
1136
1137 List<WikiPage> list = findByNodeId(nodeId, count - 1, count, obc);
1138
1139 if (list.isEmpty()) {
1140 StringBundler msg = new StringBundler(4);
1141
1142 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1143
1144 msg.append("nodeId=");
1145 msg.append(nodeId);
1146
1147 msg.append(StringPool.CLOSE_CURLY_BRACE);
1148
1149 throw new NoSuchPageException(msg.toString());
1150 }
1151 else {
1152 return list.get(0);
1153 }
1154 }
1155
1156 public WikiPage[] findByNodeId_PrevAndNext(long pageId, long nodeId,
1157 OrderByComparator obc) throws NoSuchPageException, SystemException {
1158 WikiPage wikiPage = findByPrimaryKey(pageId);
1159
1160 int count = countByNodeId(nodeId);
1161
1162 Session session = null;
1163
1164 try {
1165 session = openSession();
1166
1167 StringBundler query = null;
1168
1169 if (obc != null) {
1170 query = new StringBundler(3 +
1171 (obc.getOrderByFields().length * 3));
1172 }
1173 else {
1174 query = new StringBundler(3);
1175 }
1176
1177 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1178
1179 query.append(_FINDER_COLUMN_NODEID_NODEID_2);
1180
1181 if (obc != null) {
1182 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1183 }
1184
1185 else {
1186 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1187 }
1188
1189 String sql = query.toString();
1190
1191 Query q = session.createQuery(sql);
1192
1193 QueryPos qPos = QueryPos.getInstance(q);
1194
1195 qPos.add(nodeId);
1196
1197 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1198
1199 WikiPage[] array = new WikiPageImpl[3];
1200
1201 array[0] = (WikiPage)objArray[0];
1202 array[1] = (WikiPage)objArray[1];
1203 array[2] = (WikiPage)objArray[2];
1204
1205 return array;
1206 }
1207 catch (Exception e) {
1208 throw processException(e);
1209 }
1210 finally {
1211 closeSession(session);
1212 }
1213 }
1214
1215 public List<WikiPage> findByFormat(String format) throws SystemException {
1216 Object[] finderArgs = new Object[] { format };
1217
1218 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_FORMAT,
1219 finderArgs, this);
1220
1221 if (list == null) {
1222 Session session = null;
1223
1224 try {
1225 session = openSession();
1226
1227 StringBundler query = new StringBundler(3);
1228
1229 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1230
1231 if (format == null) {
1232 query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
1233 }
1234 else {
1235 if (format.equals(StringPool.BLANK)) {
1236 query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
1237 }
1238 else {
1239 query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
1240 }
1241 }
1242
1243 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1244
1245 String sql = query.toString();
1246
1247 Query q = session.createQuery(sql);
1248
1249 QueryPos qPos = QueryPos.getInstance(q);
1250
1251 if (format != null) {
1252 qPos.add(format);
1253 }
1254
1255 list = q.list();
1256 }
1257 catch (Exception e) {
1258 throw processException(e);
1259 }
1260 finally {
1261 if (list == null) {
1262 list = new ArrayList<WikiPage>();
1263 }
1264
1265 cacheResult(list);
1266
1267 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_FORMAT,
1268 finderArgs, list);
1269
1270 closeSession(session);
1271 }
1272 }
1273
1274 return list;
1275 }
1276
1277 public List<WikiPage> findByFormat(String format, int start, int end)
1278 throws SystemException {
1279 return findByFormat(format, start, end, null);
1280 }
1281
1282 public List<WikiPage> findByFormat(String format, int start, int end,
1283 OrderByComparator obc) throws SystemException {
1284 Object[] finderArgs = new Object[] {
1285 format,
1286
1287 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1288 };
1289
1290 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_FORMAT,
1291 finderArgs, this);
1292
1293 if (list == null) {
1294 Session session = null;
1295
1296 try {
1297 session = openSession();
1298
1299 StringBundler query = null;
1300
1301 if (obc != null) {
1302 query = new StringBundler(3 +
1303 (obc.getOrderByFields().length * 3));
1304 }
1305 else {
1306 query = new StringBundler(3);
1307 }
1308
1309 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1310
1311 if (format == null) {
1312 query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
1313 }
1314 else {
1315 if (format.equals(StringPool.BLANK)) {
1316 query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
1317 }
1318 else {
1319 query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
1320 }
1321 }
1322
1323 if (obc != null) {
1324 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1325 }
1326
1327 else {
1328 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1329 }
1330
1331 String sql = query.toString();
1332
1333 Query q = session.createQuery(sql);
1334
1335 QueryPos qPos = QueryPos.getInstance(q);
1336
1337 if (format != null) {
1338 qPos.add(format);
1339 }
1340
1341 list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
1342 end);
1343 }
1344 catch (Exception e) {
1345 throw processException(e);
1346 }
1347 finally {
1348 if (list == null) {
1349 list = new ArrayList<WikiPage>();
1350 }
1351
1352 cacheResult(list);
1353
1354 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_FORMAT,
1355 finderArgs, list);
1356
1357 closeSession(session);
1358 }
1359 }
1360
1361 return list;
1362 }
1363
1364 public WikiPage findByFormat_First(String format, OrderByComparator obc)
1365 throws NoSuchPageException, SystemException {
1366 List<WikiPage> list = findByFormat(format, 0, 1, obc);
1367
1368 if (list.isEmpty()) {
1369 StringBundler msg = new StringBundler(4);
1370
1371 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1372
1373 msg.append("format=");
1374 msg.append(format);
1375
1376 msg.append(StringPool.CLOSE_CURLY_BRACE);
1377
1378 throw new NoSuchPageException(msg.toString());
1379 }
1380 else {
1381 return list.get(0);
1382 }
1383 }
1384
1385 public WikiPage findByFormat_Last(String format, OrderByComparator obc)
1386 throws NoSuchPageException, SystemException {
1387 int count = countByFormat(format);
1388
1389 List<WikiPage> list = findByFormat(format, count - 1, count, obc);
1390
1391 if (list.isEmpty()) {
1392 StringBundler msg = new StringBundler(4);
1393
1394 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1395
1396 msg.append("format=");
1397 msg.append(format);
1398
1399 msg.append(StringPool.CLOSE_CURLY_BRACE);
1400
1401 throw new NoSuchPageException(msg.toString());
1402 }
1403 else {
1404 return list.get(0);
1405 }
1406 }
1407
1408 public WikiPage[] findByFormat_PrevAndNext(long pageId, String format,
1409 OrderByComparator obc) throws NoSuchPageException, SystemException {
1410 WikiPage wikiPage = findByPrimaryKey(pageId);
1411
1412 int count = countByFormat(format);
1413
1414 Session session = null;
1415
1416 try {
1417 session = openSession();
1418
1419 StringBundler query = null;
1420
1421 if (obc != null) {
1422 query = new StringBundler(3 +
1423 (obc.getOrderByFields().length * 3));
1424 }
1425 else {
1426 query = new StringBundler(3);
1427 }
1428
1429 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1430
1431 if (format == null) {
1432 query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
1433 }
1434 else {
1435 if (format.equals(StringPool.BLANK)) {
1436 query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
1437 }
1438 else {
1439 query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
1440 }
1441 }
1442
1443 if (obc != null) {
1444 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1445 }
1446
1447 else {
1448 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1449 }
1450
1451 String sql = query.toString();
1452
1453 Query q = session.createQuery(sql);
1454
1455 QueryPos qPos = QueryPos.getInstance(q);
1456
1457 if (format != null) {
1458 qPos.add(format);
1459 }
1460
1461 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1462
1463 WikiPage[] array = new WikiPageImpl[3];
1464
1465 array[0] = (WikiPage)objArray[0];
1466 array[1] = (WikiPage)objArray[1];
1467 array[2] = (WikiPage)objArray[2];
1468
1469 return array;
1470 }
1471 catch (Exception e) {
1472 throw processException(e);
1473 }
1474 finally {
1475 closeSession(session);
1476 }
1477 }
1478
1479 public List<WikiPage> findByN_T(long nodeId, String title)
1480 throws SystemException {
1481 Object[] finderArgs = new Object[] { new Long(nodeId), title };
1482
1483 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_T,
1484 finderArgs, this);
1485
1486 if (list == null) {
1487 Session session = null;
1488
1489 try {
1490 session = openSession();
1491
1492 StringBundler query = new StringBundler(4);
1493
1494 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1495
1496 query.append(_FINDER_COLUMN_N_T_NODEID_2);
1497
1498 if (title == null) {
1499 query.append(_FINDER_COLUMN_N_T_TITLE_1);
1500 }
1501 else {
1502 if (title.equals(StringPool.BLANK)) {
1503 query.append(_FINDER_COLUMN_N_T_TITLE_3);
1504 }
1505 else {
1506 query.append(_FINDER_COLUMN_N_T_TITLE_2);
1507 }
1508 }
1509
1510 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1511
1512 String sql = query.toString();
1513
1514 Query q = session.createQuery(sql);
1515
1516 QueryPos qPos = QueryPos.getInstance(q);
1517
1518 qPos.add(nodeId);
1519
1520 if (title != null) {
1521 qPos.add(title);
1522 }
1523
1524 list = q.list();
1525 }
1526 catch (Exception e) {
1527 throw processException(e);
1528 }
1529 finally {
1530 if (list == null) {
1531 list = new ArrayList<WikiPage>();
1532 }
1533
1534 cacheResult(list);
1535
1536 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_T, finderArgs,
1537 list);
1538
1539 closeSession(session);
1540 }
1541 }
1542
1543 return list;
1544 }
1545
1546 public List<WikiPage> findByN_T(long nodeId, String title, int start,
1547 int end) throws SystemException {
1548 return findByN_T(nodeId, title, start, end, null);
1549 }
1550
1551 public List<WikiPage> findByN_T(long nodeId, String title, int start,
1552 int end, OrderByComparator obc) throws SystemException {
1553 Object[] finderArgs = new Object[] {
1554 new Long(nodeId),
1555
1556 title,
1557
1558 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1559 };
1560
1561 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_N_T,
1562 finderArgs, this);
1563
1564 if (list == null) {
1565 Session session = null;
1566
1567 try {
1568 session = openSession();
1569
1570 StringBundler query = null;
1571
1572 if (obc != null) {
1573 query = new StringBundler(4 +
1574 (obc.getOrderByFields().length * 3));
1575 }
1576 else {
1577 query = new StringBundler(4);
1578 }
1579
1580 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1581
1582 query.append(_FINDER_COLUMN_N_T_NODEID_2);
1583
1584 if (title == null) {
1585 query.append(_FINDER_COLUMN_N_T_TITLE_1);
1586 }
1587 else {
1588 if (title.equals(StringPool.BLANK)) {
1589 query.append(_FINDER_COLUMN_N_T_TITLE_3);
1590 }
1591 else {
1592 query.append(_FINDER_COLUMN_N_T_TITLE_2);
1593 }
1594 }
1595
1596 if (obc != null) {
1597 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1598 }
1599
1600 else {
1601 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1602 }
1603
1604 String sql = query.toString();
1605
1606 Query q = session.createQuery(sql);
1607
1608 QueryPos qPos = QueryPos.getInstance(q);
1609
1610 qPos.add(nodeId);
1611
1612 if (title != null) {
1613 qPos.add(title);
1614 }
1615
1616 list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
1617 end);
1618 }
1619 catch (Exception e) {
1620 throw processException(e);
1621 }
1622 finally {
1623 if (list == null) {
1624 list = new ArrayList<WikiPage>();
1625 }
1626
1627 cacheResult(list);
1628
1629 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_N_T,
1630 finderArgs, list);
1631
1632 closeSession(session);
1633 }
1634 }
1635
1636 return list;
1637 }
1638
1639 public WikiPage findByN_T_First(long nodeId, String title,
1640 OrderByComparator obc) throws NoSuchPageException, SystemException {
1641 List<WikiPage> list = findByN_T(nodeId, title, 0, 1, obc);
1642
1643 if (list.isEmpty()) {
1644 StringBundler msg = new StringBundler(6);
1645
1646 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1647
1648 msg.append("nodeId=");
1649 msg.append(nodeId);
1650
1651 msg.append(", title=");
1652 msg.append(title);
1653
1654 msg.append(StringPool.CLOSE_CURLY_BRACE);
1655
1656 throw new NoSuchPageException(msg.toString());
1657 }
1658 else {
1659 return list.get(0);
1660 }
1661 }
1662
1663 public WikiPage findByN_T_Last(long nodeId, String title,
1664 OrderByComparator obc) throws NoSuchPageException, SystemException {
1665 int count = countByN_T(nodeId, title);
1666
1667 List<WikiPage> list = findByN_T(nodeId, title, count - 1, count, obc);
1668
1669 if (list.isEmpty()) {
1670 StringBundler msg = new StringBundler(6);
1671
1672 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1673
1674 msg.append("nodeId=");
1675 msg.append(nodeId);
1676
1677 msg.append(", title=");
1678 msg.append(title);
1679
1680 msg.append(StringPool.CLOSE_CURLY_BRACE);
1681
1682 throw new NoSuchPageException(msg.toString());
1683 }
1684 else {
1685 return list.get(0);
1686 }
1687 }
1688
1689 public WikiPage[] findByN_T_PrevAndNext(long pageId, long nodeId,
1690 String title, OrderByComparator obc)
1691 throws NoSuchPageException, SystemException {
1692 WikiPage wikiPage = findByPrimaryKey(pageId);
1693
1694 int count = countByN_T(nodeId, title);
1695
1696 Session session = null;
1697
1698 try {
1699 session = openSession();
1700
1701 StringBundler query = null;
1702
1703 if (obc != null) {
1704 query = new StringBundler(4 +
1705 (obc.getOrderByFields().length * 3));
1706 }
1707 else {
1708 query = new StringBundler(4);
1709 }
1710
1711 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1712
1713 query.append(_FINDER_COLUMN_N_T_NODEID_2);
1714
1715 if (title == null) {
1716 query.append(_FINDER_COLUMN_N_T_TITLE_1);
1717 }
1718 else {
1719 if (title.equals(StringPool.BLANK)) {
1720 query.append(_FINDER_COLUMN_N_T_TITLE_3);
1721 }
1722 else {
1723 query.append(_FINDER_COLUMN_N_T_TITLE_2);
1724 }
1725 }
1726
1727 if (obc != null) {
1728 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1729 }
1730
1731 else {
1732 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1733 }
1734
1735 String sql = query.toString();
1736
1737 Query q = session.createQuery(sql);
1738
1739 QueryPos qPos = QueryPos.getInstance(q);
1740
1741 qPos.add(nodeId);
1742
1743 if (title != null) {
1744 qPos.add(title);
1745 }
1746
1747 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1748
1749 WikiPage[] array = new WikiPageImpl[3];
1750
1751 array[0] = (WikiPage)objArray[0];
1752 array[1] = (WikiPage)objArray[1];
1753 array[2] = (WikiPage)objArray[2];
1754
1755 return array;
1756 }
1757 catch (Exception e) {
1758 throw processException(e);
1759 }
1760 finally {
1761 closeSession(session);
1762 }
1763 }
1764
1765 public List<WikiPage> findByN_H(long nodeId, boolean head)
1766 throws SystemException {
1767 Object[] finderArgs = new Object[] {
1768 new Long(nodeId), Boolean.valueOf(head)
1769 };
1770
1771 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_H,
1772 finderArgs, this);
1773
1774 if (list == null) {
1775 Session session = null;
1776
1777 try {
1778 session = openSession();
1779
1780 StringBundler query = new StringBundler(4);
1781
1782 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1783
1784 query.append(_FINDER_COLUMN_N_H_NODEID_2);
1785
1786 query.append(_FINDER_COLUMN_N_H_HEAD_2);
1787
1788 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1789
1790 String sql = query.toString();
1791
1792 Query q = session.createQuery(sql);
1793
1794 QueryPos qPos = QueryPos.getInstance(q);
1795
1796 qPos.add(nodeId);
1797
1798 qPos.add(head);
1799
1800 list = q.list();
1801 }
1802 catch (Exception e) {
1803 throw processException(e);
1804 }
1805 finally {
1806 if (list == null) {
1807 list = new ArrayList<WikiPage>();
1808 }
1809
1810 cacheResult(list);
1811
1812 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_H, finderArgs,
1813 list);
1814
1815 closeSession(session);
1816 }
1817 }
1818
1819 return list;
1820 }
1821
1822 public List<WikiPage> findByN_H(long nodeId, boolean head, int start,
1823 int end) throws SystemException {
1824 return findByN_H(nodeId, head, start, end, null);
1825 }
1826
1827 public List<WikiPage> findByN_H(long nodeId, boolean head, int start,
1828 int end, OrderByComparator obc) throws SystemException {
1829 Object[] finderArgs = new Object[] {
1830 new Long(nodeId), Boolean.valueOf(head),
1831
1832 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1833 };
1834
1835 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_N_H,
1836 finderArgs, this);
1837
1838 if (list == null) {
1839 Session session = null;
1840
1841 try {
1842 session = openSession();
1843
1844 StringBundler query = null;
1845
1846 if (obc != null) {
1847 query = new StringBundler(4 +
1848 (obc.getOrderByFields().length * 3));
1849 }
1850 else {
1851 query = new StringBundler(4);
1852 }
1853
1854 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1855
1856 query.append(_FINDER_COLUMN_N_H_NODEID_2);
1857
1858 query.append(_FINDER_COLUMN_N_H_HEAD_2);
1859
1860 if (obc != null) {
1861 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1862 }
1863
1864 else {
1865 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1866 }
1867
1868 String sql = query.toString();
1869
1870 Query q = session.createQuery(sql);
1871
1872 QueryPos qPos = QueryPos.getInstance(q);
1873
1874 qPos.add(nodeId);
1875
1876 qPos.add(head);
1877
1878 list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
1879 end);
1880 }
1881 catch (Exception e) {
1882 throw processException(e);
1883 }
1884 finally {
1885 if (list == null) {
1886 list = new ArrayList<WikiPage>();
1887 }
1888
1889 cacheResult(list);
1890
1891 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_N_H,
1892 finderArgs, list);
1893
1894 closeSession(session);
1895 }
1896 }
1897
1898 return list;
1899 }
1900
1901 public WikiPage findByN_H_First(long nodeId, boolean head,
1902 OrderByComparator obc) throws NoSuchPageException, SystemException {
1903 List<WikiPage> list = findByN_H(nodeId, head, 0, 1, obc);
1904
1905 if (list.isEmpty()) {
1906 StringBundler msg = new StringBundler(6);
1907
1908 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1909
1910 msg.append("nodeId=");
1911 msg.append(nodeId);
1912
1913 msg.append(", head=");
1914 msg.append(head);
1915
1916 msg.append(StringPool.CLOSE_CURLY_BRACE);
1917
1918 throw new NoSuchPageException(msg.toString());
1919 }
1920 else {
1921 return list.get(0);
1922 }
1923 }
1924
1925 public WikiPage findByN_H_Last(long nodeId, boolean head,
1926 OrderByComparator obc) throws NoSuchPageException, SystemException {
1927 int count = countByN_H(nodeId, head);
1928
1929 List<WikiPage> list = findByN_H(nodeId, head, count - 1, count, obc);
1930
1931 if (list.isEmpty()) {
1932 StringBundler msg = new StringBundler(6);
1933
1934 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1935
1936 msg.append("nodeId=");
1937 msg.append(nodeId);
1938
1939 msg.append(", head=");
1940 msg.append(head);
1941
1942 msg.append(StringPool.CLOSE_CURLY_BRACE);
1943
1944 throw new NoSuchPageException(msg.toString());
1945 }
1946 else {
1947 return list.get(0);
1948 }
1949 }
1950
1951 public WikiPage[] findByN_H_PrevAndNext(long pageId, long nodeId,
1952 boolean head, OrderByComparator obc)
1953 throws NoSuchPageException, SystemException {
1954 WikiPage wikiPage = findByPrimaryKey(pageId);
1955
1956 int count = countByN_H(nodeId, head);
1957
1958 Session session = null;
1959
1960 try {
1961 session = openSession();
1962
1963 StringBundler query = null;
1964
1965 if (obc != null) {
1966 query = new StringBundler(4 +
1967 (obc.getOrderByFields().length * 3));
1968 }
1969 else {
1970 query = new StringBundler(4);
1971 }
1972
1973 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
1974
1975 query.append(_FINDER_COLUMN_N_H_NODEID_2);
1976
1977 query.append(_FINDER_COLUMN_N_H_HEAD_2);
1978
1979 if (obc != null) {
1980 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
1981 }
1982
1983 else {
1984 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
1985 }
1986
1987 String sql = query.toString();
1988
1989 Query q = session.createQuery(sql);
1990
1991 QueryPos qPos = QueryPos.getInstance(q);
1992
1993 qPos.add(nodeId);
1994
1995 qPos.add(head);
1996
1997 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
1998
1999 WikiPage[] array = new WikiPageImpl[3];
2000
2001 array[0] = (WikiPage)objArray[0];
2002 array[1] = (WikiPage)objArray[1];
2003 array[2] = (WikiPage)objArray[2];
2004
2005 return array;
2006 }
2007 catch (Exception e) {
2008 throw processException(e);
2009 }
2010 finally {
2011 closeSession(session);
2012 }
2013 }
2014
2015 public List<WikiPage> findByN_P(long nodeId, String parentTitle)
2016 throws SystemException {
2017 Object[] finderArgs = new Object[] { new Long(nodeId), parentTitle };
2018
2019 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_P,
2020 finderArgs, this);
2021
2022 if (list == null) {
2023 Session session = null;
2024
2025 try {
2026 session = openSession();
2027
2028 StringBundler query = new StringBundler(4);
2029
2030 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2031
2032 query.append(_FINDER_COLUMN_N_P_NODEID_2);
2033
2034 if (parentTitle == null) {
2035 query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
2036 }
2037 else {
2038 if (parentTitle.equals(StringPool.BLANK)) {
2039 query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
2040 }
2041 else {
2042 query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
2043 }
2044 }
2045
2046 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2047
2048 String sql = query.toString();
2049
2050 Query q = session.createQuery(sql);
2051
2052 QueryPos qPos = QueryPos.getInstance(q);
2053
2054 qPos.add(nodeId);
2055
2056 if (parentTitle != null) {
2057 qPos.add(parentTitle);
2058 }
2059
2060 list = q.list();
2061 }
2062 catch (Exception e) {
2063 throw processException(e);
2064 }
2065 finally {
2066 if (list == null) {
2067 list = new ArrayList<WikiPage>();
2068 }
2069
2070 cacheResult(list);
2071
2072 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_P, finderArgs,
2073 list);
2074
2075 closeSession(session);
2076 }
2077 }
2078
2079 return list;
2080 }
2081
2082 public List<WikiPage> findByN_P(long nodeId, String parentTitle, int start,
2083 int end) throws SystemException {
2084 return findByN_P(nodeId, parentTitle, start, end, null);
2085 }
2086
2087 public List<WikiPage> findByN_P(long nodeId, String parentTitle, int start,
2088 int end, OrderByComparator obc) throws SystemException {
2089 Object[] finderArgs = new Object[] {
2090 new Long(nodeId),
2091
2092 parentTitle,
2093
2094 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2095 };
2096
2097 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_N_P,
2098 finderArgs, this);
2099
2100 if (list == null) {
2101 Session session = null;
2102
2103 try {
2104 session = openSession();
2105
2106 StringBundler query = null;
2107
2108 if (obc != null) {
2109 query = new StringBundler(4 +
2110 (obc.getOrderByFields().length * 3));
2111 }
2112 else {
2113 query = new StringBundler(4);
2114 }
2115
2116 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2117
2118 query.append(_FINDER_COLUMN_N_P_NODEID_2);
2119
2120 if (parentTitle == null) {
2121 query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
2122 }
2123 else {
2124 if (parentTitle.equals(StringPool.BLANK)) {
2125 query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
2126 }
2127 else {
2128 query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
2129 }
2130 }
2131
2132 if (obc != null) {
2133 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2134 }
2135
2136 else {
2137 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2138 }
2139
2140 String sql = query.toString();
2141
2142 Query q = session.createQuery(sql);
2143
2144 QueryPos qPos = QueryPos.getInstance(q);
2145
2146 qPos.add(nodeId);
2147
2148 if (parentTitle != null) {
2149 qPos.add(parentTitle);
2150 }
2151
2152 list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
2153 end);
2154 }
2155 catch (Exception e) {
2156 throw processException(e);
2157 }
2158 finally {
2159 if (list == null) {
2160 list = new ArrayList<WikiPage>();
2161 }
2162
2163 cacheResult(list);
2164
2165 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_N_P,
2166 finderArgs, list);
2167
2168 closeSession(session);
2169 }
2170 }
2171
2172 return list;
2173 }
2174
2175 public WikiPage findByN_P_First(long nodeId, String parentTitle,
2176 OrderByComparator obc) throws NoSuchPageException, SystemException {
2177 List<WikiPage> list = findByN_P(nodeId, parentTitle, 0, 1, obc);
2178
2179 if (list.isEmpty()) {
2180 StringBundler msg = new StringBundler(6);
2181
2182 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2183
2184 msg.append("nodeId=");
2185 msg.append(nodeId);
2186
2187 msg.append(", parentTitle=");
2188 msg.append(parentTitle);
2189
2190 msg.append(StringPool.CLOSE_CURLY_BRACE);
2191
2192 throw new NoSuchPageException(msg.toString());
2193 }
2194 else {
2195 return list.get(0);
2196 }
2197 }
2198
2199 public WikiPage findByN_P_Last(long nodeId, String parentTitle,
2200 OrderByComparator obc) throws NoSuchPageException, SystemException {
2201 int count = countByN_P(nodeId, parentTitle);
2202
2203 List<WikiPage> list = findByN_P(nodeId, parentTitle, count - 1, count,
2204 obc);
2205
2206 if (list.isEmpty()) {
2207 StringBundler msg = new StringBundler(6);
2208
2209 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2210
2211 msg.append("nodeId=");
2212 msg.append(nodeId);
2213
2214 msg.append(", parentTitle=");
2215 msg.append(parentTitle);
2216
2217 msg.append(StringPool.CLOSE_CURLY_BRACE);
2218
2219 throw new NoSuchPageException(msg.toString());
2220 }
2221 else {
2222 return list.get(0);
2223 }
2224 }
2225
2226 public WikiPage[] findByN_P_PrevAndNext(long pageId, long nodeId,
2227 String parentTitle, OrderByComparator obc)
2228 throws NoSuchPageException, SystemException {
2229 WikiPage wikiPage = findByPrimaryKey(pageId);
2230
2231 int count = countByN_P(nodeId, parentTitle);
2232
2233 Session session = null;
2234
2235 try {
2236 session = openSession();
2237
2238 StringBundler query = null;
2239
2240 if (obc != null) {
2241 query = new StringBundler(4 +
2242 (obc.getOrderByFields().length * 3));
2243 }
2244 else {
2245 query = new StringBundler(4);
2246 }
2247
2248 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2249
2250 query.append(_FINDER_COLUMN_N_P_NODEID_2);
2251
2252 if (parentTitle == null) {
2253 query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
2254 }
2255 else {
2256 if (parentTitle.equals(StringPool.BLANK)) {
2257 query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
2258 }
2259 else {
2260 query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
2261 }
2262 }
2263
2264 if (obc != null) {
2265 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2266 }
2267
2268 else {
2269 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2270 }
2271
2272 String sql = query.toString();
2273
2274 Query q = session.createQuery(sql);
2275
2276 QueryPos qPos = QueryPos.getInstance(q);
2277
2278 qPos.add(nodeId);
2279
2280 if (parentTitle != null) {
2281 qPos.add(parentTitle);
2282 }
2283
2284 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
2285
2286 WikiPage[] array = new WikiPageImpl[3];
2287
2288 array[0] = (WikiPage)objArray[0];
2289 array[1] = (WikiPage)objArray[1];
2290 array[2] = (WikiPage)objArray[2];
2291
2292 return array;
2293 }
2294 catch (Exception e) {
2295 throw processException(e);
2296 }
2297 finally {
2298 closeSession(session);
2299 }
2300 }
2301
2302 public List<WikiPage> findByN_R(long nodeId, String redirectTitle)
2303 throws SystemException {
2304 Object[] finderArgs = new Object[] { new Long(nodeId), redirectTitle };
2305
2306 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_R,
2307 finderArgs, this);
2308
2309 if (list == null) {
2310 Session session = null;
2311
2312 try {
2313 session = openSession();
2314
2315 StringBundler query = new StringBundler(4);
2316
2317 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2318
2319 query.append(_FINDER_COLUMN_N_R_NODEID_2);
2320
2321 if (redirectTitle == null) {
2322 query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
2323 }
2324 else {
2325 if (redirectTitle.equals(StringPool.BLANK)) {
2326 query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
2327 }
2328 else {
2329 query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
2330 }
2331 }
2332
2333 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2334
2335 String sql = query.toString();
2336
2337 Query q = session.createQuery(sql);
2338
2339 QueryPos qPos = QueryPos.getInstance(q);
2340
2341 qPos.add(nodeId);
2342
2343 if (redirectTitle != null) {
2344 qPos.add(redirectTitle);
2345 }
2346
2347 list = q.list();
2348 }
2349 catch (Exception e) {
2350 throw processException(e);
2351 }
2352 finally {
2353 if (list == null) {
2354 list = new ArrayList<WikiPage>();
2355 }
2356
2357 cacheResult(list);
2358
2359 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_R, finderArgs,
2360 list);
2361
2362 closeSession(session);
2363 }
2364 }
2365
2366 return list;
2367 }
2368
2369 public List<WikiPage> findByN_R(long nodeId, String redirectTitle,
2370 int start, int end) throws SystemException {
2371 return findByN_R(nodeId, redirectTitle, start, end, null);
2372 }
2373
2374 public List<WikiPage> findByN_R(long nodeId, String redirectTitle,
2375 int start, int end, OrderByComparator obc) throws SystemException {
2376 Object[] finderArgs = new Object[] {
2377 new Long(nodeId),
2378
2379 redirectTitle,
2380
2381 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2382 };
2383
2384 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_N_R,
2385 finderArgs, this);
2386
2387 if (list == null) {
2388 Session session = null;
2389
2390 try {
2391 session = openSession();
2392
2393 StringBundler query = null;
2394
2395 if (obc != null) {
2396 query = new StringBundler(4 +
2397 (obc.getOrderByFields().length * 3));
2398 }
2399 else {
2400 query = new StringBundler(4);
2401 }
2402
2403 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2404
2405 query.append(_FINDER_COLUMN_N_R_NODEID_2);
2406
2407 if (redirectTitle == null) {
2408 query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
2409 }
2410 else {
2411 if (redirectTitle.equals(StringPool.BLANK)) {
2412 query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
2413 }
2414 else {
2415 query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
2416 }
2417 }
2418
2419 if (obc != null) {
2420 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2421 }
2422
2423 else {
2424 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2425 }
2426
2427 String sql = query.toString();
2428
2429 Query q = session.createQuery(sql);
2430
2431 QueryPos qPos = QueryPos.getInstance(q);
2432
2433 qPos.add(nodeId);
2434
2435 if (redirectTitle != null) {
2436 qPos.add(redirectTitle);
2437 }
2438
2439 list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
2440 end);
2441 }
2442 catch (Exception e) {
2443 throw processException(e);
2444 }
2445 finally {
2446 if (list == null) {
2447 list = new ArrayList<WikiPage>();
2448 }
2449
2450 cacheResult(list);
2451
2452 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_N_R,
2453 finderArgs, list);
2454
2455 closeSession(session);
2456 }
2457 }
2458
2459 return list;
2460 }
2461
2462 public WikiPage findByN_R_First(long nodeId, String redirectTitle,
2463 OrderByComparator obc) throws NoSuchPageException, SystemException {
2464 List<WikiPage> list = findByN_R(nodeId, redirectTitle, 0, 1, obc);
2465
2466 if (list.isEmpty()) {
2467 StringBundler msg = new StringBundler(6);
2468
2469 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2470
2471 msg.append("nodeId=");
2472 msg.append(nodeId);
2473
2474 msg.append(", redirectTitle=");
2475 msg.append(redirectTitle);
2476
2477 msg.append(StringPool.CLOSE_CURLY_BRACE);
2478
2479 throw new NoSuchPageException(msg.toString());
2480 }
2481 else {
2482 return list.get(0);
2483 }
2484 }
2485
2486 public WikiPage findByN_R_Last(long nodeId, String redirectTitle,
2487 OrderByComparator obc) throws NoSuchPageException, SystemException {
2488 int count = countByN_R(nodeId, redirectTitle);
2489
2490 List<WikiPage> list = findByN_R(nodeId, redirectTitle, count - 1,
2491 count, obc);
2492
2493 if (list.isEmpty()) {
2494 StringBundler msg = new StringBundler(6);
2495
2496 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2497
2498 msg.append("nodeId=");
2499 msg.append(nodeId);
2500
2501 msg.append(", redirectTitle=");
2502 msg.append(redirectTitle);
2503
2504 msg.append(StringPool.CLOSE_CURLY_BRACE);
2505
2506 throw new NoSuchPageException(msg.toString());
2507 }
2508 else {
2509 return list.get(0);
2510 }
2511 }
2512
2513 public WikiPage[] findByN_R_PrevAndNext(long pageId, long nodeId,
2514 String redirectTitle, OrderByComparator obc)
2515 throws NoSuchPageException, SystemException {
2516 WikiPage wikiPage = findByPrimaryKey(pageId);
2517
2518 int count = countByN_R(nodeId, redirectTitle);
2519
2520 Session session = null;
2521
2522 try {
2523 session = openSession();
2524
2525 StringBundler query = null;
2526
2527 if (obc != null) {
2528 query = new StringBundler(4 +
2529 (obc.getOrderByFields().length * 3));
2530 }
2531 else {
2532 query = new StringBundler(4);
2533 }
2534
2535 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2536
2537 query.append(_FINDER_COLUMN_N_R_NODEID_2);
2538
2539 if (redirectTitle == null) {
2540 query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
2541 }
2542 else {
2543 if (redirectTitle.equals(StringPool.BLANK)) {
2544 query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
2545 }
2546 else {
2547 query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
2548 }
2549 }
2550
2551 if (obc != null) {
2552 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2553 }
2554
2555 else {
2556 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2557 }
2558
2559 String sql = query.toString();
2560
2561 Query q = session.createQuery(sql);
2562
2563 QueryPos qPos = QueryPos.getInstance(q);
2564
2565 qPos.add(nodeId);
2566
2567 if (redirectTitle != null) {
2568 qPos.add(redirectTitle);
2569 }
2570
2571 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
2572
2573 WikiPage[] array = new WikiPageImpl[3];
2574
2575 array[0] = (WikiPage)objArray[0];
2576 array[1] = (WikiPage)objArray[1];
2577 array[2] = (WikiPage)objArray[2];
2578
2579 return array;
2580 }
2581 catch (Exception e) {
2582 throw processException(e);
2583 }
2584 finally {
2585 closeSession(session);
2586 }
2587 }
2588
2589 public WikiPage findByN_T_V(long nodeId, String title, double version)
2590 throws NoSuchPageException, SystemException {
2591 WikiPage wikiPage = fetchByN_T_V(nodeId, title, version);
2592
2593 if (wikiPage == null) {
2594 StringBundler msg = new StringBundler(8);
2595
2596 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2597
2598 msg.append("nodeId=");
2599 msg.append(nodeId);
2600
2601 msg.append(", title=");
2602 msg.append(title);
2603
2604 msg.append(", version=");
2605 msg.append(version);
2606
2607 msg.append(StringPool.CLOSE_CURLY_BRACE);
2608
2609 if (_log.isWarnEnabled()) {
2610 _log.warn(msg.toString());
2611 }
2612
2613 throw new NoSuchPageException(msg.toString());
2614 }
2615
2616 return wikiPage;
2617 }
2618
2619 public WikiPage fetchByN_T_V(long nodeId, String title, double version)
2620 throws SystemException {
2621 return fetchByN_T_V(nodeId, title, version, true);
2622 }
2623
2624 public WikiPage fetchByN_T_V(long nodeId, String title, double version,
2625 boolean retrieveFromCache) throws SystemException {
2626 Object[] finderArgs = new Object[] {
2627 new Long(nodeId),
2628
2629 title, new Double(version)
2630 };
2631
2632 Object result = null;
2633
2634 if (retrieveFromCache) {
2635 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_N_T_V,
2636 finderArgs, this);
2637 }
2638
2639 if (result == null) {
2640 Session session = null;
2641
2642 try {
2643 session = openSession();
2644
2645 StringBundler query = new StringBundler(5);
2646
2647 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2648
2649 query.append(_FINDER_COLUMN_N_T_V_NODEID_2);
2650
2651 if (title == null) {
2652 query.append(_FINDER_COLUMN_N_T_V_TITLE_1);
2653 }
2654 else {
2655 if (title.equals(StringPool.BLANK)) {
2656 query.append(_FINDER_COLUMN_N_T_V_TITLE_3);
2657 }
2658 else {
2659 query.append(_FINDER_COLUMN_N_T_V_TITLE_2);
2660 }
2661 }
2662
2663 query.append(_FINDER_COLUMN_N_T_V_VERSION_2);
2664
2665 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2666
2667 String sql = query.toString();
2668
2669 Query q = session.createQuery(sql);
2670
2671 QueryPos qPos = QueryPos.getInstance(q);
2672
2673 qPos.add(nodeId);
2674
2675 if (title != null) {
2676 qPos.add(title);
2677 }
2678
2679 qPos.add(version);
2680
2681 List<WikiPage> list = q.list();
2682
2683 result = list;
2684
2685 WikiPage wikiPage = null;
2686
2687 if (list.isEmpty()) {
2688 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
2689 finderArgs, list);
2690 }
2691 else {
2692 wikiPage = list.get(0);
2693
2694 cacheResult(wikiPage);
2695
2696 if ((wikiPage.getNodeId() != nodeId) ||
2697 (wikiPage.getTitle() == null) ||
2698 !wikiPage.getTitle().equals(title) ||
2699 (wikiPage.getVersion() != version)) {
2700 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
2701 finderArgs, wikiPage);
2702 }
2703 }
2704
2705 return wikiPage;
2706 }
2707 catch (Exception e) {
2708 throw processException(e);
2709 }
2710 finally {
2711 if (result == null) {
2712 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_N_T_V,
2713 finderArgs, new ArrayList<WikiPage>());
2714 }
2715
2716 closeSession(session);
2717 }
2718 }
2719 else {
2720 if (result instanceof List<?>) {
2721 return null;
2722 }
2723 else {
2724 return (WikiPage)result;
2725 }
2726 }
2727 }
2728
2729 public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head)
2730 throws SystemException {
2731 Object[] finderArgs = new Object[] {
2732 new Long(nodeId),
2733
2734 title, Boolean.valueOf(head)
2735 };
2736
2737 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_T_H,
2738 finderArgs, this);
2739
2740 if (list == null) {
2741 Session session = null;
2742
2743 try {
2744 session = openSession();
2745
2746 StringBundler query = new StringBundler(5);
2747
2748 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2749
2750 query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
2751
2752 if (title == null) {
2753 query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
2754 }
2755 else {
2756 if (title.equals(StringPool.BLANK)) {
2757 query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
2758 }
2759 else {
2760 query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
2761 }
2762 }
2763
2764 query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
2765
2766 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2767
2768 String sql = query.toString();
2769
2770 Query q = session.createQuery(sql);
2771
2772 QueryPos qPos = QueryPos.getInstance(q);
2773
2774 qPos.add(nodeId);
2775
2776 if (title != null) {
2777 qPos.add(title);
2778 }
2779
2780 qPos.add(head);
2781
2782 list = q.list();
2783 }
2784 catch (Exception e) {
2785 throw processException(e);
2786 }
2787 finally {
2788 if (list == null) {
2789 list = new ArrayList<WikiPage>();
2790 }
2791
2792 cacheResult(list);
2793
2794 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_T_H,
2795 finderArgs, list);
2796
2797 closeSession(session);
2798 }
2799 }
2800
2801 return list;
2802 }
2803
2804 public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head,
2805 int start, int end) throws SystemException {
2806 return findByN_T_H(nodeId, title, head, start, end, null);
2807 }
2808
2809 public List<WikiPage> findByN_T_H(long nodeId, String title, boolean head,
2810 int start, int end, OrderByComparator obc) throws SystemException {
2811 Object[] finderArgs = new Object[] {
2812 new Long(nodeId),
2813
2814 title, Boolean.valueOf(head),
2815
2816 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2817 };
2818
2819 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_N_T_H,
2820 finderArgs, this);
2821
2822 if (list == null) {
2823 Session session = null;
2824
2825 try {
2826 session = openSession();
2827
2828 StringBundler query = null;
2829
2830 if (obc != null) {
2831 query = new StringBundler(5 +
2832 (obc.getOrderByFields().length * 3));
2833 }
2834 else {
2835 query = new StringBundler(5);
2836 }
2837
2838 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2839
2840 query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
2841
2842 if (title == null) {
2843 query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
2844 }
2845 else {
2846 if (title.equals(StringPool.BLANK)) {
2847 query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
2848 }
2849 else {
2850 query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
2851 }
2852 }
2853
2854 query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
2855
2856 if (obc != null) {
2857 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
2858 }
2859
2860 else {
2861 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
2862 }
2863
2864 String sql = query.toString();
2865
2866 Query q = session.createQuery(sql);
2867
2868 QueryPos qPos = QueryPos.getInstance(q);
2869
2870 qPos.add(nodeId);
2871
2872 if (title != null) {
2873 qPos.add(title);
2874 }
2875
2876 qPos.add(head);
2877
2878 list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
2879 end);
2880 }
2881 catch (Exception e) {
2882 throw processException(e);
2883 }
2884 finally {
2885 if (list == null) {
2886 list = new ArrayList<WikiPage>();
2887 }
2888
2889 cacheResult(list);
2890
2891 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_N_T_H,
2892 finderArgs, list);
2893
2894 closeSession(session);
2895 }
2896 }
2897
2898 return list;
2899 }
2900
2901 public WikiPage findByN_T_H_First(long nodeId, String title, boolean head,
2902 OrderByComparator obc) throws NoSuchPageException, SystemException {
2903 List<WikiPage> list = findByN_T_H(nodeId, title, head, 0, 1, obc);
2904
2905 if (list.isEmpty()) {
2906 StringBundler msg = new StringBundler(8);
2907
2908 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2909
2910 msg.append("nodeId=");
2911 msg.append(nodeId);
2912
2913 msg.append(", title=");
2914 msg.append(title);
2915
2916 msg.append(", head=");
2917 msg.append(head);
2918
2919 msg.append(StringPool.CLOSE_CURLY_BRACE);
2920
2921 throw new NoSuchPageException(msg.toString());
2922 }
2923 else {
2924 return list.get(0);
2925 }
2926 }
2927
2928 public WikiPage findByN_T_H_Last(long nodeId, String title, boolean head,
2929 OrderByComparator obc) throws NoSuchPageException, SystemException {
2930 int count = countByN_T_H(nodeId, title, head);
2931
2932 List<WikiPage> list = findByN_T_H(nodeId, title, head, count - 1,
2933 count, obc);
2934
2935 if (list.isEmpty()) {
2936 StringBundler msg = new StringBundler(8);
2937
2938 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2939
2940 msg.append("nodeId=");
2941 msg.append(nodeId);
2942
2943 msg.append(", title=");
2944 msg.append(title);
2945
2946 msg.append(", head=");
2947 msg.append(head);
2948
2949 msg.append(StringPool.CLOSE_CURLY_BRACE);
2950
2951 throw new NoSuchPageException(msg.toString());
2952 }
2953 else {
2954 return list.get(0);
2955 }
2956 }
2957
2958 public WikiPage[] findByN_T_H_PrevAndNext(long pageId, long nodeId,
2959 String title, boolean head, OrderByComparator obc)
2960 throws NoSuchPageException, SystemException {
2961 WikiPage wikiPage = findByPrimaryKey(pageId);
2962
2963 int count = countByN_T_H(nodeId, title, head);
2964
2965 Session session = null;
2966
2967 try {
2968 session = openSession();
2969
2970 StringBundler query = null;
2971
2972 if (obc != null) {
2973 query = new StringBundler(5 +
2974 (obc.getOrderByFields().length * 3));
2975 }
2976 else {
2977 query = new StringBundler(5);
2978 }
2979
2980 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
2981
2982 query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
2983
2984 if (title == null) {
2985 query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
2986 }
2987 else {
2988 if (title.equals(StringPool.BLANK)) {
2989 query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
2990 }
2991 else {
2992 query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
2993 }
2994 }
2995
2996 query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
2997
2998 if (obc != null) {
2999 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
3000 }
3001
3002 else {
3003 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3004 }
3005
3006 String sql = query.toString();
3007
3008 Query q = session.createQuery(sql);
3009
3010 QueryPos qPos = QueryPos.getInstance(q);
3011
3012 qPos.add(nodeId);
3013
3014 if (title != null) {
3015 qPos.add(title);
3016 }
3017
3018 qPos.add(head);
3019
3020 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
3021
3022 WikiPage[] array = new WikiPageImpl[3];
3023
3024 array[0] = (WikiPage)objArray[0];
3025 array[1] = (WikiPage)objArray[1];
3026 array[2] = (WikiPage)objArray[2];
3027
3028 return array;
3029 }
3030 catch (Exception e) {
3031 throw processException(e);
3032 }
3033 finally {
3034 closeSession(session);
3035 }
3036 }
3037
3038 public List<WikiPage> findByN_H_P(long nodeId, boolean head,
3039 String parentTitle) throws SystemException {
3040 Object[] finderArgs = new Object[] {
3041 new Long(nodeId), Boolean.valueOf(head),
3042
3043 parentTitle
3044 };
3045
3046 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_N_H_P,
3047 finderArgs, this);
3048
3049 if (list == null) {
3050 Session session = null;
3051
3052 try {
3053 session = openSession();
3054
3055 StringBundler query = new StringBundler(5);
3056
3057 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3058
3059 query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
3060
3061 query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
3062
3063 if (parentTitle == null) {
3064 query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
3065 }
3066 else {
3067 if (parentTitle.equals(StringPool.BLANK)) {
3068 query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
3069 }
3070 else {
3071 query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
3072 }
3073 }
3074
3075 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3076
3077 String sql = query.toString();
3078
3079 Query q = session.createQuery(sql);
3080
3081 QueryPos qPos = QueryPos.getInstance(q);
3082
3083 qPos.add(nodeId);
3084
3085 qPos.add(head);
3086
3087 if (parentTitle != null) {
3088 qPos.add(parentTitle);
3089 }
3090
3091 list = q.list();
3092 }
3093 catch (Exception e) {
3094 throw processException(e);
3095 }
3096 finally {
3097 if (list == null) {
3098 list = new ArrayList<WikiPage>();
3099 }
3100
3101 cacheResult(list);
3102
3103 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_N_H_P,
3104 finderArgs, list);
3105
3106 closeSession(session);
3107 }
3108 }
3109
3110 return list;
3111 }
3112
3113 public List<WikiPage> findByN_H_P(long nodeId, boolean head,
3114 String parentTitle, int start, int end) throws SystemException {
3115 return findByN_H_P(nodeId, head, parentTitle, start, end, null);
3116 }
3117
3118 public List<WikiPage> findByN_H_P(long nodeId, boolean head,
3119 String parentTitle, int start, int end, OrderByComparator obc)
3120 throws SystemException {
3121 Object[] finderArgs = new Object[] {
3122 new Long(nodeId), Boolean.valueOf(head),
3123
3124 parentTitle,
3125
3126 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
3127 };
3128
3129 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_N_H_P,
3130 finderArgs, this);
3131
3132 if (list == null) {
3133 Session session = null;
3134
3135 try {
3136 session = openSession();
3137
3138 StringBundler query = null;
3139
3140 if (obc != null) {
3141 query = new StringBundler(5 +
3142 (obc.getOrderByFields().length * 3));
3143 }
3144 else {
3145 query = new StringBundler(5);
3146 }
3147
3148 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3149
3150 query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
3151
3152 query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
3153
3154 if (parentTitle == null) {
3155 query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
3156 }
3157 else {
3158 if (parentTitle.equals(StringPool.BLANK)) {
3159 query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
3160 }
3161 else {
3162 query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
3163 }
3164 }
3165
3166 if (obc != null) {
3167 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
3168 }
3169
3170 else {
3171 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3172 }
3173
3174 String sql = query.toString();
3175
3176 Query q = session.createQuery(sql);
3177
3178 QueryPos qPos = QueryPos.getInstance(q);
3179
3180 qPos.add(nodeId);
3181
3182 qPos.add(head);
3183
3184 if (parentTitle != null) {
3185 qPos.add(parentTitle);
3186 }
3187
3188 list = (List<WikiPage>)QueryUtil.list(q, getDialect(), start,
3189 end);
3190 }
3191 catch (Exception e) {
3192 throw processException(e);
3193 }
3194 finally {
3195 if (list == null) {
3196 list = new ArrayList<WikiPage>();
3197 }
3198
3199 cacheResult(list);
3200
3201 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_N_H_P,
3202 finderArgs, list);
3203
3204 closeSession(session);
3205 }
3206 }
3207
3208 return list;
3209 }
3210
3211 public WikiPage findByN_H_P_First(long nodeId, boolean head,
3212 String parentTitle, OrderByComparator obc)
3213 throws NoSuchPageException, SystemException {
3214 List<WikiPage> list = findByN_H_P(nodeId, head, parentTitle, 0, 1, obc);
3215
3216 if (list.isEmpty()) {
3217 StringBundler msg = new StringBundler(8);
3218
3219 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3220
3221 msg.append("nodeId=");
3222 msg.append(nodeId);
3223
3224 msg.append(", head=");
3225 msg.append(head);
3226
3227 msg.append(", parentTitle=");
3228 msg.append(parentTitle);
3229
3230 msg.append(StringPool.CLOSE_CURLY_BRACE);
3231
3232 throw new NoSuchPageException(msg.toString());
3233 }
3234 else {
3235 return list.get(0);
3236 }
3237 }
3238
3239 public WikiPage findByN_H_P_Last(long nodeId, boolean head,
3240 String parentTitle, OrderByComparator obc)
3241 throws NoSuchPageException, SystemException {
3242 int count = countByN_H_P(nodeId, head, parentTitle);
3243
3244 List<WikiPage> list = findByN_H_P(nodeId, head, parentTitle, count - 1,
3245 count, obc);
3246
3247 if (list.isEmpty()) {
3248 StringBundler msg = new StringBundler(8);
3249
3250 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3251
3252 msg.append("nodeId=");
3253 msg.append(nodeId);
3254
3255 msg.append(", head=");
3256 msg.append(head);
3257
3258 msg.append(", parentTitle=");
3259 msg.append(parentTitle);
3260
3261 msg.append(StringPool.CLOSE_CURLY_BRACE);
3262
3263 throw new NoSuchPageException(msg.toString());
3264 }
3265 else {
3266 return list.get(0);
3267 }
3268 }
3269
3270 public WikiPage[] findByN_H_P_PrevAndNext(long pageId, long nodeId,
3271 boolean head, String parentTitle, OrderByComparator obc)
3272 throws NoSuchPageException, SystemException {
3273 WikiPage wikiPage = findByPrimaryKey(pageId);
3274
3275 int count = countByN_H_P(nodeId, head, parentTitle);
3276
3277 Session session = null;
3278
3279 try {
3280 session = openSession();
3281
3282 StringBundler query = null;
3283
3284 if (obc != null) {
3285 query = new StringBundler(5 +
3286 (obc.getOrderByFields().length * 3));
3287 }
3288 else {
3289 query = new StringBundler(5);
3290 }
3291
3292 query.append(_SQL_SELECT_WIKIPAGE_WHERE);
3293
3294 query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
3295
3296 query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
3297
3298 if (parentTitle == null) {
3299 query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
3300 }
3301 else {
3302 if (parentTitle.equals(StringPool.BLANK)) {
3303 query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
3304 }
3305 else {
3306 query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
3307 }
3308 }
3309
3310 if (obc != null) {
3311 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
3312 }
3313
3314 else {
3315 query.append(WikiPageModelImpl.ORDER_BY_JPQL);
3316 }
3317
3318 String sql = query.toString();
3319
3320 Query q = session.createQuery(sql);
3321
3322 QueryPos qPos = QueryPos.getInstance(q);
3323
3324 qPos.add(nodeId);
3325
3326 qPos.add(head);
3327
3328 if (parentTitle != null) {
3329 qPos.add(parentTitle);
3330 }
3331
3332 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc, wikiPage);
3333
3334 WikiPage[] array = new WikiPageImpl[3];
3335
3336 array[0] = (WikiPage)objArray[0];
3337 array[1] = (WikiPage)objArray[1];
3338 array[2] = (WikiPage)objArray[2];
3339
3340 return array;
3341 }
3342 catch (Exception e) {
3343 throw processException(e);
3344 }
3345 finally {
3346 closeSession(session);
3347 }
3348 }
3349
3350 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
3351 throws SystemException {
3352 Session session = null;
3353
3354 try {
3355 session = openSession();
3356
3357 dynamicQuery.compile(session);
3358
3359 return dynamicQuery.list();
3360 }
3361 catch (Exception e) {
3362 throw processException(e);
3363 }
3364 finally {
3365 closeSession(session);
3366 }
3367 }
3368
3369 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
3370 int start, int end) throws SystemException {
3371 Session session = null;
3372
3373 try {
3374 session = openSession();
3375
3376 dynamicQuery.setLimit(start, end);
3377
3378 dynamicQuery.compile(session);
3379
3380 return dynamicQuery.list();
3381 }
3382 catch (Exception e) {
3383 throw processException(e);
3384 }
3385 finally {
3386 closeSession(session);
3387 }
3388 }
3389
3390 public List<WikiPage> findAll() throws SystemException {
3391 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3392 }
3393
3394 public List<WikiPage> findAll(int start, int end) throws SystemException {
3395 return findAll(start, end, null);
3396 }
3397
3398 public List<WikiPage> findAll(int start, int end, OrderByComparator obc)
3399 throws SystemException {
3400 Object[] finderArgs = new Object[] {
3401 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
3402 };
3403
3404 List<WikiPage> list = (List<WikiPage>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
3405 finderArgs, this);
3406
3407 if (list == null) {
3408 Session session = null;
3409
3410 try {
3411 session = openSession();
3412
3413 StringBundler query = null;
3414 String sql = null;
3415
3416 if (obc != null) {
3417 query = new StringBundler(2 +
3418 (obc.getOrderByFields().length * 3));
3419
3420 query.append(_SQL_SELECT_WIKIPAGE);
3421
3422 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, obc);
3423
3424 sql = query.toString();
3425 }
3426
3427 else {
3428 sql = _SQL_SELECT_WIKIPAGE.concat(WikiPageModelImpl.ORDER_BY_JPQL);
3429 }
3430
3431 Query q = session.createQuery(sql);
3432
3433 if (obc == null) {
3434 list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
3435 start, end, false);
3436
3437 Collections.sort(list);
3438 }
3439 else {
3440 list = (List<WikiPage>)QueryUtil.list(q, getDialect(),
3441 start, end);
3442 }
3443 }
3444 catch (Exception e) {
3445 throw processException(e);
3446 }
3447 finally {
3448 if (list == null) {
3449 list = new ArrayList<WikiPage>();
3450 }
3451
3452 cacheResult(list);
3453
3454 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
3455
3456 closeSession(session);
3457 }
3458 }
3459
3460 return list;
3461 }
3462
3463 public void removeByUuid(String uuid) throws SystemException {
3464 for (WikiPage wikiPage : findByUuid(uuid)) {
3465 remove(wikiPage);
3466 }
3467 }
3468
3469 public void removeByUUID_G(String uuid, long groupId)
3470 throws NoSuchPageException, SystemException {
3471 WikiPage wikiPage = findByUUID_G(uuid, groupId);
3472
3473 remove(wikiPage);
3474 }
3475
3476 public void removeByNodeId(long nodeId) throws SystemException {
3477 for (WikiPage wikiPage : findByNodeId(nodeId)) {
3478 remove(wikiPage);
3479 }
3480 }
3481
3482 public void removeByFormat(String format) throws SystemException {
3483 for (WikiPage wikiPage : findByFormat(format)) {
3484 remove(wikiPage);
3485 }
3486 }
3487
3488 public void removeByN_T(long nodeId, String title)
3489 throws SystemException {
3490 for (WikiPage wikiPage : findByN_T(nodeId, title)) {
3491 remove(wikiPage);
3492 }
3493 }
3494
3495 public void removeByN_H(long nodeId, boolean head)
3496 throws SystemException {
3497 for (WikiPage wikiPage : findByN_H(nodeId, head)) {
3498 remove(wikiPage);
3499 }
3500 }
3501
3502 public void removeByN_P(long nodeId, String parentTitle)
3503 throws SystemException {
3504 for (WikiPage wikiPage : findByN_P(nodeId, parentTitle)) {
3505 remove(wikiPage);
3506 }
3507 }
3508
3509 public void removeByN_R(long nodeId, String redirectTitle)
3510 throws SystemException {
3511 for (WikiPage wikiPage : findByN_R(nodeId, redirectTitle)) {
3512 remove(wikiPage);
3513 }
3514 }
3515
3516 public void removeByN_T_V(long nodeId, String title, double version)
3517 throws NoSuchPageException, SystemException {
3518 WikiPage wikiPage = findByN_T_V(nodeId, title, version);
3519
3520 remove(wikiPage);
3521 }
3522
3523 public void removeByN_T_H(long nodeId, String title, boolean head)
3524 throws SystemException {
3525 for (WikiPage wikiPage : findByN_T_H(nodeId, title, head)) {
3526 remove(wikiPage);
3527 }
3528 }
3529
3530 public void removeByN_H_P(long nodeId, boolean head, String parentTitle)
3531 throws SystemException {
3532 for (WikiPage wikiPage : findByN_H_P(nodeId, head, parentTitle)) {
3533 remove(wikiPage);
3534 }
3535 }
3536
3537 public void removeAll() throws SystemException {
3538 for (WikiPage wikiPage : findAll()) {
3539 remove(wikiPage);
3540 }
3541 }
3542
3543 public int countByUuid(String uuid) throws SystemException {
3544 Object[] finderArgs = new Object[] { uuid };
3545
3546 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3547 finderArgs, this);
3548
3549 if (count == null) {
3550 Session session = null;
3551
3552 try {
3553 session = openSession();
3554
3555 StringBundler query = new StringBundler(2);
3556
3557 query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3558
3559 if (uuid == null) {
3560 query.append(_FINDER_COLUMN_UUID_UUID_1);
3561 }
3562 else {
3563 if (uuid.equals(StringPool.BLANK)) {
3564 query.append(_FINDER_COLUMN_UUID_UUID_3);
3565 }
3566 else {
3567 query.append(_FINDER_COLUMN_UUID_UUID_2);
3568 }
3569 }
3570
3571 String sql = query.toString();
3572
3573 Query q = session.createQuery(sql);
3574
3575 QueryPos qPos = QueryPos.getInstance(q);
3576
3577 if (uuid != null) {
3578 qPos.add(uuid);
3579 }
3580
3581 count = (Long)q.uniqueResult();
3582 }
3583 catch (Exception e) {
3584 throw processException(e);
3585 }
3586 finally {
3587 if (count == null) {
3588 count = Long.valueOf(0);
3589 }
3590
3591 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3592 finderArgs, count);
3593
3594 closeSession(session);
3595 }
3596 }
3597
3598 return count.intValue();
3599 }
3600
3601 public int countByUUID_G(String uuid, long groupId)
3602 throws SystemException {
3603 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
3604
3605 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
3606 finderArgs, this);
3607
3608 if (count == null) {
3609 Session session = null;
3610
3611 try {
3612 session = openSession();
3613
3614 StringBundler query = new StringBundler(3);
3615
3616 query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3617
3618 if (uuid == null) {
3619 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
3620 }
3621 else {
3622 if (uuid.equals(StringPool.BLANK)) {
3623 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
3624 }
3625 else {
3626 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
3627 }
3628 }
3629
3630 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
3631
3632 String sql = query.toString();
3633
3634 Query q = session.createQuery(sql);
3635
3636 QueryPos qPos = QueryPos.getInstance(q);
3637
3638 if (uuid != null) {
3639 qPos.add(uuid);
3640 }
3641
3642 qPos.add(groupId);
3643
3644 count = (Long)q.uniqueResult();
3645 }
3646 catch (Exception e) {
3647 throw processException(e);
3648 }
3649 finally {
3650 if (count == null) {
3651 count = Long.valueOf(0);
3652 }
3653
3654 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
3655 finderArgs, count);
3656
3657 closeSession(session);
3658 }
3659 }
3660
3661 return count.intValue();
3662 }
3663
3664 public int countByNodeId(long nodeId) throws SystemException {
3665 Object[] finderArgs = new Object[] { new Long(nodeId) };
3666
3667 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_NODEID,
3668 finderArgs, this);
3669
3670 if (count == null) {
3671 Session session = null;
3672
3673 try {
3674 session = openSession();
3675
3676 StringBundler query = new StringBundler(2);
3677
3678 query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3679
3680 query.append(_FINDER_COLUMN_NODEID_NODEID_2);
3681
3682 String sql = query.toString();
3683
3684 Query q = session.createQuery(sql);
3685
3686 QueryPos qPos = QueryPos.getInstance(q);
3687
3688 qPos.add(nodeId);
3689
3690 count = (Long)q.uniqueResult();
3691 }
3692 catch (Exception e) {
3693 throw processException(e);
3694 }
3695 finally {
3696 if (count == null) {
3697 count = Long.valueOf(0);
3698 }
3699
3700 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_NODEID,
3701 finderArgs, count);
3702
3703 closeSession(session);
3704 }
3705 }
3706
3707 return count.intValue();
3708 }
3709
3710 public int countByFormat(String format) throws SystemException {
3711 Object[] finderArgs = new Object[] { format };
3712
3713 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FORMAT,
3714 finderArgs, this);
3715
3716 if (count == null) {
3717 Session session = null;
3718
3719 try {
3720 session = openSession();
3721
3722 StringBundler query = new StringBundler(2);
3723
3724 query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3725
3726 if (format == null) {
3727 query.append(_FINDER_COLUMN_FORMAT_FORMAT_1);
3728 }
3729 else {
3730 if (format.equals(StringPool.BLANK)) {
3731 query.append(_FINDER_COLUMN_FORMAT_FORMAT_3);
3732 }
3733 else {
3734 query.append(_FINDER_COLUMN_FORMAT_FORMAT_2);
3735 }
3736 }
3737
3738 String sql = query.toString();
3739
3740 Query q = session.createQuery(sql);
3741
3742 QueryPos qPos = QueryPos.getInstance(q);
3743
3744 if (format != null) {
3745 qPos.add(format);
3746 }
3747
3748 count = (Long)q.uniqueResult();
3749 }
3750 catch (Exception e) {
3751 throw processException(e);
3752 }
3753 finally {
3754 if (count == null) {
3755 count = Long.valueOf(0);
3756 }
3757
3758 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FORMAT,
3759 finderArgs, count);
3760
3761 closeSession(session);
3762 }
3763 }
3764
3765 return count.intValue();
3766 }
3767
3768 public int countByN_T(long nodeId, String title) throws SystemException {
3769 Object[] finderArgs = new Object[] { new Long(nodeId), title };
3770
3771 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T,
3772 finderArgs, this);
3773
3774 if (count == null) {
3775 Session session = null;
3776
3777 try {
3778 session = openSession();
3779
3780 StringBundler query = new StringBundler(3);
3781
3782 query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3783
3784 query.append(_FINDER_COLUMN_N_T_NODEID_2);
3785
3786 if (title == null) {
3787 query.append(_FINDER_COLUMN_N_T_TITLE_1);
3788 }
3789 else {
3790 if (title.equals(StringPool.BLANK)) {
3791 query.append(_FINDER_COLUMN_N_T_TITLE_3);
3792 }
3793 else {
3794 query.append(_FINDER_COLUMN_N_T_TITLE_2);
3795 }
3796 }
3797
3798 String sql = query.toString();
3799
3800 Query q = session.createQuery(sql);
3801
3802 QueryPos qPos = QueryPos.getInstance(q);
3803
3804 qPos.add(nodeId);
3805
3806 if (title != null) {
3807 qPos.add(title);
3808 }
3809
3810 count = (Long)q.uniqueResult();
3811 }
3812 catch (Exception e) {
3813 throw processException(e);
3814 }
3815 finally {
3816 if (count == null) {
3817 count = Long.valueOf(0);
3818 }
3819
3820 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T, finderArgs,
3821 count);
3822
3823 closeSession(session);
3824 }
3825 }
3826
3827 return count.intValue();
3828 }
3829
3830 public int countByN_H(long nodeId, boolean head) throws SystemException {
3831 Object[] finderArgs = new Object[] {
3832 new Long(nodeId), Boolean.valueOf(head)
3833 };
3834
3835 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_H,
3836 finderArgs, this);
3837
3838 if (count == null) {
3839 Session session = null;
3840
3841 try {
3842 session = openSession();
3843
3844 StringBundler query = new StringBundler(3);
3845
3846 query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3847
3848 query.append(_FINDER_COLUMN_N_H_NODEID_2);
3849
3850 query.append(_FINDER_COLUMN_N_H_HEAD_2);
3851
3852 String sql = query.toString();
3853
3854 Query q = session.createQuery(sql);
3855
3856 QueryPos qPos = QueryPos.getInstance(q);
3857
3858 qPos.add(nodeId);
3859
3860 qPos.add(head);
3861
3862 count = (Long)q.uniqueResult();
3863 }
3864 catch (Exception e) {
3865 throw processException(e);
3866 }
3867 finally {
3868 if (count == null) {
3869 count = Long.valueOf(0);
3870 }
3871
3872 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_H, finderArgs,
3873 count);
3874
3875 closeSession(session);
3876 }
3877 }
3878
3879 return count.intValue();
3880 }
3881
3882 public int countByN_P(long nodeId, String parentTitle)
3883 throws SystemException {
3884 Object[] finderArgs = new Object[] { new Long(nodeId), parentTitle };
3885
3886 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_P,
3887 finderArgs, this);
3888
3889 if (count == null) {
3890 Session session = null;
3891
3892 try {
3893 session = openSession();
3894
3895 StringBundler query = new StringBundler(3);
3896
3897 query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3898
3899 query.append(_FINDER_COLUMN_N_P_NODEID_2);
3900
3901 if (parentTitle == null) {
3902 query.append(_FINDER_COLUMN_N_P_PARENTTITLE_1);
3903 }
3904 else {
3905 if (parentTitle.equals(StringPool.BLANK)) {
3906 query.append(_FINDER_COLUMN_N_P_PARENTTITLE_3);
3907 }
3908 else {
3909 query.append(_FINDER_COLUMN_N_P_PARENTTITLE_2);
3910 }
3911 }
3912
3913 String sql = query.toString();
3914
3915 Query q = session.createQuery(sql);
3916
3917 QueryPos qPos = QueryPos.getInstance(q);
3918
3919 qPos.add(nodeId);
3920
3921 if (parentTitle != null) {
3922 qPos.add(parentTitle);
3923 }
3924
3925 count = (Long)q.uniqueResult();
3926 }
3927 catch (Exception e) {
3928 throw processException(e);
3929 }
3930 finally {
3931 if (count == null) {
3932 count = Long.valueOf(0);
3933 }
3934
3935 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_P, finderArgs,
3936 count);
3937
3938 closeSession(session);
3939 }
3940 }
3941
3942 return count.intValue();
3943 }
3944
3945 public int countByN_R(long nodeId, String redirectTitle)
3946 throws SystemException {
3947 Object[] finderArgs = new Object[] { new Long(nodeId), redirectTitle };
3948
3949 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_R,
3950 finderArgs, this);
3951
3952 if (count == null) {
3953 Session session = null;
3954
3955 try {
3956 session = openSession();
3957
3958 StringBundler query = new StringBundler(3);
3959
3960 query.append(_SQL_COUNT_WIKIPAGE_WHERE);
3961
3962 query.append(_FINDER_COLUMN_N_R_NODEID_2);
3963
3964 if (redirectTitle == null) {
3965 query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_1);
3966 }
3967 else {
3968 if (redirectTitle.equals(StringPool.BLANK)) {
3969 query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_3);
3970 }
3971 else {
3972 query.append(_FINDER_COLUMN_N_R_REDIRECTTITLE_2);
3973 }
3974 }
3975
3976 String sql = query.toString();
3977
3978 Query q = session.createQuery(sql);
3979
3980 QueryPos qPos = QueryPos.getInstance(q);
3981
3982 qPos.add(nodeId);
3983
3984 if (redirectTitle != null) {
3985 qPos.add(redirectTitle);
3986 }
3987
3988 count = (Long)q.uniqueResult();
3989 }
3990 catch (Exception e) {
3991 throw processException(e);
3992 }
3993 finally {
3994 if (count == null) {
3995 count = Long.valueOf(0);
3996 }
3997
3998 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_R, finderArgs,
3999 count);
4000
4001 closeSession(session);
4002 }
4003 }
4004
4005 return count.intValue();
4006 }
4007
4008 public int countByN_T_V(long nodeId, String title, double version)
4009 throws SystemException {
4010 Object[] finderArgs = new Object[] {
4011 new Long(nodeId),
4012
4013 title, new Double(version)
4014 };
4015
4016 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T_V,
4017 finderArgs, this);
4018
4019 if (count == null) {
4020 Session session = null;
4021
4022 try {
4023 session = openSession();
4024
4025 StringBundler query = new StringBundler(4);
4026
4027 query.append(_SQL_COUNT_WIKIPAGE_WHERE);
4028
4029 query.append(_FINDER_COLUMN_N_T_V_NODEID_2);
4030
4031 if (title == null) {
4032 query.append(_FINDER_COLUMN_N_T_V_TITLE_1);
4033 }
4034 else {
4035 if (title.equals(StringPool.BLANK)) {
4036 query.append(_FINDER_COLUMN_N_T_V_TITLE_3);
4037 }
4038 else {
4039 query.append(_FINDER_COLUMN_N_T_V_TITLE_2);
4040 }
4041 }
4042
4043 query.append(_FINDER_COLUMN_N_T_V_VERSION_2);
4044
4045 String sql = query.toString();
4046
4047 Query q = session.createQuery(sql);
4048
4049 QueryPos qPos = QueryPos.getInstance(q);
4050
4051 qPos.add(nodeId);
4052
4053 if (title != null) {
4054 qPos.add(title);
4055 }
4056
4057 qPos.add(version);
4058
4059 count = (Long)q.uniqueResult();
4060 }
4061 catch (Exception e) {
4062 throw processException(e);
4063 }
4064 finally {
4065 if (count == null) {
4066 count = Long.valueOf(0);
4067 }
4068
4069 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_V,
4070 finderArgs, count);
4071
4072 closeSession(session);
4073 }
4074 }
4075
4076 return count.intValue();
4077 }
4078
4079 public int countByN_T_H(long nodeId, String title, boolean head)
4080 throws SystemException {
4081 Object[] finderArgs = new Object[] {
4082 new Long(nodeId),
4083
4084 title, Boolean.valueOf(head)
4085 };
4086
4087 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_T_H,
4088 finderArgs, this);
4089
4090 if (count == null) {
4091 Session session = null;
4092
4093 try {
4094 session = openSession();
4095
4096 StringBundler query = new StringBundler(4);
4097
4098 query.append(_SQL_COUNT_WIKIPAGE_WHERE);
4099
4100 query.append(_FINDER_COLUMN_N_T_H_NODEID_2);
4101
4102 if (title == null) {
4103 query.append(_FINDER_COLUMN_N_T_H_TITLE_1);
4104 }
4105 else {
4106 if (title.equals(StringPool.BLANK)) {
4107 query.append(_FINDER_COLUMN_N_T_H_TITLE_3);
4108 }
4109 else {
4110 query.append(_FINDER_COLUMN_N_T_H_TITLE_2);
4111 }
4112 }
4113
4114 query.append(_FINDER_COLUMN_N_T_H_HEAD_2);
4115
4116 String sql = query.toString();
4117
4118 Query q = session.createQuery(sql);
4119
4120 QueryPos qPos = QueryPos.getInstance(q);
4121
4122 qPos.add(nodeId);
4123
4124 if (title != null) {
4125 qPos.add(title);
4126 }
4127
4128 qPos.add(head);
4129
4130 count = (Long)q.uniqueResult();
4131 }
4132 catch (Exception e) {
4133 throw processException(e);
4134 }
4135 finally {
4136 if (count == null) {
4137 count = Long.valueOf(0);
4138 }
4139
4140 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_T_H,
4141 finderArgs, count);
4142
4143 closeSession(session);
4144 }
4145 }
4146
4147 return count.intValue();
4148 }
4149
4150 public int countByN_H_P(long nodeId, boolean head, String parentTitle)
4151 throws SystemException {
4152 Object[] finderArgs = new Object[] {
4153 new Long(nodeId), Boolean.valueOf(head),
4154
4155 parentTitle
4156 };
4157
4158 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_N_H_P,
4159 finderArgs, this);
4160
4161 if (count == null) {
4162 Session session = null;
4163
4164 try {
4165 session = openSession();
4166
4167 StringBundler query = new StringBundler(4);
4168
4169 query.append(_SQL_COUNT_WIKIPAGE_WHERE);
4170
4171 query.append(_FINDER_COLUMN_N_H_P_NODEID_2);
4172
4173 query.append(_FINDER_COLUMN_N_H_P_HEAD_2);
4174
4175 if (parentTitle == null) {
4176 query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_1);
4177 }
4178 else {
4179 if (parentTitle.equals(StringPool.BLANK)) {
4180 query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_3);
4181 }
4182 else {
4183 query.append(_FINDER_COLUMN_N_H_P_PARENTTITLE_2);
4184 }
4185 }
4186
4187 String sql = query.toString();
4188
4189 Query q = session.createQuery(sql);
4190
4191 QueryPos qPos = QueryPos.getInstance(q);
4192
4193 qPos.add(nodeId);
4194
4195 qPos.add(head);
4196
4197 if (parentTitle != null) {
4198 qPos.add(parentTitle);
4199 }
4200
4201 count = (Long)q.uniqueResult();
4202 }
4203 catch (Exception e) {
4204 throw processException(e);
4205 }
4206 finally {
4207 if (count == null) {
4208 count = Long.valueOf(0);
4209 }
4210
4211 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_N_H_P,
4212 finderArgs, count);
4213
4214 closeSession(session);
4215 }
4216 }
4217
4218 return count.intValue();
4219 }
4220
4221 public int countAll() throws SystemException {
4222 Object[] finderArgs = new Object[0];
4223
4224 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4225 finderArgs, this);
4226
4227 if (count == null) {
4228 Session session = null;
4229
4230 try {
4231 session = openSession();
4232
4233 Query q = session.createQuery(_SQL_COUNT_WIKIPAGE);
4234
4235 count = (Long)q.uniqueResult();
4236 }
4237 catch (Exception e) {
4238 throw processException(e);
4239 }
4240 finally {
4241 if (count == null) {
4242 count = Long.valueOf(0);
4243 }
4244
4245 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
4246 count);
4247
4248 closeSession(session);
4249 }
4250 }
4251
4252 return count.intValue();
4253 }
4254
4255 public void afterPropertiesSet() {
4256 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4257 com.liferay.portal.util.PropsUtil.get(
4258 "value.object.listener.com.liferay.portlet.wiki.model.WikiPage")));
4259
4260 if (listenerClassNames.length > 0) {
4261 try {
4262 List<ModelListener<WikiPage>> listenersList = new ArrayList<ModelListener<WikiPage>>();
4263
4264 for (String listenerClassName : listenerClassNames) {
4265 listenersList.add((ModelListener<WikiPage>)Class.forName(
4266 listenerClassName).newInstance());
4267 }
4268
4269 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
4270 }
4271 catch (Exception e) {
4272 _log.error(e);
4273 }
4274 }
4275 }
4276
4277 @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiNodePersistence")
4278 protected com.liferay.portlet.wiki.service.persistence.WikiNodePersistence wikiNodePersistence;
4279 @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPagePersistence")
4280 protected com.liferay.portlet.wiki.service.persistence.WikiPagePersistence wikiPagePersistence;
4281 @BeanReference(name = "com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence")
4282 protected com.liferay.portlet.wiki.service.persistence.WikiPageResourcePersistence wikiPageResourcePersistence;
4283 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence")
4284 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
4285 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence")
4286 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
4287 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence")
4288 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
4289 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence")
4290 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
4291 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence")
4292 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
4293 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence")
4294 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
4295 @BeanReference(name = "com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence")
4296 protected com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence mbMessagePersistence;
4297 @BeanReference(name = "com.liferay.portlet.social.service.persistence.SocialActivityPersistence")
4298 protected com.liferay.portlet.social.service.persistence.SocialActivityPersistence socialActivityPersistence;
4299 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsAssetPersistence")
4300 protected com.liferay.portlet.tags.service.persistence.TagsAssetPersistence tagsAssetPersistence;
4301 @BeanReference(name = "com.liferay.portlet.tags.service.persistence.TagsEntryPersistence")
4302 protected com.liferay.portlet.tags.service.persistence.TagsEntryPersistence tagsEntryPersistence;
4303 private static final String _SQL_SELECT_WIKIPAGE = "SELECT wikiPage FROM WikiPage wikiPage";
4304 private static final String _SQL_SELECT_WIKIPAGE_WHERE = "SELECT wikiPage FROM WikiPage wikiPage WHERE ";
4305 private static final String _SQL_COUNT_WIKIPAGE = "SELECT COUNT(wikiPage) FROM WikiPage wikiPage";
4306 private static final String _SQL_COUNT_WIKIPAGE_WHERE = "SELECT COUNT(wikiPage) FROM WikiPage wikiPage WHERE ";
4307 private static final String _FINDER_COLUMN_UUID_UUID_1 = "wikiPage.uuid IS NULL";
4308 private static final String _FINDER_COLUMN_UUID_UUID_2 = "wikiPage.uuid = ?";
4309 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(wikiPage.uuid IS NULL OR wikiPage.uuid = ?)";
4310 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "wikiPage.uuid IS NULL AND ";
4311 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "wikiPage.uuid = ? AND ";
4312 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(wikiPage.uuid IS NULL OR wikiPage.uuid = ?) AND ";
4313 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "wikiPage.groupId = ?";
4314 private static final String _FINDER_COLUMN_NODEID_NODEID_2 = "wikiPage.nodeId = ?";
4315 private static final String _FINDER_COLUMN_FORMAT_FORMAT_1 = "wikiPage.format IS NULL";
4316 private static final String _FINDER_COLUMN_FORMAT_FORMAT_2 = "wikiPage.format = ?";
4317 private static final String _FINDER_COLUMN_FORMAT_FORMAT_3 = "(wikiPage.format IS NULL OR wikiPage.format = ?)";
4318 private static final String _FINDER_COLUMN_N_T_NODEID_2 = "wikiPage.nodeId = ? AND ";
4319 private static final String _FINDER_COLUMN_N_T_TITLE_1 = "wikiPage.title IS NULL";
4320 private static final String _FINDER_COLUMN_N_T_TITLE_2 = "wikiPage.title = ?";
4321 private static final String _FINDER_COLUMN_N_T_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = ?)";
4322 private static final String _FINDER_COLUMN_N_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
4323 private static final String _FINDER_COLUMN_N_H_HEAD_2 = "wikiPage.head = ?";
4324 private static final String _FINDER_COLUMN_N_P_NODEID_2 = "wikiPage.nodeId = ? AND ";
4325 private static final String _FINDER_COLUMN_N_P_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL";
4326 private static final String _FINDER_COLUMN_N_P_PARENTTITLE_2 = "wikiPage.parentTitle = ?";
4327 private static final String _FINDER_COLUMN_N_P_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR wikiPage.parentTitle = ?)";
4328 private static final String _FINDER_COLUMN_N_R_NODEID_2 = "wikiPage.nodeId = ? AND ";
4329 private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_1 = "wikiPage.redirectTitle IS NULL";
4330 private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_2 = "wikiPage.redirectTitle = ?";
4331 private static final String _FINDER_COLUMN_N_R_REDIRECTTITLE_3 = "(wikiPage.redirectTitle IS NULL OR wikiPage.redirectTitle = ?)";
4332 private static final String _FINDER_COLUMN_N_T_V_NODEID_2 = "wikiPage.nodeId = ? AND ";
4333 private static final String _FINDER_COLUMN_N_T_V_TITLE_1 = "wikiPage.title IS NULL AND ";
4334 private static final String _FINDER_COLUMN_N_T_V_TITLE_2 = "wikiPage.title = ? AND ";
4335 private static final String _FINDER_COLUMN_N_T_V_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = ?) AND ";
4336 private static final String _FINDER_COLUMN_N_T_V_VERSION_2 = "wikiPage.version = ?";
4337 private static final String _FINDER_COLUMN_N_T_H_NODEID_2 = "wikiPage.nodeId = ? AND ";
4338 private static final String _FINDER_COLUMN_N_T_H_TITLE_1 = "wikiPage.title IS NULL AND ";
4339 private static final String _FINDER_COLUMN_N_T_H_TITLE_2 = "wikiPage.title = ? AND ";
4340 private static final String _FINDER_COLUMN_N_T_H_TITLE_3 = "(wikiPage.title IS NULL OR wikiPage.title = ?) AND ";
4341 private static final String _FINDER_COLUMN_N_T_H_HEAD_2 = "wikiPage.head = ?";
4342 private static final String _FINDER_COLUMN_N_H_P_NODEID_2 = "wikiPage.nodeId = ? AND ";
4343 private static final String _FINDER_COLUMN_N_H_P_HEAD_2 = "wikiPage.head = ? AND ";
4344 private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_1 = "wikiPage.parentTitle IS NULL";
4345 private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_2 = "wikiPage.parentTitle = ?";
4346 private static final String _FINDER_COLUMN_N_H_P_PARENTTITLE_3 = "(wikiPage.parentTitle IS NULL OR wikiPage.parentTitle = ?)";
4347 private static final String _ORDER_BY_ENTITY_ALIAS = "wikiPage.";
4348 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WikiPage exists with the primary key ";
4349 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WikiPage exists with the key {";
4350 private static Log _log = LogFactoryUtil.getLog(WikiPagePersistenceImpl.class);
4351}