1
22
23 package com.liferay.portlet.journal.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.annotation.BeanReference;
27 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
28 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
29 import com.liferay.portal.kernel.dao.orm.Query;
30 import com.liferay.portal.kernel.dao.orm.QueryPos;
31 import com.liferay.portal.kernel.dao.orm.QueryUtil;
32 import com.liferay.portal.kernel.dao.orm.Session;
33 import com.liferay.portal.kernel.log.Log;
34 import com.liferay.portal.kernel.log.LogFactoryUtil;
35 import com.liferay.portal.kernel.util.GetterUtil;
36 import com.liferay.portal.kernel.util.OrderByComparator;
37 import com.liferay.portal.kernel.util.StringPool;
38 import com.liferay.portal.kernel.util.StringUtil;
39 import com.liferay.portal.kernel.util.Validator;
40 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
41 import com.liferay.portal.model.ModelListener;
42 import com.liferay.portal.service.persistence.BatchSessionUtil;
43 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
44
45 import com.liferay.portlet.journal.NoSuchFeedException;
46 import com.liferay.portlet.journal.model.JournalFeed;
47 import com.liferay.portlet.journal.model.impl.JournalFeedImpl;
48 import com.liferay.portlet.journal.model.impl.JournalFeedModelImpl;
49
50 import java.util.ArrayList;
51 import java.util.Collections;
52 import java.util.Iterator;
53 import java.util.List;
54
55
61 public class JournalFeedPersistenceImpl extends BasePersistenceImpl
62 implements JournalFeedPersistence {
63 public JournalFeed create(long id) {
64 JournalFeed journalFeed = new JournalFeedImpl();
65
66 journalFeed.setNew(true);
67 journalFeed.setPrimaryKey(id);
68
69 String uuid = PortalUUIDUtil.generate();
70
71 journalFeed.setUuid(uuid);
72
73 return journalFeed;
74 }
75
76 public JournalFeed remove(long id)
77 throws NoSuchFeedException, SystemException {
78 Session session = null;
79
80 try {
81 session = openSession();
82
83 JournalFeed journalFeed = (JournalFeed)session.get(JournalFeedImpl.class,
84 new Long(id));
85
86 if (journalFeed == null) {
87 if (_log.isWarnEnabled()) {
88 _log.warn("No JournalFeed exists with the primary key " +
89 id);
90 }
91
92 throw new NoSuchFeedException(
93 "No JournalFeed exists with the primary key " + id);
94 }
95
96 return remove(journalFeed);
97 }
98 catch (NoSuchFeedException nsee) {
99 throw nsee;
100 }
101 catch (Exception e) {
102 throw processException(e);
103 }
104 finally {
105 closeSession(session);
106 }
107 }
108
109 public JournalFeed remove(JournalFeed journalFeed)
110 throws SystemException {
111 for (ModelListener listener : listeners) {
112 listener.onBeforeRemove(journalFeed);
113 }
114
115 journalFeed = removeImpl(journalFeed);
116
117 for (ModelListener listener : listeners) {
118 listener.onAfterRemove(journalFeed);
119 }
120
121 return journalFeed;
122 }
123
124 protected JournalFeed removeImpl(JournalFeed journalFeed)
125 throws SystemException {
126 Session session = null;
127
128 try {
129 session = openSession();
130
131 if (BatchSessionUtil.isEnabled()) {
132 Object staleObject = session.get(JournalFeedImpl.class,
133 journalFeed.getPrimaryKeyObj());
134
135 if (staleObject != null) {
136 session.evict(staleObject);
137 }
138 }
139
140 session.delete(journalFeed);
141
142 session.flush();
143
144 return journalFeed;
145 }
146 catch (Exception e) {
147 throw processException(e);
148 }
149 finally {
150 closeSession(session);
151
152 FinderCacheUtil.clearCache(JournalFeed.class.getName());
153 }
154 }
155
156
159 public JournalFeed update(JournalFeed journalFeed)
160 throws SystemException {
161 if (_log.isWarnEnabled()) {
162 _log.warn(
163 "Using the deprecated update(JournalFeed journalFeed) method. Use update(JournalFeed journalFeed, boolean merge) instead.");
164 }
165
166 return update(journalFeed, false);
167 }
168
169
182 public JournalFeed update(JournalFeed journalFeed, boolean merge)
183 throws SystemException {
184 boolean isNew = journalFeed.isNew();
185
186 for (ModelListener listener : listeners) {
187 if (isNew) {
188 listener.onBeforeCreate(journalFeed);
189 }
190 else {
191 listener.onBeforeUpdate(journalFeed);
192 }
193 }
194
195 journalFeed = updateImpl(journalFeed, merge);
196
197 for (ModelListener listener : listeners) {
198 if (isNew) {
199 listener.onAfterCreate(journalFeed);
200 }
201 else {
202 listener.onAfterUpdate(journalFeed);
203 }
204 }
205
206 return journalFeed;
207 }
208
209 public JournalFeed updateImpl(
210 com.liferay.portlet.journal.model.JournalFeed journalFeed, boolean merge)
211 throws SystemException {
212 if (Validator.isNull(journalFeed.getUuid())) {
213 String uuid = PortalUUIDUtil.generate();
214
215 journalFeed.setUuid(uuid);
216 }
217
218 Session session = null;
219
220 try {
221 session = openSession();
222
223 BatchSessionUtil.update(session, journalFeed, merge);
224
225 journalFeed.setNew(false);
226
227 return journalFeed;
228 }
229 catch (Exception e) {
230 throw processException(e);
231 }
232 finally {
233 closeSession(session);
234
235 FinderCacheUtil.clearCache(JournalFeed.class.getName());
236 }
237 }
238
239 public JournalFeed findByPrimaryKey(long id)
240 throws NoSuchFeedException, SystemException {
241 JournalFeed journalFeed = fetchByPrimaryKey(id);
242
243 if (journalFeed == null) {
244 if (_log.isWarnEnabled()) {
245 _log.warn("No JournalFeed exists with the primary key " + id);
246 }
247
248 throw new NoSuchFeedException(
249 "No JournalFeed exists with the primary key " + id);
250 }
251
252 return journalFeed;
253 }
254
255 public JournalFeed fetchByPrimaryKey(long id) throws SystemException {
256 Session session = null;
257
258 try {
259 session = openSession();
260
261 return (JournalFeed)session.get(JournalFeedImpl.class, new Long(id));
262 }
263 catch (Exception e) {
264 throw processException(e);
265 }
266 finally {
267 closeSession(session);
268 }
269 }
270
271 public List<JournalFeed> findByUuid(String uuid) throws SystemException {
272 boolean finderClassNameCacheEnabled = JournalFeedModelImpl.CACHE_ENABLED;
273 String finderClassName = JournalFeed.class.getName();
274 String finderMethodName = "findByUuid";
275 String[] finderParams = new String[] { String.class.getName() };
276 Object[] finderArgs = new Object[] { uuid };
277
278 Object result = null;
279
280 if (finderClassNameCacheEnabled) {
281 result = FinderCacheUtil.getResult(finderClassName,
282 finderMethodName, finderParams, finderArgs, this);
283 }
284
285 if (result == null) {
286 Session session = null;
287
288 try {
289 session = openSession();
290
291 StringBuilder query = new StringBuilder();
292
293 query.append(
294 "FROM com.liferay.portlet.journal.model.JournalFeed WHERE ");
295
296 if (uuid == null) {
297 query.append("uuid_ IS NULL");
298 }
299 else {
300 query.append("uuid_ = ?");
301 }
302
303 query.append(" ");
304
305 query.append("ORDER BY ");
306
307 query.append("feedId ASC");
308
309 Query q = session.createQuery(query.toString());
310
311 QueryPos qPos = QueryPos.getInstance(q);
312
313 if (uuid != null) {
314 qPos.add(uuid);
315 }
316
317 List<JournalFeed> list = q.list();
318
319 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
320 finderClassName, finderMethodName, finderParams,
321 finderArgs, list);
322
323 return list;
324 }
325 catch (Exception e) {
326 throw processException(e);
327 }
328 finally {
329 closeSession(session);
330 }
331 }
332 else {
333 return (List<JournalFeed>)result;
334 }
335 }
336
337 public List<JournalFeed> findByUuid(String uuid, int start, int end)
338 throws SystemException {
339 return findByUuid(uuid, start, end, null);
340 }
341
342 public List<JournalFeed> findByUuid(String uuid, int start, int end,
343 OrderByComparator obc) throws SystemException {
344 boolean finderClassNameCacheEnabled = JournalFeedModelImpl.CACHE_ENABLED;
345 String finderClassName = JournalFeed.class.getName();
346 String finderMethodName = "findByUuid";
347 String[] finderParams = new String[] {
348 String.class.getName(),
349
350 "java.lang.Integer", "java.lang.Integer",
351 "com.liferay.portal.kernel.util.OrderByComparator"
352 };
353 Object[] finderArgs = new Object[] {
354 uuid,
355
356 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
357 };
358
359 Object result = null;
360
361 if (finderClassNameCacheEnabled) {
362 result = FinderCacheUtil.getResult(finderClassName,
363 finderMethodName, finderParams, finderArgs, this);
364 }
365
366 if (result == null) {
367 Session session = null;
368
369 try {
370 session = openSession();
371
372 StringBuilder query = new StringBuilder();
373
374 query.append(
375 "FROM com.liferay.portlet.journal.model.JournalFeed WHERE ");
376
377 if (uuid == null) {
378 query.append("uuid_ IS NULL");
379 }
380 else {
381 query.append("uuid_ = ?");
382 }
383
384 query.append(" ");
385
386 if (obc != null) {
387 query.append("ORDER BY ");
388 query.append(obc.getOrderBy());
389 }
390
391 else {
392 query.append("ORDER BY ");
393
394 query.append("feedId ASC");
395 }
396
397 Query q = session.createQuery(query.toString());
398
399 QueryPos qPos = QueryPos.getInstance(q);
400
401 if (uuid != null) {
402 qPos.add(uuid);
403 }
404
405 List<JournalFeed> list = (List<JournalFeed>)QueryUtil.list(q,
406 getDialect(), start, end);
407
408 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
409 finderClassName, finderMethodName, finderParams,
410 finderArgs, list);
411
412 return list;
413 }
414 catch (Exception e) {
415 throw processException(e);
416 }
417 finally {
418 closeSession(session);
419 }
420 }
421 else {
422 return (List<JournalFeed>)result;
423 }
424 }
425
426 public JournalFeed findByUuid_First(String uuid, OrderByComparator obc)
427 throws NoSuchFeedException, SystemException {
428 List<JournalFeed> list = findByUuid(uuid, 0, 1, obc);
429
430 if (list.size() == 0) {
431 StringBuilder msg = new StringBuilder();
432
433 msg.append("No JournalFeed exists with the key {");
434
435 msg.append("uuid=" + uuid);
436
437 msg.append(StringPool.CLOSE_CURLY_BRACE);
438
439 throw new NoSuchFeedException(msg.toString());
440 }
441 else {
442 return list.get(0);
443 }
444 }
445
446 public JournalFeed findByUuid_Last(String uuid, OrderByComparator obc)
447 throws NoSuchFeedException, SystemException {
448 int count = countByUuid(uuid);
449
450 List<JournalFeed> list = findByUuid(uuid, count - 1, count, obc);
451
452 if (list.size() == 0) {
453 StringBuilder msg = new StringBuilder();
454
455 msg.append("No JournalFeed exists with the key {");
456
457 msg.append("uuid=" + uuid);
458
459 msg.append(StringPool.CLOSE_CURLY_BRACE);
460
461 throw new NoSuchFeedException(msg.toString());
462 }
463 else {
464 return list.get(0);
465 }
466 }
467
468 public JournalFeed[] findByUuid_PrevAndNext(long id, String uuid,
469 OrderByComparator obc) throws NoSuchFeedException, SystemException {
470 JournalFeed journalFeed = findByPrimaryKey(id);
471
472 int count = countByUuid(uuid);
473
474 Session session = null;
475
476 try {
477 session = openSession();
478
479 StringBuilder query = new StringBuilder();
480
481 query.append(
482 "FROM com.liferay.portlet.journal.model.JournalFeed WHERE ");
483
484 if (uuid == null) {
485 query.append("uuid_ IS NULL");
486 }
487 else {
488 query.append("uuid_ = ?");
489 }
490
491 query.append(" ");
492
493 if (obc != null) {
494 query.append("ORDER BY ");
495 query.append(obc.getOrderBy());
496 }
497
498 else {
499 query.append("ORDER BY ");
500
501 query.append("feedId ASC");
502 }
503
504 Query q = session.createQuery(query.toString());
505
506 QueryPos qPos = QueryPos.getInstance(q);
507
508 if (uuid != null) {
509 qPos.add(uuid);
510 }
511
512 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
513 journalFeed);
514
515 JournalFeed[] array = new JournalFeedImpl[3];
516
517 array[0] = (JournalFeed)objArray[0];
518 array[1] = (JournalFeed)objArray[1];
519 array[2] = (JournalFeed)objArray[2];
520
521 return array;
522 }
523 catch (Exception e) {
524 throw processException(e);
525 }
526 finally {
527 closeSession(session);
528 }
529 }
530
531 public JournalFeed findByUUID_G(String uuid, long groupId)
532 throws NoSuchFeedException, SystemException {
533 JournalFeed journalFeed = fetchByUUID_G(uuid, groupId);
534
535 if (journalFeed == null) {
536 StringBuilder msg = new StringBuilder();
537
538 msg.append("No JournalFeed exists with the key {");
539
540 msg.append("uuid=" + uuid);
541
542 msg.append(", ");
543 msg.append("groupId=" + groupId);
544
545 msg.append(StringPool.CLOSE_CURLY_BRACE);
546
547 if (_log.isWarnEnabled()) {
548 _log.warn(msg.toString());
549 }
550
551 throw new NoSuchFeedException(msg.toString());
552 }
553
554 return journalFeed;
555 }
556
557 public JournalFeed fetchByUUID_G(String uuid, long groupId)
558 throws SystemException {
559 boolean finderClassNameCacheEnabled = JournalFeedModelImpl.CACHE_ENABLED;
560 String finderClassName = JournalFeed.class.getName();
561 String finderMethodName = "fetchByUUID_G";
562 String[] finderParams = new String[] {
563 String.class.getName(), Long.class.getName()
564 };
565 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
566
567 Object result = null;
568
569 if (finderClassNameCacheEnabled) {
570 result = FinderCacheUtil.getResult(finderClassName,
571 finderMethodName, finderParams, finderArgs, this);
572 }
573
574 if (result == null) {
575 Session session = null;
576
577 try {
578 session = openSession();
579
580 StringBuilder query = new StringBuilder();
581
582 query.append(
583 "FROM com.liferay.portlet.journal.model.JournalFeed WHERE ");
584
585 if (uuid == null) {
586 query.append("uuid_ IS NULL");
587 }
588 else {
589 query.append("uuid_ = ?");
590 }
591
592 query.append(" AND ");
593
594 query.append("groupId = ?");
595
596 query.append(" ");
597
598 query.append("ORDER BY ");
599
600 query.append("feedId ASC");
601
602 Query q = session.createQuery(query.toString());
603
604 QueryPos qPos = QueryPos.getInstance(q);
605
606 if (uuid != null) {
607 qPos.add(uuid);
608 }
609
610 qPos.add(groupId);
611
612 List<JournalFeed> list = q.list();
613
614 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
615 finderClassName, finderMethodName, finderParams,
616 finderArgs, list);
617
618 if (list.size() == 0) {
619 return null;
620 }
621 else {
622 return list.get(0);
623 }
624 }
625 catch (Exception e) {
626 throw processException(e);
627 }
628 finally {
629 closeSession(session);
630 }
631 }
632 else {
633 List<JournalFeed> list = (List<JournalFeed>)result;
634
635 if (list.size() == 0) {
636 return null;
637 }
638 else {
639 return list.get(0);
640 }
641 }
642 }
643
644 public List<JournalFeed> findByGroupId(long groupId)
645 throws SystemException {
646 boolean finderClassNameCacheEnabled = JournalFeedModelImpl.CACHE_ENABLED;
647 String finderClassName = JournalFeed.class.getName();
648 String finderMethodName = "findByGroupId";
649 String[] finderParams = new String[] { Long.class.getName() };
650 Object[] finderArgs = new Object[] { new Long(groupId) };
651
652 Object result = null;
653
654 if (finderClassNameCacheEnabled) {
655 result = FinderCacheUtil.getResult(finderClassName,
656 finderMethodName, finderParams, finderArgs, this);
657 }
658
659 if (result == null) {
660 Session session = null;
661
662 try {
663 session = openSession();
664
665 StringBuilder query = new StringBuilder();
666
667 query.append(
668 "FROM com.liferay.portlet.journal.model.JournalFeed WHERE ");
669
670 query.append("groupId = ?");
671
672 query.append(" ");
673
674 query.append("ORDER BY ");
675
676 query.append("feedId ASC");
677
678 Query q = session.createQuery(query.toString());
679
680 QueryPos qPos = QueryPos.getInstance(q);
681
682 qPos.add(groupId);
683
684 List<JournalFeed> list = q.list();
685
686 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
687 finderClassName, finderMethodName, finderParams,
688 finderArgs, list);
689
690 return list;
691 }
692 catch (Exception e) {
693 throw processException(e);
694 }
695 finally {
696 closeSession(session);
697 }
698 }
699 else {
700 return (List<JournalFeed>)result;
701 }
702 }
703
704 public List<JournalFeed> findByGroupId(long groupId, int start, int end)
705 throws SystemException {
706 return findByGroupId(groupId, start, end, null);
707 }
708
709 public List<JournalFeed> findByGroupId(long groupId, int start, int end,
710 OrderByComparator obc) throws SystemException {
711 boolean finderClassNameCacheEnabled = JournalFeedModelImpl.CACHE_ENABLED;
712 String finderClassName = JournalFeed.class.getName();
713 String finderMethodName = "findByGroupId";
714 String[] finderParams = new String[] {
715 Long.class.getName(),
716
717 "java.lang.Integer", "java.lang.Integer",
718 "com.liferay.portal.kernel.util.OrderByComparator"
719 };
720 Object[] finderArgs = new Object[] {
721 new Long(groupId),
722
723 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
724 };
725
726 Object result = null;
727
728 if (finderClassNameCacheEnabled) {
729 result = FinderCacheUtil.getResult(finderClassName,
730 finderMethodName, finderParams, finderArgs, this);
731 }
732
733 if (result == null) {
734 Session session = null;
735
736 try {
737 session = openSession();
738
739 StringBuilder query = new StringBuilder();
740
741 query.append(
742 "FROM com.liferay.portlet.journal.model.JournalFeed WHERE ");
743
744 query.append("groupId = ?");
745
746 query.append(" ");
747
748 if (obc != null) {
749 query.append("ORDER BY ");
750 query.append(obc.getOrderBy());
751 }
752
753 else {
754 query.append("ORDER BY ");
755
756 query.append("feedId ASC");
757 }
758
759 Query q = session.createQuery(query.toString());
760
761 QueryPos qPos = QueryPos.getInstance(q);
762
763 qPos.add(groupId);
764
765 List<JournalFeed> list = (List<JournalFeed>)QueryUtil.list(q,
766 getDialect(), start, end);
767
768 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
769 finderClassName, finderMethodName, finderParams,
770 finderArgs, list);
771
772 return list;
773 }
774 catch (Exception e) {
775 throw processException(e);
776 }
777 finally {
778 closeSession(session);
779 }
780 }
781 else {
782 return (List<JournalFeed>)result;
783 }
784 }
785
786 public JournalFeed findByGroupId_First(long groupId, OrderByComparator obc)
787 throws NoSuchFeedException, SystemException {
788 List<JournalFeed> list = findByGroupId(groupId, 0, 1, obc);
789
790 if (list.size() == 0) {
791 StringBuilder msg = new StringBuilder();
792
793 msg.append("No JournalFeed exists with the key {");
794
795 msg.append("groupId=" + groupId);
796
797 msg.append(StringPool.CLOSE_CURLY_BRACE);
798
799 throw new NoSuchFeedException(msg.toString());
800 }
801 else {
802 return list.get(0);
803 }
804 }
805
806 public JournalFeed findByGroupId_Last(long groupId, OrderByComparator obc)
807 throws NoSuchFeedException, SystemException {
808 int count = countByGroupId(groupId);
809
810 List<JournalFeed> list = findByGroupId(groupId, count - 1, count, obc);
811
812 if (list.size() == 0) {
813 StringBuilder msg = new StringBuilder();
814
815 msg.append("No JournalFeed exists with the key {");
816
817 msg.append("groupId=" + groupId);
818
819 msg.append(StringPool.CLOSE_CURLY_BRACE);
820
821 throw new NoSuchFeedException(msg.toString());
822 }
823 else {
824 return list.get(0);
825 }
826 }
827
828 public JournalFeed[] findByGroupId_PrevAndNext(long id, long groupId,
829 OrderByComparator obc) throws NoSuchFeedException, SystemException {
830 JournalFeed journalFeed = findByPrimaryKey(id);
831
832 int count = countByGroupId(groupId);
833
834 Session session = null;
835
836 try {
837 session = openSession();
838
839 StringBuilder query = new StringBuilder();
840
841 query.append(
842 "FROM com.liferay.portlet.journal.model.JournalFeed WHERE ");
843
844 query.append("groupId = ?");
845
846 query.append(" ");
847
848 if (obc != null) {
849 query.append("ORDER BY ");
850 query.append(obc.getOrderBy());
851 }
852
853 else {
854 query.append("ORDER BY ");
855
856 query.append("feedId ASC");
857 }
858
859 Query q = session.createQuery(query.toString());
860
861 QueryPos qPos = QueryPos.getInstance(q);
862
863 qPos.add(groupId);
864
865 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
866 journalFeed);
867
868 JournalFeed[] array = new JournalFeedImpl[3];
869
870 array[0] = (JournalFeed)objArray[0];
871 array[1] = (JournalFeed)objArray[1];
872 array[2] = (JournalFeed)objArray[2];
873
874 return array;
875 }
876 catch (Exception e) {
877 throw processException(e);
878 }
879 finally {
880 closeSession(session);
881 }
882 }
883
884 public JournalFeed findByG_F(long groupId, String feedId)
885 throws NoSuchFeedException, SystemException {
886 JournalFeed journalFeed = fetchByG_F(groupId, feedId);
887
888 if (journalFeed == null) {
889 StringBuilder msg = new StringBuilder();
890
891 msg.append("No JournalFeed exists with the key {");
892
893 msg.append("groupId=" + groupId);
894
895 msg.append(", ");
896 msg.append("feedId=" + feedId);
897
898 msg.append(StringPool.CLOSE_CURLY_BRACE);
899
900 if (_log.isWarnEnabled()) {
901 _log.warn(msg.toString());
902 }
903
904 throw new NoSuchFeedException(msg.toString());
905 }
906
907 return journalFeed;
908 }
909
910 public JournalFeed fetchByG_F(long groupId, String feedId)
911 throws SystemException {
912 boolean finderClassNameCacheEnabled = JournalFeedModelImpl.CACHE_ENABLED;
913 String finderClassName = JournalFeed.class.getName();
914 String finderMethodName = "fetchByG_F";
915 String[] finderParams = new String[] {
916 Long.class.getName(), String.class.getName()
917 };
918 Object[] finderArgs = new Object[] { new Long(groupId), feedId };
919
920 Object result = null;
921
922 if (finderClassNameCacheEnabled) {
923 result = FinderCacheUtil.getResult(finderClassName,
924 finderMethodName, finderParams, finderArgs, this);
925 }
926
927 if (result == null) {
928 Session session = null;
929
930 try {
931 session = openSession();
932
933 StringBuilder query = new StringBuilder();
934
935 query.append(
936 "FROM com.liferay.portlet.journal.model.JournalFeed WHERE ");
937
938 query.append("groupId = ?");
939
940 query.append(" AND ");
941
942 if (feedId == null) {
943 query.append("feedId IS NULL");
944 }
945 else {
946 query.append("feedId = ?");
947 }
948
949 query.append(" ");
950
951 query.append("ORDER BY ");
952
953 query.append("feedId ASC");
954
955 Query q = session.createQuery(query.toString());
956
957 QueryPos qPos = QueryPos.getInstance(q);
958
959 qPos.add(groupId);
960
961 if (feedId != null) {
962 qPos.add(feedId);
963 }
964
965 List<JournalFeed> list = q.list();
966
967 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
968 finderClassName, finderMethodName, finderParams,
969 finderArgs, list);
970
971 if (list.size() == 0) {
972 return null;
973 }
974 else {
975 return list.get(0);
976 }
977 }
978 catch (Exception e) {
979 throw processException(e);
980 }
981 finally {
982 closeSession(session);
983 }
984 }
985 else {
986 List<JournalFeed> list = (List<JournalFeed>)result;
987
988 if (list.size() == 0) {
989 return null;
990 }
991 else {
992 return list.get(0);
993 }
994 }
995 }
996
997 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
998 throws SystemException {
999 Session session = null;
1000
1001 try {
1002 session = openSession();
1003
1004 dynamicQuery.compile(session);
1005
1006 return dynamicQuery.list();
1007 }
1008 catch (Exception e) {
1009 throw processException(e);
1010 }
1011 finally {
1012 closeSession(session);
1013 }
1014 }
1015
1016 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1017 int start, int end) throws SystemException {
1018 Session session = null;
1019
1020 try {
1021 session = openSession();
1022
1023 dynamicQuery.setLimit(start, end);
1024
1025 dynamicQuery.compile(session);
1026
1027 return dynamicQuery.list();
1028 }
1029 catch (Exception e) {
1030 throw processException(e);
1031 }
1032 finally {
1033 closeSession(session);
1034 }
1035 }
1036
1037 public List<JournalFeed> findAll() throws SystemException {
1038 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1039 }
1040
1041 public List<JournalFeed> findAll(int start, int end)
1042 throws SystemException {
1043 return findAll(start, end, null);
1044 }
1045
1046 public List<JournalFeed> findAll(int start, int end, OrderByComparator obc)
1047 throws SystemException {
1048 boolean finderClassNameCacheEnabled = JournalFeedModelImpl.CACHE_ENABLED;
1049 String finderClassName = JournalFeed.class.getName();
1050 String finderMethodName = "findAll";
1051 String[] finderParams = new String[] {
1052 "java.lang.Integer", "java.lang.Integer",
1053 "com.liferay.portal.kernel.util.OrderByComparator"
1054 };
1055 Object[] finderArgs = new Object[] {
1056 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1057 };
1058
1059 Object result = null;
1060
1061 if (finderClassNameCacheEnabled) {
1062 result = FinderCacheUtil.getResult(finderClassName,
1063 finderMethodName, finderParams, finderArgs, this);
1064 }
1065
1066 if (result == null) {
1067 Session session = null;
1068
1069 try {
1070 session = openSession();
1071
1072 StringBuilder query = new StringBuilder();
1073
1074 query.append(
1075 "FROM com.liferay.portlet.journal.model.JournalFeed ");
1076
1077 if (obc != null) {
1078 query.append("ORDER BY ");
1079 query.append(obc.getOrderBy());
1080 }
1081
1082 else {
1083 query.append("ORDER BY ");
1084
1085 query.append("feedId ASC");
1086 }
1087
1088 Query q = session.createQuery(query.toString());
1089
1090 List<JournalFeed> list = null;
1091
1092 if (obc == null) {
1093 list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
1094 start, end, false);
1095
1096 Collections.sort(list);
1097 }
1098 else {
1099 list = (List<JournalFeed>)QueryUtil.list(q, getDialect(),
1100 start, end);
1101 }
1102
1103 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1104 finderClassName, finderMethodName, finderParams,
1105 finderArgs, list);
1106
1107 return list;
1108 }
1109 catch (Exception e) {
1110 throw processException(e);
1111 }
1112 finally {
1113 closeSession(session);
1114 }
1115 }
1116 else {
1117 return (List<JournalFeed>)result;
1118 }
1119 }
1120
1121 public void removeByUuid(String uuid) throws SystemException {
1122 for (JournalFeed journalFeed : findByUuid(uuid)) {
1123 remove(journalFeed);
1124 }
1125 }
1126
1127 public void removeByUUID_G(String uuid, long groupId)
1128 throws NoSuchFeedException, SystemException {
1129 JournalFeed journalFeed = findByUUID_G(uuid, groupId);
1130
1131 remove(journalFeed);
1132 }
1133
1134 public void removeByGroupId(long groupId) throws SystemException {
1135 for (JournalFeed journalFeed : findByGroupId(groupId)) {
1136 remove(journalFeed);
1137 }
1138 }
1139
1140 public void removeByG_F(long groupId, String feedId)
1141 throws NoSuchFeedException, SystemException {
1142 JournalFeed journalFeed = findByG_F(groupId, feedId);
1143
1144 remove(journalFeed);
1145 }
1146
1147 public void removeAll() throws SystemException {
1148 for (JournalFeed journalFeed : findAll()) {
1149 remove(journalFeed);
1150 }
1151 }
1152
1153 public int countByUuid(String uuid) throws SystemException {
1154 boolean finderClassNameCacheEnabled = JournalFeedModelImpl.CACHE_ENABLED;
1155 String finderClassName = JournalFeed.class.getName();
1156 String finderMethodName = "countByUuid";
1157 String[] finderParams = new String[] { String.class.getName() };
1158 Object[] finderArgs = new Object[] { uuid };
1159
1160 Object result = null;
1161
1162 if (finderClassNameCacheEnabled) {
1163 result = FinderCacheUtil.getResult(finderClassName,
1164 finderMethodName, finderParams, finderArgs, this);
1165 }
1166
1167 if (result == null) {
1168 Session session = null;
1169
1170 try {
1171 session = openSession();
1172
1173 StringBuilder query = new StringBuilder();
1174
1175 query.append("SELECT COUNT(*) ");
1176 query.append(
1177 "FROM com.liferay.portlet.journal.model.JournalFeed WHERE ");
1178
1179 if (uuid == null) {
1180 query.append("uuid_ IS NULL");
1181 }
1182 else {
1183 query.append("uuid_ = ?");
1184 }
1185
1186 query.append(" ");
1187
1188 Query q = session.createQuery(query.toString());
1189
1190 QueryPos qPos = QueryPos.getInstance(q);
1191
1192 if (uuid != null) {
1193 qPos.add(uuid);
1194 }
1195
1196 Long count = null;
1197
1198 Iterator<Long> itr = q.list().iterator();
1199
1200 if (itr.hasNext()) {
1201 count = itr.next();
1202 }
1203
1204 if (count == null) {
1205 count = new Long(0);
1206 }
1207
1208 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1209 finderClassName, finderMethodName, finderParams,
1210 finderArgs, count);
1211
1212 return count.intValue();
1213 }
1214 catch (Exception e) {
1215 throw processException(e);
1216 }
1217 finally {
1218 closeSession(session);
1219 }
1220 }
1221 else {
1222 return ((Long)result).intValue();
1223 }
1224 }
1225
1226 public int countByUUID_G(String uuid, long groupId)
1227 throws SystemException {
1228 boolean finderClassNameCacheEnabled = JournalFeedModelImpl.CACHE_ENABLED;
1229 String finderClassName = JournalFeed.class.getName();
1230 String finderMethodName = "countByUUID_G";
1231 String[] finderParams = new String[] {
1232 String.class.getName(), Long.class.getName()
1233 };
1234 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1235
1236 Object result = null;
1237
1238 if (finderClassNameCacheEnabled) {
1239 result = FinderCacheUtil.getResult(finderClassName,
1240 finderMethodName, finderParams, finderArgs, this);
1241 }
1242
1243 if (result == null) {
1244 Session session = null;
1245
1246 try {
1247 session = openSession();
1248
1249 StringBuilder query = new StringBuilder();
1250
1251 query.append("SELECT COUNT(*) ");
1252 query.append(
1253 "FROM com.liferay.portlet.journal.model.JournalFeed WHERE ");
1254
1255 if (uuid == null) {
1256 query.append("uuid_ IS NULL");
1257 }
1258 else {
1259 query.append("uuid_ = ?");
1260 }
1261
1262 query.append(" AND ");
1263
1264 query.append("groupId = ?");
1265
1266 query.append(" ");
1267
1268 Query q = session.createQuery(query.toString());
1269
1270 QueryPos qPos = QueryPos.getInstance(q);
1271
1272 if (uuid != null) {
1273 qPos.add(uuid);
1274 }
1275
1276 qPos.add(groupId);
1277
1278 Long count = null;
1279
1280 Iterator<Long> itr = q.list().iterator();
1281
1282 if (itr.hasNext()) {
1283 count = itr.next();
1284 }
1285
1286 if (count == null) {
1287 count = new Long(0);
1288 }
1289
1290 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1291 finderClassName, finderMethodName, finderParams,
1292 finderArgs, count);
1293
1294 return count.intValue();
1295 }
1296 catch (Exception e) {
1297 throw processException(e);
1298 }
1299 finally {
1300 closeSession(session);
1301 }
1302 }
1303 else {
1304 return ((Long)result).intValue();
1305 }
1306 }
1307
1308 public int countByGroupId(long groupId) throws SystemException {
1309 boolean finderClassNameCacheEnabled = JournalFeedModelImpl.CACHE_ENABLED;
1310 String finderClassName = JournalFeed.class.getName();
1311 String finderMethodName = "countByGroupId";
1312 String[] finderParams = new String[] { Long.class.getName() };
1313 Object[] finderArgs = new Object[] { new Long(groupId) };
1314
1315 Object result = null;
1316
1317 if (finderClassNameCacheEnabled) {
1318 result = FinderCacheUtil.getResult(finderClassName,
1319 finderMethodName, finderParams, finderArgs, this);
1320 }
1321
1322 if (result == null) {
1323 Session session = null;
1324
1325 try {
1326 session = openSession();
1327
1328 StringBuilder query = new StringBuilder();
1329
1330 query.append("SELECT COUNT(*) ");
1331 query.append(
1332 "FROM com.liferay.portlet.journal.model.JournalFeed WHERE ");
1333
1334 query.append("groupId = ?");
1335
1336 query.append(" ");
1337
1338 Query q = session.createQuery(query.toString());
1339
1340 QueryPos qPos = QueryPos.getInstance(q);
1341
1342 qPos.add(groupId);
1343
1344 Long count = null;
1345
1346 Iterator<Long> itr = q.list().iterator();
1347
1348 if (itr.hasNext()) {
1349 count = itr.next();
1350 }
1351
1352 if (count == null) {
1353 count = new Long(0);
1354 }
1355
1356 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1357 finderClassName, finderMethodName, finderParams,
1358 finderArgs, count);
1359
1360 return count.intValue();
1361 }
1362 catch (Exception e) {
1363 throw processException(e);
1364 }
1365 finally {
1366 closeSession(session);
1367 }
1368 }
1369 else {
1370 return ((Long)result).intValue();
1371 }
1372 }
1373
1374 public int countByG_F(long groupId, String feedId)
1375 throws SystemException {
1376 boolean finderClassNameCacheEnabled = JournalFeedModelImpl.CACHE_ENABLED;
1377 String finderClassName = JournalFeed.class.getName();
1378 String finderMethodName = "countByG_F";
1379 String[] finderParams = new String[] {
1380 Long.class.getName(), String.class.getName()
1381 };
1382 Object[] finderArgs = new Object[] { new Long(groupId), feedId };
1383
1384 Object result = null;
1385
1386 if (finderClassNameCacheEnabled) {
1387 result = FinderCacheUtil.getResult(finderClassName,
1388 finderMethodName, finderParams, finderArgs, this);
1389 }
1390
1391 if (result == null) {
1392 Session session = null;
1393
1394 try {
1395 session = openSession();
1396
1397 StringBuilder query = new StringBuilder();
1398
1399 query.append("SELECT COUNT(*) ");
1400 query.append(
1401 "FROM com.liferay.portlet.journal.model.JournalFeed WHERE ");
1402
1403 query.append("groupId = ?");
1404
1405 query.append(" AND ");
1406
1407 if (feedId == null) {
1408 query.append("feedId IS NULL");
1409 }
1410 else {
1411 query.append("feedId = ?");
1412 }
1413
1414 query.append(" ");
1415
1416 Query q = session.createQuery(query.toString());
1417
1418 QueryPos qPos = QueryPos.getInstance(q);
1419
1420 qPos.add(groupId);
1421
1422 if (feedId != null) {
1423 qPos.add(feedId);
1424 }
1425
1426 Long count = null;
1427
1428 Iterator<Long> itr = q.list().iterator();
1429
1430 if (itr.hasNext()) {
1431 count = itr.next();
1432 }
1433
1434 if (count == null) {
1435 count = new Long(0);
1436 }
1437
1438 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1439 finderClassName, finderMethodName, finderParams,
1440 finderArgs, count);
1441
1442 return count.intValue();
1443 }
1444 catch (Exception e) {
1445 throw processException(e);
1446 }
1447 finally {
1448 closeSession(session);
1449 }
1450 }
1451 else {
1452 return ((Long)result).intValue();
1453 }
1454 }
1455
1456 public int countAll() throws SystemException {
1457 boolean finderClassNameCacheEnabled = JournalFeedModelImpl.CACHE_ENABLED;
1458 String finderClassName = JournalFeed.class.getName();
1459 String finderMethodName = "countAll";
1460 String[] finderParams = new String[] { };
1461 Object[] finderArgs = new Object[] { };
1462
1463 Object result = null;
1464
1465 if (finderClassNameCacheEnabled) {
1466 result = FinderCacheUtil.getResult(finderClassName,
1467 finderMethodName, finderParams, finderArgs, this);
1468 }
1469
1470 if (result == null) {
1471 Session session = null;
1472
1473 try {
1474 session = openSession();
1475
1476 Query q = session.createQuery(
1477 "SELECT COUNT(*) FROM com.liferay.portlet.journal.model.JournalFeed");
1478
1479 Long count = null;
1480
1481 Iterator<Long> itr = q.list().iterator();
1482
1483 if (itr.hasNext()) {
1484 count = itr.next();
1485 }
1486
1487 if (count == null) {
1488 count = new Long(0);
1489 }
1490
1491 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1492 finderClassName, finderMethodName, finderParams,
1493 finderArgs, count);
1494
1495 return count.intValue();
1496 }
1497 catch (Exception e) {
1498 throw processException(e);
1499 }
1500 finally {
1501 closeSession(session);
1502 }
1503 }
1504 else {
1505 return ((Long)result).intValue();
1506 }
1507 }
1508
1509 public void afterPropertiesSet() {
1510 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1511 com.liferay.portal.util.PropsUtil.get(
1512 "value.object.listener.com.liferay.portlet.journal.model.JournalFeed")));
1513
1514 if (listenerClassNames.length > 0) {
1515 try {
1516 List<ModelListener> listenersList = new ArrayList<ModelListener>();
1517
1518 for (String listenerClassName : listenerClassNames) {
1519 listenersList.add((ModelListener)Class.forName(
1520 listenerClassName).newInstance());
1521 }
1522
1523 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1524 }
1525 catch (Exception e) {
1526 _log.error(e);
1527 }
1528 }
1529 }
1530
1531 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticlePersistence.impl")
1532 protected com.liferay.portlet.journal.service.persistence.JournalArticlePersistence journalArticlePersistence;
1533 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticleImagePersistence.impl")
1534 protected com.liferay.portlet.journal.service.persistence.JournalArticleImagePersistence journalArticleImagePersistence;
1535 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence.impl")
1536 protected com.liferay.portlet.journal.service.persistence.JournalArticleResourcePersistence journalArticleResourcePersistence;
1537 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalContentSearchPersistence.impl")
1538 protected com.liferay.portlet.journal.service.persistence.JournalContentSearchPersistence journalContentSearchPersistence;
1539 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalFeedPersistence.impl")
1540 protected com.liferay.portlet.journal.service.persistence.JournalFeedPersistence journalFeedPersistence;
1541 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalStructurePersistence.impl")
1542 protected com.liferay.portlet.journal.service.persistence.JournalStructurePersistence journalStructurePersistence;
1543 @BeanReference(name = "com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence.impl")
1544 protected com.liferay.portlet.journal.service.persistence.JournalTemplatePersistence journalTemplatePersistence;
1545 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1546 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1547 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1548 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1549 private static Log _log = LogFactoryUtil.getLog(JournalFeedPersistenceImpl.class);
1550}