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 BatchSessionUtil.delete(session, journalContentSearch);
345 }
346 catch (Exception e) {
347 throw processException(e);
348 }
349 finally {
350 closeSession(session);
351 }
352
353 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
354
355 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
356
357 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
358 new Object[] {
359 new Long(journalContentSearchModelImpl.getGroupId()),
360 Boolean.valueOf(
361 journalContentSearchModelImpl.getPrivateLayout()),
362 new Long(journalContentSearchModelImpl.getLayoutId()),
363
364 journalContentSearchModelImpl.getPortletId(),
365
366 journalContentSearchModelImpl.getArticleId()
367 });
368
369 EntityCacheUtil.removeResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
370 JournalContentSearchImpl.class, journalContentSearch.getPrimaryKey());
371
372 return journalContentSearch;
373 }
374
375 public JournalContentSearch updateImpl(
376 com.liferay.portlet.journal.model.JournalContentSearch journalContentSearch,
377 boolean merge) throws SystemException {
378 journalContentSearch = toUnwrappedModel(journalContentSearch);
379
380 boolean isNew = journalContentSearch.isNew();
381
382 JournalContentSearchModelImpl journalContentSearchModelImpl = (JournalContentSearchModelImpl)journalContentSearch;
383
384 Session session = null;
385
386 try {
387 session = openSession();
388
389 BatchSessionUtil.update(session, journalContentSearch, merge);
390
391 journalContentSearch.setNew(false);
392 }
393 catch (Exception e) {
394 throw processException(e);
395 }
396 finally {
397 closeSession(session);
398 }
399
400 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
401
402 EntityCacheUtil.putResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
403 JournalContentSearchImpl.class,
404 journalContentSearch.getPrimaryKey(), journalContentSearch);
405
406 if (!isNew &&
407 ((journalContentSearch.getGroupId() != journalContentSearchModelImpl.getOriginalGroupId()) ||
408 (journalContentSearch.getPrivateLayout() != journalContentSearchModelImpl.getOriginalPrivateLayout()) ||
409 (journalContentSearch.getLayoutId() != journalContentSearchModelImpl.getOriginalLayoutId()) ||
410 !Validator.equals(journalContentSearch.getPortletId(),
411 journalContentSearchModelImpl.getOriginalPortletId()) ||
412 !Validator.equals(journalContentSearch.getArticleId(),
413 journalContentSearchModelImpl.getOriginalArticleId()))) {
414 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
415 new Object[] {
416 new Long(journalContentSearchModelImpl.getOriginalGroupId()),
417 Boolean.valueOf(
418 journalContentSearchModelImpl.getOriginalPrivateLayout()),
419 new Long(journalContentSearchModelImpl.getOriginalLayoutId()),
420
421 journalContentSearchModelImpl.getOriginalPortletId(),
422
423 journalContentSearchModelImpl.getOriginalArticleId()
424 });
425 }
426
427 if (isNew ||
428 ((journalContentSearch.getGroupId() != journalContentSearchModelImpl.getOriginalGroupId()) ||
429 (journalContentSearch.getPrivateLayout() != journalContentSearchModelImpl.getOriginalPrivateLayout()) ||
430 (journalContentSearch.getLayoutId() != journalContentSearchModelImpl.getOriginalLayoutId()) ||
431 !Validator.equals(journalContentSearch.getPortletId(),
432 journalContentSearchModelImpl.getOriginalPortletId()) ||
433 !Validator.equals(journalContentSearch.getArticleId(),
434 journalContentSearchModelImpl.getOriginalArticleId()))) {
435 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
436 new Object[] {
437 new Long(journalContentSearch.getGroupId()),
438 Boolean.valueOf(journalContentSearch.getPrivateLayout()),
439 new Long(journalContentSearch.getLayoutId()),
440
441 journalContentSearch.getPortletId(),
442
443 journalContentSearch.getArticleId()
444 }, journalContentSearch);
445 }
446
447 return journalContentSearch;
448 }
449
450 protected JournalContentSearch toUnwrappedModel(
451 JournalContentSearch journalContentSearch) {
452 if (journalContentSearch instanceof JournalContentSearchImpl) {
453 return journalContentSearch;
454 }
455
456 JournalContentSearchImpl journalContentSearchImpl = new JournalContentSearchImpl();
457
458 journalContentSearchImpl.setNew(journalContentSearch.isNew());
459 journalContentSearchImpl.setPrimaryKey(journalContentSearch.getPrimaryKey());
460
461 journalContentSearchImpl.setContentSearchId(journalContentSearch.getContentSearchId());
462 journalContentSearchImpl.setGroupId(journalContentSearch.getGroupId());
463 journalContentSearchImpl.setCompanyId(journalContentSearch.getCompanyId());
464 journalContentSearchImpl.setPrivateLayout(journalContentSearch.isPrivateLayout());
465 journalContentSearchImpl.setLayoutId(journalContentSearch.getLayoutId());
466 journalContentSearchImpl.setPortletId(journalContentSearch.getPortletId());
467 journalContentSearchImpl.setArticleId(journalContentSearch.getArticleId());
468
469 return journalContentSearchImpl;
470 }
471
472
480 public JournalContentSearch findByPrimaryKey(Serializable primaryKey)
481 throws NoSuchModelException, SystemException {
482 return findByPrimaryKey(((Long)primaryKey).longValue());
483 }
484
485
493 public JournalContentSearch findByPrimaryKey(long contentSearchId)
494 throws NoSuchContentSearchException, SystemException {
495 JournalContentSearch journalContentSearch = fetchByPrimaryKey(contentSearchId);
496
497 if (journalContentSearch == null) {
498 if (_log.isWarnEnabled()) {
499 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + contentSearchId);
500 }
501
502 throw new NoSuchContentSearchException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
503 contentSearchId);
504 }
505
506 return journalContentSearch;
507 }
508
509
516 public JournalContentSearch fetchByPrimaryKey(Serializable primaryKey)
517 throws SystemException {
518 return fetchByPrimaryKey(((Long)primaryKey).longValue());
519 }
520
521
528 public JournalContentSearch fetchByPrimaryKey(long contentSearchId)
529 throws SystemException {
530 JournalContentSearch journalContentSearch = (JournalContentSearch)EntityCacheUtil.getResult(JournalContentSearchModelImpl.ENTITY_CACHE_ENABLED,
531 JournalContentSearchImpl.class, contentSearchId, this);
532
533 if (journalContentSearch == null) {
534 Session session = null;
535
536 try {
537 session = openSession();
538
539 journalContentSearch = (JournalContentSearch)session.get(JournalContentSearchImpl.class,
540 new Long(contentSearchId));
541 }
542 catch (Exception e) {
543 throw processException(e);
544 }
545 finally {
546 if (journalContentSearch != null) {
547 cacheResult(journalContentSearch);
548 }
549
550 closeSession(session);
551 }
552 }
553
554 return journalContentSearch;
555 }
556
557
564 public List<JournalContentSearch> findByArticleId(String articleId)
565 throws SystemException {
566 return findByArticleId(articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
567 null);
568 }
569
570
583 public List<JournalContentSearch> findByArticleId(String articleId,
584 int start, int end) throws SystemException {
585 return findByArticleId(articleId, start, end, null);
586 }
587
588
602 public List<JournalContentSearch> findByArticleId(String articleId,
603 int start, int end, OrderByComparator orderByComparator)
604 throws SystemException {
605 Object[] finderArgs = new Object[] {
606 articleId,
607
608 String.valueOf(start), String.valueOf(end),
609 String.valueOf(orderByComparator)
610 };
611
612 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ARTICLEID,
613 finderArgs, this);
614
615 if (list == null) {
616 StringBundler query = null;
617
618 if (orderByComparator != null) {
619 query = new StringBundler(3 +
620 (orderByComparator.getOrderByFields().length * 3));
621 }
622 else {
623 query = new StringBundler(2);
624 }
625
626 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
627
628 if (articleId == null) {
629 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
630 }
631 else {
632 if (articleId.equals(StringPool.BLANK)) {
633 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
634 }
635 else {
636 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
637 }
638 }
639
640 if (orderByComparator != null) {
641 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
642 orderByComparator);
643 }
644
645 String sql = query.toString();
646
647 Session session = null;
648
649 try {
650 session = openSession();
651
652 Query q = session.createQuery(sql);
653
654 QueryPos qPos = QueryPos.getInstance(q);
655
656 if (articleId != null) {
657 qPos.add(articleId);
658 }
659
660 list = (List<JournalContentSearch>)QueryUtil.list(q,
661 getDialect(), start, end);
662 }
663 catch (Exception e) {
664 throw processException(e);
665 }
666 finally {
667 if (list == null) {
668 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_ARTICLEID,
669 finderArgs);
670 }
671 else {
672 cacheResult(list);
673
674 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ARTICLEID,
675 finderArgs, list);
676 }
677
678 closeSession(session);
679 }
680 }
681
682 return list;
683 }
684
685
698 public JournalContentSearch findByArticleId_First(String articleId,
699 OrderByComparator orderByComparator)
700 throws NoSuchContentSearchException, SystemException {
701 List<JournalContentSearch> list = findByArticleId(articleId, 0, 1,
702 orderByComparator);
703
704 if (list.isEmpty()) {
705 StringBundler msg = new StringBundler(4);
706
707 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
708
709 msg.append("articleId=");
710 msg.append(articleId);
711
712 msg.append(StringPool.CLOSE_CURLY_BRACE);
713
714 throw new NoSuchContentSearchException(msg.toString());
715 }
716 else {
717 return list.get(0);
718 }
719 }
720
721
734 public JournalContentSearch findByArticleId_Last(String articleId,
735 OrderByComparator orderByComparator)
736 throws NoSuchContentSearchException, SystemException {
737 int count = countByArticleId(articleId);
738
739 List<JournalContentSearch> list = findByArticleId(articleId, count - 1,
740 count, orderByComparator);
741
742 if (list.isEmpty()) {
743 StringBundler msg = new StringBundler(4);
744
745 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
746
747 msg.append("articleId=");
748 msg.append(articleId);
749
750 msg.append(StringPool.CLOSE_CURLY_BRACE);
751
752 throw new NoSuchContentSearchException(msg.toString());
753 }
754 else {
755 return list.get(0);
756 }
757 }
758
759
773 public JournalContentSearch[] findByArticleId_PrevAndNext(
774 long contentSearchId, String articleId,
775 OrderByComparator orderByComparator)
776 throws NoSuchContentSearchException, SystemException {
777 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
778
779 Session session = null;
780
781 try {
782 session = openSession();
783
784 JournalContentSearch[] array = new JournalContentSearchImpl[3];
785
786 array[0] = getByArticleId_PrevAndNext(session,
787 journalContentSearch, articleId, orderByComparator, true);
788
789 array[1] = journalContentSearch;
790
791 array[2] = getByArticleId_PrevAndNext(session,
792 journalContentSearch, articleId, orderByComparator, false);
793
794 return array;
795 }
796 catch (Exception e) {
797 throw processException(e);
798 }
799 finally {
800 closeSession(session);
801 }
802 }
803
804 protected JournalContentSearch getByArticleId_PrevAndNext(Session session,
805 JournalContentSearch journalContentSearch, String articleId,
806 OrderByComparator orderByComparator, boolean previous) {
807 StringBundler query = null;
808
809 if (orderByComparator != null) {
810 query = new StringBundler(6 +
811 (orderByComparator.getOrderByFields().length * 6));
812 }
813 else {
814 query = new StringBundler(3);
815 }
816
817 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
818
819 if (articleId == null) {
820 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
821 }
822 else {
823 if (articleId.equals(StringPool.BLANK)) {
824 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
825 }
826 else {
827 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
828 }
829 }
830
831 if (orderByComparator != null) {
832 String[] orderByFields = orderByComparator.getOrderByFields();
833
834 if (orderByFields.length > 0) {
835 query.append(WHERE_AND);
836 }
837
838 for (int i = 0; i < orderByFields.length; i++) {
839 query.append(_ORDER_BY_ENTITY_ALIAS);
840 query.append(orderByFields[i]);
841
842 if ((i + 1) < orderByFields.length) {
843 if (orderByComparator.isAscending() ^ previous) {
844 query.append(WHERE_GREATER_THAN_HAS_NEXT);
845 }
846 else {
847 query.append(WHERE_LESSER_THAN_HAS_NEXT);
848 }
849 }
850 else {
851 if (orderByComparator.isAscending() ^ previous) {
852 query.append(WHERE_GREATER_THAN);
853 }
854 else {
855 query.append(WHERE_LESSER_THAN);
856 }
857 }
858 }
859
860 query.append(ORDER_BY_CLAUSE);
861
862 for (int i = 0; i < orderByFields.length; i++) {
863 query.append(_ORDER_BY_ENTITY_ALIAS);
864 query.append(orderByFields[i]);
865
866 if ((i + 1) < orderByFields.length) {
867 if (orderByComparator.isAscending() ^ previous) {
868 query.append(ORDER_BY_ASC_HAS_NEXT);
869 }
870 else {
871 query.append(ORDER_BY_DESC_HAS_NEXT);
872 }
873 }
874 else {
875 if (orderByComparator.isAscending() ^ previous) {
876 query.append(ORDER_BY_ASC);
877 }
878 else {
879 query.append(ORDER_BY_DESC);
880 }
881 }
882 }
883 }
884
885 String sql = query.toString();
886
887 Query q = session.createQuery(sql);
888
889 q.setFirstResult(0);
890 q.setMaxResults(2);
891
892 QueryPos qPos = QueryPos.getInstance(q);
893
894 if (articleId != null) {
895 qPos.add(articleId);
896 }
897
898 if (orderByComparator != null) {
899 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
900
901 for (Object value : values) {
902 qPos.add(value);
903 }
904 }
905
906 List<JournalContentSearch> list = q.list();
907
908 if (list.size() == 2) {
909 return list.get(1);
910 }
911 else {
912 return null;
913 }
914 }
915
916
924 public List<JournalContentSearch> findByG_P(long groupId,
925 boolean privateLayout) throws SystemException {
926 return findByG_P(groupId, privateLayout, QueryUtil.ALL_POS,
927 QueryUtil.ALL_POS, null);
928 }
929
930
944 public List<JournalContentSearch> findByG_P(long groupId,
945 boolean privateLayout, int start, int end) throws SystemException {
946 return findByG_P(groupId, privateLayout, start, end, null);
947 }
948
949
964 public List<JournalContentSearch> findByG_P(long groupId,
965 boolean privateLayout, int start, int end,
966 OrderByComparator orderByComparator) throws SystemException {
967 Object[] finderArgs = new Object[] {
968 groupId, privateLayout,
969
970 String.valueOf(start), String.valueOf(end),
971 String.valueOf(orderByComparator)
972 };
973
974 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P,
975 finderArgs, this);
976
977 if (list == null) {
978 StringBundler query = null;
979
980 if (orderByComparator != null) {
981 query = new StringBundler(4 +
982 (orderByComparator.getOrderByFields().length * 3));
983 }
984 else {
985 query = new StringBundler(3);
986 }
987
988 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
989
990 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
991
992 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
993
994 if (orderByComparator != null) {
995 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
996 orderByComparator);
997 }
998
999 String sql = query.toString();
1000
1001 Session session = null;
1002
1003 try {
1004 session = openSession();
1005
1006 Query q = session.createQuery(sql);
1007
1008 QueryPos qPos = QueryPos.getInstance(q);
1009
1010 qPos.add(groupId);
1011
1012 qPos.add(privateLayout);
1013
1014 list = (List<JournalContentSearch>)QueryUtil.list(q,
1015 getDialect(), start, end);
1016 }
1017 catch (Exception e) {
1018 throw processException(e);
1019 }
1020 finally {
1021 if (list == null) {
1022 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_P,
1023 finderArgs);
1024 }
1025 else {
1026 cacheResult(list);
1027
1028 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P,
1029 finderArgs, list);
1030 }
1031
1032 closeSession(session);
1033 }
1034 }
1035
1036 return list;
1037 }
1038
1039
1053 public JournalContentSearch findByG_P_First(long groupId,
1054 boolean privateLayout, OrderByComparator orderByComparator)
1055 throws NoSuchContentSearchException, SystemException {
1056 List<JournalContentSearch> list = findByG_P(groupId, privateLayout, 0,
1057 1, orderByComparator);
1058
1059 if (list.isEmpty()) {
1060 StringBundler msg = new StringBundler(6);
1061
1062 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1063
1064 msg.append("groupId=");
1065 msg.append(groupId);
1066
1067 msg.append(", privateLayout=");
1068 msg.append(privateLayout);
1069
1070 msg.append(StringPool.CLOSE_CURLY_BRACE);
1071
1072 throw new NoSuchContentSearchException(msg.toString());
1073 }
1074 else {
1075 return list.get(0);
1076 }
1077 }
1078
1079
1093 public JournalContentSearch findByG_P_Last(long groupId,
1094 boolean privateLayout, OrderByComparator orderByComparator)
1095 throws NoSuchContentSearchException, SystemException {
1096 int count = countByG_P(groupId, privateLayout);
1097
1098 List<JournalContentSearch> list = findByG_P(groupId, privateLayout,
1099 count - 1, count, orderByComparator);
1100
1101 if (list.isEmpty()) {
1102 StringBundler msg = new StringBundler(6);
1103
1104 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1105
1106 msg.append("groupId=");
1107 msg.append(groupId);
1108
1109 msg.append(", privateLayout=");
1110 msg.append(privateLayout);
1111
1112 msg.append(StringPool.CLOSE_CURLY_BRACE);
1113
1114 throw new NoSuchContentSearchException(msg.toString());
1115 }
1116 else {
1117 return list.get(0);
1118 }
1119 }
1120
1121
1136 public JournalContentSearch[] findByG_P_PrevAndNext(long contentSearchId,
1137 long groupId, boolean privateLayout, OrderByComparator orderByComparator)
1138 throws NoSuchContentSearchException, SystemException {
1139 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1140
1141 Session session = null;
1142
1143 try {
1144 session = openSession();
1145
1146 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1147
1148 array[0] = getByG_P_PrevAndNext(session, journalContentSearch,
1149 groupId, privateLayout, orderByComparator, true);
1150
1151 array[1] = journalContentSearch;
1152
1153 array[2] = getByG_P_PrevAndNext(session, journalContentSearch,
1154 groupId, privateLayout, orderByComparator, false);
1155
1156 return array;
1157 }
1158 catch (Exception e) {
1159 throw processException(e);
1160 }
1161 finally {
1162 closeSession(session);
1163 }
1164 }
1165
1166 protected JournalContentSearch getByG_P_PrevAndNext(Session session,
1167 JournalContentSearch journalContentSearch, long groupId,
1168 boolean privateLayout, OrderByComparator orderByComparator,
1169 boolean previous) {
1170 StringBundler query = null;
1171
1172 if (orderByComparator != null) {
1173 query = new StringBundler(6 +
1174 (orderByComparator.getOrderByFields().length * 6));
1175 }
1176 else {
1177 query = new StringBundler(3);
1178 }
1179
1180 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1181
1182 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
1183
1184 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
1185
1186 if (orderByComparator != null) {
1187 String[] orderByFields = orderByComparator.getOrderByFields();
1188
1189 if (orderByFields.length > 0) {
1190 query.append(WHERE_AND);
1191 }
1192
1193 for (int i = 0; i < orderByFields.length; i++) {
1194 query.append(_ORDER_BY_ENTITY_ALIAS);
1195 query.append(orderByFields[i]);
1196
1197 if ((i + 1) < orderByFields.length) {
1198 if (orderByComparator.isAscending() ^ previous) {
1199 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1200 }
1201 else {
1202 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1203 }
1204 }
1205 else {
1206 if (orderByComparator.isAscending() ^ previous) {
1207 query.append(WHERE_GREATER_THAN);
1208 }
1209 else {
1210 query.append(WHERE_LESSER_THAN);
1211 }
1212 }
1213 }
1214
1215 query.append(ORDER_BY_CLAUSE);
1216
1217 for (int i = 0; i < orderByFields.length; i++) {
1218 query.append(_ORDER_BY_ENTITY_ALIAS);
1219 query.append(orderByFields[i]);
1220
1221 if ((i + 1) < orderByFields.length) {
1222 if (orderByComparator.isAscending() ^ previous) {
1223 query.append(ORDER_BY_ASC_HAS_NEXT);
1224 }
1225 else {
1226 query.append(ORDER_BY_DESC_HAS_NEXT);
1227 }
1228 }
1229 else {
1230 if (orderByComparator.isAscending() ^ previous) {
1231 query.append(ORDER_BY_ASC);
1232 }
1233 else {
1234 query.append(ORDER_BY_DESC);
1235 }
1236 }
1237 }
1238 }
1239
1240 String sql = query.toString();
1241
1242 Query q = session.createQuery(sql);
1243
1244 q.setFirstResult(0);
1245 q.setMaxResults(2);
1246
1247 QueryPos qPos = QueryPos.getInstance(q);
1248
1249 qPos.add(groupId);
1250
1251 qPos.add(privateLayout);
1252
1253 if (orderByComparator != null) {
1254 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
1255
1256 for (Object value : values) {
1257 qPos.add(value);
1258 }
1259 }
1260
1261 List<JournalContentSearch> list = q.list();
1262
1263 if (list.size() == 2) {
1264 return list.get(1);
1265 }
1266 else {
1267 return null;
1268 }
1269 }
1270
1271
1279 public List<JournalContentSearch> findByG_A(long groupId, String articleId)
1280 throws SystemException {
1281 return findByG_A(groupId, articleId, QueryUtil.ALL_POS,
1282 QueryUtil.ALL_POS, null);
1283 }
1284
1285
1299 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1300 int start, int end) throws SystemException {
1301 return findByG_A(groupId, articleId, start, end, null);
1302 }
1303
1304
1319 public List<JournalContentSearch> findByG_A(long groupId, String articleId,
1320 int start, int end, OrderByComparator orderByComparator)
1321 throws SystemException {
1322 Object[] finderArgs = new Object[] {
1323 groupId, articleId,
1324
1325 String.valueOf(start), String.valueOf(end),
1326 String.valueOf(orderByComparator)
1327 };
1328
1329 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_A,
1330 finderArgs, this);
1331
1332 if (list == null) {
1333 StringBundler query = null;
1334
1335 if (orderByComparator != null) {
1336 query = new StringBundler(4 +
1337 (orderByComparator.getOrderByFields().length * 3));
1338 }
1339 else {
1340 query = new StringBundler(3);
1341 }
1342
1343 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1344
1345 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1346
1347 if (articleId == null) {
1348 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1349 }
1350 else {
1351 if (articleId.equals(StringPool.BLANK)) {
1352 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1353 }
1354 else {
1355 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1356 }
1357 }
1358
1359 if (orderByComparator != null) {
1360 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1361 orderByComparator);
1362 }
1363
1364 String sql = query.toString();
1365
1366 Session session = null;
1367
1368 try {
1369 session = openSession();
1370
1371 Query q = session.createQuery(sql);
1372
1373 QueryPos qPos = QueryPos.getInstance(q);
1374
1375 qPos.add(groupId);
1376
1377 if (articleId != null) {
1378 qPos.add(articleId);
1379 }
1380
1381 list = (List<JournalContentSearch>)QueryUtil.list(q,
1382 getDialect(), start, end);
1383 }
1384 catch (Exception e) {
1385 throw processException(e);
1386 }
1387 finally {
1388 if (list == null) {
1389 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_A,
1390 finderArgs);
1391 }
1392 else {
1393 cacheResult(list);
1394
1395 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_A,
1396 finderArgs, list);
1397 }
1398
1399 closeSession(session);
1400 }
1401 }
1402
1403 return list;
1404 }
1405
1406
1420 public JournalContentSearch findByG_A_First(long groupId, String articleId,
1421 OrderByComparator orderByComparator)
1422 throws NoSuchContentSearchException, SystemException {
1423 List<JournalContentSearch> list = findByG_A(groupId, articleId, 0, 1,
1424 orderByComparator);
1425
1426 if (list.isEmpty()) {
1427 StringBundler msg = new StringBundler(6);
1428
1429 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1430
1431 msg.append("groupId=");
1432 msg.append(groupId);
1433
1434 msg.append(", articleId=");
1435 msg.append(articleId);
1436
1437 msg.append(StringPool.CLOSE_CURLY_BRACE);
1438
1439 throw new NoSuchContentSearchException(msg.toString());
1440 }
1441 else {
1442 return list.get(0);
1443 }
1444 }
1445
1446
1460 public JournalContentSearch findByG_A_Last(long groupId, String articleId,
1461 OrderByComparator orderByComparator)
1462 throws NoSuchContentSearchException, SystemException {
1463 int count = countByG_A(groupId, articleId);
1464
1465 List<JournalContentSearch> list = findByG_A(groupId, articleId,
1466 count - 1, count, orderByComparator);
1467
1468 if (list.isEmpty()) {
1469 StringBundler msg = new StringBundler(6);
1470
1471 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1472
1473 msg.append("groupId=");
1474 msg.append(groupId);
1475
1476 msg.append(", articleId=");
1477 msg.append(articleId);
1478
1479 msg.append(StringPool.CLOSE_CURLY_BRACE);
1480
1481 throw new NoSuchContentSearchException(msg.toString());
1482 }
1483 else {
1484 return list.get(0);
1485 }
1486 }
1487
1488
1503 public JournalContentSearch[] findByG_A_PrevAndNext(long contentSearchId,
1504 long groupId, String articleId, OrderByComparator orderByComparator)
1505 throws NoSuchContentSearchException, SystemException {
1506 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1507
1508 Session session = null;
1509
1510 try {
1511 session = openSession();
1512
1513 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1514
1515 array[0] = getByG_A_PrevAndNext(session, journalContentSearch,
1516 groupId, articleId, orderByComparator, true);
1517
1518 array[1] = journalContentSearch;
1519
1520 array[2] = getByG_A_PrevAndNext(session, journalContentSearch,
1521 groupId, articleId, orderByComparator, false);
1522
1523 return array;
1524 }
1525 catch (Exception e) {
1526 throw processException(e);
1527 }
1528 finally {
1529 closeSession(session);
1530 }
1531 }
1532
1533 protected JournalContentSearch getByG_A_PrevAndNext(Session session,
1534 JournalContentSearch journalContentSearch, long groupId,
1535 String articleId, OrderByComparator orderByComparator, boolean previous) {
1536 StringBundler query = null;
1537
1538 if (orderByComparator != null) {
1539 query = new StringBundler(6 +
1540 (orderByComparator.getOrderByFields().length * 6));
1541 }
1542 else {
1543 query = new StringBundler(3);
1544 }
1545
1546 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1547
1548 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
1549
1550 if (articleId == null) {
1551 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
1552 }
1553 else {
1554 if (articleId.equals(StringPool.BLANK)) {
1555 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
1556 }
1557 else {
1558 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
1559 }
1560 }
1561
1562 if (orderByComparator != null) {
1563 String[] orderByFields = orderByComparator.getOrderByFields();
1564
1565 if (orderByFields.length > 0) {
1566 query.append(WHERE_AND);
1567 }
1568
1569 for (int i = 0; i < orderByFields.length; i++) {
1570 query.append(_ORDER_BY_ENTITY_ALIAS);
1571 query.append(orderByFields[i]);
1572
1573 if ((i + 1) < orderByFields.length) {
1574 if (orderByComparator.isAscending() ^ previous) {
1575 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1576 }
1577 else {
1578 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1579 }
1580 }
1581 else {
1582 if (orderByComparator.isAscending() ^ previous) {
1583 query.append(WHERE_GREATER_THAN);
1584 }
1585 else {
1586 query.append(WHERE_LESSER_THAN);
1587 }
1588 }
1589 }
1590
1591 query.append(ORDER_BY_CLAUSE);
1592
1593 for (int i = 0; i < orderByFields.length; i++) {
1594 query.append(_ORDER_BY_ENTITY_ALIAS);
1595 query.append(orderByFields[i]);
1596
1597 if ((i + 1) < orderByFields.length) {
1598 if (orderByComparator.isAscending() ^ previous) {
1599 query.append(ORDER_BY_ASC_HAS_NEXT);
1600 }
1601 else {
1602 query.append(ORDER_BY_DESC_HAS_NEXT);
1603 }
1604 }
1605 else {
1606 if (orderByComparator.isAscending() ^ previous) {
1607 query.append(ORDER_BY_ASC);
1608 }
1609 else {
1610 query.append(ORDER_BY_DESC);
1611 }
1612 }
1613 }
1614 }
1615
1616 String sql = query.toString();
1617
1618 Query q = session.createQuery(sql);
1619
1620 q.setFirstResult(0);
1621 q.setMaxResults(2);
1622
1623 QueryPos qPos = QueryPos.getInstance(q);
1624
1625 qPos.add(groupId);
1626
1627 if (articleId != null) {
1628 qPos.add(articleId);
1629 }
1630
1631 if (orderByComparator != null) {
1632 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
1633
1634 for (Object value : values) {
1635 qPos.add(value);
1636 }
1637 }
1638
1639 List<JournalContentSearch> list = q.list();
1640
1641 if (list.size() == 2) {
1642 return list.get(1);
1643 }
1644 else {
1645 return null;
1646 }
1647 }
1648
1649
1658 public List<JournalContentSearch> findByG_P_L(long groupId,
1659 boolean privateLayout, long layoutId) throws SystemException {
1660 return findByG_P_L(groupId, privateLayout, layoutId, QueryUtil.ALL_POS,
1661 QueryUtil.ALL_POS, null);
1662 }
1663
1664
1679 public List<JournalContentSearch> findByG_P_L(long groupId,
1680 boolean privateLayout, long layoutId, int start, int end)
1681 throws SystemException {
1682 return findByG_P_L(groupId, privateLayout, layoutId, start, end, null);
1683 }
1684
1685
1701 public List<JournalContentSearch> findByG_P_L(long groupId,
1702 boolean privateLayout, long layoutId, int start, int end,
1703 OrderByComparator orderByComparator) throws SystemException {
1704 Object[] finderArgs = new Object[] {
1705 groupId, privateLayout, layoutId,
1706
1707 String.valueOf(start), String.valueOf(end),
1708 String.valueOf(orderByComparator)
1709 };
1710
1711 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_L,
1712 finderArgs, this);
1713
1714 if (list == null) {
1715 StringBundler query = null;
1716
1717 if (orderByComparator != null) {
1718 query = new StringBundler(5 +
1719 (orderByComparator.getOrderByFields().length * 3));
1720 }
1721 else {
1722 query = new StringBundler(4);
1723 }
1724
1725 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1726
1727 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
1728
1729 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
1730
1731 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
1732
1733 if (orderByComparator != null) {
1734 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1735 orderByComparator);
1736 }
1737
1738 String sql = query.toString();
1739
1740 Session session = null;
1741
1742 try {
1743 session = openSession();
1744
1745 Query q = session.createQuery(sql);
1746
1747 QueryPos qPos = QueryPos.getInstance(q);
1748
1749 qPos.add(groupId);
1750
1751 qPos.add(privateLayout);
1752
1753 qPos.add(layoutId);
1754
1755 list = (List<JournalContentSearch>)QueryUtil.list(q,
1756 getDialect(), start, end);
1757 }
1758 catch (Exception e) {
1759 throw processException(e);
1760 }
1761 finally {
1762 if (list == null) {
1763 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_P_L,
1764 finderArgs);
1765 }
1766 else {
1767 cacheResult(list);
1768
1769 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_L,
1770 finderArgs, list);
1771 }
1772
1773 closeSession(session);
1774 }
1775 }
1776
1777 return list;
1778 }
1779
1780
1795 public JournalContentSearch findByG_P_L_First(long groupId,
1796 boolean privateLayout, long layoutId,
1797 OrderByComparator orderByComparator)
1798 throws NoSuchContentSearchException, SystemException {
1799 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
1800 layoutId, 0, 1, orderByComparator);
1801
1802 if (list.isEmpty()) {
1803 StringBundler msg = new StringBundler(8);
1804
1805 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1806
1807 msg.append("groupId=");
1808 msg.append(groupId);
1809
1810 msg.append(", privateLayout=");
1811 msg.append(privateLayout);
1812
1813 msg.append(", layoutId=");
1814 msg.append(layoutId);
1815
1816 msg.append(StringPool.CLOSE_CURLY_BRACE);
1817
1818 throw new NoSuchContentSearchException(msg.toString());
1819 }
1820 else {
1821 return list.get(0);
1822 }
1823 }
1824
1825
1840 public JournalContentSearch findByG_P_L_Last(long groupId,
1841 boolean privateLayout, long layoutId,
1842 OrderByComparator orderByComparator)
1843 throws NoSuchContentSearchException, SystemException {
1844 int count = countByG_P_L(groupId, privateLayout, layoutId);
1845
1846 List<JournalContentSearch> list = findByG_P_L(groupId, privateLayout,
1847 layoutId, count - 1, count, orderByComparator);
1848
1849 if (list.isEmpty()) {
1850 StringBundler msg = new StringBundler(8);
1851
1852 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1853
1854 msg.append("groupId=");
1855 msg.append(groupId);
1856
1857 msg.append(", privateLayout=");
1858 msg.append(privateLayout);
1859
1860 msg.append(", layoutId=");
1861 msg.append(layoutId);
1862
1863 msg.append(StringPool.CLOSE_CURLY_BRACE);
1864
1865 throw new NoSuchContentSearchException(msg.toString());
1866 }
1867 else {
1868 return list.get(0);
1869 }
1870 }
1871
1872
1888 public JournalContentSearch[] findByG_P_L_PrevAndNext(
1889 long contentSearchId, long groupId, boolean privateLayout,
1890 long layoutId, OrderByComparator orderByComparator)
1891 throws NoSuchContentSearchException, SystemException {
1892 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
1893
1894 Session session = null;
1895
1896 try {
1897 session = openSession();
1898
1899 JournalContentSearch[] array = new JournalContentSearchImpl[3];
1900
1901 array[0] = getByG_P_L_PrevAndNext(session, journalContentSearch,
1902 groupId, privateLayout, layoutId, orderByComparator, true);
1903
1904 array[1] = journalContentSearch;
1905
1906 array[2] = getByG_P_L_PrevAndNext(session, journalContentSearch,
1907 groupId, privateLayout, layoutId, orderByComparator, false);
1908
1909 return array;
1910 }
1911 catch (Exception e) {
1912 throw processException(e);
1913 }
1914 finally {
1915 closeSession(session);
1916 }
1917 }
1918
1919 protected JournalContentSearch getByG_P_L_PrevAndNext(Session session,
1920 JournalContentSearch journalContentSearch, long groupId,
1921 boolean privateLayout, long layoutId,
1922 OrderByComparator orderByComparator, boolean previous) {
1923 StringBundler query = null;
1924
1925 if (orderByComparator != null) {
1926 query = new StringBundler(6 +
1927 (orderByComparator.getOrderByFields().length * 6));
1928 }
1929 else {
1930 query = new StringBundler(3);
1931 }
1932
1933 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
1934
1935 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
1936
1937 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
1938
1939 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
1940
1941 if (orderByComparator != null) {
1942 String[] orderByFields = orderByComparator.getOrderByFields();
1943
1944 if (orderByFields.length > 0) {
1945 query.append(WHERE_AND);
1946 }
1947
1948 for (int i = 0; i < orderByFields.length; i++) {
1949 query.append(_ORDER_BY_ENTITY_ALIAS);
1950 query.append(orderByFields[i]);
1951
1952 if ((i + 1) < orderByFields.length) {
1953 if (orderByComparator.isAscending() ^ previous) {
1954 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1955 }
1956 else {
1957 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1958 }
1959 }
1960 else {
1961 if (orderByComparator.isAscending() ^ previous) {
1962 query.append(WHERE_GREATER_THAN);
1963 }
1964 else {
1965 query.append(WHERE_LESSER_THAN);
1966 }
1967 }
1968 }
1969
1970 query.append(ORDER_BY_CLAUSE);
1971
1972 for (int i = 0; i < orderByFields.length; i++) {
1973 query.append(_ORDER_BY_ENTITY_ALIAS);
1974 query.append(orderByFields[i]);
1975
1976 if ((i + 1) < orderByFields.length) {
1977 if (orderByComparator.isAscending() ^ previous) {
1978 query.append(ORDER_BY_ASC_HAS_NEXT);
1979 }
1980 else {
1981 query.append(ORDER_BY_DESC_HAS_NEXT);
1982 }
1983 }
1984 else {
1985 if (orderByComparator.isAscending() ^ previous) {
1986 query.append(ORDER_BY_ASC);
1987 }
1988 else {
1989 query.append(ORDER_BY_DESC);
1990 }
1991 }
1992 }
1993 }
1994
1995 String sql = query.toString();
1996
1997 Query q = session.createQuery(sql);
1998
1999 q.setFirstResult(0);
2000 q.setMaxResults(2);
2001
2002 QueryPos qPos = QueryPos.getInstance(q);
2003
2004 qPos.add(groupId);
2005
2006 qPos.add(privateLayout);
2007
2008 qPos.add(layoutId);
2009
2010 if (orderByComparator != null) {
2011 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
2012
2013 for (Object value : values) {
2014 qPos.add(value);
2015 }
2016 }
2017
2018 List<JournalContentSearch> list = q.list();
2019
2020 if (list.size() == 2) {
2021 return list.get(1);
2022 }
2023 else {
2024 return null;
2025 }
2026 }
2027
2028
2037 public List<JournalContentSearch> findByG_P_A(long groupId,
2038 boolean privateLayout, String articleId) throws SystemException {
2039 return findByG_P_A(groupId, privateLayout, articleId,
2040 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2041 }
2042
2043
2058 public List<JournalContentSearch> findByG_P_A(long groupId,
2059 boolean privateLayout, String articleId, int start, int end)
2060 throws SystemException {
2061 return findByG_P_A(groupId, privateLayout, articleId, start, end, null);
2062 }
2063
2064
2080 public List<JournalContentSearch> findByG_P_A(long groupId,
2081 boolean privateLayout, String articleId, int start, int end,
2082 OrderByComparator orderByComparator) throws SystemException {
2083 Object[] finderArgs = new Object[] {
2084 groupId, privateLayout, articleId,
2085
2086 String.valueOf(start), String.valueOf(end),
2087 String.valueOf(orderByComparator)
2088 };
2089
2090 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_A,
2091 finderArgs, this);
2092
2093 if (list == null) {
2094 StringBundler query = null;
2095
2096 if (orderByComparator != null) {
2097 query = new StringBundler(5 +
2098 (orderByComparator.getOrderByFields().length * 3));
2099 }
2100 else {
2101 query = new StringBundler(4);
2102 }
2103
2104 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2105
2106 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2107
2108 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2109
2110 if (articleId == null) {
2111 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2112 }
2113 else {
2114 if (articleId.equals(StringPool.BLANK)) {
2115 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
2116 }
2117 else {
2118 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
2119 }
2120 }
2121
2122 if (orderByComparator != null) {
2123 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2124 orderByComparator);
2125 }
2126
2127 String sql = query.toString();
2128
2129 Session session = null;
2130
2131 try {
2132 session = openSession();
2133
2134 Query q = session.createQuery(sql);
2135
2136 QueryPos qPos = QueryPos.getInstance(q);
2137
2138 qPos.add(groupId);
2139
2140 qPos.add(privateLayout);
2141
2142 if (articleId != null) {
2143 qPos.add(articleId);
2144 }
2145
2146 list = (List<JournalContentSearch>)QueryUtil.list(q,
2147 getDialect(), start, end);
2148 }
2149 catch (Exception e) {
2150 throw processException(e);
2151 }
2152 finally {
2153 if (list == null) {
2154 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_P_A,
2155 finderArgs);
2156 }
2157 else {
2158 cacheResult(list);
2159
2160 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_A,
2161 finderArgs, list);
2162 }
2163
2164 closeSession(session);
2165 }
2166 }
2167
2168 return list;
2169 }
2170
2171
2186 public JournalContentSearch findByG_P_A_First(long groupId,
2187 boolean privateLayout, String articleId,
2188 OrderByComparator orderByComparator)
2189 throws NoSuchContentSearchException, SystemException {
2190 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
2191 articleId, 0, 1, orderByComparator);
2192
2193 if (list.isEmpty()) {
2194 StringBundler msg = new StringBundler(8);
2195
2196 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2197
2198 msg.append("groupId=");
2199 msg.append(groupId);
2200
2201 msg.append(", privateLayout=");
2202 msg.append(privateLayout);
2203
2204 msg.append(", articleId=");
2205 msg.append(articleId);
2206
2207 msg.append(StringPool.CLOSE_CURLY_BRACE);
2208
2209 throw new NoSuchContentSearchException(msg.toString());
2210 }
2211 else {
2212 return list.get(0);
2213 }
2214 }
2215
2216
2231 public JournalContentSearch findByG_P_A_Last(long groupId,
2232 boolean privateLayout, String articleId,
2233 OrderByComparator orderByComparator)
2234 throws NoSuchContentSearchException, SystemException {
2235 int count = countByG_P_A(groupId, privateLayout, articleId);
2236
2237 List<JournalContentSearch> list = findByG_P_A(groupId, privateLayout,
2238 articleId, count - 1, count, orderByComparator);
2239
2240 if (list.isEmpty()) {
2241 StringBundler msg = new StringBundler(8);
2242
2243 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2244
2245 msg.append("groupId=");
2246 msg.append(groupId);
2247
2248 msg.append(", privateLayout=");
2249 msg.append(privateLayout);
2250
2251 msg.append(", articleId=");
2252 msg.append(articleId);
2253
2254 msg.append(StringPool.CLOSE_CURLY_BRACE);
2255
2256 throw new NoSuchContentSearchException(msg.toString());
2257 }
2258 else {
2259 return list.get(0);
2260 }
2261 }
2262
2263
2279 public JournalContentSearch[] findByG_P_A_PrevAndNext(
2280 long contentSearchId, long groupId, boolean privateLayout,
2281 String articleId, OrderByComparator orderByComparator)
2282 throws NoSuchContentSearchException, SystemException {
2283 JournalContentSearch journalContentSearch = findByPrimaryKey(contentSearchId);
2284
2285 Session session = null;
2286
2287 try {
2288 session = openSession();
2289
2290 JournalContentSearch[] array = new JournalContentSearchImpl[3];
2291
2292 array[0] = getByG_P_A_PrevAndNext(session, journalContentSearch,
2293 groupId, privateLayout, articleId, orderByComparator, true);
2294
2295 array[1] = journalContentSearch;
2296
2297 array[2] = getByG_P_A_PrevAndNext(session, journalContentSearch,
2298 groupId, privateLayout, articleId, orderByComparator, false);
2299
2300 return array;
2301 }
2302 catch (Exception e) {
2303 throw processException(e);
2304 }
2305 finally {
2306 closeSession(session);
2307 }
2308 }
2309
2310 protected JournalContentSearch getByG_P_A_PrevAndNext(Session session,
2311 JournalContentSearch journalContentSearch, long groupId,
2312 boolean privateLayout, String articleId,
2313 OrderByComparator orderByComparator, boolean previous) {
2314 StringBundler query = null;
2315
2316 if (orderByComparator != null) {
2317 query = new StringBundler(6 +
2318 (orderByComparator.getOrderByFields().length * 6));
2319 }
2320 else {
2321 query = new StringBundler(3);
2322 }
2323
2324 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2325
2326 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
2327
2328 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
2329
2330 if (articleId == null) {
2331 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
2332 }
2333 else {
2334 if (articleId.equals(StringPool.BLANK)) {
2335 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
2336 }
2337 else {
2338 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
2339 }
2340 }
2341
2342 if (orderByComparator != null) {
2343 String[] orderByFields = orderByComparator.getOrderByFields();
2344
2345 if (orderByFields.length > 0) {
2346 query.append(WHERE_AND);
2347 }
2348
2349 for (int i = 0; i < orderByFields.length; i++) {
2350 query.append(_ORDER_BY_ENTITY_ALIAS);
2351 query.append(orderByFields[i]);
2352
2353 if ((i + 1) < orderByFields.length) {
2354 if (orderByComparator.isAscending() ^ previous) {
2355 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2356 }
2357 else {
2358 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2359 }
2360 }
2361 else {
2362 if (orderByComparator.isAscending() ^ previous) {
2363 query.append(WHERE_GREATER_THAN);
2364 }
2365 else {
2366 query.append(WHERE_LESSER_THAN);
2367 }
2368 }
2369 }
2370
2371 query.append(ORDER_BY_CLAUSE);
2372
2373 for (int i = 0; i < orderByFields.length; i++) {
2374 query.append(_ORDER_BY_ENTITY_ALIAS);
2375 query.append(orderByFields[i]);
2376
2377 if ((i + 1) < orderByFields.length) {
2378 if (orderByComparator.isAscending() ^ previous) {
2379 query.append(ORDER_BY_ASC_HAS_NEXT);
2380 }
2381 else {
2382 query.append(ORDER_BY_DESC_HAS_NEXT);
2383 }
2384 }
2385 else {
2386 if (orderByComparator.isAscending() ^ previous) {
2387 query.append(ORDER_BY_ASC);
2388 }
2389 else {
2390 query.append(ORDER_BY_DESC);
2391 }
2392 }
2393 }
2394 }
2395
2396 String sql = query.toString();
2397
2398 Query q = session.createQuery(sql);
2399
2400 q.setFirstResult(0);
2401 q.setMaxResults(2);
2402
2403 QueryPos qPos = QueryPos.getInstance(q);
2404
2405 qPos.add(groupId);
2406
2407 qPos.add(privateLayout);
2408
2409 if (articleId != null) {
2410 qPos.add(articleId);
2411 }
2412
2413 if (orderByComparator != null) {
2414 Object[] values = orderByComparator.getOrderByValues(journalContentSearch);
2415
2416 for (Object value : values) {
2417 qPos.add(value);
2418 }
2419 }
2420
2421 List<JournalContentSearch> list = q.list();
2422
2423 if (list.size() == 2) {
2424 return list.get(1);
2425 }
2426 else {
2427 return null;
2428 }
2429 }
2430
2431
2441 public List<JournalContentSearch> findByG_P_L_P(long groupId,
2442 boolean privateLayout, long layoutId, String portletId)
2443 throws SystemException {
2444 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
2445 QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2446 }
2447
2448
2464 public List<JournalContentSearch> findByG_P_L_P(long groupId,
2465 boolean privateLayout, long layoutId, String portletId, int start,
2466 int end) throws SystemException {
2467 return findByG_P_L_P(groupId, privateLayout, layoutId, portletId,
2468 start, end, null);
2469 }
2470
2471
2488 public List<JournalContentSearch> findByG_P_L_P(long groupId,
2489 boolean privateLayout, long layoutId, String portletId, int start,
2490 int end, OrderByComparator orderByComparator) throws SystemException {
2491 Object[] finderArgs = new Object[] {
2492 groupId, privateLayout, layoutId, portletId,
2493
2494 String.valueOf(start), String.valueOf(end),
2495 String.valueOf(orderByComparator)
2496 };
2497
2498 List<JournalContentSearch> list = (List<JournalContentSearch>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P_L_P,
2499 finderArgs, this);
2500
2501 if (list == null) {
2502 StringBundler query = null;
2503
2504 if (orderByComparator != null) {
2505 query = new StringBundler(6 +
2506 (orderByComparator.getOrderByFields().length * 3));
2507 }
2508 else {
2509 query = new StringBundler(5);
2510 }
2511
2512 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2513
2514 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
2515
2516 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
2517
2518 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
2519
2520 if (portletId == null) {
2521 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
2522 }
2523 else {
2524 if (portletId.equals(StringPool.BLANK)) {
2525 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
2526 }
2527 else {
2528 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
2529 }
2530 }
2531
2532 if (orderByComparator != null) {
2533 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2534 orderByComparator);
2535 }
2536
2537 String sql = query.toString();
2538
2539 Session session = null;
2540
2541 try {
2542 session = openSession();
2543
2544 Query q = session.createQuery(sql);
2545
2546 QueryPos qPos = QueryPos.getInstance(q);
2547
2548 qPos.add(groupId);
2549
2550 qPos.add(privateLayout);
2551
2552 qPos.add(layoutId);
2553
2554 if (portletId != null) {
2555 qPos.add(portletId);
2556 }
2557
2558 list = (List<JournalContentSearch>)QueryUtil.list(q,
2559 getDialect(), start, end);
2560 }
2561 catch (Exception e) {
2562 throw processException(e);
2563 }
2564 finally {
2565 if (list == null) {
2566 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_G_P_L_P,
2567 finderArgs);
2568 }
2569 else {
2570 cacheResult(list);
2571
2572 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P_L_P,
2573 finderArgs, list);
2574 }
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 StringBundler query = new StringBundler(6);
2953
2954 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH_WHERE);
2955
2956 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
2957
2958 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
2959
2960 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
2961
2962 if (portletId == null) {
2963 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
2964 }
2965 else {
2966 if (portletId.equals(StringPool.BLANK)) {
2967 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
2968 }
2969 else {
2970 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
2971 }
2972 }
2973
2974 if (articleId == null) {
2975 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
2976 }
2977 else {
2978 if (articleId.equals(StringPool.BLANK)) {
2979 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
2980 }
2981 else {
2982 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
2983 }
2984 }
2985
2986 String sql = query.toString();
2987
2988 Session session = null;
2989
2990 try {
2991 session = openSession();
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.removeResult(FINDER_PATH_FETCH_BY_G_P_L_P_A,
3048 finderArgs);
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 StringBundler query = null;
3116 String sql = null;
3117
3118 if (orderByComparator != null) {
3119 query = new StringBundler(2 +
3120 (orderByComparator.getOrderByFields().length * 3));
3121
3122 query.append(_SQL_SELECT_JOURNALCONTENTSEARCH);
3123
3124 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3125 orderByComparator);
3126
3127 sql = query.toString();
3128 }
3129 else {
3130 sql = _SQL_SELECT_JOURNALCONTENTSEARCH;
3131 }
3132
3133 Session session = null;
3134
3135 try {
3136 session = openSession();
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 FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
3157 finderArgs);
3158 }
3159 else {
3160 cacheResult(list);
3161
3162 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
3163 list);
3164 }
3165
3166 closeSession(session);
3167 }
3168 }
3169
3170 return list;
3171 }
3172
3173
3179 public void removeByArticleId(String articleId) throws SystemException {
3180 for (JournalContentSearch journalContentSearch : findByArticleId(
3181 articleId)) {
3182 remove(journalContentSearch);
3183 }
3184 }
3185
3186
3193 public void removeByG_P(long groupId, boolean privateLayout)
3194 throws SystemException {
3195 for (JournalContentSearch journalContentSearch : findByG_P(groupId,
3196 privateLayout)) {
3197 remove(journalContentSearch);
3198 }
3199 }
3200
3201
3208 public void removeByG_A(long groupId, String articleId)
3209 throws SystemException {
3210 for (JournalContentSearch journalContentSearch : findByG_A(groupId,
3211 articleId)) {
3212 remove(journalContentSearch);
3213 }
3214 }
3215
3216
3224 public void removeByG_P_L(long groupId, boolean privateLayout, long layoutId)
3225 throws SystemException {
3226 for (JournalContentSearch journalContentSearch : findByG_P_L(groupId,
3227 privateLayout, layoutId)) {
3228 remove(journalContentSearch);
3229 }
3230 }
3231
3232
3240 public void removeByG_P_A(long groupId, boolean privateLayout,
3241 String articleId) throws SystemException {
3242 for (JournalContentSearch journalContentSearch : findByG_P_A(groupId,
3243 privateLayout, articleId)) {
3244 remove(journalContentSearch);
3245 }
3246 }
3247
3248
3257 public void removeByG_P_L_P(long groupId, boolean privateLayout,
3258 long layoutId, String portletId) throws SystemException {
3259 for (JournalContentSearch journalContentSearch : findByG_P_L_P(
3260 groupId, privateLayout, layoutId, portletId)) {
3261 remove(journalContentSearch);
3262 }
3263 }
3264
3265
3275 public void removeByG_P_L_P_A(long groupId, boolean privateLayout,
3276 long layoutId, String portletId, String articleId)
3277 throws NoSuchContentSearchException, SystemException {
3278 JournalContentSearch journalContentSearch = findByG_P_L_P_A(groupId,
3279 privateLayout, layoutId, portletId, articleId);
3280
3281 remove(journalContentSearch);
3282 }
3283
3284
3289 public void removeAll() throws SystemException {
3290 for (JournalContentSearch journalContentSearch : findAll()) {
3291 remove(journalContentSearch);
3292 }
3293 }
3294
3295
3302 public int countByArticleId(String articleId) throws SystemException {
3303 Object[] finderArgs = new Object[] { articleId };
3304
3305 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ARTICLEID,
3306 finderArgs, this);
3307
3308 if (count == null) {
3309 StringBundler query = new StringBundler(2);
3310
3311 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3312
3313 if (articleId == null) {
3314 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_1);
3315 }
3316 else {
3317 if (articleId.equals(StringPool.BLANK)) {
3318 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_3);
3319 }
3320 else {
3321 query.append(_FINDER_COLUMN_ARTICLEID_ARTICLEID_2);
3322 }
3323 }
3324
3325 String sql = query.toString();
3326
3327 Session session = null;
3328
3329 try {
3330 session = openSession();
3331
3332 Query q = session.createQuery(sql);
3333
3334 QueryPos qPos = QueryPos.getInstance(q);
3335
3336 if (articleId != null) {
3337 qPos.add(articleId);
3338 }
3339
3340 count = (Long)q.uniqueResult();
3341 }
3342 catch (Exception e) {
3343 throw processException(e);
3344 }
3345 finally {
3346 if (count == null) {
3347 count = Long.valueOf(0);
3348 }
3349
3350 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ARTICLEID,
3351 finderArgs, count);
3352
3353 closeSession(session);
3354 }
3355 }
3356
3357 return count.intValue();
3358 }
3359
3360
3368 public int countByG_P(long groupId, boolean privateLayout)
3369 throws SystemException {
3370 Object[] finderArgs = new Object[] { groupId, privateLayout };
3371
3372 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
3373 finderArgs, this);
3374
3375 if (count == null) {
3376 StringBundler query = new StringBundler(3);
3377
3378 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3379
3380 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3381
3382 query.append(_FINDER_COLUMN_G_P_PRIVATELAYOUT_2);
3383
3384 String sql = query.toString();
3385
3386 Session session = null;
3387
3388 try {
3389 session = openSession();
3390
3391 Query q = session.createQuery(sql);
3392
3393 QueryPos qPos = QueryPos.getInstance(q);
3394
3395 qPos.add(groupId);
3396
3397 qPos.add(privateLayout);
3398
3399 count = (Long)q.uniqueResult();
3400 }
3401 catch (Exception e) {
3402 throw processException(e);
3403 }
3404 finally {
3405 if (count == null) {
3406 count = Long.valueOf(0);
3407 }
3408
3409 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
3410 count);
3411
3412 closeSession(session);
3413 }
3414 }
3415
3416 return count.intValue();
3417 }
3418
3419
3427 public int countByG_A(long groupId, String articleId)
3428 throws SystemException {
3429 Object[] finderArgs = new Object[] { groupId, articleId };
3430
3431 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_A,
3432 finderArgs, this);
3433
3434 if (count == null) {
3435 StringBundler query = new StringBundler(3);
3436
3437 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3438
3439 query.append(_FINDER_COLUMN_G_A_GROUPID_2);
3440
3441 if (articleId == null) {
3442 query.append(_FINDER_COLUMN_G_A_ARTICLEID_1);
3443 }
3444 else {
3445 if (articleId.equals(StringPool.BLANK)) {
3446 query.append(_FINDER_COLUMN_G_A_ARTICLEID_3);
3447 }
3448 else {
3449 query.append(_FINDER_COLUMN_G_A_ARTICLEID_2);
3450 }
3451 }
3452
3453 String sql = query.toString();
3454
3455 Session session = null;
3456
3457 try {
3458 session = openSession();
3459
3460 Query q = session.createQuery(sql);
3461
3462 QueryPos qPos = QueryPos.getInstance(q);
3463
3464 qPos.add(groupId);
3465
3466 if (articleId != null) {
3467 qPos.add(articleId);
3468 }
3469
3470 count = (Long)q.uniqueResult();
3471 }
3472 catch (Exception e) {
3473 throw processException(e);
3474 }
3475 finally {
3476 if (count == null) {
3477 count = Long.valueOf(0);
3478 }
3479
3480 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_A, finderArgs,
3481 count);
3482
3483 closeSession(session);
3484 }
3485 }
3486
3487 return count.intValue();
3488 }
3489
3490
3499 public int countByG_P_L(long groupId, boolean privateLayout, long layoutId)
3500 throws SystemException {
3501 Object[] finderArgs = new Object[] { groupId, privateLayout, layoutId };
3502
3503 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L,
3504 finderArgs, this);
3505
3506 if (count == null) {
3507 StringBundler query = new StringBundler(4);
3508
3509 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3510
3511 query.append(_FINDER_COLUMN_G_P_L_GROUPID_2);
3512
3513 query.append(_FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2);
3514
3515 query.append(_FINDER_COLUMN_G_P_L_LAYOUTID_2);
3516
3517 String sql = query.toString();
3518
3519 Session session = null;
3520
3521 try {
3522 session = openSession();
3523
3524 Query q = session.createQuery(sql);
3525
3526 QueryPos qPos = QueryPos.getInstance(q);
3527
3528 qPos.add(groupId);
3529
3530 qPos.add(privateLayout);
3531
3532 qPos.add(layoutId);
3533
3534 count = (Long)q.uniqueResult();
3535 }
3536 catch (Exception e) {
3537 throw processException(e);
3538 }
3539 finally {
3540 if (count == null) {
3541 count = Long.valueOf(0);
3542 }
3543
3544 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L,
3545 finderArgs, count);
3546
3547 closeSession(session);
3548 }
3549 }
3550
3551 return count.intValue();
3552 }
3553
3554
3563 public int countByG_P_A(long groupId, boolean privateLayout,
3564 String articleId) throws SystemException {
3565 Object[] finderArgs = new Object[] { groupId, privateLayout, articleId };
3566
3567 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_A,
3568 finderArgs, this);
3569
3570 if (count == null) {
3571 StringBundler query = new StringBundler(4);
3572
3573 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3574
3575 query.append(_FINDER_COLUMN_G_P_A_GROUPID_2);
3576
3577 query.append(_FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2);
3578
3579 if (articleId == null) {
3580 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_1);
3581 }
3582 else {
3583 if (articleId.equals(StringPool.BLANK)) {
3584 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_3);
3585 }
3586 else {
3587 query.append(_FINDER_COLUMN_G_P_A_ARTICLEID_2);
3588 }
3589 }
3590
3591 String sql = query.toString();
3592
3593 Session session = null;
3594
3595 try {
3596 session = openSession();
3597
3598 Query q = session.createQuery(sql);
3599
3600 QueryPos qPos = QueryPos.getInstance(q);
3601
3602 qPos.add(groupId);
3603
3604 qPos.add(privateLayout);
3605
3606 if (articleId != null) {
3607 qPos.add(articleId);
3608 }
3609
3610 count = (Long)q.uniqueResult();
3611 }
3612 catch (Exception e) {
3613 throw processException(e);
3614 }
3615 finally {
3616 if (count == null) {
3617 count = Long.valueOf(0);
3618 }
3619
3620 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_A,
3621 finderArgs, count);
3622
3623 closeSession(session);
3624 }
3625 }
3626
3627 return count.intValue();
3628 }
3629
3630
3640 public int countByG_P_L_P(long groupId, boolean privateLayout,
3641 long layoutId, String portletId) throws SystemException {
3642 Object[] finderArgs = new Object[] {
3643 groupId, privateLayout, layoutId, portletId
3644 };
3645
3646 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L_P,
3647 finderArgs, this);
3648
3649 if (count == null) {
3650 StringBundler query = new StringBundler(5);
3651
3652 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3653
3654 query.append(_FINDER_COLUMN_G_P_L_P_GROUPID_2);
3655
3656 query.append(_FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2);
3657
3658 query.append(_FINDER_COLUMN_G_P_L_P_LAYOUTID_2);
3659
3660 if (portletId == null) {
3661 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_1);
3662 }
3663 else {
3664 if (portletId.equals(StringPool.BLANK)) {
3665 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_3);
3666 }
3667 else {
3668 query.append(_FINDER_COLUMN_G_P_L_P_PORTLETID_2);
3669 }
3670 }
3671
3672 String sql = query.toString();
3673
3674 Session session = null;
3675
3676 try {
3677 session = openSession();
3678
3679 Query q = session.createQuery(sql);
3680
3681 QueryPos qPos = QueryPos.getInstance(q);
3682
3683 qPos.add(groupId);
3684
3685 qPos.add(privateLayout);
3686
3687 qPos.add(layoutId);
3688
3689 if (portletId != null) {
3690 qPos.add(portletId);
3691 }
3692
3693 count = (Long)q.uniqueResult();
3694 }
3695 catch (Exception e) {
3696 throw processException(e);
3697 }
3698 finally {
3699 if (count == null) {
3700 count = Long.valueOf(0);
3701 }
3702
3703 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P,
3704 finderArgs, count);
3705
3706 closeSession(session);
3707 }
3708 }
3709
3710 return count.intValue();
3711 }
3712
3713
3724 public int countByG_P_L_P_A(long groupId, boolean privateLayout,
3725 long layoutId, String portletId, String articleId)
3726 throws SystemException {
3727 Object[] finderArgs = new Object[] {
3728 groupId, privateLayout, layoutId, portletId, articleId
3729 };
3730
3731 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
3732 finderArgs, this);
3733
3734 if (count == null) {
3735 StringBundler query = new StringBundler(6);
3736
3737 query.append(_SQL_COUNT_JOURNALCONTENTSEARCH_WHERE);
3738
3739 query.append(_FINDER_COLUMN_G_P_L_P_A_GROUPID_2);
3740
3741 query.append(_FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2);
3742
3743 query.append(_FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2);
3744
3745 if (portletId == null) {
3746 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_1);
3747 }
3748 else {
3749 if (portletId.equals(StringPool.BLANK)) {
3750 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_3);
3751 }
3752 else {
3753 query.append(_FINDER_COLUMN_G_P_L_P_A_PORTLETID_2);
3754 }
3755 }
3756
3757 if (articleId == null) {
3758 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1);
3759 }
3760 else {
3761 if (articleId.equals(StringPool.BLANK)) {
3762 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3);
3763 }
3764 else {
3765 query.append(_FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2);
3766 }
3767 }
3768
3769 String sql = query.toString();
3770
3771 Session session = null;
3772
3773 try {
3774 session = openSession();
3775
3776 Query q = session.createQuery(sql);
3777
3778 QueryPos qPos = QueryPos.getInstance(q);
3779
3780 qPos.add(groupId);
3781
3782 qPos.add(privateLayout);
3783
3784 qPos.add(layoutId);
3785
3786 if (portletId != null) {
3787 qPos.add(portletId);
3788 }
3789
3790 if (articleId != null) {
3791 qPos.add(articleId);
3792 }
3793
3794 count = (Long)q.uniqueResult();
3795 }
3796 catch (Exception e) {
3797 throw processException(e);
3798 }
3799 finally {
3800 if (count == null) {
3801 count = Long.valueOf(0);
3802 }
3803
3804 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P_L_P_A,
3805 finderArgs, count);
3806
3807 closeSession(session);
3808 }
3809 }
3810
3811 return count.intValue();
3812 }
3813
3814
3820 public int countAll() throws SystemException {
3821 Object[] finderArgs = new Object[0];
3822
3823 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3824 finderArgs, this);
3825
3826 if (count == null) {
3827 Session session = null;
3828
3829 try {
3830 session = openSession();
3831
3832 Query q = session.createQuery(_SQL_COUNT_JOURNALCONTENTSEARCH);
3833
3834 count = (Long)q.uniqueResult();
3835 }
3836 catch (Exception e) {
3837 throw processException(e);
3838 }
3839 finally {
3840 if (count == null) {
3841 count = Long.valueOf(0);
3842 }
3843
3844 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3845 count);
3846
3847 closeSession(session);
3848 }
3849 }
3850
3851 return count.intValue();
3852 }
3853
3854
3857 public void afterPropertiesSet() {
3858 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3859 com.liferay.portal.util.PropsUtil.get(
3860 "value.object.listener.com.liferay.portlet.journal.model.JournalContentSearch")));
3861
3862 if (listenerClassNames.length > 0) {
3863 try {
3864 List<ModelListener<JournalContentSearch>> listenersList = new ArrayList<ModelListener<JournalContentSearch>>();
3865
3866 for (String listenerClassName : listenerClassNames) {
3867 listenersList.add((ModelListener<JournalContentSearch>)InstanceFactory.newInstance(
3868 listenerClassName));
3869 }
3870
3871 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3872 }
3873 catch (Exception e) {
3874 _log.error(e);
3875 }
3876 }
3877 }
3878
3879 public void destroy() {
3880 EntityCacheUtil.removeCache(JournalContentSearchImpl.class.getName());
3881 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3882 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
3883 }
3884
3885 @BeanReference(type = JournalArticlePersistence.class)
3886 protected JournalArticlePersistence journalArticlePersistence;
3887 @BeanReference(type = JournalArticleImagePersistence.class)
3888 protected JournalArticleImagePersistence journalArticleImagePersistence;
3889 @BeanReference(type = JournalArticleResourcePersistence.class)
3890 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
3891 @BeanReference(type = JournalContentSearchPersistence.class)
3892 protected JournalContentSearchPersistence journalContentSearchPersistence;
3893 @BeanReference(type = JournalFeedPersistence.class)
3894 protected JournalFeedPersistence journalFeedPersistence;
3895 @BeanReference(type = JournalStructurePersistence.class)
3896 protected JournalStructurePersistence journalStructurePersistence;
3897 @BeanReference(type = JournalTemplatePersistence.class)
3898 protected JournalTemplatePersistence journalTemplatePersistence;
3899 @BeanReference(type = GroupPersistence.class)
3900 protected GroupPersistence groupPersistence;
3901 @BeanReference(type = LayoutPersistence.class)
3902 protected LayoutPersistence layoutPersistence;
3903 @BeanReference(type = PortletPreferencesPersistence.class)
3904 protected PortletPreferencesPersistence portletPreferencesPersistence;
3905 @BeanReference(type = ResourcePersistence.class)
3906 protected ResourcePersistence resourcePersistence;
3907 @BeanReference(type = UserPersistence.class)
3908 protected UserPersistence userPersistence;
3909 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch";
3910 private static final String _SQL_SELECT_JOURNALCONTENTSEARCH_WHERE = "SELECT journalContentSearch FROM JournalContentSearch journalContentSearch WHERE ";
3911 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch";
3912 private static final String _SQL_COUNT_JOURNALCONTENTSEARCH_WHERE = "SELECT COUNT(journalContentSearch) FROM JournalContentSearch journalContentSearch WHERE ";
3913 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3914 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3915 private static final String _FINDER_COLUMN_ARTICLEID_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3916 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3917 private static final String _FINDER_COLUMN_G_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ?";
3918 private static final String _FINDER_COLUMN_G_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3919 private static final String _FINDER_COLUMN_G_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3920 private static final String _FINDER_COLUMN_G_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3921 private static final String _FINDER_COLUMN_G_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3922 private static final String _FINDER_COLUMN_G_P_L_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3923 private static final String _FINDER_COLUMN_G_P_L_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3924 private static final String _FINDER_COLUMN_G_P_L_LAYOUTID_2 = "journalContentSearch.layoutId = ?";
3925 private static final String _FINDER_COLUMN_G_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3926 private static final String _FINDER_COLUMN_G_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3927 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3928 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3929 private static final String _FINDER_COLUMN_G_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3930 private static final String _FINDER_COLUMN_G_P_L_P_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3931 private static final String _FINDER_COLUMN_G_P_L_P_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3932 private static final String _FINDER_COLUMN_G_P_L_P_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
3933 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_1 = "journalContentSearch.portletId IS NULL";
3934 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_2 = "journalContentSearch.portletId = ?";
3935 private static final String _FINDER_COLUMN_G_P_L_P_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?)";
3936 private static final String _FINDER_COLUMN_G_P_L_P_A_GROUPID_2 = "journalContentSearch.groupId = ? AND ";
3937 private static final String _FINDER_COLUMN_G_P_L_P_A_PRIVATELAYOUT_2 = "journalContentSearch.privateLayout = ? AND ";
3938 private static final String _FINDER_COLUMN_G_P_L_P_A_LAYOUTID_2 = "journalContentSearch.layoutId = ? AND ";
3939 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_1 = "journalContentSearch.portletId IS NULL AND ";
3940 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_2 = "journalContentSearch.portletId = ? AND ";
3941 private static final String _FINDER_COLUMN_G_P_L_P_A_PORTLETID_3 = "(journalContentSearch.portletId IS NULL OR journalContentSearch.portletId = ?) AND ";
3942 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_1 = "journalContentSearch.articleId IS NULL";
3943 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_2 = "journalContentSearch.articleId = ?";
3944 private static final String _FINDER_COLUMN_G_P_L_P_A_ARTICLEID_3 = "(journalContentSearch.articleId IS NULL OR journalContentSearch.articleId = ?)";
3945 private static final String _ORDER_BY_ENTITY_ALIAS = "journalContentSearch.";
3946 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalContentSearch exists with the primary key ";
3947 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalContentSearch exists with the key {";
3948 private static Log _log = LogFactoryUtil.getLog(JournalContentSearchPersistenceImpl.class);
3949 }