1
14
15 package com.liferay.portlet.journal.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.kernel.annotation.BeanReference;
19 import com.liferay.portal.kernel.cache.CacheRegistry;
20 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
21 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
22 import com.liferay.portal.kernel.dao.orm.FinderPath;
23 import com.liferay.portal.kernel.dao.orm.Query;
24 import com.liferay.portal.kernel.dao.orm.QueryPos;
25 import com.liferay.portal.kernel.dao.orm.QueryUtil;
26 import com.liferay.portal.kernel.dao.orm.Session;
27 import com.liferay.portal.kernel.exception.SystemException;
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.InstanceFactory;
32 import com.liferay.portal.kernel.util.OrderByComparator;
33 import com.liferay.portal.kernel.util.StringBundler;
34 import com.liferay.portal.kernel.util.StringPool;
35 import com.liferay.portal.kernel.util.StringUtil;
36 import com.liferay.portal.kernel.util.Validator;
37 import com.liferay.portal.model.ModelListener;
38 import com.liferay.portal.service.persistence.BatchSessionUtil;
39 import com.liferay.portal.service.persistence.GroupPersistence;
40 import com.liferay.portal.service.persistence.LayoutPersistence;
41 import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
42 import com.liferay.portal.service.persistence.ResourcePersistence;
43 import com.liferay.portal.service.persistence.UserPersistence;
44 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
45
46 import com.liferay.portlet.journal.NoSuchContentSearchException;
47 import com.liferay.portlet.journal.model.JournalContentSearch;
48 import com.liferay.portlet.journal.model.impl.JournalContentSearchImpl;
49 import com.liferay.portlet.journal.model.impl.JournalContentSearchModelImpl;
50
51 import java.io.Serializable;
52
53 import java.util.ArrayList;
54 import java.util.Collections;
55 import java.util.List;
56
57
70 public class JournalContentSearchPersistenceImpl extends BasePersistenceImpl<JournalContentSearch>
71 implements JournalContentSearchPersistence {
72 public static final String FINDER_CLASS_NAME_ENTITY = JournalContentSearchImpl.class.getName();
73 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
74 ".List";
75 public static final FinderPath FINDER_PATH_FIND_BY_ARTICLEID = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
76 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
77 FINDER_CLASS_NAME_LIST, "findByArticleId",
78 new String[] {
79 String.class.getName(),
80
81 "java.lang.Integer", "java.lang.Integer",
82 "com.liferay.portal.kernel.util.OrderByComparator"
83 });
84 public static final FinderPath FINDER_PATH_COUNT_BY_ARTICLEID = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
85 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
86 FINDER_CLASS_NAME_LIST, "countByArticleId",
87 new String[] { String.class.getName() });
88 public static final FinderPath FINDER_PATH_FIND_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
89 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
90 FINDER_CLASS_NAME_LIST, "findByG_P",
91 new String[] {
92 Long.class.getName(), Boolean.class.getName(),
93
94 "java.lang.Integer", "java.lang.Integer",
95 "com.liferay.portal.kernel.util.OrderByComparator"
96 });
97 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
98 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
99 FINDER_CLASS_NAME_LIST, "countByG_P",
100 new String[] { Long.class.getName(), Boolean.class.getName() });
101 public static final FinderPath FINDER_PATH_FIND_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
102 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
103 FINDER_CLASS_NAME_LIST, "findByG_A",
104 new String[] {
105 Long.class.getName(), String.class.getName(),
106
107 "java.lang.Integer", "java.lang.Integer",
108 "com.liferay.portal.kernel.util.OrderByComparator"
109 });
110 public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
111 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
112 FINDER_CLASS_NAME_LIST, "countByG_A",
113 new String[] { Long.class.getName(), String.class.getName() });
114 public static final FinderPath FINDER_PATH_FIND_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
115 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
116 FINDER_CLASS_NAME_LIST, "findByG_P_L",
117 new String[] {
118 Long.class.getName(), Boolean.class.getName(),
119 Long.class.getName(),
120
121 "java.lang.Integer", "java.lang.Integer",
122 "com.liferay.portal.kernel.util.OrderByComparator"
123 });
124 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
125 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
126 FINDER_CLASS_NAME_LIST, "countByG_P_L",
127 new String[] {
128 Long.class.getName(), Boolean.class.getName(),
129 Long.class.getName()
130 });
131 public static final FinderPath FINDER_PATH_FIND_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
132 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
133 FINDER_CLASS_NAME_LIST, "findByG_P_A",
134 new String[] {
135 Long.class.getName(), Boolean.class.getName(),
136 String.class.getName(),
137
138 "java.lang.Integer", "java.lang.Integer",
139 "com.liferay.portal.kernel.util.OrderByComparator"
140 });
141 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
142 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
143 FINDER_CLASS_NAME_LIST, "countByG_P_A",
144 new String[] {
145 Long.class.getName(), Boolean.class.getName(),
146 String.class.getName()
147 });
148 public static final FinderPath FINDER_PATH_FIND_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
149 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
150 FINDER_CLASS_NAME_LIST, "findByG_P_L_P",
151 new String[] {
152 Long.class.getName(), Boolean.class.getName(),
153 Long.class.getName(), String.class.getName(),
154
155 "java.lang.Integer", "java.lang.Integer",
156 "com.liferay.portal.kernel.util.OrderByComparator"
157 });
158 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
159 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
160 FINDER_CLASS_NAME_LIST, "countByG_P_L_P",
161 new String[] {
162 Long.class.getName(), Boolean.class.getName(),
163 Long.class.getName(), String.class.getName()
164 });
165 public static final FinderPath FINDER_PATH_FETCH_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
166 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
167 FINDER_CLASS_NAME_ENTITY, "fetchByG_P_L_P_A",
168 new String[] {
169 Long.class.getName(), Boolean.class.getName(),
170 Long.class.getName(), String.class.getName(),
171 String.class.getName()
172 });
173 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
174 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
175 FINDER_CLASS_NAME_LIST, "countByG_P_L_P_A",
176 new String[] {
177 Long.class.getName(), Boolean.class.getName(),
178 Long.class.getName(), String.class.getName(),
179 String.class.getName()
180 });
181 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
182 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
183 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
184 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
185 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
186 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
187
188 public void cacheResult(JournalContentSearch journalContentSearch) {
189 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
190 JournalContentSearchImpl.class,
191 journalContentSearch.getPrimaryKey(), journalContentSearch);
192
193 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
194 new Object[] {
195 new Long(journalContentSearch.getGroupId()),
196 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
197 new Long(journalContentSearch.getLayoutId()),
198
199 journalContentSearch.getPortletId(),
200
201 journalContentSearch.getArticleId()
202 }, journalContentSearch);
203 }
204
205 public void cacheResult(List<JournalContentSearch> journalContentSearchs) {
206 for (JournalContentSearch journalContentSearch : journalContentSearchs) {
207 if (EntityCacheUtil.getResult(
208 JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
209 JournalContentSearchImpl.class,
210 journalContentSearch.getPrimaryKey(), this) == null) {
211 cacheResult(journalContentSearch);
212 }
213 }
214 }
215
216 public void clearCache() {
217 CacheRegistry.clear(JournalContentSearchImpl.class.getName());
218 EntityCacheUtil.clearCache(JournalContentSearchImpl.class.getName());
219 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
220 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
221 }
222
223 public void clearCache(JournalContentSearch journalContentSearch) {
224 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
225 JournalContentSearchImpl.class, journalContentSearch.getPrimaryKey());
226
227 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
228 new Object[] {
229 new Long(journalContentSearch.getGroupId()),
230 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
231 new Long(journalContentSearch.getLayoutId()),
232
233 journalContentSearch.getPortletId(),
234
235 journalContentSearch.getArticleId()
236 });
237 }
238
239 public JournalContentSearch create(long contentSearchId) {
240 JournalContentSearch journalContentSearch = new JournalContentSearchImpl();
241
242 journalContentSearch.setNew(true);
243 journalContentSearch.setPrimaryKey(contentSearchId);
244
245 return journalContentSearch;
246 }
247
248 public JournalContentSearch remove(Serializable primaryKey)
249 throws NoSuchModelException, SystemException {
250 return remove(((Long)primaryKey).longValue());
251 }
252
253 public JournalContentSearch remove(long contentSearchId)
254 throws NoSuchContentSearchException, SystemException {
255 Session session = null;
256
257 try {
258 session = openSession();
259
260 JournalContentSearch journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
261 new Long(contentSearchId));
262
263 if (journalContentSearch == null) {
264 if (_log.isWarnEnabled()) {
265 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
266 contentSearchId);
267 }
268
269 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
270 contentSearchId);
271 }
272
273 return remove(journalContentSearch);
274 }
275 catch (NoSuchContentSearchException nsee) {
276 throw nsee;
277 }
278 catch (Exception e) {
279 throw processException(e);
280 }
281 finally {
282 closeSession(session);
283 }
284 }
285
286 public JournalContentSearch remove(
287 JournalContentSearch journalContentSearch) throws SystemException {
288 for (ModelListener<JournalContentSearch> listener : listeners) {
289 listener.onBeforeRemove(journalContentSearch);
290 }
291
292 journalContentSearch = removeImpl(journalContentSearch);
293
294 for (ModelListener<JournalContentSearch> listener : listeners) {
295 listener.onAfterRemove(journalContentSearch);
296 }
297
298 return journalContentSearch;
299 }
300
301 protected JournalContentSearch removeImpl(
302 JournalContentSearch journalContentSearch) throws SystemException {
303 journalContentSearch = toUnwrappedModel(journalContentSearch);
304
305 Session session = null;
306
307 try {
308 session = openSession();
309
310 if (journalContentSearch.isCachedModel() ||
311 BatchSessionUtil.isEnabled()) {
312 Object staleObject = session.get(JournalContentSearchImpl.class,
313 journalContentSearch.getPrimaryKeyObj());
314
315 if (staleObject != null) {
316 session.evict(staleObject);
317 }
318 }
319
320 session.delete(journalContentSearch);
321
322 session.flush();
323 }
324 catch (Exception e) {
325 throw processException(e);
326 }
327 finally {
328 closeSession(session);
329 }
330
331 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
332
333 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
334
335 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
336 new Object[] {
337 new Long(journalContentSearchModelImpl.getOriginalGroupId()),
338 Boolean.valueOf(
339 journalContentSearchModelImpl.getOriginalPrivateLayout()),
340 new Long(journalContentSearchModelImpl.getOriginalLayoutId()),
341
342 journalContentSearchModelImpl.getOriginalPortletId(),
343
344 journalContentSearchModelImpl.getOriginalArticleId()
345 });
346
347 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
348 JournalContentSearchImpl.class, journalContentSearch.getPrimaryKey());
349
350 return journalContentSearch;
351 }
352
353 public JournalContentSearch updateImpl(
354 com.liferay.portlet.journal.model.JournalContentSearch journalContentSearch,
355 boolean merge) throws SystemException {
356 journalContentSearch = toUnwrappedModel(journalContentSearch);
357
358 boolean isNew = journalContentSearch.isNew();
359
360 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
361
362 Session session = null;
363
364 try {
365 session = openSession();
366
367 BatchSessionUtil.update(session, journalContentSearch, merge);
368
369 journalContentSearch.setNew(false);
370 }
371 catch (Exception e) {
372 throw processException(e);
373 }
374 finally {
375 closeSession(session);
376 }
377
378 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
379
380 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
381 JournalContentSearchImpl.class,
382 journalContentSearch.getPrimaryKey(), journalContentSearch);
383
384 if (!isNew &&
385 ((journalContentSearch.getGroupId() != journalContentSearchModelImpl.getOriginalGroupId()) ||
386 (journalContentSearch.getPrivateLayout() != journalContentSearchModelImpl.getOriginalPrivateLayout()) ||
387 (journalContentSearch.getLayoutId() != journalContentSearchModelImpl.getOriginalLayoutId()) ||
388 !Validator.equals(journalContentSearch.getPortletId(),
389 journalContentSearchModelImpl.getOriginalPortletId()) ||
390 !Validator.equals(journalContentSearch.getArticleId(),
391 journalContentSearchModelImpl.getOriginalArticleId()))) {
392 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
393 new Object[] {
394 new Long(journalContentSearchModelImpl.getOriginalGroupId()),
395 Boolean.valueOf(
396 journalContentSearchModelImpl.getOriginalPrivateLayout()),
397 new Long(journalContentSearchModelImpl.getOriginalLayoutId()),
398
399 journalContentSearchModelImpl.getOriginalPortletId(),
400
401 journalContentSearchModelImpl.getOriginalArticleId()
402 });
403 }
404
405 if (isNew ||
406 ((journalContentSearch.getGroupId() != journalContentSearchModelImpl.getOriginalGroupId()) ||
407 (journalContentSearch.getPrivateLayout() != journalContentSearchModelImpl.getOriginalPrivateLayout()) ||
408 (journalContentSearch.getLayoutId() != journalContentSearchModelImpl.getOriginalLayoutId()) ||
409 !Validator.equals(journalContentSearch.getPortletId(),
410 journalContentSearchModelImpl.getOriginalPortletId()) ||
411 !Validator.equals(journalContentSearch.getArticleId(),
412 journalContentSearchModelImpl.getOriginalArticleId()))) {
413 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
414 new Object[] {
415 new Long(journalContentSearch.getGroupId()),
416 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
417 new Long(journalContentSearch.getLayoutId()),
418
419 journalContentSearch.getPortletId(),
420
421 journalContentSearch.getArticleId()
422 }, journalContentSearch);
423 }
424
425 return journalContentSearch;
426 }
427
428 protected JournalContentSearch toUnwrappedModel(
429 JournalContentSearch journalContentSearch) {
430 if (journalContentSearch instanceof JournalContentSearchImpl) {
431 return journalContentSearch;
432 }
433
434 JournalContentSearchImpl journalContentSearchImpl = new JournalContentSearchImpl();
435
436 journalContentSearchImpl.setNew(journalContentSearch.isNew());
437 journalContentSearchImpl.setPrimaryKey(journalContentSearch.getPrimaryKey());
438
439 journalContentSearchImpl.setContentSearchId(journalContentSearch.getContentSearchId());
440 journalContentSearchImpl.setGroupId(journalContentSearch.getGroupId());
441 journalContentSearchImpl.setCompanyId(journalContentSearch.getCompanyId());
442 journalContentSearchImpl.setPrivateLayout(journalContentSearch.isPrivateLayout());
443 journalContentSearchImpl.setLayoutId(journalContentSearch.getLayoutId());
444 journalContentSearchImpl.setPortletId(journalContentSearch.getPortletId());
445 journalContentSearchImpl.setArticleId(journalContentSearch.getArticleId());
446
447 return journalContentSearchImpl;
448 }
449
450 public JournalContentSearch findByPrimaryKey(Serializable primaryKey)
451 throws NoSuchModelException, SystemException {
452 return findByPrimaryKey(((Long)primaryKey).longValue());
453 }
454
455 public JournalContentSearch findByPrimaryKey(long contentSearchId)
456 throws NoSuchContentSearchException, SystemException {
457 JournalContentSearch journalContentSearch = fetchByPrimaryKey(contentSearchId);
458
459 if (journalContentSearch == null) {
460 if (_log.isWarnEnabled()) {
461 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + contentSearchId);
462 }
463
464 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
465 contentSearchId);
466 }
467
468 return journalContentSearch;
469 }
470
471 public JournalContentSearch fetchByPrimaryKey(Serializable primaryKey)
472 throws SystemException {
473 return fetchByPrimaryKey(((Long)primaryKey).longValue());
474 }
475
476 public JournalContentSearch fetchByPrimaryKey(long contentSearchId)
477 throws SystemException {
478 JournalContentSearch journalContentSearch = (JournalContentSearch)EntityCacheUtil.getResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
479 JournalContentSearchImpl.class, contentSearchId, this);
480
481 if (journalContentSearch == null) {
482 Session session = null;
483
484 try {
485 session = openSession();
486
487 journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
488 new Long(contentSearchId));
489 }
490 catch (Exception e) {
491 throw processException(e);
492 }
493 finally {
494 if (journalContentSearch != null) {
495 cacheResult(journalContentSearch);
496 }
497
498 closeSession(session);
499 }
500 }
501
502 return journalContentSearch;
503 }
504
505 public List<JournalContentSearch> findByArticleId(String articleId)
506 throws SystemException {
507 return findByArticleId(articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
508 null);
509 }
510
511 public List<JournalContentSearch> findByArticleId(String articleId,
512 int start, int end) throws SystemException {
513 return findByArticleId(articleId, start, end, null);
514 }
515
516 public List<JournalContentSearch> findByArticleId(String articleId,
517 int start, int end, OrderByComparator orderByComparator)
518 throws SystemException {
519 Object[] finderArgs = new Object[] {
520 articleId,
521
522 String.valueOf(start), String.valueOf(end),
523 String.valueOf(orderByComparator)
524 };
525
526 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ARTICLEID,
527 finderArgs, this);
528
529 if (list == null) {
530 Session session = null;
531
532 try {
533 session = openSession();
534
535 StringBundler query = null;
536
537 if (orderByComparator != null) {
538 query = new StringBundler(3 +
539 (orderByComparator.getOrderByFields().length * 3));
540 }
541 else {
542 query = new StringBundler(2);
543 }
544
545 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
546
547 if (articleId == null) {
548 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
549 }
550 else {
551 if (articleId.equals(StringPool.BLANK)) {
552 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
553 }
554 else {
555 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
556 }
557 }
558
559 if (orderByComparator != null) {
560 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
561 orderByComparator);
562 }
563
564 String sql = query.toString();
565
566 Query q = session.createQuery(sql);
567
568 QueryPos qPos = QueryPos.getInstance(q);
569
570 if (articleId != null) {
571 qPos.add(articleId);
572 }
573
574 list = (List<JournalContentSearch>)QueryUtil.list(q,
575 getDialect(), start, end);
576 }
577 catch (Exception e) {
578 throw processException(e);
579 }
580 finally {
581 if (list == null) {
582 list = new ArrayList<JournalContentSearch>();
583 }
584
585 cacheResult(list);
586
587 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ARTICLEID,
588 finderArgs, list);
589
590 closeSession(session);
591 }
592 }
593
594 return list;
595 }
596
597 public JournalContentSearch findByArticleId_First(String articleId,
598 OrderByComparator orderByComparator)
599 throws NoSuchContentSearchException, SystemException {
600 List<JournalContentSearch> list = findByArticleId(articleId, 0, 1,
601 orderByComparator);
602
603 if (list.isEmpty()) {
604 StringBundler msg = new StringBundler(4);
605
606 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
607
608 msg.append("articleId=");
609 msg.append(articleId);
610
611 msg.append(StringPool.CLOSE_CURLY_BRACE);
612
613 throw new NoSuchContentSearchException(msg.toString());
614 }
615 else {
616 return list.get(0);
617 }
618 }
619
620 public JournalContentSearch findByArticleId_Last(String articleId,
621 OrderByComparator orderByComparator)
622 throws NoSuchContentSearchException, SystemException {
623 int count = countByArticleId(articleId);
624
625 List<JournalContentSearch> list = findByArticleId(articleId, count - 1,
626 count, orderByComparator);
627
628 if (list.isEmpty()) {
629 StringBundler msg = new StringBundler(4);
630
631 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
632
633 msg.append("articleId=");
634 msg.append(articleId);
635
636 msg.append(StringPool.CLOSE_CURLY_BRACE);
637
638 throw new NoSuchContentSearchException(msg.toString());
639 }
640 else {
641 return list.get(0);
642 }
643 }
644
645 public JournalContentSearch[] findByArticleId_PrevAndNext(
646 long contentSearchId, String articleId,
647 OrderByComparator orderByComparator)
648 throws NoSuchContentSearchException, SystemException {
649 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
650
651 Session session = null;
652
653 try {
654 session = openSession();
655
656 JournalContentSearch[] array = new JournalContentSearchImpl[3];
657
658 array[0] = getByArticleId_PrevAndNext(session,
659 journalContentSearch, articleId, orderByComparator, true);
660
661 array[1] = journalContentSearch;
662
663 array[2] = getByArticleId_PrevAndNext(session,
664 journalContentSearch, articleId, orderByComparator, false);
665
666 return array;
667 }
668 catch (Exception e) {
669 throw processException(e);
670 }
671 finally {
672 closeSession(session);
673 }
674 }
675
676 protected JournalContentSearch getByArticleId_PrevAndNext(Session session,
677 JournalContentSearch journalContentSearch, String articleId,
678 OrderByComparator orderByComparator, boolean previous) {
679 StringBundler query = null;
680
681 if (orderByComparator != null) {
682 query = new StringBundler(6 +
683 (orderByComparator.getOrderByFields().length * 6));
684 }
685 else {
686 query = new StringBundler(3);
687 }
688
689 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
690
691 if (articleId == null) {
692 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
693 }
694 else {
695 if (articleId.equals(StringPool.BLANK)) {
696 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
697 }
698 else {
699 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
700 }
701 }
702
703 if (orderByComparator != null) {
704 String[] orderByFields = orderByComparator.getOrderByFields();
705
706 if (orderByFields.length > 0) {
707 query.append(WHERE_AND);
708 }
709
710 for (int i = 0; i < orderByFields.length; i++) {
711 query.append(_ORDER_BY_ENTITY_ALIAS);
712 query.append(orderByFields[i]);
713
714 if ((i + 1) < orderByFields.length) {
715 if (orderByComparator.isAscending() ^ previous) {
716 query.append(WHERE_GREATER_THAN_HAS_NEXT);
717 }
718 else {
719 query.append(WHERE_LESSER_THAN_HAS_NEXT);
720 }
721 }
722 else {
723 if (orderByComparator.isAscending() ^ previous) {
724 query.append(WHERE_GREATER_THAN);
725 }
726 else {
727 query.append(WHERE_LESSER_THAN);
728 }
729 }
730 }
731
732 query.append(ORDER_BY_CLAUSE);
733
734 for (int i = 0; i < orderByFields.length; i++) {
735 query.append(_ORDER_BY_ENTITY_ALIAS);
736 query.append(orderByFields[i]);
737
738 if ((i + 1) < orderByFields.length) {
739 if (orderByComparator.isAscending() ^ previous) {
740 query.append(ORDER_BY_ASC_HAS_NEXT);
741 }
742 else {
743 query.append(ORDER_BY_DESC_HAS_NEXT);
744 }
745 }
746 else {
747 if (orderByComparator.isAscending() ^ previous) {
748 query.append(ORDER_BY_ASC);
749 }
750 else {
751 query.append(ORDER_BY_DESC);
752 }
753 }
754 }
755 }
756
757 String sql = query.toString();
758
759 Query q = session.createQuery(sql);
760
761 q.setFirstResult(0);
762 q.setMaxResults(2);
763
764 QueryPos qPos = QueryPos.getInstance(q);
765
766 if (articleId != null) {
767 qPos.add(articleId);
768 }
769
770 if (orderByComparator != null) {
771 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
772
773 for (Object value : values) {
774 qPos.add(value);
775 }
776 }
777
778 List<JournalContentSearch> list = q.list();
779
780 if (list.size() == 2) {
781 return list.get(1);
782 }
783 else {
784 return null;
785 }
786 }
787
788 public List<JournalContentSearch> findByG_P(long groupId,
789 boolean privateLayout) throws SystemException {
790 return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
791 QueryUtil.ALL_POS, null);
792 }
793
794 public List<JournalContentSearch> findByG_P(long groupId,
795 boolean privateLayout, int start, int end) throws SystemException {
796 return findByG_P(groupId, privateLayout, start, end, null);
797 }
798
799 public List<JournalContentSearch> findByG_P(long groupId,
800 boolean privateLayout, int start, int end,
801 OrderByComparator orderByComparator) throws SystemException {
802 Object[] finderArgs = new Object[] {
803 new Long(groupId), Boolean.valueOf(privateLayout),
804
805 String.valueOf(start), String.valueOf(end),
806 String.valueOf(orderByComparator)
807 };
808
809 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P,
810 finderArgs, this);
811
812 if (list == null) {
813 Session session = null;
814
815 try {
816 session = openSession();
817
818 StringBundler query = null;
819
820 if (orderByComparator != null) {
821 query = new StringBundler(4 +
822 (orderByComparator.getOrderByFields().length * 3));
823 }
824 else {
825 query = new StringBundler(3);
826 }
827
828 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
829
830 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
831
832 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
833
834 if (orderByComparator != null) {
835 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
836 orderByComparator);
837 }
838
839 String sql = query.toString();
840
841 Query q = session.createQuery(sql);
842
843 QueryPos qPos = QueryPos.getInstance(q);
844
845 qPos.add(groupId);
846
847 qPos.add(privateLayout);
848
849 list = (List<JournalContentSearch>)QueryUtil.list(q,
850 getDialect(), start, end);
851 }
852 catch (Exception e) {
853 throw processException(e);
854 }
855 finally {
856 if (list == null) {
857 list = new ArrayList<JournalContentSearch>();
858 }
859
860 cacheResult(list);
861
862 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P, finderArgs,
863 list);
864
865 closeSession(session);
866 }
867 }
868
869 return list;
870 }
871
872 public JournalContentSearch findByG_P_First(long groupId,
873 boolean privateLayout, OrderByComparator orderByComparator)
874 throws NoSuchContentSearchException, SystemException {
875 List<JournalContentSearch> list = findByG_P(groupId, privateLayout, 0,
876 1, orderByComparator);
877
878 if (list.isEmpty()) {
879 StringBundler msg = new StringBundler(6);
880
881 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
882
883 msg.append("groupId=");
884 msg.append(groupId);
885
886 msg.append(", privateLayout=");
887 msg.append(privateLayout);
888
889 msg.append(StringPool.CLOSE_CURLY_BRACE);
890
891 throw new NoSuchContentSearchException(msg.toString());
892 }
893 else {
894 return list.get(0);
895 }
896 }
897
898 public JournalContentSearch findByG_P_Last(long groupId,
899 boolean privateLayout, OrderByComparator orderByComparator)
900 throws NoSuchContentSearchException, SystemException {
901 int count = countByG_P(groupId, privateLayout);
902
903 List<JournalContentSearch> list = findByG_P(groupId, privateLayout,
904 count - 1, count, orderByComparator);
905
906 if (list.isEmpty()) {
907 StringBundler msg = new StringBundler(6);
908
909 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
910
911 msg.append("groupId=");
912 msg.append(groupId);
913
914 msg.append(", privateLayout=");
915 msg.append(privateLayout);
916
917 msg.append(StringPool.CLOSE_CURLY_BRACE);
918
919 throw new NoSuchContentSearchException(msg.toString());
920 }
921 else {
922 return list.get(0);
923 }
924 }
925
926 public JournalContentSearch[] findByG_P_PrevAndNext(long contentSearchId,
927 long groupId, boolean privateLayout, OrderByComparator orderByComparator)
928 throws NoSuchContentSearchException, SystemException {
929 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
930
931 Session session = null;
932
933 try {
934 session = openSession();
935
936 JournalContentSearch[] array = new JournalContentSearchImpl[3];
937
938 array[0] = getByG_P_PrevAndNext(session, journalContentSearch,
939 groupId, privateLayout, orderByComparator, true);
940
941 array[1] = journalContentSearch;
942
943 array[2] = getByG_P_PrevAndNext(session, journalContentSearch,
944 groupId, privateLayout, orderByComparator, false);
945
946 return array;
947 }
948 catch (Exception e) {
949 throw processException(e);
950 }
951 finally {
952 closeSession(session);
953 }
954 }
955
956 protected JournalContentSearch getByG_P_PrevAndNext(Session session,
957 JournalContentSearch journalContentSearch, long groupId,
958 boolean privateLayout, OrderByComparator orderByComparator,
959 boolean previous) {
960 StringBundler query = null;
961
962 if (orderByComparator != null) {
963 query = new StringBundler(6 +
964 (orderByComparator.getOrderByFields().length * 6));
965 }
966 else {
967 query = new StringBundler(3);
968 }
969
970 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
971
972 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
973
974 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
975
976 if (orderByComparator != null) {
977 String[] orderByFields = orderByComparator.getOrderByFields();
978
979 if (orderByFields.length > 0) {
980 query.append(WHERE_AND);
981 }
982
983 for (int i = 0; i < orderByFields.length; i++) {
984 query.append(_ORDER_BY_ENTITY_ALIAS);
985 query.append(orderByFields[i]);
986
987 if ((i + 1) < orderByFields.length) {
988 if (orderByComparator.isAscending() ^ previous) {
989 query.append(WHERE_GREATER_THAN_HAS_NEXT);
990 }
991 else {
992 query.append(WHERE_LESSER_THAN_HAS_NEXT);
993 }
994 }
995 else {
996 if (orderByComparator.isAscending() ^ previous) {
997 query.append(WHERE_GREATER_THAN);
998 }
999 else {
1000 query.append(WHERE_LESSER_THAN);
1001 }
1002 }
1003 }
1004
1005 query.append(ORDER_BY_CLAUSE);
1006
1007 for (int i = 0; i < orderByFields.length; i++) {
1008 query.append(_ORDER_BY_ENTITY_ALIAS);
1009 query.append(orderByFields[i]);
1010
1011 if ((i + 1) < orderByFields.length) {
1012 if (orderByComparator.isAscending() ^ previous) {
1013 query.append(ORDER_BY_ASC_HAS_NEXT);
1014 }
1015 else {
1016 query.append(ORDER_BY_DESC_HAS_NEXT);
1017 }
1018 }
1019 else {
1020 if (orderByComparator.isAscending() ^ previous) {
1021 query.append(ORDER_BY_ASC);
1022 }
1023 else {
1024 query.append(ORDER_BY_DESC);
1025 }
1026 }
1027 }
1028 }
1029
1030 String sql = query.toString();
1031
1032 Query q = session.createQuery(sql);
1033
1034 q.setFirstResult(0);
1035 q.setMaxResults(2);
1036
1037 QueryPos qPos = QueryPos.getInstance(q);
1038
1039 qPos.add(groupId);
1040
1041 qPos.add(privateLayout);
1042
1043 if (orderByComparator != null) {
1044 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
1045
1046 for (Object value : values) {
1047 qPos.add(value);
1048 }
1049 }
1050
1051 List<JournalContentSearch> list = q.list();
1052
1053 if (list.size() == 2) {
1054 return list.get(1);
1055 }
1056 else {
1057 return null;
1058 }
1059 }
1060
1061 public List<JournalContentSearch> findByG_A(long groupId, String articleId)
1062 throws SystemException {
1063 return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
1064 QueryUtil.ALL_POS, null);
1065 }
1066
1067 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1068 int start, int end) throws SystemException {
1069 return findByG_A(groupId, articleId, start, end, null);
1070 }
1071
1072 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1073 int start, int end, OrderByComparator orderByComparator)
1074 throws SystemException {
1075 Object[] finderArgs = new Object[] {
1076 new Long(groupId),
1077
1078 articleId,
1079
1080 String.valueOf(start), String.valueOf(end),
1081 String.valueOf(orderByComparator)
1082 };
1083
1084 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_A,
1085 finderArgs, this);
1086
1087 if (list == null) {
1088 Session session = null;
1089
1090 try {
1091 session = openSession();
1092
1093 StringBundler query = null;
1094
1095 if (orderByComparator != null) {
1096 query = new StringBundler(4 +
1097 (orderByComparator.getOrderByFields().length * 3));
1098 }
1099 else {
1100 query = new StringBundler(3);
1101 }
1102
1103 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1104
1105 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1106
1107 if (articleId == null) {
1108 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1109 }
1110 else {
1111 if (articleId.equals(StringPool.BLANK)) {
1112 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1113 }
1114 else {
1115 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1116 }
1117 }
1118
1119 if (orderByComparator != null) {
1120 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1121 orderByComparator);
1122 }
1123
1124 String sql = query.toString();
1125
1126 Query q = session.createQuery(sql);
1127
1128 QueryPos qPos = QueryPos.getInstance(q);
1129
1130 qPos.add(groupId);
1131
1132 if (articleId != null) {
1133 qPos.add(articleId);
1134 }
1135
1136 list = (List<JournalContentSearch>)QueryUtil.list(q,
1137 getDialect(), start, end);
1138 }
1139 catch (Exception e) {
1140 throw processException(e);
1141 }
1142 finally {
1143 if (list == null) {
1144 list = new ArrayList<JournalContentSearch>();
1145 }
1146
1147 cacheResult(list);
1148
1149 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_A, finderArgs,
1150 list);
1151
1152 closeSession(session);
1153 }
1154 }
1155
1156 return list;
1157 }
1158
1159 public JournalContentSearch findByG_A_First(long groupId, String articleId,
1160 OrderByComparator orderByComparator)
1161 throws NoSuchContentSearchException, SystemException {
1162 List<JournalContentSearch> list = findByG_A(groupId, articleId, 0, 1,
1163 orderByComparator);
1164
1165 if (list.isEmpty()) {
1166 StringBundler msg = new StringBundler(6);
1167
1168 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1169
1170 msg.append("groupId=");
1171 msg.append(groupId);
1172
1173 msg.append(", articleId=");
1174 msg.append(articleId);
1175
1176 msg.append(StringPool.CLOSE_CURLY_BRACE);
1177
1178 throw new NoSuchContentSearchException(msg.toString());
1179 }
1180 else {
1181 return list.get(0);
1182 }
1183 }
1184
1185 public JournalContentSearch findByG_A_Last(long groupId, String articleId,
1186 OrderByComparator orderByComparator)
1187 throws NoSuchContentSearchException, SystemException {
1188 int count = countByG_A(groupId, articleId);
1189
1190 List<JournalContentSearch> list = findByG_A(groupId, articleId,
1191 count - 1, count, orderByComparator);
1192
1193 if (list.isEmpty()) {
1194 StringBundler msg = new StringBundler(6);
1195
1196 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1197
1198 msg.append("groupId=");
1199 msg.append(groupId);
1200
1201 msg.append(", articleId=");
1202 msg.append(articleId);
1203
1204 msg.append(StringPool.CLOSE_CURLY_BRACE);
1205
1206 throw new NoSuchContentSearchException(msg.toString());
1207 }
1208 else {
1209 return list.get(0);
1210 }
1211 }
1212
1213 public JournalContentSearch[] findByG_A_PrevAndNext(long contentSearchId,
1214 long groupId, String articleId, OrderByComparator orderByComparator)
1215 throws NoSuchContentSearchException, SystemException {
1216 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1217
1218 Session session = null;
1219
1220 try {
1221 session = openSession();
1222
1223 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1224
1225 array[0] = getByG_A_PrevAndNext(session, journalContentSearch,
1226 groupId, articleId, orderByComparator, true);
1227
1228 array[1] = journalContentSearch;
1229
1230 array[2] = getByG_A_PrevAndNext(session, journalContentSearch,
1231 groupId, articleId, orderByComparator, false);
1232
1233 return array;
1234 }
1235 catch (Exception e) {
1236 throw processException(e);
1237 }
1238 finally {
1239 closeSession(session);
1240 }
1241 }
1242
1243 protected JournalContentSearch getByG_A_PrevAndNext(Session session,
1244 JournalContentSearch journalContentSearch, long groupId,
1245 String articleId, OrderByComparator orderByComparator, boolean previous) {
1246 StringBundler query = null;
1247
1248 if (orderByComparator != null) {
1249 query = new StringBundler(6 +
1250 (orderByComparator.getOrderByFields().length * 6));
1251 }
1252 else {
1253 query = new StringBundler(3);
1254 }
1255
1256 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1257
1258 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1259
1260 if (articleId == null) {
1261 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1262 }
1263 else {
1264 if (articleId.equals(StringPool.BLANK)) {
1265 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1266 }
1267 else {
1268 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1269 }
1270 }
1271
1272 if (orderByComparator != null) {
1273 String[] orderByFields = orderByComparator.getOrderByFields();
1274
1275 if (orderByFields.length > 0) {
1276 query.append(WHERE_AND);
1277 }
1278
1279 for (int i = 0; i < orderByFields.length; i++) {
1280 query.append(_ORDER_BY_ENTITY_ALIAS);
1281 query.append(orderByFields[i]);
1282
1283 if ((i + 1) < orderByFields.length) {
1284 if (orderByComparator.isAscending() ^ previous) {
1285 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1286 }
1287 else {
1288 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1289 }
1290 }
1291 else {
1292 if (orderByComparator.isAscending() ^ previous) {
1293 query.append(WHERE_GREATER_THAN);
1294 }
1295 else {
1296 query.append(WHERE_LESSER_THAN);
1297 }
1298 }
1299 }
1300
1301 query.append(ORDER_BY_CLAUSE);
1302
1303 for (int i = 0; i < orderByFields.length; i++) {
1304 query.append(_ORDER_BY_ENTITY_ALIAS);
1305 query.append(orderByFields[i]);
1306
1307 if ((i + 1) < orderByFields.length) {
1308 if (orderByComparator.isAscending() ^ previous) {
1309 query.append(ORDER_BY_ASC_HAS_NEXT);
1310 }
1311 else {
1312 query.append(ORDER_BY_DESC_HAS_NEXT);
1313 }
1314 }
1315 else {
1316 if (orderByComparator.isAscending() ^ previous) {
1317 query.append(ORDER_BY_ASC);
1318 }
1319 else {
1320 query.append(ORDER_BY_DESC);
1321 }
1322 }
1323 }
1324 }
1325
1326 String sql = query.toString();
1327
1328 Query q = session.createQuery(sql);
1329
1330 q.setFirstResult(0);
1331 q.setMaxResults(2);
1332
1333 QueryPos qPos = QueryPos.getInstance(q);
1334
1335 qPos.add(groupId);
1336
1337 if (articleId != null) {
1338 qPos.add(articleId);
1339 }
1340
1341 if (orderByComparator != null) {
1342 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
1343
1344 for (Object value : values) {
1345 qPos.add(value);
1346 }
1347 }
1348
1349 List<JournalContentSearch> list = q.list();
1350
1351 if (list.size() == 2) {
1352 return list.get(1);
1353 }
1354 else {
1355 return null;
1356 }
1357 }
1358
1359 public List<JournalContentSearch> findByG_P_L(long groupId,
1360 boolean privateLayout, long layoutId) throws SystemException {
1361 return findByG_P_L(groupId, privateLayout, layoutId, QueryUtil.ALL_POS,
1362 QueryUtil.ALL_POS, null);
1363 }
1364
1365 public List<JournalContentSearch> findByG_P_L(long groupId,
1366 boolean privateLayout, long layoutId, int start, int end)
1367 throws SystemException {
1368 return findByG_P_L(groupId, privateLayout, layoutId, start, end, null);
1369 }
1370
1371 public List<JournalContentSearch> findByG_P_L(long groupId,
1372 boolean privateLayout, long layoutId, int start, int end,
1373 OrderByComparator orderByComparator) throws SystemException {
1374 Object[] finderArgs = new Object[] {
1375 new Long(groupId), Boolean.valueOf(privateLayout),
1376 new Long(layoutId),
1377
1378 String.valueOf(start), String.valueOf(end),
1379 String.valueOf(orderByComparator)
1380 };
1381
1382 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_L,
1383 finderArgs, this);
1384
1385 if (list == null) {
1386 Session session = null;
1387
1388 try {
1389 session = openSession();
1390
1391 StringBundler query = null;
1392
1393 if (orderByComparator != null) {
1394 query = new StringBundler(5 +
1395 (orderByComparator.getOrderByFields().length * 3));
1396 }
1397 else {
1398 query = new StringBundler(4);
1399 }
1400
1401 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1402
1403 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
1404
1405 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
1406
1407 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
1408
1409 if (orderByComparator != null) {
1410 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1411 orderByComparator);
1412 }
1413
1414 String sql = query.toString();
1415
1416 Query q = session.createQuery(sql);
1417
1418 QueryPos qPos = QueryPos.getInstance(q);
1419
1420 qPos.add(groupId);
1421
1422 qPos.add(privateLayout);
1423
1424 qPos.add(layoutId);
1425
1426 list = (List<JournalContentSearch>)QueryUtil.list(q,
1427 getDialect(), start, end);
1428 }
1429 catch (Exception e) {
1430 throw processException(e);
1431 }
1432 finally {
1433 if (list == null) {
1434 list = new ArrayList<JournalContentSearch>();
1435 }
1436
1437 cacheResult(list);
1438
1439 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_L,
1440 finderArgs, list);
1441
1442 closeSession(session);
1443 }
1444 }
1445
1446 return list;
1447 }
1448
1449 public JournalContentSearch findByG_P_L_First(long groupId,
1450 boolean privateLayout, long layoutId,
1451 OrderByComparator orderByComparator)
1452 throws NoSuchContentSearchException, SystemException {
1453 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
1454 layoutId, 0, 1, orderByComparator);
1455
1456 if (list.isEmpty()) {
1457 StringBundler msg = new StringBundler(8);
1458
1459 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1460
1461 msg.append("groupId=");
1462 msg.append(groupId);
1463
1464 msg.append(", privateLayout=");
1465 msg.append(privateLayout);
1466
1467 msg.append(", layoutId=");
1468 msg.append(layoutId);
1469
1470 msg.append(StringPool.CLOSE_CURLY_BRACE);
1471
1472 throw new NoSuchContentSearchException(msg.toString());
1473 }
1474 else {
1475 return list.get(0);
1476 }
1477 }
1478
1479 public JournalContentSearch findByG_P_L_Last(long groupId,
1480 boolean privateLayout, long layoutId,
1481 OrderByComparator orderByComparator)
1482 throws NoSuchContentSearchException, SystemException {
1483 int count = countByG_P_L(groupId, privateLayout, layoutId);
1484
1485 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
1486 layoutId, count - 1, count, orderByComparator);
1487
1488 if (list.isEmpty()) {
1489 StringBundler msg = new StringBundler(8);
1490
1491 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1492
1493 msg.append("groupId=");
1494 msg.append(groupId);
1495
1496 msg.append(", privateLayout=");
1497 msg.append(privateLayout);
1498
1499 msg.append(", layoutId=");
1500 msg.append(layoutId);
1501
1502 msg.append(StringPool.CLOSE_CURLY_BRACE);
1503
1504 throw new NoSuchContentSearchException(msg.toString());
1505 }
1506 else {
1507 return list.get(0);
1508 }
1509 }
1510
1511 public JournalContentSearch[] findByG_P_L_PrevAndNext(
1512 long contentSearchId, long groupId, boolean privateLayout,
1513 long layoutId, OrderByComparator orderByComparator)
1514 throws NoSuchContentSearchException, SystemException {
1515 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1516
1517 Session session = null;
1518
1519 try {
1520 session = openSession();
1521
1522 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1523
1524 array[0] = getByG_P_L_PrevAndNext(session, journalContentSearch,
1525 groupId, privateLayout, layoutId, orderByComparator, true);
1526
1527 array[1] = journalContentSearch;
1528
1529 array[2] = getByG_P_L_PrevAndNext(session, journalContentSearch,
1530 groupId, privateLayout, layoutId, orderByComparator, false);
1531
1532 return array;
1533 }
1534 catch (Exception e) {
1535 throw processException(e);
1536 }
1537 finally {
1538 closeSession(session);
1539 }
1540 }
1541
1542 protected JournalContentSearch getByG_P_L_PrevAndNext(Session session,
1543 JournalContentSearch journalContentSearch, long groupId,
1544 boolean privateLayout, long layoutId,
1545 OrderByComparator orderByComparator, boolean previous) {
1546 StringBundler query = null;
1547
1548 if (orderByComparator != null) {
1549 query = new StringBundler(6 +
1550 (orderByComparator.getOrderByFields().length * 6));
1551 }
1552 else {
1553 query = new StringBundler(3);
1554 }
1555
1556 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1557
1558 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
1559
1560 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
1561
1562 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
1563
1564 if (orderByComparator != null) {
1565 String[] orderByFields = orderByComparator.getOrderByFields();
1566
1567 if (orderByFields.length > 0) {
1568 query.append(WHERE_AND);
1569 }
1570
1571 for (int i = 0; i < orderByFields.length; i++) {
1572 query.append(_ORDER_BY_ENTITY_ALIAS);
1573 query.append(orderByFields[i]);
1574
1575 if ((i + 1) < orderByFields.length) {
1576 if (orderByComparator.isAscending() ^ previous) {
1577 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1578 }
1579 else {
1580 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1581 }
1582 }
1583 else {
1584 if (orderByComparator.isAscending() ^ previous) {
1585 query.append(WHERE_GREATER_THAN);
1586 }
1587 else {
1588 query.append(WHERE_LESSER_THAN);
1589 }
1590 }
1591 }
1592
1593 query.append(ORDER_BY_CLAUSE);
1594
1595 for (int i = 0; i < orderByFields.length; i++) {
1596 query.append(_ORDER_BY_ENTITY_ALIAS);
1597 query.append(orderByFields[i]);
1598
1599 if ((i + 1) < orderByFields.length) {
1600 if (orderByComparator.isAscending() ^ previous) {
1601 query.append(ORDER_BY_ASC_HAS_NEXT);
1602 }
1603 else {
1604 query.append(ORDER_BY_DESC_HAS_NEXT);
1605 }
1606 }
1607 else {
1608 if (orderByComparator.isAscending() ^ previous) {
1609 query.append(ORDER_BY_ASC);
1610 }
1611 else {
1612 query.append(ORDER_BY_DESC);
1613 }
1614 }
1615 }
1616 }
1617
1618 String sql = query.toString();
1619
1620 Query q = session.createQuery(sql);
1621
1622 q.setFirstResult(0);
1623 q.setMaxResults(2);
1624
1625 QueryPos qPos = QueryPos.getInstance(q);
1626
1627 qPos.add(groupId);
1628
1629 qPos.add(privateLayout);
1630
1631 qPos.add(layoutId);
1632
1633 if (orderByComparator != null) {
1634 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
1635
1636 for (Object value : values) {
1637 qPos.add(value);
1638 }
1639 }
1640
1641 List<JournalContentSearch> list = q.list();
1642
1643 if (list.size() == 2) {
1644 return list.get(1);
1645 }
1646 else {
1647 return null;
1648 }
1649 }
1650
1651 public List<JournalContentSearch> findByG_P_A(long groupId,
1652 boolean privateLayout, String articleId) throws SystemException {
1653 return findByG_P_A(groupId, privateLayout, articleId,
1654 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1655 }
1656
1657 public List<JournalContentSearch> findByG_P_A(long groupId,
1658 boolean privateLayout, String articleId, int start, int end)
1659 throws SystemException {
1660 return findByG_P_A(groupId, privateLayout, articleId, start, end, null);
1661 }
1662
1663 public List<JournalContentSearch> findByG_P_A(long groupId,
1664 boolean privateLayout, String articleId, int start, int end,
1665 OrderByComparator orderByComparator) throws SystemException {
1666 Object[] finderArgs = new Object[] {
1667 new Long(groupId), Boolean.valueOf(privateLayout),
1668
1669 articleId,
1670
1671 String.valueOf(start), String.valueOf(end),
1672 String.valueOf(orderByComparator)
1673 };
1674
1675 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_A,
1676 finderArgs, this);
1677
1678 if (list == null) {
1679 Session session = null;
1680
1681 try {
1682 session = openSession();
1683
1684 StringBundler query = null;
1685
1686 if (orderByComparator != null) {
1687 query = new StringBundler(5 +
1688 (orderByComparator.getOrderByFields().length * 3));
1689 }
1690 else {
1691 query = new StringBundler(4);
1692 }
1693
1694 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1695
1696 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
1697
1698 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
1699
1700 if (articleId == null) {
1701 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
1702 }
1703 else {
1704 if (articleId.equals(StringPool.BLANK)) {
1705 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
1706 }
1707 else {
1708 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
1709 }
1710 }
1711
1712 if (orderByComparator != null) {
1713 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1714 orderByComparator);
1715 }
1716
1717 String sql = query.toString();
1718
1719 Query q = session.createQuery(sql);
1720
1721 QueryPos qPos = QueryPos.getInstance(q);
1722
1723 qPos.add(groupId);
1724
1725 qPos.add(privateLayout);
1726
1727 if (articleId != null) {
1728 qPos.add(articleId);
1729 }
1730
1731 list = (List<JournalContentSearch>)QueryUtil.list(q,
1732 getDialect(), start, end);
1733 }
1734 catch (Exception e) {
1735 throw processException(e);
1736 }
1737 finally {
1738 if (list == null) {
1739 list = new ArrayList<JournalContentSearch>();
1740 }
1741
1742 cacheResult(list);
1743
1744 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_A,
1745 finderArgs, list);
1746
1747 closeSession(session);
1748 }
1749 }
1750
1751 return list;
1752 }
1753
1754 public JournalContentSearch findByG_P_A_First(long groupId,
1755 boolean privateLayout, String articleId,
1756 OrderByComparator orderByComparator)
1757 throws NoSuchContentSearchException, SystemException {
1758 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
1759 articleId, 0, 1, orderByComparator);
1760
1761 if (list.isEmpty()) {
1762 StringBundler msg = new StringBundler(8);
1763
1764 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1765
1766 msg.append("groupId=");
1767 msg.append(groupId);
1768
1769 msg.append(", privateLayout=");
1770 msg.append(privateLayout);
1771
1772 msg.append(", articleId=");
1773 msg.append(articleId);
1774
1775 msg.append(StringPool.CLOSE_CURLY_BRACE);
1776
1777 throw new NoSuchContentSearchException(msg.toString());
1778 }
1779 else {
1780 return list.get(0);
1781 }
1782 }
1783
1784 public JournalContentSearch findByG_P_A_Last(long groupId,
1785 boolean privateLayout, String articleId,
1786 OrderByComparator orderByComparator)
1787 throws NoSuchContentSearchException, SystemException {
1788 int count = countByG_P_A(groupId, privateLayout, articleId);
1789
1790 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
1791 articleId, count - 1, count, orderByComparator);
1792
1793 if (list.isEmpty()) {
1794 StringBundler msg = new StringBundler(8);
1795
1796 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1797
1798 msg.append("groupId=");
1799 msg.append(groupId);
1800
1801 msg.append(", privateLayout=");
1802 msg.append(privateLayout);
1803
1804 msg.append(", articleId=");
1805 msg.append(articleId);
1806
1807 msg.append(StringPool.CLOSE_CURLY_BRACE);
1808
1809 throw new NoSuchContentSearchException(msg.toString());
1810 }
1811 else {
1812 return list.get(0);
1813 }
1814 }
1815
1816 public JournalContentSearch[] findByG_P_A_PrevAndNext(
1817 long contentSearchId, long groupId, boolean privateLayout,
1818 String articleId, OrderByComparator orderByComparator)
1819 throws NoSuchContentSearchException, SystemException {
1820 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1821
1822 Session session = null;
1823
1824 try {
1825 session = openSession();
1826
1827 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1828
1829 array[0] = getByG_P_A_PrevAndNext(session, journalContentSearch,
1830 groupId, privateLayout, articleId, orderByComparator, true);
1831
1832 array[1] = journalContentSearch;
1833
1834 array[2] = getByG_P_A_PrevAndNext(session, journalContentSearch,
1835 groupId, privateLayout, articleId, orderByComparator, false);
1836
1837 return array;
1838 }
1839 catch (Exception e) {
1840 throw processException(e);
1841 }
1842 finally {
1843 closeSession(session);
1844 }
1845 }
1846
1847 protected JournalContentSearch getByG_P_A_PrevAndNext(Session session,
1848 JournalContentSearch journalContentSearch, long groupId,
1849 boolean privateLayout, String articleId,
1850 OrderByComparator orderByComparator, boolean previous) {
1851 StringBundler query = null;
1852
1853 if (orderByComparator != null) {
1854 query = new StringBundler(6 +
1855 (orderByComparator.getOrderByFields().length * 6));
1856 }
1857 else {
1858 query = new StringBundler(3);
1859 }
1860
1861 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1862
1863 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
1864
1865 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
1866
1867 if (articleId == null) {
1868 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
1869 }
1870 else {
1871 if (articleId.equals(StringPool.BLANK)) {
1872 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
1873 }
1874 else {
1875 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
1876 }
1877 }
1878
1879 if (orderByComparator != null) {
1880 String[] orderByFields = orderByComparator.getOrderByFields();
1881
1882 if (orderByFields.length > 0) {
1883 query.append(WHERE_AND);
1884 }
1885
1886 for (int i = 0; i < orderByFields.length; i++) {
1887 query.append(_ORDER_BY_ENTITY_ALIAS);
1888 query.append(orderByFields[i]);
1889
1890 if ((i + 1) < orderByFields.length) {
1891 if (orderByComparator.isAscending() ^ previous) {
1892 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1893 }
1894 else {
1895 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1896 }
1897 }
1898 else {
1899 if (orderByComparator.isAscending() ^ previous) {
1900 query.append(WHERE_GREATER_THAN);
1901 }
1902 else {
1903 query.append(WHERE_LESSER_THAN);
1904 }
1905 }
1906 }
1907
1908 query.append(ORDER_BY_CLAUSE);
1909
1910 for (int i = 0; i < orderByFields.length; i++) {
1911 query.append(_ORDER_BY_ENTITY_ALIAS);
1912 query.append(orderByFields[i]);
1913
1914 if ((i + 1) < orderByFields.length) {
1915 if (orderByComparator.isAscending() ^ previous) {
1916 query.append(ORDER_BY_ASC_HAS_NEXT);
1917 }
1918 else {
1919 query.append(ORDER_BY_DESC_HAS_NEXT);
1920 }
1921 }
1922 else {
1923 if (orderByComparator.isAscending() ^ previous) {
1924 query.append(ORDER_BY_ASC);
1925 }
1926 else {
1927 query.append(ORDER_BY_DESC);
1928 }
1929 }
1930 }
1931 }
1932
1933 String sql = query.toString();
1934
1935 Query q = session.createQuery(sql);
1936
1937 q.setFirstResult(0);
1938 q.setMaxResults(2);
1939
1940 QueryPos qPos = QueryPos.getInstance(q);
1941
1942 qPos.add(groupId);
1943
1944 qPos.add(privateLayout);
1945
1946 if (articleId != null) {
1947 qPos.add(articleId);
1948 }
1949
1950 if (orderByComparator != null) {
1951 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
1952
1953 for (Object value : values) {
1954 qPos.add(value);
1955 }
1956 }
1957
1958 List<JournalContentSearch> list = q.list();
1959
1960 if (list.size() == 2) {
1961 return list.get(1);
1962 }
1963 else {
1964 return null;
1965 }
1966 }
1967
1968 public List<JournalContentSearch> findByG_P_L_P(long groupId,
1969 boolean privateLayout, long layoutId, String portletId)
1970 throws SystemException {
1971 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
1972 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1973 }
1974
1975 public List<JournalContentSearch> findByG_P_L_P(long groupId,
1976 boolean privateLayout, long layoutId, String portletId, int start,
1977 int end) throws SystemException {
1978 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
1979 start, end, null);
1980 }
1981
1982 public List<JournalContentSearch> findByG_P_L_P(long groupId,
1983 boolean privateLayout, long layoutId, String portletId, int start,
1984 int end, OrderByComparator orderByComparator) throws SystemException {
1985 Object[] finderArgs = new Object[] {
1986 new Long(groupId), Boolean.valueOf(privateLayout),
1987 new Long(layoutId),
1988
1989 portletId,
1990
1991 String.valueOf(start), String.valueOf(end),
1992 String.valueOf(orderByComparator)
1993 };
1994
1995 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_L_P,
1996 finderArgs, this);
1997
1998 if (list == null) {
1999 Session session = null;
2000
2001 try {
2002 session = openSession();
2003
2004 StringBundler query = null;
2005
2006 if (orderByComparator != null) {
2007 query = new StringBundler(6 +
2008 (orderByComparator.getOrderByFields().length * 3));
2009 }
2010 else {
2011 query = new StringBundler(5);
2012 }
2013
2014 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2015
2016 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
2017
2018 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
2019
2020 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
2021
2022 if (portletId == null) {
2023 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
2024 }
2025 else {
2026 if (portletId.equals(StringPool.BLANK)) {
2027 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
2028 }
2029 else {
2030 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
2031 }
2032 }
2033
2034 if (orderByComparator != null) {
2035 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2036 orderByComparator);
2037 }
2038
2039 String sql = query.toString();
2040
2041 Query q = session.createQuery(sql);
2042
2043 QueryPos qPos = QueryPos.getInstance(q);
2044
2045 qPos.add(groupId);
2046
2047 qPos.add(privateLayout);
2048
2049 qPos.add(layoutId);
2050
2051 if (portletId != null) {
2052 qPos.add(portletId);
2053 }
2054
2055 list = (List<JournalContentSearch>)QueryUtil.list(q,
2056 getDialect(), start, end);
2057 }
2058 catch (Exception e) {
2059 throw processException(e);
2060 }
2061 finally {
2062 if (list == null) {
2063 list = new ArrayList<JournalContentSearch>();
2064 }
2065
2066 cacheResult(list);
2067
2068 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_L_P,
2069 finderArgs, list);
2070
2071 closeSession(session);
2072 }
2073 }
2074
2075 return list;
2076 }
2077
2078 public JournalContentSearch findByG_P_L_P_First(long groupId,
2079 boolean privateLayout, long layoutId, String portletId,
2080 OrderByComparator orderByComparator)
2081 throws NoSuchContentSearchException, SystemException {
2082 List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
2083 layoutId, portletId, 0, 1, orderByComparator);
2084
2085 if (list.isEmpty()) {
2086 StringBundler msg = new StringBundler(10);
2087
2088 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2089
2090 msg.append("groupId=");
2091 msg.append(groupId);
2092
2093 msg.append(", privateLayout=");
2094 msg.append(privateLayout);
2095
2096 msg.append(", layoutId=");
2097 msg.append(layoutId);
2098
2099 msg.append(", portletId=");
2100 msg.append(portletId);
2101
2102 msg.append(StringPool.CLOSE_CURLY_BRACE);
2103
2104 throw new NoSuchContentSearchException(msg.toString());
2105 }
2106 else {
2107 return list.get(0);
2108 }
2109 }
2110
2111 public JournalContentSearch findByG_P_L_P_Last(long groupId,
2112 boolean privateLayout, long layoutId, String portletId,
2113 OrderByComparator orderByComparator)
2114 throws NoSuchContentSearchException, SystemException {
2115 int count = countByG_P_L_P(groupId, privateLayout, layoutId, portletId);
2116
2117 List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
2118 layoutId, portletId, count - 1, count, orderByComparator);
2119
2120 if (list.isEmpty()) {
2121 StringBundler msg = new StringBundler(10);
2122
2123 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2124
2125 msg.append("groupId=");
2126 msg.append(groupId);
2127
2128 msg.append(", privateLayout=");
2129 msg.append(privateLayout);
2130
2131 msg.append(", layoutId=");
2132 msg.append(layoutId);
2133
2134 msg.append(", portletId=");
2135 msg.append(portletId);
2136
2137 msg.append(StringPool.CLOSE_CURLY_BRACE);
2138
2139 throw new NoSuchContentSearchException(msg.toString());
2140 }
2141 else {
2142 return list.get(0);
2143 }
2144 }
2145
2146 public JournalContentSearch[] findByG_P_L_P_PrevAndNext(
2147 long contentSearchId, long groupId, boolean privateLayout,
2148 long layoutId, String portletId, OrderByComparator orderByComparator)
2149 throws NoSuchContentSearchException, SystemException {
2150 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2151
2152 Session session = null;
2153
2154 try {
2155 session = openSession();
2156
2157 JournalContentSearch[] array = new JournalContentSearchImpl[3];
2158
2159 array[0] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
2160 groupId, privateLayout, layoutId, portletId,
2161 orderByComparator, true);
2162
2163 array[1] = journalContentSearch;
2164
2165 array[2] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
2166 groupId, privateLayout, layoutId, portletId,
2167 orderByComparator, false);
2168
2169 return array;
2170 }
2171 catch (Exception e) {
2172 throw processException(e);
2173 }
2174 finally {
2175 closeSession(session);
2176 }
2177 }
2178
2179 protected JournalContentSearch getByG_P_L_P_PrevAndNext(Session session,
2180 JournalContentSearch journalContentSearch, long groupId,
2181 boolean privateLayout, long layoutId, String portletId,
2182 OrderByComparator orderByComparator, boolean previous) {
2183 StringBundler query = null;
2184
2185 if (orderByComparator != null) {
2186 query = new StringBundler(6 +
2187 (orderByComparator.getOrderByFields().length * 6));
2188 }
2189 else {
2190 query = new StringBundler(3);
2191 }
2192
2193 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2194
2195 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
2196
2197 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
2198
2199 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
2200
2201 if (portletId == null) {
2202 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
2203 }
2204 else {
2205 if (portletId.equals(StringPool.BLANK)) {
2206 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
2207 }
2208 else {
2209 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
2210 }
2211 }
2212
2213 if (orderByComparator != null) {
2214 String[] orderByFields = orderByComparator.getOrderByFields();
2215
2216 if (orderByFields.length > 0) {
2217 query.append(WHERE_AND);
2218 }
2219
2220 for (int i = 0; i < orderByFields.length; i++) {
2221 query.append(_ORDER_BY_ENTITY_ALIAS);
2222 query.append(orderByFields[i]);
2223
2224 if ((i + 1) < orderByFields.length) {
2225 if (orderByComparator.isAscending() ^ previous) {
2226 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2227 }
2228 else {
2229 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2230 }
2231 }
2232 else {
2233 if (orderByComparator.isAscending() ^ previous) {
2234 query.append(WHERE_GREATER_THAN);
2235 }
2236 else {
2237 query.append(WHERE_LESSER_THAN);
2238 }
2239 }
2240 }
2241
2242 query.append(ORDER_BY_CLAUSE);
2243
2244 for (int i = 0; i < orderByFields.length; i++) {
2245 query.append(_ORDER_BY_ENTITY_ALIAS);
2246 query.append(orderByFields[i]);
2247
2248 if ((i + 1) < orderByFields.length) {
2249 if (orderByComparator.isAscending() ^ previous) {
2250 query.append(ORDER_BY_ASC_HAS_NEXT);
2251 }
2252 else {
2253 query.append(ORDER_BY_DESC_HAS_NEXT);
2254 }
2255 }
2256 else {
2257 if (orderByComparator.isAscending() ^ previous) {
2258 query.append(ORDER_BY_ASC);
2259 }
2260 else {
2261 query.append(ORDER_BY_DESC);
2262 }
2263 }
2264 }
2265 }
2266
2267 String sql = query.toString();
2268
2269 Query q = session.createQuery(sql);
2270
2271 q.setFirstResult(0);
2272 q.setMaxResults(2);
2273
2274 QueryPos qPos = QueryPos.getInstance(q);
2275
2276 qPos.add(groupId);
2277
2278 qPos.add(privateLayout);
2279
2280 qPos.add(layoutId);
2281
2282 if (portletId != null) {
2283 qPos.add(portletId);
2284 }
2285
2286 if (orderByComparator != null) {
2287 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
2288
2289 for (Object value : values) {
2290 qPos.add(value);
2291 }
2292 }
2293
2294 List<JournalContentSearch> list = q.list();
2295
2296 if (list.size() == 2) {
2297 return list.get(1);
2298 }
2299 else {
2300 return null;
2301 }
2302 }
2303
2304 public JournalContentSearch findByG_P_L_P_A(long groupId,
2305 boolean privateLayout, long layoutId, String portletId, String articleId)
2306 throws NoSuchContentSearchException, SystemException {
2307 JournalContentSearch journalContentSearch = fetchByG_P_L_P_A(groupId,
2308 privateLayout, layoutId, portletId, articleId);
2309
2310 if (journalContentSearch == null) {
2311 StringBundler msg = new StringBundler(12);
2312
2313 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2314
2315 msg.append("groupId=");
2316 msg.append(groupId);
2317
2318 msg.append(", privateLayout=");
2319 msg.append(privateLayout);
2320
2321 msg.append(", layoutId=");
2322 msg.append(layoutId);
2323
2324 msg.append(", portletId=");
2325 msg.append(portletId);
2326
2327 msg.append(", articleId=");
2328 msg.append(articleId);
2329
2330 msg.append(StringPool.CLOSE_CURLY_BRACE);
2331
2332 if (_log.isWarnEnabled()) {
2333 _log.warn(msg.toString());
2334 }
2335
2336 throw new NoSuchContentSearchException(msg.toString());
2337 }
2338
2339 return journalContentSearch;
2340 }
2341
2342 public JournalContentSearch fetchByG_P_L_P_A(long groupId,
2343 boolean privateLayout, long layoutId, String portletId, String articleId)
2344 throws SystemException {
2345 return fetchByG_P_L_P_A(groupId, privateLayout, layoutId, portletId,
2346 articleId, true);
2347 }
2348
2349 public JournalContentSearch fetchByG_P_L_P_A(long groupId,
2350 boolean privateLayout, long layoutId, String portletId,
2351 String articleId, boolean retrieveFromCache) throws SystemException {
2352 Object[] finderArgs = new Object[] {
2353 new Long(groupId), Boolean.valueOf(privateLayout),
2354 new Long(layoutId),
2355
2356 portletId,
2357
2358 articleId
2359 };
2360
2361 Object result = null;
2362
2363 if (retrieveFromCache) {
2364 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
2365 finderArgs, this);
2366 }
2367
2368 if (result == null) {
2369 Session session = null;
2370
2371 try {
2372 session = openSession();
2373
2374 StringBundler query = new StringBundler(6);
2375
2376 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2377
2378 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
2379
2380 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
2381
2382 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
2383
2384 if (portletId == null) {
2385 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
2386 }
2387 else {
2388 if (portletId.equals(StringPool.BLANK)) {
2389 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
2390 }
2391 else {
2392 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
2393 }
2394 }
2395
2396 if (articleId == null) {
2397 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
2398 }
2399 else {
2400 if (articleId.equals(StringPool.BLANK)) {
2401 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
2402 }
2403 else {
2404 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
2405 }
2406 }
2407
2408 String sql = query.toString();
2409
2410 Query q = session.createQuery(sql);
2411
2412 QueryPos qPos = QueryPos.getInstance(q);
2413
2414 qPos.add(groupId);
2415
2416 qPos.add(privateLayout);
2417
2418 qPos.add(layoutId);
2419
2420 if (portletId != null) {
2421 qPos.add(portletId);
2422 }
2423
2424 if (articleId != null) {
2425 qPos.add(articleId);
2426 }
2427
2428 List<JournalContentSearch> list = q.list();
2429
2430 result = list;
2431
2432 JournalContentSearch journalContentSearch = null;
2433
2434 if (list.isEmpty()) {
2435 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
2436 finderArgs, list);
2437 }
2438 else {
2439 journalContentSearch = list.get(0);
2440
2441 cacheResult(journalContentSearch);
2442
2443 if ((journalContentSearch.getGroupId() != groupId) ||
2444 (journalContentSearch.getPrivateLayout() != privateLayout) ||
2445 (journalContentSearch.getLayoutId() != layoutId) ||
2446 (journalContentSearch.getPortletId() == null) ||
2447 !journalContentSearch.getPortletId()
2448 .equals(portletId) ||
2449 (journalContentSearch.getArticleId() == null) ||
2450 !journalContentSearch.getArticleId()
2451 .equals(articleId)) {
2452 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
2453 finderArgs, journalContentSearch);
2454 }
2455 }
2456
2457 return journalContentSearch;
2458 }
2459 catch (Exception e) {
2460 throw processException(e);
2461 }
2462 finally {
2463 if (result == null) {
2464 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
2465 finderArgs, new ArrayList<JournalContentSearch>());
2466 }
2467
2468 closeSession(session);
2469 }
2470 }
2471 else {
2472 if (result instanceof List<?>) {
2473 return null;
2474 }
2475 else {
2476 return (JournalContentSearch)result;
2477 }
2478 }
2479 }
2480
2481 public List<JournalContentSearch> findAll() throws SystemException {
2482 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2483 }
2484
2485 public List<JournalContentSearch> findAll(int start, int end)
2486 throws SystemException {
2487 return findAll(start, end, null);
2488 }
2489
2490 public List<JournalContentSearch> findAll(int start, int end,
2491 OrderByComparator orderByComparator) throws SystemException {
2492 Object[] finderArgs = new Object[] {
2493 String.valueOf(start), String.valueOf(end),
2494 String.valueOf(orderByComparator)
2495 };
2496
2497 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2498 finderArgs, this);
2499
2500 if (list == null) {
2501 Session session = null;
2502
2503 try {
2504 session = openSession();
2505
2506 StringBundler query = null;
2507 String sql = null;
2508
2509 if (orderByComparator != null) {
2510 query = new StringBundler(2 +
2511 (orderByComparator.getOrderByFields().length * 3));
2512
2513 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH);
2514
2515 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2516 orderByComparator);
2517
2518 sql = query.toString();
2519 }
2520
2521 sql = _SQL_SELECT_JOURNALCONTENTSEARCH;
2522
2523 Query q = session.createQuery(sql);
2524
2525 if (orderByComparator == null) {
2526 list = (List<JournalContentSearch>)QueryUtil.list(q,
2527 getDialect(), start, end, false);
2528
2529 Collections.sort(list);
2530 }
2531 else {
2532 list = (List<JournalContentSearch>)QueryUtil.list(q,
2533 getDialect(), start, end);
2534 }
2535 }
2536 catch (Exception e) {
2537 throw processException(e);
2538 }
2539 finally {
2540 if (list == null) {
2541 list = new ArrayList<JournalContentSearch>();
2542 }
2543
2544 cacheResult(list);
2545
2546 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2547
2548 closeSession(session);
2549 }
2550 }
2551
2552 return list;
2553 }
2554
2555 public void removeByArticleId(String articleId) throws SystemException {
2556 for (JournalContentSearch journalContentSearch : findByArticleId(
2557 articleId)) {
2558 remove(journalContentSearch);
2559 }
2560 }
2561
2562 public void removeByG_P(long groupId, boolean privateLayout)
2563 throws SystemException {
2564 for (JournalContentSearch journalContentSearch : findByG_P(groupId,
2565 privateLayout)) {
2566 remove(journalContentSearch);
2567 }
2568 }
2569
2570 public void removeByG_A(long groupId, String articleId)
2571 throws SystemException {
2572 for (JournalContentSearch journalContentSearch : findByG_A(groupId,
2573 articleId)) {
2574 remove(journalContentSearch);
2575 }
2576 }
2577
2578 public void removeByG_P_L(long groupId, boolean privateLayout, long layoutId)
2579 throws SystemException {
2580 for (JournalContentSearch journalContentSearch : findByG_P_L(groupId,
2581 privateLayout, layoutId)) {
2582 remove(journalContentSearch);
2583 }
2584 }
2585
2586 public void removeByG_P_A(long groupId, boolean privateLayout,
2587 String articleId) throws SystemException {
2588 for (JournalContentSearch journalContentSearch : findByG_P_A(groupId,
2589 privateLayout, articleId)) {
2590 remove(journalContentSearch);
2591 }
2592 }
2593
2594 public void removeByG_P_L_P(long groupId, boolean privateLayout,
2595 long layoutId, String portletId) throws SystemException {
2596 for (JournalContentSearch journalContentSearch : findByG_P_L_P(
2597 groupId, privateLayout, layoutId, portletId)) {
2598 remove(journalContentSearch);
2599 }
2600 }
2601
2602 public void removeByG_P_L_P_A(long groupId, boolean privateLayout,
2603 long layoutId, String portletId, String articleId)
2604 throws NoSuchContentSearchException, SystemException {
2605 JournalContentSearch journalContentSearch = findByG_P_L_P_A(groupId,
2606 privateLayout, layoutId, portletId, articleId);
2607
2608 remove(journalContentSearch);
2609 }
2610
2611 public void removeAll() throws SystemException {
2612 for (JournalContentSearch journalContentSearch : findAll()) {
2613 remove(journalContentSearch);
2614 }
2615 }
2616
2617 public int countByArticleId(String articleId) throws SystemException {
2618 Object[] finderArgs = new Object[] { articleId };
2619
2620 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ARTICLEID,
2621 finderArgs, this);
2622
2623 if (count == null) {
2624 Session session = null;
2625
2626 try {
2627 session = openSession();
2628
2629 StringBundler query = new StringBundler(2);
2630
2631 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2632
2633 if (articleId == null) {
2634 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
2635 }
2636 else {
2637 if (articleId.equals(StringPool.BLANK)) {
2638 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
2639 }
2640 else {
2641 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
2642 }
2643 }
2644
2645 String sql = query.toString();
2646
2647 Query q = session.createQuery(sql);
2648
2649 QueryPos qPos = QueryPos.getInstance(q);
2650
2651 if (articleId != null) {
2652 qPos.add(articleId);
2653 }
2654
2655 count = (Long)q.uniqueResult();
2656 }
2657 catch (Exception e) {
2658 throw processException(e);
2659 }
2660 finally {
2661 if (count == null) {
2662 count = Long.valueOf(0);
2663 }
2664
2665 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ARTICLEID,
2666 finderArgs, count);
2667
2668 closeSession(session);
2669 }
2670 }
2671
2672 return count.intValue();
2673 }
2674
2675 public int countByG_P(long groupId, boolean privateLayout)
2676 throws SystemException {
2677 Object[] finderArgs = new Object[] {
2678 new Long(groupId), Boolean.valueOf(privateLayout)
2679 };
2680
2681 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
2682 finderArgs, this);
2683
2684 if (count == null) {
2685 Session session = null;
2686
2687 try {
2688 session = openSession();
2689
2690 StringBundler query = new StringBundler(3);
2691
2692 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2693
2694 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2695
2696 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
2697
2698 String sql = query.toString();
2699
2700 Query q = session.createQuery(sql);
2701
2702 QueryPos qPos = QueryPos.getInstance(q);
2703
2704 qPos.add(groupId);
2705
2706 qPos.add(privateLayout);
2707
2708 count = (Long)q.uniqueResult();
2709 }
2710 catch (Exception e) {
2711 throw processException(e);
2712 }
2713 finally {
2714 if (count == null) {
2715 count = Long.valueOf(0);
2716 }
2717
2718 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
2719 count);
2720
2721 closeSession(session);
2722 }
2723 }
2724
2725 return count.intValue();
2726 }
2727
2728 public int countByG_A(long groupId, String articleId)
2729 throws SystemException {
2730 Object[] finderArgs = new Object[] { new Long(groupId), articleId };
2731
2732 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
2733 finderArgs, this);
2734
2735 if (count == null) {
2736 Session session = null;
2737
2738 try {
2739 session = openSession();
2740
2741 StringBundler query = new StringBundler(3);
2742
2743 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2744
2745 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
2746
2747 if (articleId == null) {
2748 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
2749 }
2750 else {
2751 if (articleId.equals(StringPool.BLANK)) {
2752 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
2753 }
2754 else {
2755 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
2756 }
2757 }
2758
2759 String sql = query.toString();
2760
2761 Query q = session.createQuery(sql);
2762
2763 QueryPos qPos = QueryPos.getInstance(q);
2764
2765 qPos.add(groupId);
2766
2767 if (articleId != null) {
2768 qPos.add(articleId);
2769 }
2770
2771 count = (Long)q.uniqueResult();
2772 }
2773 catch (Exception e) {
2774 throw processException(e);
2775 }
2776 finally {
2777 if (count == null) {
2778 count = Long.valueOf(0);
2779 }
2780
2781 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
2782 count);
2783
2784 closeSession(session);
2785 }
2786 }
2787
2788 return count.intValue();
2789 }
2790
2791 public int countByG_P_L(long groupId, boolean privateLayout, long layoutId)
2792 throws SystemException {
2793 Object[] finderArgs = new Object[] {
2794 new Long(groupId), Boolean.valueOf(privateLayout),
2795 new Long(layoutId)
2796 };
2797
2798 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L,
2799 finderArgs, this);
2800
2801 if (count == null) {
2802 Session session = null;
2803
2804 try {
2805 session = openSession();
2806
2807 StringBundler query = new StringBundler(4);
2808
2809 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2810
2811 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
2812
2813 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
2814
2815 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
2816
2817 String sql = query.toString();
2818
2819 Query q = session.createQuery(sql);
2820
2821 QueryPos qPos = QueryPos.getInstance(q);
2822
2823 qPos.add(groupId);
2824
2825 qPos.add(privateLayout);
2826
2827 qPos.add(layoutId);
2828
2829 count = (Long)q.uniqueResult();
2830 }
2831 catch (Exception e) {
2832 throw processException(e);
2833 }
2834 finally {
2835 if (count == null) {
2836 count = Long.valueOf(0);
2837 }
2838
2839 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L,
2840 finderArgs, count);
2841
2842 closeSession(session);
2843 }
2844 }
2845
2846 return count.intValue();
2847 }
2848
2849 public int countByG_P_A(long groupId, boolean privateLayout,
2850 String articleId) throws SystemException {
2851 Object[] finderArgs = new Object[] {
2852 new Long(groupId), Boolean.valueOf(privateLayout),
2853
2854 articleId
2855 };
2856
2857 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_A,
2858 finderArgs, this);
2859
2860 if (count == null) {
2861 Session session = null;
2862
2863 try {
2864 session = openSession();
2865
2866 StringBundler query = new StringBundler(4);
2867
2868 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2869
2870 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2871
2872 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2873
2874 if (articleId == null) {
2875 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2876 }
2877 else {
2878 if (articleId.equals(StringPool.BLANK)) {
2879 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
2880 }
2881 else {
2882 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
2883 }
2884 }
2885
2886 String sql = query.toString();
2887
2888 Query q = session.createQuery(sql);
2889
2890 QueryPos qPos = QueryPos.getInstance(q);
2891
2892 qPos.add(groupId);
2893
2894 qPos.add(privateLayout);
2895
2896 if (articleId != null) {
2897 qPos.add(articleId);
2898 }
2899
2900 count = (Long)q.uniqueResult();
2901 }
2902 catch (Exception e) {
2903 throw processException(e);
2904 }
2905 finally {
2906 if (count == null) {
2907 count = Long.valueOf(0);
2908 }
2909
2910 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_A,
2911 finderArgs, count);
2912
2913 closeSession(session);
2914 }
2915 }
2916
2917 return count.intValue();
2918 }
2919
2920 public int countByG_P_L_P(long groupId, boolean privateLayout,
2921 long layoutId, String portletId) throws SystemException {
2922 Object[] finderArgs = new Object[] {
2923 new Long(groupId), Boolean.valueOf(privateLayout),
2924 new Long(layoutId),
2925
2926 portletId
2927 };
2928
2929 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L_P,
2930 finderArgs, this);
2931
2932 if (count == null) {
2933 Session session = null;
2934
2935 try {
2936 session = openSession();
2937
2938 StringBundler query = new StringBundler(5);
2939
2940 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
2941
2942 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
2943
2944 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
2945
2946 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
2947
2948 if (portletId == null) {
2949 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
2950 }
2951 else {
2952 if (portletId.equals(StringPool.BLANK)) {
2953 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
2954 }
2955 else {
2956 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
2957 }
2958 }
2959
2960 String sql = query.toString();
2961
2962 Query q = session.createQuery(sql);
2963
2964 QueryPos qPos = QueryPos.getInstance(q);
2965
2966 qPos.add(groupId);
2967
2968 qPos.add(privateLayout);
2969
2970 qPos.add(layoutId);
2971
2972 if (portletId != null) {
2973 qPos.add(portletId);
2974 }
2975
2976 count = (Long)q.uniqueResult();
2977 }
2978 catch (Exception e) {
2979 throw processException(e);
2980 }
2981 finally {
2982 if (count == null) {
2983 count = Long.valueOf(0);
2984 }
2985
2986 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P,
2987 finderArgs, count);
2988
2989 closeSession(session);
2990 }
2991 }
2992
2993 return count.intValue();
2994 }
2995
2996 public int countByG_P_L_P_A(long groupId, boolean privateLayout,
2997 long layoutId, String portletId, String articleId)
2998 throws SystemException {
2999 Object[] finderArgs = new Object[] {
3000 new Long(groupId), Boolean.valueOf(privateLayout),
3001 new Long(layoutId),
3002
3003 portletId,
3004
3005 articleId
3006 };
3007
3008 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
3009 finderArgs, this);
3010
3011 if (count == null) {
3012 Session session = null;
3013
3014 try {
3015 session = openSession();
3016
3017 StringBundler query = new StringBundler(6);
3018
3019 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3020
3021 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
3022
3023 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
3024
3025 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
3026
3027 if (portletId == null) {
3028 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
3029 }
3030 else {
3031 if (portletId.equals(StringPool.BLANK)) {
3032 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
3033 }
3034 else {
3035 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
3036 }
3037 }
3038
3039 if (articleId == null) {
3040 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
3041 }
3042 else {
3043 if (articleId.equals(StringPool.BLANK)) {
3044 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
3045 }
3046 else {
3047 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
3048 }
3049 }
3050
3051 String sql = query.toString();
3052
3053 Query q = session.createQuery(sql);
3054
3055 QueryPos qPos = QueryPos.getInstance(q);
3056
3057 qPos.add(groupId);
3058
3059 qPos.add(privateLayout);
3060
3061 qPos.add(layoutId);
3062
3063 if (portletId != null) {
3064 qPos.add(portletId);
3065 }
3066
3067 if (articleId != null) {
3068 qPos.add(articleId);
3069 }
3070
3071 count = (Long)q.uniqueResult();
3072 }
3073 catch (Exception e) {
3074 throw processException(e);
3075 }
3076 finally {
3077 if (count == null) {
3078 count = Long.valueOf(0);
3079 }
3080
3081 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
3082 finderArgs, count);
3083
3084 closeSession(session);
3085 }
3086 }
3087
3088 return count.intValue();
3089 }
3090
3091 public int countAll() throws SystemException {
3092 Object[] finderArgs = new Object[0];
3093
3094 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3095 finderArgs, this);
3096
3097 if (count == null) {
3098 Session session = null;
3099
3100 try {
3101 session = openSession();
3102
3103 Query q = session.createQuery(_SQL_COUNT_JOURNALCONTENTSEARCH);
3104
3105 count = (Long)q.uniqueResult();
3106 }
3107 catch (Exception e) {
3108 throw processException(e);
3109 }
3110 finally {
3111 if (count == null) {
3112 count = Long.valueOf(0);
3113 }
3114
3115 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3116 count);
3117
3118 closeSession(session);
3119 }
3120 }
3121
3122 return count.intValue();
3123 }
3124
3125 public void afterPropertiesSet() {
3126 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3127 com.liferay.portal.util.PropsUtil.get(
3128 "value.object.listener.com.liferay.portlet.journal.model.JournalContentSearch")));
3129
3130 if (listenerClassNames.length > 0) {
3131 try {
3132 List<ModelListener<JournalContentSearch>> listenersList = new ArrayList<ModelListener<JournalContentSearch>>();
3133
3134 for (String listenerClassName : listenerClassNames) {
3135 listenersList.add((ModelListener<JournalContentSearch>)InstanceFactory.newInstance(
3136 listenerClassName));
3137 }
3138
3139 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3140 }
3141 catch (Exception e) {
3142 _log.error(e);
3143 }
3144 }
3145 }
3146
3147 @BeanReference(type = JournalArticlePersistence.class)
3148 protected JournalArticlePersistence journalArticlePersistence;
3149 @BeanReference(type = JournalArticleImagePersistence.class)
3150 protected JournalArticleImagePersistence journalArticleImagePersistence;
3151 @BeanReference(type = JournalArticleResourcePersistence.class)
3152 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
3153 @BeanReference(type = JournalContentSearchPersistence.class)
3154 protected JournalContentSearchPersistence journalContentSearchPersistence;
3155 @BeanReference(type = JournalFeedPersistence.class)
3156 protected JournalFeedPersistence journalFeedPersistence;
3157 @BeanReference(type = JournalStructurePersistence.class)
3158 protected JournalStructurePersistence journalStructurePersistence;
3159 @BeanReference(type = JournalTemplatePersistence.class)
3160 protected JournalTemplatePersistence journalTemplatePersistence;
3161 @BeanReference(type = GroupPersistence.class)
3162 protected GroupPersistence groupPersistence;
3163 @BeanReference(type = LayoutPersistence.class)
3164 protected LayoutPersistence layoutPersistence;
3165 @BeanReference(type = PortletPreferencesPersistence.class)
3166 protected PortletPreferencesPersistence portletPreferencesPersistence;
3167 @BeanReference(type = ResourcePersistence.class)
3168 protected ResourcePersistence resourcePersistence;
3169 @BeanReference(type = UserPersistence.class)
3170 protected UserPersistence userPersistence;
3171 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch";
3172 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH_WHERE = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch WHERE ";
3173 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch";
3174 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH_WHERE = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch WHERE ";
3175 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3176 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3177 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3178 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3179 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ?";
3180 private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3181 private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3182 private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3183 private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3184 private static final String _FINDER_COLUMN_G_P_L_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3185 private static final String _FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3186 private static final String _FINDER_COLUMN_G_P_L_LAYOUTID_2 = "journalContentSearch.layoutId = ?";
3187 private static final String _FINDER_COLUMN_G_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3188 private static final String _FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3189 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3190 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3191 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3192 private static final String _FINDER_COLUMN_G_P_L_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3193 private static final String _FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3194 private static final String _FINDER_COLUMN_G_P_L_P_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
3195 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_1 = "journalContentSearch.portletId IS NULL";
3196 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_2 = "journalContentSearch.portletId = ?";
3197 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?)";
3198 private static final String _FINDER_COLUMN_G_P_L_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3199 private static final String _FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3200 private static final String _FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
3201 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_1 = "journalContentSearch.portletId IS NULL AND ";
3202 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_2 = "journalContentSearch.portletId = ? AND ";
3203 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?) AND ";
3204 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3205 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3206 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3207 private static final String _ORDER_BY_ENTITY_ALIAS = "journalContentSearch.";
3208 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalContentSearch exists with the primary key ";
3209 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalContentSearch exists with the key {";
3210 private static Log _log = LogFactoryUtil.getLog(JournalContentSearchPersistenceImpl.class);
3211}