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