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