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