001
014
015 package com.liferay.portlet.journal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.annotation.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.Session;
027 import com.liferay.portal.kernel.exception.SystemException;
028 import com.liferay.portal.kernel.log.Log;
029 import com.liferay.portal.kernel.log.LogFactoryUtil;
030 import com.liferay.portal.kernel.util.GetterUtil;
031 import com.liferay.portal.kernel.util.InstanceFactory;
032 import com.liferay.portal.kernel.util.OrderByComparator;
033 import com.liferay.portal.kernel.util.StringBundler;
034 import com.liferay.portal.kernel.util.StringPool;
035 import com.liferay.portal.kernel.util.StringUtil;
036 import com.liferay.portal.kernel.util.Validator;
037 import com.liferay.portal.model.ModelListener;
038 import com.liferay.portal.service.persistence.BatchSessionUtil;
039 import com.liferay.portal.service.persistence.GroupPersistence;
040 import com.liferay.portal.service.persistence.LayoutPersistence;
041 import com.liferay.portal.service.persistence.PortletPreferencesPersistence;
042 import com.liferay.portal.service.persistence.ResourcePersistence;
043 import com.liferay.portal.service.persistence.UserPersistence;
044 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
045
046 import com.liferay.portlet.journal.NoSuchContentSearchException;
047 import com.liferay.portlet.journal.model.JournalContentSearch;
048 import com.liferay.portlet.journal.model.impl.JournalContentSearchImpl;
049 import com.liferay.portlet.journal.model.impl.JournalContentSearchModelImpl;
050
051 import java.io.Serializable;
052
053 import java.util.ArrayList;
054 import java.util.Collections;
055 import java.util.List;
056
057
073 public class JournalContentSearchPersistenceImpl extends BasePersistenceImpl<JournalContentSearch>
074 implements JournalContentSearchPersistence {
075 public static final String FINDER_CLASS_NAME_ENTITY = JournalContentSearchImpl.class.getName();
076 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
077 ".List";
078 public static final FinderPath FINDER_PATH_FIND_BY_ARTICLEID = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
079 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
080 FINDER_CLASS_NAME_LIST, "findByArticleId",
081 new String[] {
082 String.class.getName(),
083
084 "java.lang.Integer", "java.lang.Integer",
085 "com.liferay.portal.kernel.util.OrderByComparator"
086 });
087 public static final FinderPath FINDER_PATH_COUNT_BY_ARTICLEID = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
088 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
089 FINDER_CLASS_NAME_LIST, "countByArticleId",
090 new String[] { String.class.getName() });
091 public static final FinderPath FINDER_PATH_FIND_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
092 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
093 FINDER_CLASS_NAME_LIST, "findByG_P",
094 new String[] {
095 Long.class.getName(), Boolean.class.getName(),
096
097 "java.lang.Integer", "java.lang.Integer",
098 "com.liferay.portal.kernel.util.OrderByComparator"
099 });
100 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
101 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
102 FINDER_CLASS_NAME_LIST, "countByG_P",
103 new String[] { Long.class.getName(), Boolean.class.getName() });
104 public static final FinderPath FINDER_PATH_FIND_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
105 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
106 FINDER_CLASS_NAME_LIST, "findByG_A",
107 new String[] {
108 Long.class.getName(), String.class.getName(),
109
110 "java.lang.Integer", "java.lang.Integer",
111 "com.liferay.portal.kernel.util.OrderByComparator"
112 });
113 public static final FinderPath FINDER_PATH_COUNT_BY_G_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
114 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
115 FINDER_CLASS_NAME_LIST, "countByG_A",
116 new String[] { Long.class.getName(), String.class.getName() });
117 public static final FinderPath FINDER_PATH_FIND_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
118 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
119 FINDER_CLASS_NAME_LIST, "findByG_P_L",
120 new String[] {
121 Long.class.getName(), Boolean.class.getName(),
122 Long.class.getName(),
123
124 "java.lang.Integer", "java.lang.Integer",
125 "com.liferay.portal.kernel.util.OrderByComparator"
126 });
127 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
128 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
129 FINDER_CLASS_NAME_LIST, "countByG_P_L",
130 new String[] {
131 Long.class.getName(), Boolean.class.getName(),
132 Long.class.getName()
133 });
134 public static final FinderPath FINDER_PATH_FIND_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
135 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
136 FINDER_CLASS_NAME_LIST, "findByG_P_A",
137 new String[] {
138 Long.class.getName(), Boolean.class.getName(),
139 String.class.getName(),
140
141 "java.lang.Integer", "java.lang.Integer",
142 "com.liferay.portal.kernel.util.OrderByComparator"
143 });
144 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
145 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
146 FINDER_CLASS_NAME_LIST, "countByG_P_A",
147 new String[] {
148 Long.class.getName(), Boolean.class.getName(),
149 String.class.getName()
150 });
151 public static final FinderPath FINDER_PATH_FIND_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
152 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
153 FINDER_CLASS_NAME_LIST, "findByG_P_L_P",
154 new String[] {
155 Long.class.getName(), Boolean.class.getName(),
156 Long.class.getName(), String.class.getName(),
157
158 "java.lang.Integer", "java.lang.Integer",
159 "com.liferay.portal.kernel.util.OrderByComparator"
160 });
161 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
162 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
163 FINDER_CLASS_NAME_LIST, "countByG_P_L_P",
164 new String[] {
165 Long.class.getName(), Boolean.class.getName(),
166 Long.class.getName(), String.class.getName()
167 });
168 public static final FinderPath FINDER_PATH_FETCH_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
169 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
170 FINDER_CLASS_NAME_ENTITY, "fetchByG_P_L_P_A",
171 new String[] {
172 Long.class.getName(), Boolean.class.getName(),
173 Long.class.getName(), String.class.getName(),
174 String.class.getName()
175 });
176 public static final FinderPath FINDER_PATH_COUNT_BY_G_P_L_P_A = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
177 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
178 FINDER_CLASS_NAME_LIST, "countByG_P_L_P_A",
179 new String[] {
180 Long.class.getName(), Boolean.class.getName(),
181 Long.class.getName(), String.class.getName(),
182 String.class.getName()
183 });
184 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
185 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
186 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
187 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
188 JournalContentSearchModelImpl.FINDER_CACHE_ENABLED,
189 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
190
191
196 public void cacheResult(JournalContentSearch journalContentSearch) {
197 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
198 JournalContentSearchImpl.class,
199 journalContentSearch.getPrimaryKey(), journalContentSearch);
200
201 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
202 new Object[] {
203 new Long(journalContentSearch.getGroupId()),
204 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
205 new Long(journalContentSearch.getLayoutId()),
206
207 journalContentSearch.getPortletId(),
208
209 journalContentSearch.getArticleId()
210 }, journalContentSearch);
211 }
212
213
218 public void cacheResult(List<JournalContentSearch> journalContentSearchs) {
219 for (JournalContentSearch journalContentSearch : journalContentSearchs) {
220 if (EntityCacheUtil.getResult(
221 JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
222 JournalContentSearchImpl.class,
223 journalContentSearch.getPrimaryKey(), this) == null) {
224 cacheResult(journalContentSearch);
225 }
226 }
227 }
228
229
236 public void clearCache() {
237 CacheRegistryUtil.clear(JournalContentSearchImpl.class.getName());
238 EntityCacheUtil.clearCache(JournalContentSearchImpl.class.getName());
239 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
240 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
241 }
242
243
250 public void clearCache(JournalContentSearch journalContentSearch) {
251 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
252 JournalContentSearchImpl.class, journalContentSearch.getPrimaryKey());
253
254 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
255 new Object[] {
256 new Long(journalContentSearch.getGroupId()),
257 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
258 new Long(journalContentSearch.getLayoutId()),
259
260 journalContentSearch.getPortletId(),
261
262 journalContentSearch.getArticleId()
263 });
264 }
265
266
272 public JournalContentSearch create(long contentSearchId) {
273 JournalContentSearch journalContentSearch = new JournalContentSearchImpl();
274
275 journalContentSearch.setNew(true);
276 journalContentSearch.setPrimaryKey(contentSearchId);
277
278 return journalContentSearch;
279 }
280
281
289 public JournalContentSearch remove(Serializable primaryKey)
290 throws NoSuchModelException, SystemException {
291 return remove(((Long)primaryKey).longValue());
292 }
293
294
302 public JournalContentSearch remove(long contentSearchId)
303 throws NoSuchContentSearchException, SystemException {
304 Session session = null;
305
306 try {
307 session = openSession();
308
309 JournalContentSearch journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
310 new Long(contentSearchId));
311
312 if (journalContentSearch == null) {
313 if (_log.isWarnEnabled()) {
314 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
315 contentSearchId);
316 }
317
318 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
319 contentSearchId);
320 }
321
322 return remove(journalContentSearch);
323 }
324 catch (NoSuchContentSearchException nsee) {
325 throw nsee;
326 }
327 catch (Exception e) {
328 throw processException(e);
329 }
330 finally {
331 closeSession(session);
332 }
333 }
334
335 protected JournalContentSearch removeImpl(
336 JournalContentSearch journalContentSearch) throws SystemException {
337 journalContentSearch = toUnwrappedModel(journalContentSearch);
338
339 Session session = null;
340
341 try {
342 session = openSession();
343
344 if (journalContentSearch.isCachedModel() ||
345 BatchSessionUtil.isEnabled()) {
346 Object staleObject = session.get(JournalContentSearchImpl.class,
347 journalContentSearch.getPrimaryKeyObj());
348
349 if (staleObject != null) {
350 session.evict(staleObject);
351 }
352 }
353
354 session.delete(journalContentSearch);
355
356 session.flush();
357 }
358 catch (Exception e) {
359 throw processException(e);
360 }
361 finally {
362 closeSession(session);
363 }
364
365 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
366
367 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
368
369 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
370 new Object[] {
371 new Long(journalContentSearchModelImpl.getOriginalGroupId()),
372 Boolean.valueOf(
373 journalContentSearchModelImpl.getOriginalPrivateLayout()),
374 new Long(journalContentSearchModelImpl.getOriginalLayoutId()),
375
376 journalContentSearchModelImpl.getOriginalPortletId(),
377
378 journalContentSearchModelImpl.getOriginalArticleId()
379 });
380
381 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
382 JournalContentSearchImpl.class, journalContentSearch.getPrimaryKey());
383
384 return journalContentSearch;
385 }
386
387 public JournalContentSearch updateImpl(
388 com.liferay.portlet.journal.model.JournalContentSearch journalContentSearch,
389 boolean merge) throws SystemException {
390 journalContentSearch = toUnwrappedModel(journalContentSearch);
391
392 boolean isNew = journalContentSearch.isNew();
393
394 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
395
396 Session session = null;
397
398 try {
399 session = openSession();
400
401 BatchSessionUtil.update(session, journalContentSearch, merge);
402
403 journalContentSearch.setNew(false);
404 }
405 catch (Exception e) {
406 throw processException(e);
407 }
408 finally {
409 closeSession(session);
410 }
411
412 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
413
414 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
415 JournalContentSearchImpl.class,
416 journalContentSearch.getPrimaryKey(), journalContentSearch);
417
418 if (!isNew &&
419 ((journalContentSearch.getGroupId() != journalContentSearchModelImpl.getOriginalGroupId()) ||
420 (journalContentSearch.getPrivateLayout() != journalContentSearchModelImpl.getOriginalPrivateLayout()) ||
421 (journalContentSearch.getLayoutId() != journalContentSearchModelImpl.getOriginalLayoutId()) ||
422 !Validator.equals(journalContentSearch.getPortletId(),
423 journalContentSearchModelImpl.getOriginalPortletId()) ||
424 !Validator.equals(journalContentSearch.getArticleId(),
425 journalContentSearchModelImpl.getOriginalArticleId()))) {
426 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
427 new Object[] {
428 new Long(journalContentSearchModelImpl.getOriginalGroupId()),
429 Boolean.valueOf(
430 journalContentSearchModelImpl.getOriginalPrivateLayout()),
431 new Long(journalContentSearchModelImpl.getOriginalLayoutId()),
432
433 journalContentSearchModelImpl.getOriginalPortletId(),
434
435 journalContentSearchModelImpl.getOriginalArticleId()
436 });
437 }
438
439 if (isNew ||
440 ((journalContentSearch.getGroupId() != journalContentSearchModelImpl.getOriginalGroupId()) ||
441 (journalContentSearch.getPrivateLayout() != journalContentSearchModelImpl.getOriginalPrivateLayout()) ||
442 (journalContentSearch.getLayoutId() != journalContentSearchModelImpl.getOriginalLayoutId()) ||
443 !Validator.equals(journalContentSearch.getPortletId(),
444 journalContentSearchModelImpl.getOriginalPortletId()) ||
445 !Validator.equals(journalContentSearch.getArticleId(),
446 journalContentSearchModelImpl.getOriginalArticleId()))) {
447 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
448 new Object[] {
449 new Long(journalContentSearch.getGroupId()),
450 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
451 new Long(journalContentSearch.getLayoutId()),
452
453 journalContentSearch.getPortletId(),
454
455 journalContentSearch.getArticleId()
456 }, journalContentSearch);
457 }
458
459 return journalContentSearch;
460 }
461
462 protected JournalContentSearch toUnwrappedModel(
463 JournalContentSearch journalContentSearch) {
464 if (journalContentSearch instanceof JournalContentSearchImpl) {
465 return journalContentSearch;
466 }
467
468 JournalContentSearchImpl journalContentSearchImpl = new JournalContentSearchImpl();
469
470 journalContentSearchImpl.setNew(journalContentSearch.isNew());
471 journalContentSearchImpl.setPrimaryKey(journalContentSearch.getPrimaryKey());
472
473 journalContentSearchImpl.setContentSearchId(journalContentSearch.getContentSearchId());
474 journalContentSearchImpl.setGroupId(journalContentSearch.getGroupId());
475 journalContentSearchImpl.setCompanyId(journalContentSearch.getCompanyId());
476 journalContentSearchImpl.setPrivateLayout(journalContentSearch.isPrivateLayout());
477 journalContentSearchImpl.setLayoutId(journalContentSearch.getLayoutId());
478 journalContentSearchImpl.setPortletId(journalContentSearch.getPortletId());
479 journalContentSearchImpl.setArticleId(journalContentSearch.getArticleId());
480
481 return journalContentSearchImpl;
482 }
483
484
492 public JournalContentSearch findByPrimaryKey(Serializable primaryKey)
493 throws NoSuchModelException, SystemException {
494 return findByPrimaryKey(((Long)primaryKey).longValue());
495 }
496
497
505 public JournalContentSearch findByPrimaryKey(long contentSearchId)
506 throws NoSuchContentSearchException, SystemException {
507 JournalContentSearch journalContentSearch = fetchByPrimaryKey(contentSearchId);
508
509 if (journalContentSearch == null) {
510 if (_log.isWarnEnabled()) {
511 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + contentSearchId);
512 }
513
514 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
515 contentSearchId);
516 }
517
518 return journalContentSearch;
519 }
520
521
528 public JournalContentSearch fetchByPrimaryKey(Serializable primaryKey)
529 throws SystemException {
530 return fetchByPrimaryKey(((Long)primaryKey).longValue());
531 }
532
533
540 public JournalContentSearch fetchByPrimaryKey(long contentSearchId)
541 throws SystemException {
542 JournalContentSearch journalContentSearch = (JournalContentSearch)EntityCacheUtil.getResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
543 JournalContentSearchImpl.class, contentSearchId, this);
544
545 if (journalContentSearch == null) {
546 Session session = null;
547
548 try {
549 session = openSession();
550
551 journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
552 new Long(contentSearchId));
553 }
554 catch (Exception e) {
555 throw processException(e);
556 }
557 finally {
558 if (journalContentSearch != null) {
559 cacheResult(journalContentSearch);
560 }
561
562 closeSession(session);
563 }
564 }
565
566 return journalContentSearch;
567 }
568
569
576 public List<JournalContentSearch> findByArticleId(String articleId)
577 throws SystemException {
578 return findByArticleId(articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
579 null);
580 }
581
582
595 public List<JournalContentSearch> findByArticleId(String articleId,
596 int start, int end) throws SystemException {
597 return findByArticleId(articleId, start, end, null);
598 }
599
600
614 public List<JournalContentSearch> findByArticleId(String articleId,
615 int start, int end, OrderByComparator orderByComparator)
616 throws SystemException {
617 Object[] finderArgs = new Object[] {
618 articleId,
619
620 String.valueOf(start), String.valueOf(end),
621 String.valueOf(orderByComparator)
622 };
623
624 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ARTICLEID,
625 finderArgs, this);
626
627 if (list == null) {
628 Session session = null;
629
630 try {
631 session = openSession();
632
633 StringBundler query = null;
634
635 if (orderByComparator != null) {
636 query = new StringBundler(3 +
637 (orderByComparator.getOrderByFields().length * 3));
638 }
639 else {
640 query = new StringBundler(2);
641 }
642
643 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
644
645 if (articleId == null) {
646 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
647 }
648 else {
649 if (articleId.equals(StringPool.BLANK)) {
650 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
651 }
652 else {
653 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
654 }
655 }
656
657 if (orderByComparator != null) {
658 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
659 orderByComparator);
660 }
661
662 String sql = query.toString();
663
664 Query q = session.createQuery(sql);
665
666 QueryPos qPos = QueryPos.getInstance(q);
667
668 if (articleId != null) {
669 qPos.add(articleId);
670 }
671
672 list = (List<JournalContentSearch>)QueryUtil.list(q,
673 getDialect(), start, end);
674 }
675 catch (Exception e) {
676 throw processException(e);
677 }
678 finally {
679 if (list == null) {
680 list = new ArrayList<JournalContentSearch>();
681 }
682
683 cacheResult(list);
684
685 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ARTICLEID,
686 finderArgs, list);
687
688 closeSession(session);
689 }
690 }
691
692 return list;
693 }
694
695
708 public JournalContentSearch findByArticleId_First(String articleId,
709 OrderByComparator orderByComparator)
710 throws NoSuchContentSearchException, SystemException {
711 List<JournalContentSearch> list = findByArticleId(articleId, 0, 1,
712 orderByComparator);
713
714 if (list.isEmpty()) {
715 StringBundler msg = new StringBundler(4);
716
717 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
718
719 msg.append("articleId=");
720 msg.append(articleId);
721
722 msg.append(StringPool.CLOSE_CURLY_BRACE);
723
724 throw new NoSuchContentSearchException(msg.toString());
725 }
726 else {
727 return list.get(0);
728 }
729 }
730
731
744 public JournalContentSearch findByArticleId_Last(String articleId,
745 OrderByComparator orderByComparator)
746 throws NoSuchContentSearchException, SystemException {
747 int count = countByArticleId(articleId);
748
749 List<JournalContentSearch> list = findByArticleId(articleId, count - 1,
750 count, orderByComparator);
751
752 if (list.isEmpty()) {
753 StringBundler msg = new StringBundler(4);
754
755 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
756
757 msg.append("articleId=");
758 msg.append(articleId);
759
760 msg.append(StringPool.CLOSE_CURLY_BRACE);
761
762 throw new NoSuchContentSearchException(msg.toString());
763 }
764 else {
765 return list.get(0);
766 }
767 }
768
769
783 public JournalContentSearch[] findByArticleId_PrevAndNext(
784 long contentSearchId, String articleId,
785 OrderByComparator orderByComparator)
786 throws NoSuchContentSearchException, SystemException {
787 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
788
789 Session session = null;
790
791 try {
792 session = openSession();
793
794 JournalContentSearch[] array = new JournalContentSearchImpl[3];
795
796 array[0] = getByArticleId_PrevAndNext(session,
797 journalContentSearch, articleId, orderByComparator, true);
798
799 array[1] = journalContentSearch;
800
801 array[2] = getByArticleId_PrevAndNext(session,
802 journalContentSearch, articleId, orderByComparator, false);
803
804 return array;
805 }
806 catch (Exception e) {
807 throw processException(e);
808 }
809 finally {
810 closeSession(session);
811 }
812 }
813
814 protected JournalContentSearch getByArticleId_PrevAndNext(Session session,
815 JournalContentSearch journalContentSearch, String articleId,
816 OrderByComparator orderByComparator, boolean previous) {
817 StringBundler query = null;
818
819 if (orderByComparator != null) {
820 query = new StringBundler(6 +
821 (orderByComparator.getOrderByFields().length * 6));
822 }
823 else {
824 query = new StringBundler(3);
825 }
826
827 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
828
829 if (articleId == null) {
830 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
831 }
832 else {
833 if (articleId.equals(StringPool.BLANK)) {
834 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
835 }
836 else {
837 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
838 }
839 }
840
841 if (orderByComparator != null) {
842 String[] orderByFields = orderByComparator.getOrderByFields();
843
844 if (orderByFields.length > 0) {
845 query.append(WHERE_AND);
846 }
847
848 for (int i = 0; i < orderByFields.length; i++) {
849 query.append(_ORDER_BY_ENTITY_ALIAS);
850 query.append(orderByFields[i]);
851
852 if ((i + 1) < orderByFields.length) {
853 if (orderByComparator.isAscending() ^ previous) {
854 query.append(WHERE_GREATER_THAN_HAS_NEXT);
855 }
856 else {
857 query.append(WHERE_LESSER_THAN_HAS_NEXT);
858 }
859 }
860 else {
861 if (orderByComparator.isAscending() ^ previous) {
862 query.append(WHERE_GREATER_THAN);
863 }
864 else {
865 query.append(WHERE_LESSER_THAN);
866 }
867 }
868 }
869
870 query.append(ORDER_BY_CLAUSE);
871
872 for (int i = 0; i < orderByFields.length; i++) {
873 query.append(_ORDER_BY_ENTITY_ALIAS);
874 query.append(orderByFields[i]);
875
876 if ((i + 1) < orderByFields.length) {
877 if (orderByComparator.isAscending() ^ previous) {
878 query.append(ORDER_BY_ASC_HAS_NEXT);
879 }
880 else {
881 query.append(ORDER_BY_DESC_HAS_NEXT);
882 }
883 }
884 else {
885 if (orderByComparator.isAscending() ^ previous) {
886 query.append(ORDER_BY_ASC);
887 }
888 else {
889 query.append(ORDER_BY_DESC);
890 }
891 }
892 }
893 }
894
895 String sql = query.toString();
896
897 Query q = session.createQuery(sql);
898
899 q.setFirstResult(0);
900 q.setMaxResults(2);
901
902 QueryPos qPos = QueryPos.getInstance(q);
903
904 if (articleId != null) {
905 qPos.add(articleId);
906 }
907
908 if (orderByComparator != null) {
909 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
910
911 for (Object value : values) {
912 qPos.add(value);
913 }
914 }
915
916 List<JournalContentSearch> list = q.list();
917
918 if (list.size() == 2) {
919 return list.get(1);
920 }
921 else {
922 return null;
923 }
924 }
925
926
934 public List<JournalContentSearch> findByG_P(long groupId,
935 boolean privateLayout) throws SystemException {
936 return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
937 QueryUtil.ALL_POS, null);
938 }
939
940
954 public List<JournalContentSearch> findByG_P(long groupId,
955 boolean privateLayout, int start, int end) throws SystemException {
956 return findByG_P(groupId, privateLayout, start, end, null);
957 }
958
959
974 public List<JournalContentSearch> findByG_P(long groupId,
975 boolean privateLayout, int start, int end,
976 OrderByComparator orderByComparator) throws SystemException {
977 Object[] finderArgs = new Object[] {
978 groupId, privateLayout,
979
980 String.valueOf(start), String.valueOf(end),
981 String.valueOf(orderByComparator)
982 };
983
984 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P,
985 finderArgs, this);
986
987 if (list == null) {
988 Session session = null;
989
990 try {
991 session = openSession();
992
993 StringBundler query = null;
994
995 if (orderByComparator != null) {
996 query = new StringBundler(4 +
997 (orderByComparator.getOrderByFields().length * 3));
998 }
999 else {
1000 query = new StringBundler(3);
1001 }
1002
1003 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1004
1005 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1006
1007 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1008
1009 if (orderByComparator != null) {
1010 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1011 orderByComparator);
1012 }
1013
1014 String sql = query.toString();
1015
1016 Query q = session.createQuery(sql);
1017
1018 QueryPos qPos = QueryPos.getInstance(q);
1019
1020 qPos.add(groupId);
1021
1022 qPos.add(privateLayout);
1023
1024 list = (List<JournalContentSearch>)QueryUtil.list(q,
1025 getDialect(), start, end);
1026 }
1027 catch (Exception e) {
1028 throw processException(e);
1029 }
1030 finally {
1031 if (list == null) {
1032 list = new ArrayList<JournalContentSearch>();
1033 }
1034
1035 cacheResult(list);
1036
1037 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P, finderArgs,
1038 list);
1039
1040 closeSession(session);
1041 }
1042 }
1043
1044 return list;
1045 }
1046
1047
1061 public JournalContentSearch findByG_P_First(long groupId,
1062 boolean privateLayout, OrderByComparator orderByComparator)
1063 throws NoSuchContentSearchException, SystemException {
1064 List<JournalContentSearch> list = findByG_P(groupId, privateLayout, 0,
1065 1, orderByComparator);
1066
1067 if (list.isEmpty()) {
1068 StringBundler msg = new StringBundler(6);
1069
1070 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1071
1072 msg.append("groupId=");
1073 msg.append(groupId);
1074
1075 msg.append(", privateLayout=");
1076 msg.append(privateLayout);
1077
1078 msg.append(StringPool.CLOSE_CURLY_BRACE);
1079
1080 throw new NoSuchContentSearchException(msg.toString());
1081 }
1082 else {
1083 return list.get(0);
1084 }
1085 }
1086
1087
1101 public JournalContentSearch findByG_P_Last(long groupId,
1102 boolean privateLayout, OrderByComparator orderByComparator)
1103 throws NoSuchContentSearchException, SystemException {
1104 int count = countByG_P(groupId, privateLayout);
1105
1106 List<JournalContentSearch> list = findByG_P(groupId, privateLayout,
1107 count - 1, count, orderByComparator);
1108
1109 if (list.isEmpty()) {
1110 StringBundler msg = new StringBundler(6);
1111
1112 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1113
1114 msg.append("groupId=");
1115 msg.append(groupId);
1116
1117 msg.append(", privateLayout=");
1118 msg.append(privateLayout);
1119
1120 msg.append(StringPool.CLOSE_CURLY_BRACE);
1121
1122 throw new NoSuchContentSearchException(msg.toString());
1123 }
1124 else {
1125 return list.get(0);
1126 }
1127 }
1128
1129
1144 public JournalContentSearch[] findByG_P_PrevAndNext(long contentSearchId,
1145 long groupId, boolean privateLayout, OrderByComparator orderByComparator)
1146 throws NoSuchContentSearchException, SystemException {
1147 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1148
1149 Session session = null;
1150
1151 try {
1152 session = openSession();
1153
1154 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1155
1156 array[0] = getByG_P_PrevAndNext(session, journalContentSearch,
1157 groupId, privateLayout, orderByComparator, true);
1158
1159 array[1] = journalContentSearch;
1160
1161 array[2] = getByG_P_PrevAndNext(session, journalContentSearch,
1162 groupId, privateLayout, orderByComparator, false);
1163
1164 return array;
1165 }
1166 catch (Exception e) {
1167 throw processException(e);
1168 }
1169 finally {
1170 closeSession(session);
1171 }
1172 }
1173
1174 protected JournalContentSearch getByG_P_PrevAndNext(Session session,
1175 JournalContentSearch journalContentSearch, long groupId,
1176 boolean privateLayout, OrderByComparator orderByComparator,
1177 boolean previous) {
1178 StringBundler query = null;
1179
1180 if (orderByComparator != null) {
1181 query = new StringBundler(6 +
1182 (orderByComparator.getOrderByFields().length * 6));
1183 }
1184 else {
1185 query = new StringBundler(3);
1186 }
1187
1188 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1189
1190 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1191
1192 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1193
1194 if (orderByComparator != null) {
1195 String[] orderByFields = orderByComparator.getOrderByFields();
1196
1197 if (orderByFields.length > 0) {
1198 query.append(WHERE_AND);
1199 }
1200
1201 for (int i = 0; i < orderByFields.length; i++) {
1202 query.append(_ORDER_BY_ENTITY_ALIAS);
1203 query.append(orderByFields[i]);
1204
1205 if ((i + 1) < orderByFields.length) {
1206 if (orderByComparator.isAscending() ^ previous) {
1207 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1208 }
1209 else {
1210 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1211 }
1212 }
1213 else {
1214 if (orderByComparator.isAscending() ^ previous) {
1215 query.append(WHERE_GREATER_THAN);
1216 }
1217 else {
1218 query.append(WHERE_LESSER_THAN);
1219 }
1220 }
1221 }
1222
1223 query.append(ORDER_BY_CLAUSE);
1224
1225 for (int i = 0; i < orderByFields.length; i++) {
1226 query.append(_ORDER_BY_ENTITY_ALIAS);
1227 query.append(orderByFields[i]);
1228
1229 if ((i + 1) < orderByFields.length) {
1230 if (orderByComparator.isAscending() ^ previous) {
1231 query.append(ORDER_BY_ASC_HAS_NEXT);
1232 }
1233 else {
1234 query.append(ORDER_BY_DESC_HAS_NEXT);
1235 }
1236 }
1237 else {
1238 if (orderByComparator.isAscending() ^ previous) {
1239 query.append(ORDER_BY_ASC);
1240 }
1241 else {
1242 query.append(ORDER_BY_DESC);
1243 }
1244 }
1245 }
1246 }
1247
1248 String sql = query.toString();
1249
1250 Query q = session.createQuery(sql);
1251
1252 q.setFirstResult(0);
1253 q.setMaxResults(2);
1254
1255 QueryPos qPos = QueryPos.getInstance(q);
1256
1257 qPos.add(groupId);
1258
1259 qPos.add(privateLayout);
1260
1261 if (orderByComparator != null) {
1262 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
1263
1264 for (Object value : values) {
1265 qPos.add(value);
1266 }
1267 }
1268
1269 List<JournalContentSearch> list = q.list();
1270
1271 if (list.size() == 2) {
1272 return list.get(1);
1273 }
1274 else {
1275 return null;
1276 }
1277 }
1278
1279
1287 public List<JournalContentSearch> findByG_A(long groupId, String articleId)
1288 throws SystemException {
1289 return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
1290 QueryUtil.ALL_POS, null);
1291 }
1292
1293
1307 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1308 int start, int end) throws SystemException {
1309 return findByG_A(groupId, articleId, start, end, null);
1310 }
1311
1312
1327 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1328 int start, int end, OrderByComparator orderByComparator)
1329 throws SystemException {
1330 Object[] finderArgs = new Object[] {
1331 groupId, articleId,
1332
1333 String.valueOf(start), String.valueOf(end),
1334 String.valueOf(orderByComparator)
1335 };
1336
1337 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_A,
1338 finderArgs, this);
1339
1340 if (list == null) {
1341 Session session = null;
1342
1343 try {
1344 session = openSession();
1345
1346 StringBundler query = null;
1347
1348 if (orderByComparator != null) {
1349 query = new StringBundler(4 +
1350 (orderByComparator.getOrderByFields().length * 3));
1351 }
1352 else {
1353 query = new StringBundler(3);
1354 }
1355
1356 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1357
1358 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1359
1360 if (articleId == null) {
1361 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1362 }
1363 else {
1364 if (articleId.equals(StringPool.BLANK)) {
1365 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1366 }
1367 else {
1368 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1369 }
1370 }
1371
1372 if (orderByComparator != null) {
1373 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1374 orderByComparator);
1375 }
1376
1377 String sql = query.toString();
1378
1379 Query q = session.createQuery(sql);
1380
1381 QueryPos qPos = QueryPos.getInstance(q);
1382
1383 qPos.add(groupId);
1384
1385 if (articleId != null) {
1386 qPos.add(articleId);
1387 }
1388
1389 list = (List<JournalContentSearch>)QueryUtil.list(q,
1390 getDialect(), start, end);
1391 }
1392 catch (Exception e) {
1393 throw processException(e);
1394 }
1395 finally {
1396 if (list == null) {
1397 list = new ArrayList<JournalContentSearch>();
1398 }
1399
1400 cacheResult(list);
1401
1402 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_A, finderArgs,
1403 list);
1404
1405 closeSession(session);
1406 }
1407 }
1408
1409 return list;
1410 }
1411
1412
1426 public JournalContentSearch findByG_A_First(long groupId, String articleId,
1427 OrderByComparator orderByComparator)
1428 throws NoSuchContentSearchException, SystemException {
1429 List<JournalContentSearch> list = findByG_A(groupId, articleId, 0, 1,
1430 orderByComparator);
1431
1432 if (list.isEmpty()) {
1433 StringBundler msg = new StringBundler(6);
1434
1435 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1436
1437 msg.append("groupId=");
1438 msg.append(groupId);
1439
1440 msg.append(", articleId=");
1441 msg.append(articleId);
1442
1443 msg.append(StringPool.CLOSE_CURLY_BRACE);
1444
1445 throw new NoSuchContentSearchException(msg.toString());
1446 }
1447 else {
1448 return list.get(0);
1449 }
1450 }
1451
1452
1466 public JournalContentSearch findByG_A_Last(long groupId, String articleId,
1467 OrderByComparator orderByComparator)
1468 throws NoSuchContentSearchException, SystemException {
1469 int count = countByG_A(groupId, articleId);
1470
1471 List<JournalContentSearch> list = findByG_A(groupId, articleId,
1472 count - 1, count, orderByComparator);
1473
1474 if (list.isEmpty()) {
1475 StringBundler msg = new StringBundler(6);
1476
1477 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1478
1479 msg.append("groupId=");
1480 msg.append(groupId);
1481
1482 msg.append(", articleId=");
1483 msg.append(articleId);
1484
1485 msg.append(StringPool.CLOSE_CURLY_BRACE);
1486
1487 throw new NoSuchContentSearchException(msg.toString());
1488 }
1489 else {
1490 return list.get(0);
1491 }
1492 }
1493
1494
1509 public JournalContentSearch[] findByG_A_PrevAndNext(long contentSearchId,
1510 long groupId, String articleId, OrderByComparator orderByComparator)
1511 throws NoSuchContentSearchException, SystemException {
1512 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1513
1514 Session session = null;
1515
1516 try {
1517 session = openSession();
1518
1519 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1520
1521 array[0] = getByG_A_PrevAndNext(session, journalContentSearch,
1522 groupId, articleId, orderByComparator, true);
1523
1524 array[1] = journalContentSearch;
1525
1526 array[2] = getByG_A_PrevAndNext(session, journalContentSearch,
1527 groupId, articleId, orderByComparator, false);
1528
1529 return array;
1530 }
1531 catch (Exception e) {
1532 throw processException(e);
1533 }
1534 finally {
1535 closeSession(session);
1536 }
1537 }
1538
1539 protected JournalContentSearch getByG_A_PrevAndNext(Session session,
1540 JournalContentSearch journalContentSearch, long groupId,
1541 String articleId, OrderByComparator orderByComparator, boolean previous) {
1542 StringBundler query = null;
1543
1544 if (orderByComparator != null) {
1545 query = new StringBundler(6 +
1546 (orderByComparator.getOrderByFields().length * 6));
1547 }
1548 else {
1549 query = new StringBundler(3);
1550 }
1551
1552 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1553
1554 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1555
1556 if (articleId == null) {
1557 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1558 }
1559 else {
1560 if (articleId.equals(StringPool.BLANK)) {
1561 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1562 }
1563 else {
1564 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1565 }
1566 }
1567
1568 if (orderByComparator != null) {
1569 String[] orderByFields = orderByComparator.getOrderByFields();
1570
1571 if (orderByFields.length > 0) {
1572 query.append(WHERE_AND);
1573 }
1574
1575 for (int i = 0; i < orderByFields.length; i++) {
1576 query.append(_ORDER_BY_ENTITY_ALIAS);
1577 query.append(orderByFields[i]);
1578
1579 if ((i + 1) < orderByFields.length) {
1580 if (orderByComparator.isAscending() ^ previous) {
1581 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1582 }
1583 else {
1584 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1585 }
1586 }
1587 else {
1588 if (orderByComparator.isAscending() ^ previous) {
1589 query.append(WHERE_GREATER_THAN);
1590 }
1591 else {
1592 query.append(WHERE_LESSER_THAN);
1593 }
1594 }
1595 }
1596
1597 query.append(ORDER_BY_CLAUSE);
1598
1599 for (int i = 0; i < orderByFields.length; i++) {
1600 query.append(_ORDER_BY_ENTITY_ALIAS);
1601 query.append(orderByFields[i]);
1602
1603 if ((i + 1) < orderByFields.length) {
1604 if (orderByComparator.isAscending() ^ previous) {
1605 query.append(ORDER_BY_ASC_HAS_NEXT);
1606 }
1607 else {
1608 query.append(ORDER_BY_DESC_HAS_NEXT);
1609 }
1610 }
1611 else {
1612 if (orderByComparator.isAscending() ^ previous) {
1613 query.append(ORDER_BY_ASC);
1614 }
1615 else {
1616 query.append(ORDER_BY_DESC);
1617 }
1618 }
1619 }
1620 }
1621
1622 String sql = query.toString();
1623
1624 Query q = session.createQuery(sql);
1625
1626 q.setFirstResult(0);
1627 q.setMaxResults(2);
1628
1629 QueryPos qPos = QueryPos.getInstance(q);
1630
1631 qPos.add(groupId);
1632
1633 if (articleId != null) {
1634 qPos.add(articleId);
1635 }
1636
1637 if (orderByComparator != null) {
1638 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
1639
1640 for (Object value : values) {
1641 qPos.add(value);
1642 }
1643 }
1644
1645 List<JournalContentSearch> list = q.list();
1646
1647 if (list.size() == 2) {
1648 return list.get(1);
1649 }
1650 else {
1651 return null;
1652 }
1653 }
1654
1655
1664 public List<JournalContentSearch> findByG_P_L(long groupId,
1665 boolean privateLayout, long layoutId) throws SystemException {
1666 return findByG_P_L(groupId, privateLayout, layoutId, QueryUtil.ALL_POS,
1667 QueryUtil.ALL_POS, null);
1668 }
1669
1670
1685 public List<JournalContentSearch> findByG_P_L(long groupId,
1686 boolean privateLayout, long layoutId, int start, int end)
1687 throws SystemException {
1688 return findByG_P_L(groupId, privateLayout, layoutId, start, end, null);
1689 }
1690
1691
1707 public List<JournalContentSearch> findByG_P_L(long groupId,
1708 boolean privateLayout, long layoutId, int start, int end,
1709 OrderByComparator orderByComparator) throws SystemException {
1710 Object[] finderArgs = new Object[] {
1711 groupId, privateLayout, layoutId,
1712
1713 String.valueOf(start), String.valueOf(end),
1714 String.valueOf(orderByComparator)
1715 };
1716
1717 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_L,
1718 finderArgs, this);
1719
1720 if (list == null) {
1721 Session session = null;
1722
1723 try {
1724 session = openSession();
1725
1726 StringBundler query = null;
1727
1728 if (orderByComparator != null) {
1729 query = new StringBundler(5 +
1730 (orderByComparator.getOrderByFields().length * 3));
1731 }
1732 else {
1733 query = new StringBundler(4);
1734 }
1735
1736 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1737
1738 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
1739
1740 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
1741
1742 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
1743
1744 if (orderByComparator != null) {
1745 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1746 orderByComparator);
1747 }
1748
1749 String sql = query.toString();
1750
1751 Query q = session.createQuery(sql);
1752
1753 QueryPos qPos = QueryPos.getInstance(q);
1754
1755 qPos.add(groupId);
1756
1757 qPos.add(privateLayout);
1758
1759 qPos.add(layoutId);
1760
1761 list = (List<JournalContentSearch>)QueryUtil.list(q,
1762 getDialect(), start, end);
1763 }
1764 catch (Exception e) {
1765 throw processException(e);
1766 }
1767 finally {
1768 if (list == null) {
1769 list = new ArrayList<JournalContentSearch>();
1770 }
1771
1772 cacheResult(list);
1773
1774 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_L,
1775 finderArgs, list);
1776
1777 closeSession(session);
1778 }
1779 }
1780
1781 return list;
1782 }
1783
1784
1799 public JournalContentSearch findByG_P_L_First(long groupId,
1800 boolean privateLayout, long layoutId,
1801 OrderByComparator orderByComparator)
1802 throws NoSuchContentSearchException, SystemException {
1803 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
1804 layoutId, 0, 1, orderByComparator);
1805
1806 if (list.isEmpty()) {
1807 StringBundler msg = new StringBundler(8);
1808
1809 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1810
1811 msg.append("groupId=");
1812 msg.append(groupId);
1813
1814 msg.append(", privateLayout=");
1815 msg.append(privateLayout);
1816
1817 msg.append(", layoutId=");
1818 msg.append(layoutId);
1819
1820 msg.append(StringPool.CLOSE_CURLY_BRACE);
1821
1822 throw new NoSuchContentSearchException(msg.toString());
1823 }
1824 else {
1825 return list.get(0);
1826 }
1827 }
1828
1829
1844 public JournalContentSearch findByG_P_L_Last(long groupId,
1845 boolean privateLayout, long layoutId,
1846 OrderByComparator orderByComparator)
1847 throws NoSuchContentSearchException, SystemException {
1848 int count = countByG_P_L(groupId, privateLayout, layoutId);
1849
1850 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
1851 layoutId, count - 1, count, orderByComparator);
1852
1853 if (list.isEmpty()) {
1854 StringBundler msg = new StringBundler(8);
1855
1856 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1857
1858 msg.append("groupId=");
1859 msg.append(groupId);
1860
1861 msg.append(", privateLayout=");
1862 msg.append(privateLayout);
1863
1864 msg.append(", layoutId=");
1865 msg.append(layoutId);
1866
1867 msg.append(StringPool.CLOSE_CURLY_BRACE);
1868
1869 throw new NoSuchContentSearchException(msg.toString());
1870 }
1871 else {
1872 return list.get(0);
1873 }
1874 }
1875
1876
1892 public JournalContentSearch[] findByG_P_L_PrevAndNext(
1893 long contentSearchId, long groupId, boolean privateLayout,
1894 long layoutId, OrderByComparator orderByComparator)
1895 throws NoSuchContentSearchException, SystemException {
1896 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1897
1898 Session session = null;
1899
1900 try {
1901 session = openSession();
1902
1903 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1904
1905 array[0] = getByG_P_L_PrevAndNext(session, journalContentSearch,
1906 groupId, privateLayout, layoutId, orderByComparator, true);
1907
1908 array[1] = journalContentSearch;
1909
1910 array[2] = getByG_P_L_PrevAndNext(session, journalContentSearch,
1911 groupId, privateLayout, layoutId, orderByComparator, false);
1912
1913 return array;
1914 }
1915 catch (Exception e) {
1916 throw processException(e);
1917 }
1918 finally {
1919 closeSession(session);
1920 }
1921 }
1922
1923 protected JournalContentSearch getByG_P_L_PrevAndNext(Session session,
1924 JournalContentSearch journalContentSearch, long groupId,
1925 boolean privateLayout, long layoutId,
1926 OrderByComparator orderByComparator, boolean previous) {
1927 StringBundler query = null;
1928
1929 if (orderByComparator != null) {
1930 query = new StringBundler(6 +
1931 (orderByComparator.getOrderByFields().length * 6));
1932 }
1933 else {
1934 query = new StringBundler(3);
1935 }
1936
1937 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1938
1939 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
1940
1941 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
1942
1943 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
1944
1945 if (orderByComparator != null) {
1946 String[] orderByFields = orderByComparator.getOrderByFields();
1947
1948 if (orderByFields.length > 0) {
1949 query.append(WHERE_AND);
1950 }
1951
1952 for (int i = 0; i < orderByFields.length; i++) {
1953 query.append(_ORDER_BY_ENTITY_ALIAS);
1954 query.append(orderByFields[i]);
1955
1956 if ((i + 1) < orderByFields.length) {
1957 if (orderByComparator.isAscending() ^ previous) {
1958 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1959 }
1960 else {
1961 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1962 }
1963 }
1964 else {
1965 if (orderByComparator.isAscending() ^ previous) {
1966 query.append(WHERE_GREATER_THAN);
1967 }
1968 else {
1969 query.append(WHERE_LESSER_THAN);
1970 }
1971 }
1972 }
1973
1974 query.append(ORDER_BY_CLAUSE);
1975
1976 for (int i = 0; i < orderByFields.length; i++) {
1977 query.append(_ORDER_BY_ENTITY_ALIAS);
1978 query.append(orderByFields[i]);
1979
1980 if ((i + 1) < orderByFields.length) {
1981 if (orderByComparator.isAscending() ^ previous) {
1982 query.append(ORDER_BY_ASC_HAS_NEXT);
1983 }
1984 else {
1985 query.append(ORDER_BY_DESC_HAS_NEXT);
1986 }
1987 }
1988 else {
1989 if (orderByComparator.isAscending() ^ previous) {
1990 query.append(ORDER_BY_ASC);
1991 }
1992 else {
1993 query.append(ORDER_BY_DESC);
1994 }
1995 }
1996 }
1997 }
1998
1999 String sql = query.toString();
2000
2001 Query q = session.createQuery(sql);
2002
2003 q.setFirstResult(0);
2004 q.setMaxResults(2);
2005
2006 QueryPos qPos = QueryPos.getInstance(q);
2007
2008 qPos.add(groupId);
2009
2010 qPos.add(privateLayout);
2011
2012 qPos.add(layoutId);
2013
2014 if (orderByComparator != null) {
2015 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
2016
2017 for (Object value : values) {
2018 qPos.add(value);
2019 }
2020 }
2021
2022 List<JournalContentSearch> list = q.list();
2023
2024 if (list.size() == 2) {
2025 return list.get(1);
2026 }
2027 else {
2028 return null;
2029 }
2030 }
2031
2032
2041 public List<JournalContentSearch> findByG_P_A(long groupId,
2042 boolean privateLayout, String articleId) throws SystemException {
2043 return findByG_P_A(groupId, privateLayout, articleId,
2044 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2045 }
2046
2047
2062 public List<JournalContentSearch> findByG_P_A(long groupId,
2063 boolean privateLayout, String articleId, int start, int end)
2064 throws SystemException {
2065 return findByG_P_A(groupId, privateLayout, articleId, start, end, null);
2066 }
2067
2068
2084 public List<JournalContentSearch> findByG_P_A(long groupId,
2085 boolean privateLayout, String articleId, int start, int end,
2086 OrderByComparator orderByComparator) throws SystemException {
2087 Object[] finderArgs = new Object[] {
2088 groupId, privateLayout, articleId,
2089
2090 String.valueOf(start), String.valueOf(end),
2091 String.valueOf(orderByComparator)
2092 };
2093
2094 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_A,
2095 finderArgs, this);
2096
2097 if (list == null) {
2098 Session session = null;
2099
2100 try {
2101 session = openSession();
2102
2103 StringBundler query = null;
2104
2105 if (orderByComparator != null) {
2106 query = new StringBundler(5 +
2107 (orderByComparator.getOrderByFields().length * 3));
2108 }
2109 else {
2110 query = new StringBundler(4);
2111 }
2112
2113 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2114
2115 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2116
2117 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2118
2119 if (articleId == null) {
2120 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2121 }
2122 else {
2123 if (articleId.equals(StringPool.BLANK)) {
2124 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
2125 }
2126 else {
2127 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
2128 }
2129 }
2130
2131 if (orderByComparator != null) {
2132 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2133 orderByComparator);
2134 }
2135
2136 String sql = query.toString();
2137
2138 Query q = session.createQuery(sql);
2139
2140 QueryPos qPos = QueryPos.getInstance(q);
2141
2142 qPos.add(groupId);
2143
2144 qPos.add(privateLayout);
2145
2146 if (articleId != null) {
2147 qPos.add(articleId);
2148 }
2149
2150 list = (List<JournalContentSearch>)QueryUtil.list(q,
2151 getDialect(), start, end);
2152 }
2153 catch (Exception e) {
2154 throw processException(e);
2155 }
2156 finally {
2157 if (list == null) {
2158 list = new ArrayList<JournalContentSearch>();
2159 }
2160
2161 cacheResult(list);
2162
2163 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_A,
2164 finderArgs, list);
2165
2166 closeSession(session);
2167 }
2168 }
2169
2170 return list;
2171 }
2172
2173
2188 public JournalContentSearch findByG_P_A_First(long groupId,
2189 boolean privateLayout, String articleId,
2190 OrderByComparator orderByComparator)
2191 throws NoSuchContentSearchException, SystemException {
2192 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
2193 articleId, 0, 1, orderByComparator);
2194
2195 if (list.isEmpty()) {
2196 StringBundler msg = new StringBundler(8);
2197
2198 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2199
2200 msg.append("groupId=");
2201 msg.append(groupId);
2202
2203 msg.append(", privateLayout=");
2204 msg.append(privateLayout);
2205
2206 msg.append(", articleId=");
2207 msg.append(articleId);
2208
2209 msg.append(StringPool.CLOSE_CURLY_BRACE);
2210
2211 throw new NoSuchContentSearchException(msg.toString());
2212 }
2213 else {
2214 return list.get(0);
2215 }
2216 }
2217
2218
2233 public JournalContentSearch findByG_P_A_Last(long groupId,
2234 boolean privateLayout, String articleId,
2235 OrderByComparator orderByComparator)
2236 throws NoSuchContentSearchException, SystemException {
2237 int count = countByG_P_A(groupId, privateLayout, articleId);
2238
2239 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
2240 articleId, count - 1, count, orderByComparator);
2241
2242 if (list.isEmpty()) {
2243 StringBundler msg = new StringBundler(8);
2244
2245 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2246
2247 msg.append("groupId=");
2248 msg.append(groupId);
2249
2250 msg.append(", privateLayout=");
2251 msg.append(privateLayout);
2252
2253 msg.append(", articleId=");
2254 msg.append(articleId);
2255
2256 msg.append(StringPool.CLOSE_CURLY_BRACE);
2257
2258 throw new NoSuchContentSearchException(msg.toString());
2259 }
2260 else {
2261 return list.get(0);
2262 }
2263 }
2264
2265
2281 public JournalContentSearch[] findByG_P_A_PrevAndNext(
2282 long contentSearchId, long groupId, boolean privateLayout,
2283 String articleId, OrderByComparator orderByComparator)
2284 throws NoSuchContentSearchException, SystemException {
2285 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2286
2287 Session session = null;
2288
2289 try {
2290 session = openSession();
2291
2292 JournalContentSearch[] array = new JournalContentSearchImpl[3];
2293
2294 array[0] = getByG_P_A_PrevAndNext(session, journalContentSearch,
2295 groupId, privateLayout, articleId, orderByComparator, true);
2296
2297 array[1] = journalContentSearch;
2298
2299 array[2] = getByG_P_A_PrevAndNext(session, journalContentSearch,
2300 groupId, privateLayout, articleId, orderByComparator, false);
2301
2302 return array;
2303 }
2304 catch (Exception e) {
2305 throw processException(e);
2306 }
2307 finally {
2308 closeSession(session);
2309 }
2310 }
2311
2312 protected JournalContentSearch getByG_P_A_PrevAndNext(Session session,
2313 JournalContentSearch journalContentSearch, long groupId,
2314 boolean privateLayout, String articleId,
2315 OrderByComparator orderByComparator, boolean previous) {
2316 StringBundler query = null;
2317
2318 if (orderByComparator != null) {
2319 query = new StringBundler(6 +
2320 (orderByComparator.getOrderByFields().length * 6));
2321 }
2322 else {
2323 query = new StringBundler(3);
2324 }
2325
2326 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2327
2328 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2329
2330 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2331
2332 if (articleId == null) {
2333 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2334 }
2335 else {
2336 if (articleId.equals(StringPool.BLANK)) {
2337 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
2338 }
2339 else {
2340 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
2341 }
2342 }
2343
2344 if (orderByComparator != null) {
2345 String[] orderByFields = orderByComparator.getOrderByFields();
2346
2347 if (orderByFields.length > 0) {
2348 query.append(WHERE_AND);
2349 }
2350
2351 for (int i = 0; i < orderByFields.length; i++) {
2352 query.append(_ORDER_BY_ENTITY_ALIAS);
2353 query.append(orderByFields[i]);
2354
2355 if ((i + 1) < orderByFields.length) {
2356 if (orderByComparator.isAscending() ^ previous) {
2357 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2358 }
2359 else {
2360 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2361 }
2362 }
2363 else {
2364 if (orderByComparator.isAscending() ^ previous) {
2365 query.append(WHERE_GREATER_THAN);
2366 }
2367 else {
2368 query.append(WHERE_LESSER_THAN);
2369 }
2370 }
2371 }
2372
2373 query.append(ORDER_BY_CLAUSE);
2374
2375 for (int i = 0; i < orderByFields.length; i++) {
2376 query.append(_ORDER_BY_ENTITY_ALIAS);
2377 query.append(orderByFields[i]);
2378
2379 if ((i + 1) < orderByFields.length) {
2380 if (orderByComparator.isAscending() ^ previous) {
2381 query.append(ORDER_BY_ASC_HAS_NEXT);
2382 }
2383 else {
2384 query.append(ORDER_BY_DESC_HAS_NEXT);
2385 }
2386 }
2387 else {
2388 if (orderByComparator.isAscending() ^ previous) {
2389 query.append(ORDER_BY_ASC);
2390 }
2391 else {
2392 query.append(ORDER_BY_DESC);
2393 }
2394 }
2395 }
2396 }
2397
2398 String sql = query.toString();
2399
2400 Query q = session.createQuery(sql);
2401
2402 q.setFirstResult(0);
2403 q.setMaxResults(2);
2404
2405 QueryPos qPos = QueryPos.getInstance(q);
2406
2407 qPos.add(groupId);
2408
2409 qPos.add(privateLayout);
2410
2411 if (articleId != null) {
2412 qPos.add(articleId);
2413 }
2414
2415 if (orderByComparator != null) {
2416 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
2417
2418 for (Object value : values) {
2419 qPos.add(value);
2420 }
2421 }
2422
2423 List<JournalContentSearch> list = q.list();
2424
2425 if (list.size() == 2) {
2426 return list.get(1);
2427 }
2428 else {
2429 return null;
2430 }
2431 }
2432
2433
2443 public List<JournalContentSearch> findByG_P_L_P(long groupId,
2444 boolean privateLayout, long layoutId, String portletId)
2445 throws SystemException {
2446 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
2447 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2448 }
2449
2450
2466 public List<JournalContentSearch> findByG_P_L_P(long groupId,
2467 boolean privateLayout, long layoutId, String portletId, int start,
2468 int end) throws SystemException {
2469 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
2470 start, end, null);
2471 }
2472
2473
2490 public List<JournalContentSearch> findByG_P_L_P(long groupId,
2491 boolean privateLayout, long layoutId, String portletId, int start,
2492 int end, OrderByComparator orderByComparator) throws SystemException {
2493 Object[] finderArgs = new Object[] {
2494 groupId, privateLayout, layoutId, portletId,
2495
2496 String.valueOf(start), String.valueOf(end),
2497 String.valueOf(orderByComparator)
2498 };
2499
2500 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_L_P,
2501 finderArgs, this);
2502
2503 if (list == null) {
2504 Session session = null;
2505
2506 try {
2507 session = openSession();
2508
2509 StringBundler query = null;
2510
2511 if (orderByComparator != null) {
2512 query = new StringBundler(6 +
2513 (orderByComparator.getOrderByFields().length * 3));
2514 }
2515 else {
2516 query = new StringBundler(5);
2517 }
2518
2519 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2520
2521 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
2522
2523 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
2524
2525 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
2526
2527 if (portletId == null) {
2528 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
2529 }
2530 else {
2531 if (portletId.equals(StringPool.BLANK)) {
2532 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
2533 }
2534 else {
2535 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
2536 }
2537 }
2538
2539 if (orderByComparator != null) {
2540 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2541 orderByComparator);
2542 }
2543
2544 String sql = query.toString();
2545
2546 Query q = session.createQuery(sql);
2547
2548 QueryPos qPos = QueryPos.getInstance(q);
2549
2550 qPos.add(groupId);
2551
2552 qPos.add(privateLayout);
2553
2554 qPos.add(layoutId);
2555
2556 if (portletId != null) {
2557 qPos.add(portletId);
2558 }
2559
2560 list = (List<JournalContentSearch>)QueryUtil.list(q,
2561 getDialect(), start, end);
2562 }
2563 catch (Exception e) {
2564 throw processException(e);
2565 }
2566 finally {
2567 if (list == null) {
2568 list = new ArrayList<JournalContentSearch>();
2569 }
2570
2571 cacheResult(list);
2572
2573 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_L_P,
2574 finderArgs, list);
2575
2576 closeSession(session);
2577 }
2578 }
2579
2580 return list;
2581 }
2582
2583
2599 public JournalContentSearch findByG_P_L_P_First(long groupId,
2600 boolean privateLayout, long layoutId, String portletId,
2601 OrderByComparator orderByComparator)
2602 throws NoSuchContentSearchException, SystemException {
2603 List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
2604 layoutId, portletId, 0, 1, orderByComparator);
2605
2606 if (list.isEmpty()) {
2607 StringBundler msg = new StringBundler(10);
2608
2609 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2610
2611 msg.append("groupId=");
2612 msg.append(groupId);
2613
2614 msg.append(", privateLayout=");
2615 msg.append(privateLayout);
2616
2617 msg.append(", layoutId=");
2618 msg.append(layoutId);
2619
2620 msg.append(", portletId=");
2621 msg.append(portletId);
2622
2623 msg.append(StringPool.CLOSE_CURLY_BRACE);
2624
2625 throw new NoSuchContentSearchException(msg.toString());
2626 }
2627 else {
2628 return list.get(0);
2629 }
2630 }
2631
2632
2648 public JournalContentSearch findByG_P_L_P_Last(long groupId,
2649 boolean privateLayout, long layoutId, String portletId,
2650 OrderByComparator orderByComparator)
2651 throws NoSuchContentSearchException, SystemException {
2652 int count = countByG_P_L_P(groupId, privateLayout, layoutId, portletId);
2653
2654 List<JournalContentSearch> list = findByG_P_L_P(groupId, privateLayout,
2655 layoutId, portletId, count - 1, count, orderByComparator);
2656
2657 if (list.isEmpty()) {
2658 StringBundler msg = new StringBundler(10);
2659
2660 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2661
2662 msg.append("groupId=");
2663 msg.append(groupId);
2664
2665 msg.append(", privateLayout=");
2666 msg.append(privateLayout);
2667
2668 msg.append(", layoutId=");
2669 msg.append(layoutId);
2670
2671 msg.append(", portletId=");
2672 msg.append(portletId);
2673
2674 msg.append(StringPool.CLOSE_CURLY_BRACE);
2675
2676 throw new NoSuchContentSearchException(msg.toString());
2677 }
2678 else {
2679 return list.get(0);
2680 }
2681 }
2682
2683
2700 public JournalContentSearch[] findByG_P_L_P_PrevAndNext(
2701 long contentSearchId, long groupId, boolean privateLayout,
2702 long layoutId, String portletId, OrderByComparator orderByComparator)
2703 throws NoSuchContentSearchException, SystemException {
2704 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2705
2706 Session session = null;
2707
2708 try {
2709 session = openSession();
2710
2711 JournalContentSearch[] array = new JournalContentSearchImpl[3];
2712
2713 array[0] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
2714 groupId, privateLayout, layoutId, portletId,
2715 orderByComparator, true);
2716
2717 array[1] = journalContentSearch;
2718
2719 array[2] = getByG_P_L_P_PrevAndNext(session, journalContentSearch,
2720 groupId, privateLayout, layoutId, portletId,
2721 orderByComparator, false);
2722
2723 return array;
2724 }
2725 catch (Exception e) {
2726 throw processException(e);
2727 }
2728 finally {
2729 closeSession(session);
2730 }
2731 }
2732
2733 protected JournalContentSearch getByG_P_L_P_PrevAndNext(Session session,
2734 JournalContentSearch journalContentSearch, long groupId,
2735 boolean privateLayout, long layoutId, String portletId,
2736 OrderByComparator orderByComparator, boolean previous) {
2737 StringBundler query = null;
2738
2739 if (orderByComparator != null) {
2740 query = new StringBundler(6 +
2741 (orderByComparator.getOrderByFields().length * 6));
2742 }
2743 else {
2744 query = new StringBundler(3);
2745 }
2746
2747 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2748
2749 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
2750
2751 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
2752
2753 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
2754
2755 if (portletId == null) {
2756 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
2757 }
2758 else {
2759 if (portletId.equals(StringPool.BLANK)) {
2760 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
2761 }
2762 else {
2763 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
2764 }
2765 }
2766
2767 if (orderByComparator != null) {
2768 String[] orderByFields = orderByComparator.getOrderByFields();
2769
2770 if (orderByFields.length > 0) {
2771 query.append(WHERE_AND);
2772 }
2773
2774 for (int i = 0; i < orderByFields.length; i++) {
2775 query.append(_ORDER_BY_ENTITY_ALIAS);
2776 query.append(orderByFields[i]);
2777
2778 if ((i + 1) < orderByFields.length) {
2779 if (orderByComparator.isAscending() ^ previous) {
2780 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2781 }
2782 else {
2783 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2784 }
2785 }
2786 else {
2787 if (orderByComparator.isAscending() ^ previous) {
2788 query.append(WHERE_GREATER_THAN);
2789 }
2790 else {
2791 query.append(WHERE_LESSER_THAN);
2792 }
2793 }
2794 }
2795
2796 query.append(ORDER_BY_CLAUSE);
2797
2798 for (int i = 0; i < orderByFields.length; i++) {
2799 query.append(_ORDER_BY_ENTITY_ALIAS);
2800 query.append(orderByFields[i]);
2801
2802 if ((i + 1) < orderByFields.length) {
2803 if (orderByComparator.isAscending() ^ previous) {
2804 query.append(ORDER_BY_ASC_HAS_NEXT);
2805 }
2806 else {
2807 query.append(ORDER_BY_DESC_HAS_NEXT);
2808 }
2809 }
2810 else {
2811 if (orderByComparator.isAscending() ^ previous) {
2812 query.append(ORDER_BY_ASC);
2813 }
2814 else {
2815 query.append(ORDER_BY_DESC);
2816 }
2817 }
2818 }
2819 }
2820
2821 String sql = query.toString();
2822
2823 Query q = session.createQuery(sql);
2824
2825 q.setFirstResult(0);
2826 q.setMaxResults(2);
2827
2828 QueryPos qPos = QueryPos.getInstance(q);
2829
2830 qPos.add(groupId);
2831
2832 qPos.add(privateLayout);
2833
2834 qPos.add(layoutId);
2835
2836 if (portletId != null) {
2837 qPos.add(portletId);
2838 }
2839
2840 if (orderByComparator != null) {
2841 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
2842
2843 for (Object value : values) {
2844 qPos.add(value);
2845 }
2846 }
2847
2848 List<JournalContentSearch> list = q.list();
2849
2850 if (list.size() == 2) {
2851 return list.get(1);
2852 }
2853 else {
2854 return null;
2855 }
2856 }
2857
2858
2870 public JournalContentSearch findByG_P_L_P_A(long groupId,
2871 boolean privateLayout, long layoutId, String portletId, String articleId)
2872 throws NoSuchContentSearchException, SystemException {
2873 JournalContentSearch journalContentSearch = fetchByG_P_L_P_A(groupId,
2874 privateLayout, layoutId, portletId, articleId);
2875
2876 if (journalContentSearch == null) {
2877 StringBundler msg = new StringBundler(12);
2878
2879 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2880
2881 msg.append("groupId=");
2882 msg.append(groupId);
2883
2884 msg.append(", privateLayout=");
2885 msg.append(privateLayout);
2886
2887 msg.append(", layoutId=");
2888 msg.append(layoutId);
2889
2890 msg.append(", portletId=");
2891 msg.append(portletId);
2892
2893 msg.append(", articleId=");
2894 msg.append(articleId);
2895
2896 msg.append(StringPool.CLOSE_CURLY_BRACE);
2897
2898 if (_log.isWarnEnabled()) {
2899 _log.warn(msg.toString());
2900 }
2901
2902 throw new NoSuchContentSearchException(msg.toString());
2903 }
2904
2905 return journalContentSearch;
2906 }
2907
2908
2919 public JournalContentSearch fetchByG_P_L_P_A(long groupId,
2920 boolean privateLayout, long layoutId, String portletId, String articleId)
2921 throws SystemException {
2922 return fetchByG_P_L_P_A(groupId, privateLayout, layoutId, portletId,
2923 articleId, true);
2924 }
2925
2926
2937 public JournalContentSearch fetchByG_P_L_P_A(long groupId,
2938 boolean privateLayout, long layoutId, String portletId,
2939 String articleId, boolean retrieveFromCache) throws SystemException {
2940 Object[] finderArgs = new Object[] {
2941 groupId, privateLayout, layoutId, portletId, articleId
2942 };
2943
2944 Object result = null;
2945
2946 if (retrieveFromCache) {
2947 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
2948 finderArgs, this);
2949 }
2950
2951 if (result == null) {
2952 Session session = null;
2953
2954 try {
2955 session = openSession();
2956
2957 StringBundler query = new StringBundler(6);
2958
2959 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2960
2961 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
2962
2963 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
2964
2965 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
2966
2967 if (portletId == null) {
2968 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
2969 }
2970 else {
2971 if (portletId.equals(StringPool.BLANK)) {
2972 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
2973 }
2974 else {
2975 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
2976 }
2977 }
2978
2979 if (articleId == null) {
2980 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
2981 }
2982 else {
2983 if (articleId.equals(StringPool.BLANK)) {
2984 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
2985 }
2986 else {
2987 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
2988 }
2989 }
2990
2991 String sql = query.toString();
2992
2993 Query q = session.createQuery(sql);
2994
2995 QueryPos qPos = QueryPos.getInstance(q);
2996
2997 qPos.add(groupId);
2998
2999 qPos.add(privateLayout);
3000
3001 qPos.add(layoutId);
3002
3003 if (portletId != null) {
3004 qPos.add(portletId);
3005 }
3006
3007 if (articleId != null) {
3008 qPos.add(articleId);
3009 }
3010
3011 List<JournalContentSearch> list = q.list();
3012
3013 result = list;
3014
3015 JournalContentSearch journalContentSearch = null;
3016
3017 if (list.isEmpty()) {
3018 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3019 finderArgs, list);
3020 }
3021 else {
3022 journalContentSearch = list.get(0);
3023
3024 cacheResult(journalContentSearch);
3025
3026 if ((journalContentSearch.getGroupId() != groupId) ||
3027 (journalContentSearch.getPrivateLayout() != privateLayout) ||
3028 (journalContentSearch.getLayoutId() != layoutId) ||
3029 (journalContentSearch.getPortletId() == null) ||
3030 !journalContentSearch.getPortletId()
3031 .equals(portletId) ||
3032 (journalContentSearch.getArticleId() == null) ||
3033 !journalContentSearch.getArticleId()
3034 .equals(articleId)) {
3035 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3036 finderArgs, journalContentSearch);
3037 }
3038 }
3039
3040 return journalContentSearch;
3041 }
3042 catch (Exception e) {
3043 throw processException(e);
3044 }
3045 finally {
3046 if (result == null) {
3047 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3048 finderArgs, new ArrayList<JournalContentSearch>());
3049 }
3050
3051 closeSession(session);
3052 }
3053 }
3054 else {
3055 if (result instanceof List<?>) {
3056 return null;
3057 }
3058 else {
3059 return (JournalContentSearch)result;
3060 }
3061 }
3062 }
3063
3064
3070 public List<JournalContentSearch> findAll() throws SystemException {
3071 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3072 }
3073
3074
3086 public List<JournalContentSearch> findAll(int start, int end)
3087 throws SystemException {
3088 return findAll(start, end, null);
3089 }
3090
3091
3104 public List<JournalContentSearch> findAll(int start, int end,
3105 OrderByComparator orderByComparator) throws SystemException {
3106 Object[] finderArgs = new Object[] {
3107 String.valueOf(start), String.valueOf(end),
3108 String.valueOf(orderByComparator)
3109 };
3110
3111 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
3112 finderArgs, this);
3113
3114 if (list == null) {
3115 Session session = null;
3116
3117 try {
3118 session = openSession();
3119
3120 StringBundler query = null;
3121 String sql = null;
3122
3123 if (orderByComparator != null) {
3124 query = new StringBundler(2 +
3125 (orderByComparator.getOrderByFields().length * 3));
3126
3127 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH);
3128
3129 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3130 orderByComparator);
3131
3132 sql = query.toString();
3133 }
3134 else {
3135 sql = _SQL_SELECT_JOURNALCONTENTSEARCH;
3136 }
3137
3138 Query q = session.createQuery(sql);
3139
3140 if (orderByComparator == null) {
3141 list = (List<JournalContentSearch>)QueryUtil.list(q,
3142 getDialect(), start, end, false);
3143
3144 Collections.sort(list);
3145 }
3146 else {
3147 list = (List<JournalContentSearch>)QueryUtil.list(q,
3148 getDialect(), start, end);
3149 }
3150 }
3151 catch (Exception e) {
3152 throw processException(e);
3153 }
3154 finally {
3155 if (list == null) {
3156 list = new ArrayList<JournalContentSearch>();
3157 }
3158
3159 cacheResult(list);
3160
3161 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
3162
3163 closeSession(session);
3164 }
3165 }
3166
3167 return list;
3168 }
3169
3170
3176 public void removeByArticleId(String articleId) throws SystemException {
3177 for (JournalContentSearch journalContentSearch : findByArticleId(
3178 articleId)) {
3179 remove(journalContentSearch);
3180 }
3181 }
3182
3183
3190 public void removeByG_P(long groupId, boolean privateLayout)
3191 throws SystemException {
3192 for (JournalContentSearch journalContentSearch : findByG_P(groupId,
3193 privateLayout)) {
3194 remove(journalContentSearch);
3195 }
3196 }
3197
3198
3205 public void removeByG_A(long groupId, String articleId)
3206 throws SystemException {
3207 for (JournalContentSearch journalContentSearch : findByG_A(groupId,
3208 articleId)) {
3209 remove(journalContentSearch);
3210 }
3211 }
3212
3213
3221 public void removeByG_P_L(long groupId, boolean privateLayout, long layoutId)
3222 throws SystemException {
3223 for (JournalContentSearch journalContentSearch : findByG_P_L(groupId,
3224 privateLayout, layoutId)) {
3225 remove(journalContentSearch);
3226 }
3227 }
3228
3229
3237 public void removeByG_P_A(long groupId, boolean privateLayout,
3238 String articleId) throws SystemException {
3239 for (JournalContentSearch journalContentSearch : findByG_P_A(groupId,
3240 privateLayout, articleId)) {
3241 remove(journalContentSearch);
3242 }
3243 }
3244
3245
3254 public void removeByG_P_L_P(long groupId, boolean privateLayout,
3255 long layoutId, String portletId) throws SystemException {
3256 for (JournalContentSearch journalContentSearch : findByG_P_L_P(
3257 groupId, privateLayout, layoutId, portletId)) {
3258 remove(journalContentSearch);
3259 }
3260 }
3261
3262
3272 public void removeByG_P_L_P_A(long groupId, boolean privateLayout,
3273 long layoutId, String portletId, String articleId)
3274 throws NoSuchContentSearchException, SystemException {
3275 JournalContentSearch journalContentSearch = findByG_P_L_P_A(groupId,
3276 privateLayout, layoutId, portletId, articleId);
3277
3278 remove(journalContentSearch);
3279 }
3280
3281
3286 public void removeAll() throws SystemException {
3287 for (JournalContentSearch journalContentSearch : findAll()) {
3288 remove(journalContentSearch);
3289 }
3290 }
3291
3292
3299 public int countByArticleId(String articleId) throws SystemException {
3300 Object[] finderArgs = new Object[] { articleId };
3301
3302 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ARTICLEID,
3303 finderArgs, this);
3304
3305 if (count == null) {
3306 Session session = null;
3307
3308 try {
3309 session = openSession();
3310
3311 StringBundler query = new StringBundler(2);
3312
3313 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3314
3315 if (articleId == null) {
3316 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
3317 }
3318 else {
3319 if (articleId.equals(StringPool.BLANK)) {
3320 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
3321 }
3322 else {
3323 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
3324 }
3325 }
3326
3327 String sql = query.toString();
3328
3329 Query q = session.createQuery(sql);
3330
3331 QueryPos qPos = QueryPos.getInstance(q);
3332
3333 if (articleId != null) {
3334 qPos.add(articleId);
3335 }
3336
3337 count = (Long)q.uniqueResult();
3338 }
3339 catch (Exception e) {
3340 throw processException(e);
3341 }
3342 finally {
3343 if (count == null) {
3344 count = Long.valueOf(0);
3345 }
3346
3347 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ARTICLEID,
3348 finderArgs, count);
3349
3350 closeSession(session);
3351 }
3352 }
3353
3354 return count.intValue();
3355 }
3356
3357
3365 public int countByG_P(long groupId, boolean privateLayout)
3366 throws SystemException {
3367 Object[] finderArgs = new Object[] { groupId, privateLayout };
3368
3369 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
3370 finderArgs, this);
3371
3372 if (count == null) {
3373 Session session = null;
3374
3375 try {
3376 session = openSession();
3377
3378 StringBundler query = new StringBundler(3);
3379
3380 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3381
3382 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3383
3384 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
3385
3386 String sql = query.toString();
3387
3388 Query q = session.createQuery(sql);
3389
3390 QueryPos qPos = QueryPos.getInstance(q);
3391
3392 qPos.add(groupId);
3393
3394 qPos.add(privateLayout);
3395
3396 count = (Long)q.uniqueResult();
3397 }
3398 catch (Exception e) {
3399 throw processException(e);
3400 }
3401 finally {
3402 if (count == null) {
3403 count = Long.valueOf(0);
3404 }
3405
3406 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
3407 count);
3408
3409 closeSession(session);
3410 }
3411 }
3412
3413 return count.intValue();
3414 }
3415
3416
3424 public int countByG_A(long groupId, String articleId)
3425 throws SystemException {
3426 Object[] finderArgs = new Object[] { groupId, articleId };
3427
3428 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
3429 finderArgs, this);
3430
3431 if (count == null) {
3432 Session session = null;
3433
3434 try {
3435 session = openSession();
3436
3437 StringBundler query = new StringBundler(3);
3438
3439 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3440
3441 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
3442
3443 if (articleId == null) {
3444 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
3445 }
3446 else {
3447 if (articleId.equals(StringPool.BLANK)) {
3448 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
3449 }
3450 else {
3451 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
3452 }
3453 }
3454
3455 String sql = query.toString();
3456
3457 Query q = session.createQuery(sql);
3458
3459 QueryPos qPos = QueryPos.getInstance(q);
3460
3461 qPos.add(groupId);
3462
3463 if (articleId != null) {
3464 qPos.add(articleId);
3465 }
3466
3467 count = (Long)q.uniqueResult();
3468 }
3469 catch (Exception e) {
3470 throw processException(e);
3471 }
3472 finally {
3473 if (count == null) {
3474 count = Long.valueOf(0);
3475 }
3476
3477 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
3478 count);
3479
3480 closeSession(session);
3481 }
3482 }
3483
3484 return count.intValue();
3485 }
3486
3487
3496 public int countByG_P_L(long groupId, boolean privateLayout, long layoutId)
3497 throws SystemException {
3498 Object[] finderArgs = new Object[] { groupId, privateLayout, layoutId };
3499
3500 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L,
3501 finderArgs, this);
3502
3503 if (count == null) {
3504 Session session = null;
3505
3506 try {
3507 session = openSession();
3508
3509 StringBundler query = new StringBundler(4);
3510
3511 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3512
3513 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
3514
3515 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
3516
3517 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
3518
3519 String sql = query.toString();
3520
3521 Query q = session.createQuery(sql);
3522
3523 QueryPos qPos = QueryPos.getInstance(q);
3524
3525 qPos.add(groupId);
3526
3527 qPos.add(privateLayout);
3528
3529 qPos.add(layoutId);
3530
3531 count = (Long)q.uniqueResult();
3532 }
3533 catch (Exception e) {
3534 throw processException(e);
3535 }
3536 finally {
3537 if (count == null) {
3538 count = Long.valueOf(0);
3539 }
3540
3541 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L,
3542 finderArgs, count);
3543
3544 closeSession(session);
3545 }
3546 }
3547
3548 return count.intValue();
3549 }
3550
3551
3560 public int countByG_P_A(long groupId, boolean privateLayout,
3561 String articleId) throws SystemException {
3562 Object[] finderArgs = new Object[] { groupId, privateLayout, articleId };
3563
3564 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_A,
3565 finderArgs, this);
3566
3567 if (count == null) {
3568 Session session = null;
3569
3570 try {
3571 session = openSession();
3572
3573 StringBundler query = new StringBundler(4);
3574
3575 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3576
3577 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
3578
3579 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
3580
3581 if (articleId == null) {
3582 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
3583 }
3584 else {
3585 if (articleId.equals(StringPool.BLANK)) {
3586 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
3587 }
3588 else {
3589 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
3590 }
3591 }
3592
3593 String sql = query.toString();
3594
3595 Query q = session.createQuery(sql);
3596
3597 QueryPos qPos = QueryPos.getInstance(q);
3598
3599 qPos.add(groupId);
3600
3601 qPos.add(privateLayout);
3602
3603 if (articleId != null) {
3604 qPos.add(articleId);
3605 }
3606
3607 count = (Long)q.uniqueResult();
3608 }
3609 catch (Exception e) {
3610 throw processException(e);
3611 }
3612 finally {
3613 if (count == null) {
3614 count = Long.valueOf(0);
3615 }
3616
3617 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_A,
3618 finderArgs, count);
3619
3620 closeSession(session);
3621 }
3622 }
3623
3624 return count.intValue();
3625 }
3626
3627
3637 public int countByG_P_L_P(long groupId, boolean privateLayout,
3638 long layoutId, String portletId) throws SystemException {
3639 Object[] finderArgs = new Object[] {
3640 groupId, privateLayout, layoutId, portletId
3641 };
3642
3643 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L_P,
3644 finderArgs, this);
3645
3646 if (count == null) {
3647 Session session = null;
3648
3649 try {
3650 session = openSession();
3651
3652 StringBundler query = new StringBundler(5);
3653
3654 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3655
3656 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
3657
3658 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
3659
3660 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
3661
3662 if (portletId == null) {
3663 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
3664 }
3665 else {
3666 if (portletId.equals(StringPool.BLANK)) {
3667 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
3668 }
3669 else {
3670 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
3671 }
3672 }
3673
3674 String sql = query.toString();
3675
3676 Query q = session.createQuery(sql);
3677
3678 QueryPos qPos = QueryPos.getInstance(q);
3679
3680 qPos.add(groupId);
3681
3682 qPos.add(privateLayout);
3683
3684 qPos.add(layoutId);
3685
3686 if (portletId != null) {
3687 qPos.add(portletId);
3688 }
3689
3690 count = (Long)q.uniqueResult();
3691 }
3692 catch (Exception e) {
3693 throw processException(e);
3694 }
3695 finally {
3696 if (count == null) {
3697 count = Long.valueOf(0);
3698 }
3699
3700 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P,
3701 finderArgs, count);
3702
3703 closeSession(session);
3704 }
3705 }
3706
3707 return count.intValue();
3708 }
3709
3710
3721 public int countByG_P_L_P_A(long groupId, boolean privateLayout,
3722 long layoutId, String portletId, String articleId)
3723 throws SystemException {
3724 Object[] finderArgs = new Object[] {
3725 groupId, privateLayout, layoutId, portletId, articleId
3726 };
3727
3728 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
3729 finderArgs, this);
3730
3731 if (count == null) {
3732 Session session = null;
3733
3734 try {
3735 session = openSession();
3736
3737 StringBundler query = new StringBundler(6);
3738
3739 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3740
3741 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
3742
3743 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
3744
3745 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
3746
3747 if (portletId == null) {
3748 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
3749 }
3750 else {
3751 if (portletId.equals(StringPool.BLANK)) {
3752 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
3753 }
3754 else {
3755 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
3756 }
3757 }
3758
3759 if (articleId == null) {
3760 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
3761 }
3762 else {
3763 if (articleId.equals(StringPool.BLANK)) {
3764 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
3765 }
3766 else {
3767 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
3768 }
3769 }
3770
3771 String sql = query.toString();
3772
3773 Query q = session.createQuery(sql);
3774
3775 QueryPos qPos = QueryPos.getInstance(q);
3776
3777 qPos.add(groupId);
3778
3779 qPos.add(privateLayout);
3780
3781 qPos.add(layoutId);
3782
3783 if (portletId != null) {
3784 qPos.add(portletId);
3785 }
3786
3787 if (articleId != null) {
3788 qPos.add(articleId);
3789 }
3790
3791 count = (Long)q.uniqueResult();
3792 }
3793 catch (Exception e) {
3794 throw processException(e);
3795 }
3796 finally {
3797 if (count == null) {
3798 count = Long.valueOf(0);
3799 }
3800
3801 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
3802 finderArgs, count);
3803
3804 closeSession(session);
3805 }
3806 }
3807
3808 return count.intValue();
3809 }
3810
3811
3817 public int countAll() throws SystemException {
3818 Object[] finderArgs = new Object[0];
3819
3820 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3821 finderArgs, this);
3822
3823 if (count == null) {
3824 Session session = null;
3825
3826 try {
3827 session = openSession();
3828
3829 Query q = session.createQuery(_SQL_COUNT_JOURNALCONTENTSEARCH);
3830
3831 count = (Long)q.uniqueResult();
3832 }
3833 catch (Exception e) {
3834 throw processException(e);
3835 }
3836 finally {
3837 if (count == null) {
3838 count = Long.valueOf(0);
3839 }
3840
3841 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3842 count);
3843
3844 closeSession(session);
3845 }
3846 }
3847
3848 return count.intValue();
3849 }
3850
3851
3854 public void afterPropertiesSet() {
3855 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3856 com.liferay.portal.util.PropsUtil.get(
3857 "value.object.listener.com.liferay.portlet.journal.model.JournalContentSearch")));
3858
3859 if (listenerClassNames.length > 0) {
3860 try {
3861 List<ModelListener<JournalContentSearch>> listenersList = new ArrayList<ModelListener<JournalContentSearch>>();
3862
3863 for (String listenerClassName : listenerClassNames) {
3864 listenersList.add((ModelListener<JournalContentSearch>)InstanceFactory.newInstance(
3865 listenerClassName));
3866 }
3867
3868 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3869 }
3870 catch (Exception e) {
3871 _log.error(e);
3872 }
3873 }
3874 }
3875
3876 @BeanReference(type = JournalArticlePersistence.class)
3877 protected JournalArticlePersistence journalArticlePersistence;
3878 @BeanReference(type = JournalArticleImagePersistence.class)
3879 protected JournalArticleImagePersistence journalArticleImagePersistence;
3880 @BeanReference(type = JournalArticleResourcePersistence.class)
3881 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
3882 @BeanReference(type = JournalContentSearchPersistence.class)
3883 protected JournalContentSearchPersistence journalContentSearchPersistence;
3884 @BeanReference(type = JournalFeedPersistence.class)
3885 protected JournalFeedPersistence journalFeedPersistence;
3886 @BeanReference(type = JournalStructurePersistence.class)
3887 protected JournalStructurePersistence journalStructurePersistence;
3888 @BeanReference(type = JournalTemplatePersistence.class)
3889 protected JournalTemplatePersistence journalTemplatePersistence;
3890 @BeanReference(type = GroupPersistence.class)
3891 protected GroupPersistence groupPersistence;
3892 @BeanReference(type = LayoutPersistence.class)
3893 protected LayoutPersistence layoutPersistence;
3894 @BeanReference(type = PortletPreferencesPersistence.class)
3895 protected PortletPreferencesPersistence portletPreferencesPersistence;
3896 @BeanReference(type = ResourcePersistence.class)
3897 protected ResourcePersistence resourcePersistence;
3898 @BeanReference(type = UserPersistence.class)
3899 protected UserPersistence userPersistence;
3900 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch";
3901 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH_WHERE = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch WHERE ";
3902 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch";
3903 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH_WHERE = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch WHERE ";
3904 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3905 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3906 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3907 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3908 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ?";
3909 private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3910 private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3911 private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3912 private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3913 private static final String _FINDER_COLUMN_G_P_L_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3914 private static final String _FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3915 private static final String _FINDER_COLUMN_G_P_L_LAYOUTID_2 = "journalContentSearch.layoutId = ?";
3916 private static final String _FINDER_COLUMN_G_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3917 private static final String _FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3918 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3919 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3920 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3921 private static final String _FINDER_COLUMN_G_P_L_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3922 private static final String _FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3923 private static final String _FINDER_COLUMN_G_P_L_P_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
3924 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_1 = "journalContentSearch.portletId IS NULL";
3925 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_2 = "journalContentSearch.portletId = ?";
3926 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?)";
3927 private static final String _FINDER_COLUMN_G_P_L_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3928 private static final String _FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3929 private static final String _FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
3930 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_1 = "journalContentSearch.portletId IS NULL AND ";
3931 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_2 = "journalContentSearch.portletId = ? AND ";
3932 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?) AND ";
3933 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3934 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3935 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3936 private static final String _ORDER_BY_ENTITY_ALIAS = "journalContentSearch.";
3937 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalContentSearch exists with the primary key ";
3938 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalContentSearch exists with the key {";
3939 private static Log _log = LogFactoryUtil.getLog(JournalContentSearchPersistenceImpl.class);
3940 }