1
22
23 package com.liferay.portlet.journal.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.bean.InitializingBean;
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.util.GetterUtil;
34 import com.liferay.portal.kernel.util.ListUtil;
35 import com.liferay.portal.kernel.util.OrderByComparator;
36 import com.liferay.portal.kernel.util.StringPool;
37 import com.liferay.portal.kernel.util.StringUtil;
38 import com.liferay.portal.kernel.util.Validator;
39 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
40 import com.liferay.portal.model.ModelListener;
41 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
42
43 import com.liferay.portlet.journal.NoSuchArticleException;
44 import com.liferay.portlet.journal.model.JournalArticle;
45 import com.liferay.portlet.journal.model.impl.JournalArticleImpl;
46 import com.liferay.portlet.journal.model.impl.JournalArticleModelImpl;
47
48 import org.apache.commons.logging.Log;
49 import org.apache.commons.logging.LogFactory;
50
51 import java.util.ArrayList;
52 import java.util.Collections;
53 import java.util.Iterator;
54 import java.util.List;
55
56
62 public class JournalArticlePersistenceImpl extends BasePersistenceImpl
63 implements JournalArticlePersistence, InitializingBean {
64 public JournalArticle create(long id) {
65 JournalArticle journalArticle = new JournalArticleImpl();
66
67 journalArticle.setNew(true);
68 journalArticle.setPrimaryKey(id);
69
70 String uuid = PortalUUIDUtil.generate();
71
72 journalArticle.setUuid(uuid);
73
74 return journalArticle;
75 }
76
77 public JournalArticle remove(long id)
78 throws NoSuchArticleException, SystemException {
79 Session session = null;
80
81 try {
82 session = openSession();
83
84 JournalArticle journalArticle = (JournalArticle)session.get(JournalArticleImpl.class,
85 new Long(id));
86
87 if (journalArticle == null) {
88 if (_log.isWarnEnabled()) {
89 _log.warn("No JournalArticle exists with the primary key " +
90 id);
91 }
92
93 throw new NoSuchArticleException(
94 "No JournalArticle exists with the primary key " + id);
95 }
96
97 return remove(journalArticle);
98 }
99 catch (NoSuchArticleException nsee) {
100 throw nsee;
101 }
102 catch (Exception e) {
103 throw processException(e);
104 }
105 finally {
106 closeSession(session);
107 }
108 }
109
110 public JournalArticle remove(JournalArticle journalArticle)
111 throws SystemException {
112 if (_listeners.length > 0) {
113 for (ModelListener listener : _listeners) {
114 listener.onBeforeRemove(journalArticle);
115 }
116 }
117
118 journalArticle = removeImpl(journalArticle);
119
120 if (_listeners.length > 0) {
121 for (ModelListener listener : _listeners) {
122 listener.onAfterRemove(journalArticle);
123 }
124 }
125
126 return journalArticle;
127 }
128
129 protected JournalArticle removeImpl(JournalArticle journalArticle)
130 throws SystemException {
131 Session session = null;
132
133 try {
134 session = openSession();
135
136 session.delete(journalArticle);
137
138 session.flush();
139
140 return journalArticle;
141 }
142 catch (Exception e) {
143 throw processException(e);
144 }
145 finally {
146 closeSession(session);
147
148 FinderCacheUtil.clearCache(JournalArticle.class.getName());
149 }
150 }
151
152
155 public JournalArticle update(JournalArticle journalArticle)
156 throws SystemException {
157 if (_log.isWarnEnabled()) {
158 _log.warn(
159 "Using the deprecated update(JournalArticle journalArticle) method. Use update(JournalArticle journalArticle, boolean merge) instead.");
160 }
161
162 return update(journalArticle, false);
163 }
164
165
178 public JournalArticle update(JournalArticle journalArticle, boolean merge)
179 throws SystemException {
180 boolean isNew = journalArticle.isNew();
181
182 if (_listeners.length > 0) {
183 for (ModelListener listener : _listeners) {
184 if (isNew) {
185 listener.onBeforeCreate(journalArticle);
186 }
187 else {
188 listener.onBeforeUpdate(journalArticle);
189 }
190 }
191 }
192
193 journalArticle = updateImpl(journalArticle, merge);
194
195 if (_listeners.length > 0) {
196 for (ModelListener listener : _listeners) {
197 if (isNew) {
198 listener.onAfterCreate(journalArticle);
199 }
200 else {
201 listener.onAfterUpdate(journalArticle);
202 }
203 }
204 }
205
206 return journalArticle;
207 }
208
209 public JournalArticle updateImpl(
210 com.liferay.portlet.journal.model.JournalArticle journalArticle,
211 boolean merge) throws SystemException {
212 if (Validator.isNull(journalArticle.getUuid())) {
213 String uuid = PortalUUIDUtil.generate();
214
215 journalArticle.setUuid(uuid);
216 }
217
218 Session session = null;
219
220 try {
221 session = openSession();
222
223 if (merge) {
224 session.merge(journalArticle);
225 }
226 else {
227 if (journalArticle.isNew()) {
228 session.save(journalArticle);
229 }
230 }
231
232 session.flush();
233
234 journalArticle.setNew(false);
235
236 return journalArticle;
237 }
238 catch (Exception e) {
239 throw processException(e);
240 }
241 finally {
242 closeSession(session);
243
244 FinderCacheUtil.clearCache(JournalArticle.class.getName());
245 }
246 }
247
248 public JournalArticle findByPrimaryKey(long id)
249 throws NoSuchArticleException, SystemException {
250 JournalArticle journalArticle = fetchByPrimaryKey(id);
251
252 if (journalArticle == null) {
253 if (_log.isWarnEnabled()) {
254 _log.warn("No JournalArticle exists with the primary key " +
255 id);
256 }
257
258 throw new NoSuchArticleException(
259 "No JournalArticle exists with the primary key " + id);
260 }
261
262 return journalArticle;
263 }
264
265 public JournalArticle fetchByPrimaryKey(long id) throws SystemException {
266 Session session = null;
267
268 try {
269 session = openSession();
270
271 return (JournalArticle)session.get(JournalArticleImpl.class,
272 new Long(id));
273 }
274 catch (Exception e) {
275 throw processException(e);
276 }
277 finally {
278 closeSession(session);
279 }
280 }
281
282 public List<JournalArticle> findByUuid(String uuid)
283 throws SystemException {
284 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
285 String finderClassName = JournalArticle.class.getName();
286 String finderMethodName = "findByUuid";
287 String[] finderParams = new String[] { String.class.getName() };
288 Object[] finderArgs = new Object[] { uuid };
289
290 Object result = null;
291
292 if (finderClassNameCacheEnabled) {
293 result = FinderCacheUtil.getResult(finderClassName,
294 finderMethodName, finderParams, finderArgs, this);
295 }
296
297 if (result == null) {
298 Session session = null;
299
300 try {
301 session = openSession();
302
303 StringBuilder query = new StringBuilder();
304
305 query.append(
306 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
307
308 if (uuid == null) {
309 query.append("uuid_ IS NULL");
310 }
311 else {
312 query.append("uuid_ = ?");
313 }
314
315 query.append(" ");
316
317 query.append("ORDER BY ");
318
319 query.append("articleId ASC, ");
320 query.append("version DESC");
321
322 Query q = session.createQuery(query.toString());
323
324 QueryPos qPos = QueryPos.getInstance(q);
325
326 if (uuid != null) {
327 qPos.add(uuid);
328 }
329
330 List<JournalArticle> list = q.list();
331
332 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
333 finderClassName, finderMethodName, finderParams,
334 finderArgs, list);
335
336 return list;
337 }
338 catch (Exception e) {
339 throw processException(e);
340 }
341 finally {
342 closeSession(session);
343 }
344 }
345 else {
346 return (List<JournalArticle>)result;
347 }
348 }
349
350 public List<JournalArticle> findByUuid(String uuid, int start, int end)
351 throws SystemException {
352 return findByUuid(uuid, start, end, null);
353 }
354
355 public List<JournalArticle> findByUuid(String uuid, int start, int end,
356 OrderByComparator obc) throws SystemException {
357 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
358 String finderClassName = JournalArticle.class.getName();
359 String finderMethodName = "findByUuid";
360 String[] finderParams = new String[] {
361 String.class.getName(),
362
363 "java.lang.Integer", "java.lang.Integer",
364 "com.liferay.portal.kernel.util.OrderByComparator"
365 };
366 Object[] finderArgs = new Object[] {
367 uuid,
368
369 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
370 };
371
372 Object result = null;
373
374 if (finderClassNameCacheEnabled) {
375 result = FinderCacheUtil.getResult(finderClassName,
376 finderMethodName, finderParams, finderArgs, this);
377 }
378
379 if (result == null) {
380 Session session = null;
381
382 try {
383 session = openSession();
384
385 StringBuilder query = new StringBuilder();
386
387 query.append(
388 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
389
390 if (uuid == null) {
391 query.append("uuid_ IS NULL");
392 }
393 else {
394 query.append("uuid_ = ?");
395 }
396
397 query.append(" ");
398
399 if (obc != null) {
400 query.append("ORDER BY ");
401 query.append(obc.getOrderBy());
402 }
403
404 else {
405 query.append("ORDER BY ");
406
407 query.append("articleId ASC, ");
408 query.append("version DESC");
409 }
410
411 Query q = session.createQuery(query.toString());
412
413 QueryPos qPos = QueryPos.getInstance(q);
414
415 if (uuid != null) {
416 qPos.add(uuid);
417 }
418
419 List<JournalArticle> list = (List<JournalArticle>)QueryUtil.list(q,
420 getDialect(), start, end);
421
422 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
423 finderClassName, finderMethodName, finderParams,
424 finderArgs, list);
425
426 return list;
427 }
428 catch (Exception e) {
429 throw processException(e);
430 }
431 finally {
432 closeSession(session);
433 }
434 }
435 else {
436 return (List<JournalArticle>)result;
437 }
438 }
439
440 public JournalArticle findByUuid_First(String uuid, OrderByComparator obc)
441 throws NoSuchArticleException, SystemException {
442 List<JournalArticle> list = findByUuid(uuid, 0, 1, obc);
443
444 if (list.size() == 0) {
445 StringBuilder msg = new StringBuilder();
446
447 msg.append("No JournalArticle exists with the key {");
448
449 msg.append("uuid=" + uuid);
450
451 msg.append(StringPool.CLOSE_CURLY_BRACE);
452
453 throw new NoSuchArticleException(msg.toString());
454 }
455 else {
456 return list.get(0);
457 }
458 }
459
460 public JournalArticle findByUuid_Last(String uuid, OrderByComparator obc)
461 throws NoSuchArticleException, SystemException {
462 int count = countByUuid(uuid);
463
464 List<JournalArticle> list = findByUuid(uuid, count - 1, count, obc);
465
466 if (list.size() == 0) {
467 StringBuilder msg = new StringBuilder();
468
469 msg.append("No JournalArticle exists with the key {");
470
471 msg.append("uuid=" + uuid);
472
473 msg.append(StringPool.CLOSE_CURLY_BRACE);
474
475 throw new NoSuchArticleException(msg.toString());
476 }
477 else {
478 return list.get(0);
479 }
480 }
481
482 public JournalArticle[] findByUuid_PrevAndNext(long id, String uuid,
483 OrderByComparator obc) throws NoSuchArticleException, SystemException {
484 JournalArticle journalArticle = findByPrimaryKey(id);
485
486 int count = countByUuid(uuid);
487
488 Session session = null;
489
490 try {
491 session = openSession();
492
493 StringBuilder query = new StringBuilder();
494
495 query.append(
496 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
497
498 if (uuid == null) {
499 query.append("uuid_ IS NULL");
500 }
501 else {
502 query.append("uuid_ = ?");
503 }
504
505 query.append(" ");
506
507 if (obc != null) {
508 query.append("ORDER BY ");
509 query.append(obc.getOrderBy());
510 }
511
512 else {
513 query.append("ORDER BY ");
514
515 query.append("articleId ASC, ");
516 query.append("version DESC");
517 }
518
519 Query q = session.createQuery(query.toString());
520
521 QueryPos qPos = QueryPos.getInstance(q);
522
523 if (uuid != null) {
524 qPos.add(uuid);
525 }
526
527 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
528 journalArticle);
529
530 JournalArticle[] array = new JournalArticleImpl[3];
531
532 array[0] = (JournalArticle)objArray[0];
533 array[1] = (JournalArticle)objArray[1];
534 array[2] = (JournalArticle)objArray[2];
535
536 return array;
537 }
538 catch (Exception e) {
539 throw processException(e);
540 }
541 finally {
542 closeSession(session);
543 }
544 }
545
546 public JournalArticle findByUUID_G(String uuid, long groupId)
547 throws NoSuchArticleException, SystemException {
548 JournalArticle journalArticle = fetchByUUID_G(uuid, groupId);
549
550 if (journalArticle == null) {
551 StringBuilder msg = new StringBuilder();
552
553 msg.append("No JournalArticle exists with the key {");
554
555 msg.append("uuid=" + uuid);
556
557 msg.append(", ");
558 msg.append("groupId=" + groupId);
559
560 msg.append(StringPool.CLOSE_CURLY_BRACE);
561
562 if (_log.isWarnEnabled()) {
563 _log.warn(msg.toString());
564 }
565
566 throw new NoSuchArticleException(msg.toString());
567 }
568
569 return journalArticle;
570 }
571
572 public JournalArticle fetchByUUID_G(String uuid, long groupId)
573 throws SystemException {
574 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
575 String finderClassName = JournalArticle.class.getName();
576 String finderMethodName = "fetchByUUID_G";
577 String[] finderParams = new String[] {
578 String.class.getName(), Long.class.getName()
579 };
580 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
581
582 Object result = null;
583
584 if (finderClassNameCacheEnabled) {
585 result = FinderCacheUtil.getResult(finderClassName,
586 finderMethodName, finderParams, finderArgs, this);
587 }
588
589 if (result == null) {
590 Session session = null;
591
592 try {
593 session = openSession();
594
595 StringBuilder query = new StringBuilder();
596
597 query.append(
598 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
599
600 if (uuid == null) {
601 query.append("uuid_ IS NULL");
602 }
603 else {
604 query.append("uuid_ = ?");
605 }
606
607 query.append(" AND ");
608
609 query.append("groupId = ?");
610
611 query.append(" ");
612
613 query.append("ORDER BY ");
614
615 query.append("articleId ASC, ");
616 query.append("version DESC");
617
618 Query q = session.createQuery(query.toString());
619
620 QueryPos qPos = QueryPos.getInstance(q);
621
622 if (uuid != null) {
623 qPos.add(uuid);
624 }
625
626 qPos.add(groupId);
627
628 List<JournalArticle> list = q.list();
629
630 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
631 finderClassName, finderMethodName, finderParams,
632 finderArgs, list);
633
634 if (list.size() == 0) {
635 return null;
636 }
637 else {
638 return list.get(0);
639 }
640 }
641 catch (Exception e) {
642 throw processException(e);
643 }
644 finally {
645 closeSession(session);
646 }
647 }
648 else {
649 List<JournalArticle> list = (List<JournalArticle>)result;
650
651 if (list.size() == 0) {
652 return null;
653 }
654 else {
655 return list.get(0);
656 }
657 }
658 }
659
660 public List<JournalArticle> findByGroupId(long groupId)
661 throws SystemException {
662 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
663 String finderClassName = JournalArticle.class.getName();
664 String finderMethodName = "findByGroupId";
665 String[] finderParams = new String[] { Long.class.getName() };
666 Object[] finderArgs = new Object[] { new Long(groupId) };
667
668 Object result = null;
669
670 if (finderClassNameCacheEnabled) {
671 result = FinderCacheUtil.getResult(finderClassName,
672 finderMethodName, finderParams, finderArgs, this);
673 }
674
675 if (result == null) {
676 Session session = null;
677
678 try {
679 session = openSession();
680
681 StringBuilder query = new StringBuilder();
682
683 query.append(
684 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
685
686 query.append("groupId = ?");
687
688 query.append(" ");
689
690 query.append("ORDER BY ");
691
692 query.append("articleId ASC, ");
693 query.append("version DESC");
694
695 Query q = session.createQuery(query.toString());
696
697 QueryPos qPos = QueryPos.getInstance(q);
698
699 qPos.add(groupId);
700
701 List<JournalArticle> list = q.list();
702
703 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
704 finderClassName, finderMethodName, finderParams,
705 finderArgs, list);
706
707 return list;
708 }
709 catch (Exception e) {
710 throw processException(e);
711 }
712 finally {
713 closeSession(session);
714 }
715 }
716 else {
717 return (List<JournalArticle>)result;
718 }
719 }
720
721 public List<JournalArticle> findByGroupId(long groupId, int start, int end)
722 throws SystemException {
723 return findByGroupId(groupId, start, end, null);
724 }
725
726 public List<JournalArticle> findByGroupId(long groupId, int start, int end,
727 OrderByComparator obc) throws SystemException {
728 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
729 String finderClassName = JournalArticle.class.getName();
730 String finderMethodName = "findByGroupId";
731 String[] finderParams = new String[] {
732 Long.class.getName(),
733
734 "java.lang.Integer", "java.lang.Integer",
735 "com.liferay.portal.kernel.util.OrderByComparator"
736 };
737 Object[] finderArgs = new Object[] {
738 new Long(groupId),
739
740 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
741 };
742
743 Object result = null;
744
745 if (finderClassNameCacheEnabled) {
746 result = FinderCacheUtil.getResult(finderClassName,
747 finderMethodName, finderParams, finderArgs, this);
748 }
749
750 if (result == null) {
751 Session session = null;
752
753 try {
754 session = openSession();
755
756 StringBuilder query = new StringBuilder();
757
758 query.append(
759 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
760
761 query.append("groupId = ?");
762
763 query.append(" ");
764
765 if (obc != null) {
766 query.append("ORDER BY ");
767 query.append(obc.getOrderBy());
768 }
769
770 else {
771 query.append("ORDER BY ");
772
773 query.append("articleId ASC, ");
774 query.append("version DESC");
775 }
776
777 Query q = session.createQuery(query.toString());
778
779 QueryPos qPos = QueryPos.getInstance(q);
780
781 qPos.add(groupId);
782
783 List<JournalArticle> list = (List<JournalArticle>)QueryUtil.list(q,
784 getDialect(), start, end);
785
786 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
787 finderClassName, finderMethodName, finderParams,
788 finderArgs, list);
789
790 return list;
791 }
792 catch (Exception e) {
793 throw processException(e);
794 }
795 finally {
796 closeSession(session);
797 }
798 }
799 else {
800 return (List<JournalArticle>)result;
801 }
802 }
803
804 public JournalArticle findByGroupId_First(long groupId,
805 OrderByComparator obc) throws NoSuchArticleException, SystemException {
806 List<JournalArticle> list = findByGroupId(groupId, 0, 1, obc);
807
808 if (list.size() == 0) {
809 StringBuilder msg = new StringBuilder();
810
811 msg.append("No JournalArticle exists with the key {");
812
813 msg.append("groupId=" + groupId);
814
815 msg.append(StringPool.CLOSE_CURLY_BRACE);
816
817 throw new NoSuchArticleException(msg.toString());
818 }
819 else {
820 return list.get(0);
821 }
822 }
823
824 public JournalArticle findByGroupId_Last(long groupId, OrderByComparator obc)
825 throws NoSuchArticleException, SystemException {
826 int count = countByGroupId(groupId);
827
828 List<JournalArticle> list = findByGroupId(groupId, count - 1, count, obc);
829
830 if (list.size() == 0) {
831 StringBuilder msg = new StringBuilder();
832
833 msg.append("No JournalArticle exists with the key {");
834
835 msg.append("groupId=" + groupId);
836
837 msg.append(StringPool.CLOSE_CURLY_BRACE);
838
839 throw new NoSuchArticleException(msg.toString());
840 }
841 else {
842 return list.get(0);
843 }
844 }
845
846 public JournalArticle[] findByGroupId_PrevAndNext(long id, long groupId,
847 OrderByComparator obc) throws NoSuchArticleException, SystemException {
848 JournalArticle journalArticle = findByPrimaryKey(id);
849
850 int count = countByGroupId(groupId);
851
852 Session session = null;
853
854 try {
855 session = openSession();
856
857 StringBuilder query = new StringBuilder();
858
859 query.append(
860 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
861
862 query.append("groupId = ?");
863
864 query.append(" ");
865
866 if (obc != null) {
867 query.append("ORDER BY ");
868 query.append(obc.getOrderBy());
869 }
870
871 else {
872 query.append("ORDER BY ");
873
874 query.append("articleId ASC, ");
875 query.append("version DESC");
876 }
877
878 Query q = session.createQuery(query.toString());
879
880 QueryPos qPos = QueryPos.getInstance(q);
881
882 qPos.add(groupId);
883
884 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
885 journalArticle);
886
887 JournalArticle[] array = new JournalArticleImpl[3];
888
889 array[0] = (JournalArticle)objArray[0];
890 array[1] = (JournalArticle)objArray[1];
891 array[2] = (JournalArticle)objArray[2];
892
893 return array;
894 }
895 catch (Exception e) {
896 throw processException(e);
897 }
898 finally {
899 closeSession(session);
900 }
901 }
902
903 public List<JournalArticle> findByCompanyId(long companyId)
904 throws SystemException {
905 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
906 String finderClassName = JournalArticle.class.getName();
907 String finderMethodName = "findByCompanyId";
908 String[] finderParams = new String[] { Long.class.getName() };
909 Object[] finderArgs = new Object[] { new Long(companyId) };
910
911 Object result = null;
912
913 if (finderClassNameCacheEnabled) {
914 result = FinderCacheUtil.getResult(finderClassName,
915 finderMethodName, finderParams, finderArgs, this);
916 }
917
918 if (result == null) {
919 Session session = null;
920
921 try {
922 session = openSession();
923
924 StringBuilder query = new StringBuilder();
925
926 query.append(
927 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
928
929 query.append("companyId = ?");
930
931 query.append(" ");
932
933 query.append("ORDER BY ");
934
935 query.append("articleId ASC, ");
936 query.append("version DESC");
937
938 Query q = session.createQuery(query.toString());
939
940 QueryPos qPos = QueryPos.getInstance(q);
941
942 qPos.add(companyId);
943
944 List<JournalArticle> list = q.list();
945
946 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
947 finderClassName, finderMethodName, finderParams,
948 finderArgs, list);
949
950 return list;
951 }
952 catch (Exception e) {
953 throw processException(e);
954 }
955 finally {
956 closeSession(session);
957 }
958 }
959 else {
960 return (List<JournalArticle>)result;
961 }
962 }
963
964 public List<JournalArticle> findByCompanyId(long companyId, int start,
965 int end) throws SystemException {
966 return findByCompanyId(companyId, start, end, null);
967 }
968
969 public List<JournalArticle> findByCompanyId(long companyId, int start,
970 int end, OrderByComparator obc) throws SystemException {
971 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
972 String finderClassName = JournalArticle.class.getName();
973 String finderMethodName = "findByCompanyId";
974 String[] finderParams = new String[] {
975 Long.class.getName(),
976
977 "java.lang.Integer", "java.lang.Integer",
978 "com.liferay.portal.kernel.util.OrderByComparator"
979 };
980 Object[] finderArgs = new Object[] {
981 new Long(companyId),
982
983 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
984 };
985
986 Object result = null;
987
988 if (finderClassNameCacheEnabled) {
989 result = FinderCacheUtil.getResult(finderClassName,
990 finderMethodName, finderParams, finderArgs, this);
991 }
992
993 if (result == null) {
994 Session session = null;
995
996 try {
997 session = openSession();
998
999 StringBuilder query = new StringBuilder();
1000
1001 query.append(
1002 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1003
1004 query.append("companyId = ?");
1005
1006 query.append(" ");
1007
1008 if (obc != null) {
1009 query.append("ORDER BY ");
1010 query.append(obc.getOrderBy());
1011 }
1012
1013 else {
1014 query.append("ORDER BY ");
1015
1016 query.append("articleId ASC, ");
1017 query.append("version DESC");
1018 }
1019
1020 Query q = session.createQuery(query.toString());
1021
1022 QueryPos qPos = QueryPos.getInstance(q);
1023
1024 qPos.add(companyId);
1025
1026 List<JournalArticle> list = (List<JournalArticle>)QueryUtil.list(q,
1027 getDialect(), start, end);
1028
1029 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1030 finderClassName, finderMethodName, finderParams,
1031 finderArgs, list);
1032
1033 return list;
1034 }
1035 catch (Exception e) {
1036 throw processException(e);
1037 }
1038 finally {
1039 closeSession(session);
1040 }
1041 }
1042 else {
1043 return (List<JournalArticle>)result;
1044 }
1045 }
1046
1047 public JournalArticle findByCompanyId_First(long companyId,
1048 OrderByComparator obc) throws NoSuchArticleException, SystemException {
1049 List<JournalArticle> list = findByCompanyId(companyId, 0, 1, obc);
1050
1051 if (list.size() == 0) {
1052 StringBuilder msg = new StringBuilder();
1053
1054 msg.append("No JournalArticle exists with the key {");
1055
1056 msg.append("companyId=" + companyId);
1057
1058 msg.append(StringPool.CLOSE_CURLY_BRACE);
1059
1060 throw new NoSuchArticleException(msg.toString());
1061 }
1062 else {
1063 return list.get(0);
1064 }
1065 }
1066
1067 public JournalArticle findByCompanyId_Last(long companyId,
1068 OrderByComparator obc) throws NoSuchArticleException, SystemException {
1069 int count = countByCompanyId(companyId);
1070
1071 List<JournalArticle> list = findByCompanyId(companyId, count - 1,
1072 count, obc);
1073
1074 if (list.size() == 0) {
1075 StringBuilder msg = new StringBuilder();
1076
1077 msg.append("No JournalArticle exists with the key {");
1078
1079 msg.append("companyId=" + companyId);
1080
1081 msg.append(StringPool.CLOSE_CURLY_BRACE);
1082
1083 throw new NoSuchArticleException(msg.toString());
1084 }
1085 else {
1086 return list.get(0);
1087 }
1088 }
1089
1090 public JournalArticle[] findByCompanyId_PrevAndNext(long id,
1091 long companyId, OrderByComparator obc)
1092 throws NoSuchArticleException, SystemException {
1093 JournalArticle journalArticle = findByPrimaryKey(id);
1094
1095 int count = countByCompanyId(companyId);
1096
1097 Session session = null;
1098
1099 try {
1100 session = openSession();
1101
1102 StringBuilder query = new StringBuilder();
1103
1104 query.append(
1105 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1106
1107 query.append("companyId = ?");
1108
1109 query.append(" ");
1110
1111 if (obc != null) {
1112 query.append("ORDER BY ");
1113 query.append(obc.getOrderBy());
1114 }
1115
1116 else {
1117 query.append("ORDER BY ");
1118
1119 query.append("articleId ASC, ");
1120 query.append("version DESC");
1121 }
1122
1123 Query q = session.createQuery(query.toString());
1124
1125 QueryPos qPos = QueryPos.getInstance(q);
1126
1127 qPos.add(companyId);
1128
1129 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1130 journalArticle);
1131
1132 JournalArticle[] array = new JournalArticleImpl[3];
1133
1134 array[0] = (JournalArticle)objArray[0];
1135 array[1] = (JournalArticle)objArray[1];
1136 array[2] = (JournalArticle)objArray[2];
1137
1138 return array;
1139 }
1140 catch (Exception e) {
1141 throw processException(e);
1142 }
1143 finally {
1144 closeSession(session);
1145 }
1146 }
1147
1148 public List<JournalArticle> findBySmallImageId(long smallImageId)
1149 throws SystemException {
1150 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1151 String finderClassName = JournalArticle.class.getName();
1152 String finderMethodName = "findBySmallImageId";
1153 String[] finderParams = new String[] { Long.class.getName() };
1154 Object[] finderArgs = new Object[] { new Long(smallImageId) };
1155
1156 Object result = null;
1157
1158 if (finderClassNameCacheEnabled) {
1159 result = FinderCacheUtil.getResult(finderClassName,
1160 finderMethodName, finderParams, finderArgs, this);
1161 }
1162
1163 if (result == null) {
1164 Session session = null;
1165
1166 try {
1167 session = openSession();
1168
1169 StringBuilder query = new StringBuilder();
1170
1171 query.append(
1172 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1173
1174 query.append("smallImageId = ?");
1175
1176 query.append(" ");
1177
1178 query.append("ORDER BY ");
1179
1180 query.append("articleId ASC, ");
1181 query.append("version DESC");
1182
1183 Query q = session.createQuery(query.toString());
1184
1185 QueryPos qPos = QueryPos.getInstance(q);
1186
1187 qPos.add(smallImageId);
1188
1189 List<JournalArticle> list = q.list();
1190
1191 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1192 finderClassName, finderMethodName, finderParams,
1193 finderArgs, list);
1194
1195 return list;
1196 }
1197 catch (Exception e) {
1198 throw processException(e);
1199 }
1200 finally {
1201 closeSession(session);
1202 }
1203 }
1204 else {
1205 return (List<JournalArticle>)result;
1206 }
1207 }
1208
1209 public List<JournalArticle> findBySmallImageId(long smallImageId,
1210 int start, int end) throws SystemException {
1211 return findBySmallImageId(smallImageId, start, end, null);
1212 }
1213
1214 public List<JournalArticle> findBySmallImageId(long smallImageId,
1215 int start, int end, OrderByComparator obc) throws SystemException {
1216 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1217 String finderClassName = JournalArticle.class.getName();
1218 String finderMethodName = "findBySmallImageId";
1219 String[] finderParams = new String[] {
1220 Long.class.getName(),
1221
1222 "java.lang.Integer", "java.lang.Integer",
1223 "com.liferay.portal.kernel.util.OrderByComparator"
1224 };
1225 Object[] finderArgs = new Object[] {
1226 new Long(smallImageId),
1227
1228 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1229 };
1230
1231 Object result = null;
1232
1233 if (finderClassNameCacheEnabled) {
1234 result = FinderCacheUtil.getResult(finderClassName,
1235 finderMethodName, finderParams, finderArgs, this);
1236 }
1237
1238 if (result == null) {
1239 Session session = null;
1240
1241 try {
1242 session = openSession();
1243
1244 StringBuilder query = new StringBuilder();
1245
1246 query.append(
1247 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1248
1249 query.append("smallImageId = ?");
1250
1251 query.append(" ");
1252
1253 if (obc != null) {
1254 query.append("ORDER BY ");
1255 query.append(obc.getOrderBy());
1256 }
1257
1258 else {
1259 query.append("ORDER BY ");
1260
1261 query.append("articleId ASC, ");
1262 query.append("version DESC");
1263 }
1264
1265 Query q = session.createQuery(query.toString());
1266
1267 QueryPos qPos = QueryPos.getInstance(q);
1268
1269 qPos.add(smallImageId);
1270
1271 List<JournalArticle> list = (List<JournalArticle>)QueryUtil.list(q,
1272 getDialect(), start, end);
1273
1274 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1275 finderClassName, finderMethodName, finderParams,
1276 finderArgs, list);
1277
1278 return list;
1279 }
1280 catch (Exception e) {
1281 throw processException(e);
1282 }
1283 finally {
1284 closeSession(session);
1285 }
1286 }
1287 else {
1288 return (List<JournalArticle>)result;
1289 }
1290 }
1291
1292 public JournalArticle findBySmallImageId_First(long smallImageId,
1293 OrderByComparator obc) throws NoSuchArticleException, SystemException {
1294 List<JournalArticle> list = findBySmallImageId(smallImageId, 0, 1, obc);
1295
1296 if (list.size() == 0) {
1297 StringBuilder msg = new StringBuilder();
1298
1299 msg.append("No JournalArticle exists with the key {");
1300
1301 msg.append("smallImageId=" + smallImageId);
1302
1303 msg.append(StringPool.CLOSE_CURLY_BRACE);
1304
1305 throw new NoSuchArticleException(msg.toString());
1306 }
1307 else {
1308 return list.get(0);
1309 }
1310 }
1311
1312 public JournalArticle findBySmallImageId_Last(long smallImageId,
1313 OrderByComparator obc) throws NoSuchArticleException, SystemException {
1314 int count = countBySmallImageId(smallImageId);
1315
1316 List<JournalArticle> list = findBySmallImageId(smallImageId, count - 1,
1317 count, obc);
1318
1319 if (list.size() == 0) {
1320 StringBuilder msg = new StringBuilder();
1321
1322 msg.append("No JournalArticle exists with the key {");
1323
1324 msg.append("smallImageId=" + smallImageId);
1325
1326 msg.append(StringPool.CLOSE_CURLY_BRACE);
1327
1328 throw new NoSuchArticleException(msg.toString());
1329 }
1330 else {
1331 return list.get(0);
1332 }
1333 }
1334
1335 public JournalArticle[] findBySmallImageId_PrevAndNext(long id,
1336 long smallImageId, OrderByComparator obc)
1337 throws NoSuchArticleException, SystemException {
1338 JournalArticle journalArticle = findByPrimaryKey(id);
1339
1340 int count = countBySmallImageId(smallImageId);
1341
1342 Session session = null;
1343
1344 try {
1345 session = openSession();
1346
1347 StringBuilder query = new StringBuilder();
1348
1349 query.append(
1350 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1351
1352 query.append("smallImageId = ?");
1353
1354 query.append(" ");
1355
1356 if (obc != null) {
1357 query.append("ORDER BY ");
1358 query.append(obc.getOrderBy());
1359 }
1360
1361 else {
1362 query.append("ORDER BY ");
1363
1364 query.append("articleId ASC, ");
1365 query.append("version DESC");
1366 }
1367
1368 Query q = session.createQuery(query.toString());
1369
1370 QueryPos qPos = QueryPos.getInstance(q);
1371
1372 qPos.add(smallImageId);
1373
1374 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1375 journalArticle);
1376
1377 JournalArticle[] array = new JournalArticleImpl[3];
1378
1379 array[0] = (JournalArticle)objArray[0];
1380 array[1] = (JournalArticle)objArray[1];
1381 array[2] = (JournalArticle)objArray[2];
1382
1383 return array;
1384 }
1385 catch (Exception e) {
1386 throw processException(e);
1387 }
1388 finally {
1389 closeSession(session);
1390 }
1391 }
1392
1393 public List<JournalArticle> findByG_A(long groupId, String articleId)
1394 throws SystemException {
1395 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1396 String finderClassName = JournalArticle.class.getName();
1397 String finderMethodName = "findByG_A";
1398 String[] finderParams = new String[] {
1399 Long.class.getName(), String.class.getName()
1400 };
1401 Object[] finderArgs = new Object[] { new Long(groupId), articleId };
1402
1403 Object result = null;
1404
1405 if (finderClassNameCacheEnabled) {
1406 result = FinderCacheUtil.getResult(finderClassName,
1407 finderMethodName, finderParams, finderArgs, this);
1408 }
1409
1410 if (result == null) {
1411 Session session = null;
1412
1413 try {
1414 session = openSession();
1415
1416 StringBuilder query = new StringBuilder();
1417
1418 query.append(
1419 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1420
1421 query.append("groupId = ?");
1422
1423 query.append(" AND ");
1424
1425 if (articleId == null) {
1426 query.append("articleId IS NULL");
1427 }
1428 else {
1429 query.append("articleId = ?");
1430 }
1431
1432 query.append(" ");
1433
1434 query.append("ORDER BY ");
1435
1436 query.append("articleId ASC, ");
1437 query.append("version DESC");
1438
1439 Query q = session.createQuery(query.toString());
1440
1441 QueryPos qPos = QueryPos.getInstance(q);
1442
1443 qPos.add(groupId);
1444
1445 if (articleId != null) {
1446 qPos.add(articleId);
1447 }
1448
1449 List<JournalArticle> list = q.list();
1450
1451 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1452 finderClassName, finderMethodName, finderParams,
1453 finderArgs, list);
1454
1455 return list;
1456 }
1457 catch (Exception e) {
1458 throw processException(e);
1459 }
1460 finally {
1461 closeSession(session);
1462 }
1463 }
1464 else {
1465 return (List<JournalArticle>)result;
1466 }
1467 }
1468
1469 public List<JournalArticle> findByG_A(long groupId, String articleId,
1470 int start, int end) throws SystemException {
1471 return findByG_A(groupId, articleId, start, end, null);
1472 }
1473
1474 public List<JournalArticle> findByG_A(long groupId, String articleId,
1475 int start, int end, OrderByComparator obc) throws SystemException {
1476 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1477 String finderClassName = JournalArticle.class.getName();
1478 String finderMethodName = "findByG_A";
1479 String[] finderParams = new String[] {
1480 Long.class.getName(), String.class.getName(),
1481
1482 "java.lang.Integer", "java.lang.Integer",
1483 "com.liferay.portal.kernel.util.OrderByComparator"
1484 };
1485 Object[] finderArgs = new Object[] {
1486 new Long(groupId),
1487
1488 articleId,
1489
1490 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1491 };
1492
1493 Object result = null;
1494
1495 if (finderClassNameCacheEnabled) {
1496 result = FinderCacheUtil.getResult(finderClassName,
1497 finderMethodName, finderParams, finderArgs, this);
1498 }
1499
1500 if (result == null) {
1501 Session session = null;
1502
1503 try {
1504 session = openSession();
1505
1506 StringBuilder query = new StringBuilder();
1507
1508 query.append(
1509 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1510
1511 query.append("groupId = ?");
1512
1513 query.append(" AND ");
1514
1515 if (articleId == null) {
1516 query.append("articleId IS NULL");
1517 }
1518 else {
1519 query.append("articleId = ?");
1520 }
1521
1522 query.append(" ");
1523
1524 if (obc != null) {
1525 query.append("ORDER BY ");
1526 query.append(obc.getOrderBy());
1527 }
1528
1529 else {
1530 query.append("ORDER BY ");
1531
1532 query.append("articleId ASC, ");
1533 query.append("version DESC");
1534 }
1535
1536 Query q = session.createQuery(query.toString());
1537
1538 QueryPos qPos = QueryPos.getInstance(q);
1539
1540 qPos.add(groupId);
1541
1542 if (articleId != null) {
1543 qPos.add(articleId);
1544 }
1545
1546 List<JournalArticle> list = (List<JournalArticle>)QueryUtil.list(q,
1547 getDialect(), start, end);
1548
1549 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1550 finderClassName, finderMethodName, finderParams,
1551 finderArgs, list);
1552
1553 return list;
1554 }
1555 catch (Exception e) {
1556 throw processException(e);
1557 }
1558 finally {
1559 closeSession(session);
1560 }
1561 }
1562 else {
1563 return (List<JournalArticle>)result;
1564 }
1565 }
1566
1567 public JournalArticle findByG_A_First(long groupId, String articleId,
1568 OrderByComparator obc) throws NoSuchArticleException, SystemException {
1569 List<JournalArticle> list = findByG_A(groupId, articleId, 0, 1, obc);
1570
1571 if (list.size() == 0) {
1572 StringBuilder msg = new StringBuilder();
1573
1574 msg.append("No JournalArticle exists with the key {");
1575
1576 msg.append("groupId=" + groupId);
1577
1578 msg.append(", ");
1579 msg.append("articleId=" + articleId);
1580
1581 msg.append(StringPool.CLOSE_CURLY_BRACE);
1582
1583 throw new NoSuchArticleException(msg.toString());
1584 }
1585 else {
1586 return list.get(0);
1587 }
1588 }
1589
1590 public JournalArticle findByG_A_Last(long groupId, String articleId,
1591 OrderByComparator obc) throws NoSuchArticleException, SystemException {
1592 int count = countByG_A(groupId, articleId);
1593
1594 List<JournalArticle> list = findByG_A(groupId, articleId, count - 1,
1595 count, obc);
1596
1597 if (list.size() == 0) {
1598 StringBuilder msg = new StringBuilder();
1599
1600 msg.append("No JournalArticle exists with the key {");
1601
1602 msg.append("groupId=" + groupId);
1603
1604 msg.append(", ");
1605 msg.append("articleId=" + articleId);
1606
1607 msg.append(StringPool.CLOSE_CURLY_BRACE);
1608
1609 throw new NoSuchArticleException(msg.toString());
1610 }
1611 else {
1612 return list.get(0);
1613 }
1614 }
1615
1616 public JournalArticle[] findByG_A_PrevAndNext(long id, long groupId,
1617 String articleId, OrderByComparator obc)
1618 throws NoSuchArticleException, SystemException {
1619 JournalArticle journalArticle = findByPrimaryKey(id);
1620
1621 int count = countByG_A(groupId, articleId);
1622
1623 Session session = null;
1624
1625 try {
1626 session = openSession();
1627
1628 StringBuilder query = new StringBuilder();
1629
1630 query.append(
1631 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1632
1633 query.append("groupId = ?");
1634
1635 query.append(" AND ");
1636
1637 if (articleId == null) {
1638 query.append("articleId IS NULL");
1639 }
1640 else {
1641 query.append("articleId = ?");
1642 }
1643
1644 query.append(" ");
1645
1646 if (obc != null) {
1647 query.append("ORDER BY ");
1648 query.append(obc.getOrderBy());
1649 }
1650
1651 else {
1652 query.append("ORDER BY ");
1653
1654 query.append("articleId ASC, ");
1655 query.append("version DESC");
1656 }
1657
1658 Query q = session.createQuery(query.toString());
1659
1660 QueryPos qPos = QueryPos.getInstance(q);
1661
1662 qPos.add(groupId);
1663
1664 if (articleId != null) {
1665 qPos.add(articleId);
1666 }
1667
1668 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1669 journalArticle);
1670
1671 JournalArticle[] array = new JournalArticleImpl[3];
1672
1673 array[0] = (JournalArticle)objArray[0];
1674 array[1] = (JournalArticle)objArray[1];
1675 array[2] = (JournalArticle)objArray[2];
1676
1677 return array;
1678 }
1679 catch (Exception e) {
1680 throw processException(e);
1681 }
1682 finally {
1683 closeSession(session);
1684 }
1685 }
1686
1687 public List<JournalArticle> findByG_S(long groupId, String structureId)
1688 throws SystemException {
1689 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1690 String finderClassName = JournalArticle.class.getName();
1691 String finderMethodName = "findByG_S";
1692 String[] finderParams = new String[] {
1693 Long.class.getName(), String.class.getName()
1694 };
1695 Object[] finderArgs = new Object[] { new Long(groupId), structureId };
1696
1697 Object result = null;
1698
1699 if (finderClassNameCacheEnabled) {
1700 result = FinderCacheUtil.getResult(finderClassName,
1701 finderMethodName, finderParams, finderArgs, this);
1702 }
1703
1704 if (result == null) {
1705 Session session = null;
1706
1707 try {
1708 session = openSession();
1709
1710 StringBuilder query = new StringBuilder();
1711
1712 query.append(
1713 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1714
1715 query.append("groupId = ?");
1716
1717 query.append(" AND ");
1718
1719 if (structureId == null) {
1720 query.append("structureId IS NULL");
1721 }
1722 else {
1723 query.append("structureId = ?");
1724 }
1725
1726 query.append(" ");
1727
1728 query.append("ORDER BY ");
1729
1730 query.append("articleId ASC, ");
1731 query.append("version DESC");
1732
1733 Query q = session.createQuery(query.toString());
1734
1735 QueryPos qPos = QueryPos.getInstance(q);
1736
1737 qPos.add(groupId);
1738
1739 if (structureId != null) {
1740 qPos.add(structureId);
1741 }
1742
1743 List<JournalArticle> list = q.list();
1744
1745 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1746 finderClassName, finderMethodName, finderParams,
1747 finderArgs, list);
1748
1749 return list;
1750 }
1751 catch (Exception e) {
1752 throw processException(e);
1753 }
1754 finally {
1755 closeSession(session);
1756 }
1757 }
1758 else {
1759 return (List<JournalArticle>)result;
1760 }
1761 }
1762
1763 public List<JournalArticle> findByG_S(long groupId, String structureId,
1764 int start, int end) throws SystemException {
1765 return findByG_S(groupId, structureId, start, end, null);
1766 }
1767
1768 public List<JournalArticle> findByG_S(long groupId, String structureId,
1769 int start, int end, OrderByComparator obc) throws SystemException {
1770 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1771 String finderClassName = JournalArticle.class.getName();
1772 String finderMethodName = "findByG_S";
1773 String[] finderParams = new String[] {
1774 Long.class.getName(), String.class.getName(),
1775
1776 "java.lang.Integer", "java.lang.Integer",
1777 "com.liferay.portal.kernel.util.OrderByComparator"
1778 };
1779 Object[] finderArgs = new Object[] {
1780 new Long(groupId),
1781
1782 structureId,
1783
1784 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1785 };
1786
1787 Object result = null;
1788
1789 if (finderClassNameCacheEnabled) {
1790 result = FinderCacheUtil.getResult(finderClassName,
1791 finderMethodName, finderParams, finderArgs, this);
1792 }
1793
1794 if (result == null) {
1795 Session session = null;
1796
1797 try {
1798 session = openSession();
1799
1800 StringBuilder query = new StringBuilder();
1801
1802 query.append(
1803 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1804
1805 query.append("groupId = ?");
1806
1807 query.append(" AND ");
1808
1809 if (structureId == null) {
1810 query.append("structureId IS NULL");
1811 }
1812 else {
1813 query.append("structureId = ?");
1814 }
1815
1816 query.append(" ");
1817
1818 if (obc != null) {
1819 query.append("ORDER BY ");
1820 query.append(obc.getOrderBy());
1821 }
1822
1823 else {
1824 query.append("ORDER BY ");
1825
1826 query.append("articleId ASC, ");
1827 query.append("version DESC");
1828 }
1829
1830 Query q = session.createQuery(query.toString());
1831
1832 QueryPos qPos = QueryPos.getInstance(q);
1833
1834 qPos.add(groupId);
1835
1836 if (structureId != null) {
1837 qPos.add(structureId);
1838 }
1839
1840 List<JournalArticle> list = (List<JournalArticle>)QueryUtil.list(q,
1841 getDialect(), start, end);
1842
1843 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1844 finderClassName, finderMethodName, finderParams,
1845 finderArgs, list);
1846
1847 return list;
1848 }
1849 catch (Exception e) {
1850 throw processException(e);
1851 }
1852 finally {
1853 closeSession(session);
1854 }
1855 }
1856 else {
1857 return (List<JournalArticle>)result;
1858 }
1859 }
1860
1861 public JournalArticle findByG_S_First(long groupId, String structureId,
1862 OrderByComparator obc) throws NoSuchArticleException, SystemException {
1863 List<JournalArticle> list = findByG_S(groupId, structureId, 0, 1, obc);
1864
1865 if (list.size() == 0) {
1866 StringBuilder msg = new StringBuilder();
1867
1868 msg.append("No JournalArticle exists with the key {");
1869
1870 msg.append("groupId=" + groupId);
1871
1872 msg.append(", ");
1873 msg.append("structureId=" + structureId);
1874
1875 msg.append(StringPool.CLOSE_CURLY_BRACE);
1876
1877 throw new NoSuchArticleException(msg.toString());
1878 }
1879 else {
1880 return list.get(0);
1881 }
1882 }
1883
1884 public JournalArticle findByG_S_Last(long groupId, String structureId,
1885 OrderByComparator obc) throws NoSuchArticleException, SystemException {
1886 int count = countByG_S(groupId, structureId);
1887
1888 List<JournalArticle> list = findByG_S(groupId, structureId, count - 1,
1889 count, obc);
1890
1891 if (list.size() == 0) {
1892 StringBuilder msg = new StringBuilder();
1893
1894 msg.append("No JournalArticle exists with the key {");
1895
1896 msg.append("groupId=" + groupId);
1897
1898 msg.append(", ");
1899 msg.append("structureId=" + structureId);
1900
1901 msg.append(StringPool.CLOSE_CURLY_BRACE);
1902
1903 throw new NoSuchArticleException(msg.toString());
1904 }
1905 else {
1906 return list.get(0);
1907 }
1908 }
1909
1910 public JournalArticle[] findByG_S_PrevAndNext(long id, long groupId,
1911 String structureId, OrderByComparator obc)
1912 throws NoSuchArticleException, SystemException {
1913 JournalArticle journalArticle = findByPrimaryKey(id);
1914
1915 int count = countByG_S(groupId, structureId);
1916
1917 Session session = null;
1918
1919 try {
1920 session = openSession();
1921
1922 StringBuilder query = new StringBuilder();
1923
1924 query.append(
1925 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
1926
1927 query.append("groupId = ?");
1928
1929 query.append(" AND ");
1930
1931 if (structureId == null) {
1932 query.append("structureId IS NULL");
1933 }
1934 else {
1935 query.append("structureId = ?");
1936 }
1937
1938 query.append(" ");
1939
1940 if (obc != null) {
1941 query.append("ORDER BY ");
1942 query.append(obc.getOrderBy());
1943 }
1944
1945 else {
1946 query.append("ORDER BY ");
1947
1948 query.append("articleId ASC, ");
1949 query.append("version DESC");
1950 }
1951
1952 Query q = session.createQuery(query.toString());
1953
1954 QueryPos qPos = QueryPos.getInstance(q);
1955
1956 qPos.add(groupId);
1957
1958 if (structureId != null) {
1959 qPos.add(structureId);
1960 }
1961
1962 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1963 journalArticle);
1964
1965 JournalArticle[] array = new JournalArticleImpl[3];
1966
1967 array[0] = (JournalArticle)objArray[0];
1968 array[1] = (JournalArticle)objArray[1];
1969 array[2] = (JournalArticle)objArray[2];
1970
1971 return array;
1972 }
1973 catch (Exception e) {
1974 throw processException(e);
1975 }
1976 finally {
1977 closeSession(session);
1978 }
1979 }
1980
1981 public List<JournalArticle> findByG_T(long groupId, String templateId)
1982 throws SystemException {
1983 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
1984 String finderClassName = JournalArticle.class.getName();
1985 String finderMethodName = "findByG_T";
1986 String[] finderParams = new String[] {
1987 Long.class.getName(), String.class.getName()
1988 };
1989 Object[] finderArgs = new Object[] { new Long(groupId), templateId };
1990
1991 Object result = null;
1992
1993 if (finderClassNameCacheEnabled) {
1994 result = FinderCacheUtil.getResult(finderClassName,
1995 finderMethodName, finderParams, finderArgs, this);
1996 }
1997
1998 if (result == null) {
1999 Session session = null;
2000
2001 try {
2002 session = openSession();
2003
2004 StringBuilder query = new StringBuilder();
2005
2006 query.append(
2007 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2008
2009 query.append("groupId = ?");
2010
2011 query.append(" AND ");
2012
2013 if (templateId == null) {
2014 query.append("templateId IS NULL");
2015 }
2016 else {
2017 query.append("templateId = ?");
2018 }
2019
2020 query.append(" ");
2021
2022 query.append("ORDER BY ");
2023
2024 query.append("articleId ASC, ");
2025 query.append("version DESC");
2026
2027 Query q = session.createQuery(query.toString());
2028
2029 QueryPos qPos = QueryPos.getInstance(q);
2030
2031 qPos.add(groupId);
2032
2033 if (templateId != null) {
2034 qPos.add(templateId);
2035 }
2036
2037 List<JournalArticle> list = q.list();
2038
2039 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2040 finderClassName, finderMethodName, finderParams,
2041 finderArgs, list);
2042
2043 return list;
2044 }
2045 catch (Exception e) {
2046 throw processException(e);
2047 }
2048 finally {
2049 closeSession(session);
2050 }
2051 }
2052 else {
2053 return (List<JournalArticle>)result;
2054 }
2055 }
2056
2057 public List<JournalArticle> findByG_T(long groupId, String templateId,
2058 int start, int end) throws SystemException {
2059 return findByG_T(groupId, templateId, start, end, null);
2060 }
2061
2062 public List<JournalArticle> findByG_T(long groupId, String templateId,
2063 int start, int end, OrderByComparator obc) throws SystemException {
2064 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
2065 String finderClassName = JournalArticle.class.getName();
2066 String finderMethodName = "findByG_T";
2067 String[] finderParams = new String[] {
2068 Long.class.getName(), String.class.getName(),
2069
2070 "java.lang.Integer", "java.lang.Integer",
2071 "com.liferay.portal.kernel.util.OrderByComparator"
2072 };
2073 Object[] finderArgs = new Object[] {
2074 new Long(groupId),
2075
2076 templateId,
2077
2078 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2079 };
2080
2081 Object result = null;
2082
2083 if (finderClassNameCacheEnabled) {
2084 result = FinderCacheUtil.getResult(finderClassName,
2085 finderMethodName, finderParams, finderArgs, this);
2086 }
2087
2088 if (result == null) {
2089 Session session = null;
2090
2091 try {
2092 session = openSession();
2093
2094 StringBuilder query = new StringBuilder();
2095
2096 query.append(
2097 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2098
2099 query.append("groupId = ?");
2100
2101 query.append(" AND ");
2102
2103 if (templateId == null) {
2104 query.append("templateId IS NULL");
2105 }
2106 else {
2107 query.append("templateId = ?");
2108 }
2109
2110 query.append(" ");
2111
2112 if (obc != null) {
2113 query.append("ORDER BY ");
2114 query.append(obc.getOrderBy());
2115 }
2116
2117 else {
2118 query.append("ORDER BY ");
2119
2120 query.append("articleId ASC, ");
2121 query.append("version DESC");
2122 }
2123
2124 Query q = session.createQuery(query.toString());
2125
2126 QueryPos qPos = QueryPos.getInstance(q);
2127
2128 qPos.add(groupId);
2129
2130 if (templateId != null) {
2131 qPos.add(templateId);
2132 }
2133
2134 List<JournalArticle> list = (List<JournalArticle>)QueryUtil.list(q,
2135 getDialect(), start, end);
2136
2137 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2138 finderClassName, finderMethodName, finderParams,
2139 finderArgs, list);
2140
2141 return list;
2142 }
2143 catch (Exception e) {
2144 throw processException(e);
2145 }
2146 finally {
2147 closeSession(session);
2148 }
2149 }
2150 else {
2151 return (List<JournalArticle>)result;
2152 }
2153 }
2154
2155 public JournalArticle findByG_T_First(long groupId, String templateId,
2156 OrderByComparator obc) throws NoSuchArticleException, SystemException {
2157 List<JournalArticle> list = findByG_T(groupId, templateId, 0, 1, obc);
2158
2159 if (list.size() == 0) {
2160 StringBuilder msg = new StringBuilder();
2161
2162 msg.append("No JournalArticle exists with the key {");
2163
2164 msg.append("groupId=" + groupId);
2165
2166 msg.append(", ");
2167 msg.append("templateId=" + templateId);
2168
2169 msg.append(StringPool.CLOSE_CURLY_BRACE);
2170
2171 throw new NoSuchArticleException(msg.toString());
2172 }
2173 else {
2174 return list.get(0);
2175 }
2176 }
2177
2178 public JournalArticle findByG_T_Last(long groupId, String templateId,
2179 OrderByComparator obc) throws NoSuchArticleException, SystemException {
2180 int count = countByG_T(groupId, templateId);
2181
2182 List<JournalArticle> list = findByG_T(groupId, templateId, count - 1,
2183 count, obc);
2184
2185 if (list.size() == 0) {
2186 StringBuilder msg = new StringBuilder();
2187
2188 msg.append("No JournalArticle exists with the key {");
2189
2190 msg.append("groupId=" + groupId);
2191
2192 msg.append(", ");
2193 msg.append("templateId=" + templateId);
2194
2195 msg.append(StringPool.CLOSE_CURLY_BRACE);
2196
2197 throw new NoSuchArticleException(msg.toString());
2198 }
2199 else {
2200 return list.get(0);
2201 }
2202 }
2203
2204 public JournalArticle[] findByG_T_PrevAndNext(long id, long groupId,
2205 String templateId, OrderByComparator obc)
2206 throws NoSuchArticleException, SystemException {
2207 JournalArticle journalArticle = findByPrimaryKey(id);
2208
2209 int count = countByG_T(groupId, templateId);
2210
2211 Session session = null;
2212
2213 try {
2214 session = openSession();
2215
2216 StringBuilder query = new StringBuilder();
2217
2218 query.append(
2219 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2220
2221 query.append("groupId = ?");
2222
2223 query.append(" AND ");
2224
2225 if (templateId == null) {
2226 query.append("templateId IS NULL");
2227 }
2228 else {
2229 query.append("templateId = ?");
2230 }
2231
2232 query.append(" ");
2233
2234 if (obc != null) {
2235 query.append("ORDER BY ");
2236 query.append(obc.getOrderBy());
2237 }
2238
2239 else {
2240 query.append("ORDER BY ");
2241
2242 query.append("articleId ASC, ");
2243 query.append("version DESC");
2244 }
2245
2246 Query q = session.createQuery(query.toString());
2247
2248 QueryPos qPos = QueryPos.getInstance(q);
2249
2250 qPos.add(groupId);
2251
2252 if (templateId != null) {
2253 qPos.add(templateId);
2254 }
2255
2256 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2257 journalArticle);
2258
2259 JournalArticle[] array = new JournalArticleImpl[3];
2260
2261 array[0] = (JournalArticle)objArray[0];
2262 array[1] = (JournalArticle)objArray[1];
2263 array[2] = (JournalArticle)objArray[2];
2264
2265 return array;
2266 }
2267 catch (Exception e) {
2268 throw processException(e);
2269 }
2270 finally {
2271 closeSession(session);
2272 }
2273 }
2274
2275 public JournalArticle findByG_A_V(long groupId, String articleId,
2276 double version) throws NoSuchArticleException, SystemException {
2277 JournalArticle journalArticle = fetchByG_A_V(groupId, articleId, version);
2278
2279 if (journalArticle == null) {
2280 StringBuilder msg = new StringBuilder();
2281
2282 msg.append("No JournalArticle exists with the key {");
2283
2284 msg.append("groupId=" + groupId);
2285
2286 msg.append(", ");
2287 msg.append("articleId=" + articleId);
2288
2289 msg.append(", ");
2290 msg.append("version=" + version);
2291
2292 msg.append(StringPool.CLOSE_CURLY_BRACE);
2293
2294 if (_log.isWarnEnabled()) {
2295 _log.warn(msg.toString());
2296 }
2297
2298 throw new NoSuchArticleException(msg.toString());
2299 }
2300
2301 return journalArticle;
2302 }
2303
2304 public JournalArticle fetchByG_A_V(long groupId, String articleId,
2305 double version) throws SystemException {
2306 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
2307 String finderClassName = JournalArticle.class.getName();
2308 String finderMethodName = "fetchByG_A_V";
2309 String[] finderParams = new String[] {
2310 Long.class.getName(), String.class.getName(),
2311 Double.class.getName()
2312 };
2313 Object[] finderArgs = new Object[] {
2314 new Long(groupId),
2315
2316 articleId, new Double(version)
2317 };
2318
2319 Object result = null;
2320
2321 if (finderClassNameCacheEnabled) {
2322 result = FinderCacheUtil.getResult(finderClassName,
2323 finderMethodName, finderParams, finderArgs, this);
2324 }
2325
2326 if (result == null) {
2327 Session session = null;
2328
2329 try {
2330 session = openSession();
2331
2332 StringBuilder query = new StringBuilder();
2333
2334 query.append(
2335 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2336
2337 query.append("groupId = ?");
2338
2339 query.append(" AND ");
2340
2341 if (articleId == null) {
2342 query.append("articleId IS NULL");
2343 }
2344 else {
2345 query.append("articleId = ?");
2346 }
2347
2348 query.append(" AND ");
2349
2350 query.append("version = ?");
2351
2352 query.append(" ");
2353
2354 query.append("ORDER BY ");
2355
2356 query.append("articleId ASC, ");
2357 query.append("version DESC");
2358
2359 Query q = session.createQuery(query.toString());
2360
2361 QueryPos qPos = QueryPos.getInstance(q);
2362
2363 qPos.add(groupId);
2364
2365 if (articleId != null) {
2366 qPos.add(articleId);
2367 }
2368
2369 qPos.add(version);
2370
2371 List<JournalArticle> list = q.list();
2372
2373 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2374 finderClassName, finderMethodName, finderParams,
2375 finderArgs, list);
2376
2377 if (list.size() == 0) {
2378 return null;
2379 }
2380 else {
2381 return list.get(0);
2382 }
2383 }
2384 catch (Exception e) {
2385 throw processException(e);
2386 }
2387 finally {
2388 closeSession(session);
2389 }
2390 }
2391 else {
2392 List<JournalArticle> list = (List<JournalArticle>)result;
2393
2394 if (list.size() == 0) {
2395 return null;
2396 }
2397 else {
2398 return list.get(0);
2399 }
2400 }
2401 }
2402
2403 public List<JournalArticle> findByG_A_A(long groupId, String articleId,
2404 boolean approved) throws SystemException {
2405 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
2406 String finderClassName = JournalArticle.class.getName();
2407 String finderMethodName = "findByG_A_A";
2408 String[] finderParams = new String[] {
2409 Long.class.getName(), String.class.getName(),
2410 Boolean.class.getName()
2411 };
2412 Object[] finderArgs = new Object[] {
2413 new Long(groupId),
2414
2415 articleId, Boolean.valueOf(approved)
2416 };
2417
2418 Object result = null;
2419
2420 if (finderClassNameCacheEnabled) {
2421 result = FinderCacheUtil.getResult(finderClassName,
2422 finderMethodName, finderParams, finderArgs, this);
2423 }
2424
2425 if (result == null) {
2426 Session session = null;
2427
2428 try {
2429 session = openSession();
2430
2431 StringBuilder query = new StringBuilder();
2432
2433 query.append(
2434 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2435
2436 query.append("groupId = ?");
2437
2438 query.append(" AND ");
2439
2440 if (articleId == null) {
2441 query.append("articleId IS NULL");
2442 }
2443 else {
2444 query.append("articleId = ?");
2445 }
2446
2447 query.append(" AND ");
2448
2449 query.append("approved = ?");
2450
2451 query.append(" ");
2452
2453 query.append("ORDER BY ");
2454
2455 query.append("articleId ASC, ");
2456 query.append("version DESC");
2457
2458 Query q = session.createQuery(query.toString());
2459
2460 QueryPos qPos = QueryPos.getInstance(q);
2461
2462 qPos.add(groupId);
2463
2464 if (articleId != null) {
2465 qPos.add(articleId);
2466 }
2467
2468 qPos.add(approved);
2469
2470 List<JournalArticle> list = q.list();
2471
2472 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2473 finderClassName, finderMethodName, finderParams,
2474 finderArgs, list);
2475
2476 return list;
2477 }
2478 catch (Exception e) {
2479 throw processException(e);
2480 }
2481 finally {
2482 closeSession(session);
2483 }
2484 }
2485 else {
2486 return (List<JournalArticle>)result;
2487 }
2488 }
2489
2490 public List<JournalArticle> findByG_A_A(long groupId, String articleId,
2491 boolean approved, int start, int end) throws SystemException {
2492 return findByG_A_A(groupId, articleId, approved, start, end, null);
2493 }
2494
2495 public List<JournalArticle> findByG_A_A(long groupId, String articleId,
2496 boolean approved, int start, int end, OrderByComparator obc)
2497 throws SystemException {
2498 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
2499 String finderClassName = JournalArticle.class.getName();
2500 String finderMethodName = "findByG_A_A";
2501 String[] finderParams = new String[] {
2502 Long.class.getName(), String.class.getName(),
2503 Boolean.class.getName(),
2504
2505 "java.lang.Integer", "java.lang.Integer",
2506 "com.liferay.portal.kernel.util.OrderByComparator"
2507 };
2508 Object[] finderArgs = new Object[] {
2509 new Long(groupId),
2510
2511 articleId, Boolean.valueOf(approved),
2512
2513 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2514 };
2515
2516 Object result = null;
2517
2518 if (finderClassNameCacheEnabled) {
2519 result = FinderCacheUtil.getResult(finderClassName,
2520 finderMethodName, finderParams, finderArgs, this);
2521 }
2522
2523 if (result == null) {
2524 Session session = null;
2525
2526 try {
2527 session = openSession();
2528
2529 StringBuilder query = new StringBuilder();
2530
2531 query.append(
2532 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2533
2534 query.append("groupId = ?");
2535
2536 query.append(" AND ");
2537
2538 if (articleId == null) {
2539 query.append("articleId IS NULL");
2540 }
2541 else {
2542 query.append("articleId = ?");
2543 }
2544
2545 query.append(" AND ");
2546
2547 query.append("approved = ?");
2548
2549 query.append(" ");
2550
2551 if (obc != null) {
2552 query.append("ORDER BY ");
2553 query.append(obc.getOrderBy());
2554 }
2555
2556 else {
2557 query.append("ORDER BY ");
2558
2559 query.append("articleId ASC, ");
2560 query.append("version DESC");
2561 }
2562
2563 Query q = session.createQuery(query.toString());
2564
2565 QueryPos qPos = QueryPos.getInstance(q);
2566
2567 qPos.add(groupId);
2568
2569 if (articleId != null) {
2570 qPos.add(articleId);
2571 }
2572
2573 qPos.add(approved);
2574
2575 List<JournalArticle> list = (List<JournalArticle>)QueryUtil.list(q,
2576 getDialect(), start, end);
2577
2578 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2579 finderClassName, finderMethodName, finderParams,
2580 finderArgs, list);
2581
2582 return list;
2583 }
2584 catch (Exception e) {
2585 throw processException(e);
2586 }
2587 finally {
2588 closeSession(session);
2589 }
2590 }
2591 else {
2592 return (List<JournalArticle>)result;
2593 }
2594 }
2595
2596 public JournalArticle findByG_A_A_First(long groupId, String articleId,
2597 boolean approved, OrderByComparator obc)
2598 throws NoSuchArticleException, SystemException {
2599 List<JournalArticle> list = findByG_A_A(groupId, articleId, approved,
2600 0, 1, obc);
2601
2602 if (list.size() == 0) {
2603 StringBuilder msg = new StringBuilder();
2604
2605 msg.append("No JournalArticle exists with the key {");
2606
2607 msg.append("groupId=" + groupId);
2608
2609 msg.append(", ");
2610 msg.append("articleId=" + articleId);
2611
2612 msg.append(", ");
2613 msg.append("approved=" + approved);
2614
2615 msg.append(StringPool.CLOSE_CURLY_BRACE);
2616
2617 throw new NoSuchArticleException(msg.toString());
2618 }
2619 else {
2620 return list.get(0);
2621 }
2622 }
2623
2624 public JournalArticle findByG_A_A_Last(long groupId, String articleId,
2625 boolean approved, OrderByComparator obc)
2626 throws NoSuchArticleException, SystemException {
2627 int count = countByG_A_A(groupId, articleId, approved);
2628
2629 List<JournalArticle> list = findByG_A_A(groupId, articleId, approved,
2630 count - 1, count, obc);
2631
2632 if (list.size() == 0) {
2633 StringBuilder msg = new StringBuilder();
2634
2635 msg.append("No JournalArticle exists with the key {");
2636
2637 msg.append("groupId=" + groupId);
2638
2639 msg.append(", ");
2640 msg.append("articleId=" + articleId);
2641
2642 msg.append(", ");
2643 msg.append("approved=" + approved);
2644
2645 msg.append(StringPool.CLOSE_CURLY_BRACE);
2646
2647 throw new NoSuchArticleException(msg.toString());
2648 }
2649 else {
2650 return list.get(0);
2651 }
2652 }
2653
2654 public JournalArticle[] findByG_A_A_PrevAndNext(long id, long groupId,
2655 String articleId, boolean approved, OrderByComparator obc)
2656 throws NoSuchArticleException, SystemException {
2657 JournalArticle journalArticle = findByPrimaryKey(id);
2658
2659 int count = countByG_A_A(groupId, articleId, approved);
2660
2661 Session session = null;
2662
2663 try {
2664 session = openSession();
2665
2666 StringBuilder query = new StringBuilder();
2667
2668 query.append(
2669 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2670
2671 query.append("groupId = ?");
2672
2673 query.append(" AND ");
2674
2675 if (articleId == null) {
2676 query.append("articleId IS NULL");
2677 }
2678 else {
2679 query.append("articleId = ?");
2680 }
2681
2682 query.append(" AND ");
2683
2684 query.append("approved = ?");
2685
2686 query.append(" ");
2687
2688 if (obc != null) {
2689 query.append("ORDER BY ");
2690 query.append(obc.getOrderBy());
2691 }
2692
2693 else {
2694 query.append("ORDER BY ");
2695
2696 query.append("articleId ASC, ");
2697 query.append("version DESC");
2698 }
2699
2700 Query q = session.createQuery(query.toString());
2701
2702 QueryPos qPos = QueryPos.getInstance(q);
2703
2704 qPos.add(groupId);
2705
2706 if (articleId != null) {
2707 qPos.add(articleId);
2708 }
2709
2710 qPos.add(approved);
2711
2712 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
2713 journalArticle);
2714
2715 JournalArticle[] array = new JournalArticleImpl[3];
2716
2717 array[0] = (JournalArticle)objArray[0];
2718 array[1] = (JournalArticle)objArray[1];
2719 array[2] = (JournalArticle)objArray[2];
2720
2721 return array;
2722 }
2723 catch (Exception e) {
2724 throw processException(e);
2725 }
2726 finally {
2727 closeSession(session);
2728 }
2729 }
2730
2731 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
2732 throws SystemException {
2733 Session session = null;
2734
2735 try {
2736 session = openSession();
2737
2738 dynamicQuery.compile(session);
2739
2740 return dynamicQuery.list();
2741 }
2742 catch (Exception e) {
2743 throw processException(e);
2744 }
2745 finally {
2746 closeSession(session);
2747 }
2748 }
2749
2750 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
2751 int start, int end) throws SystemException {
2752 Session session = null;
2753
2754 try {
2755 session = openSession();
2756
2757 dynamicQuery.setLimit(start, end);
2758
2759 dynamicQuery.compile(session);
2760
2761 return dynamicQuery.list();
2762 }
2763 catch (Exception e) {
2764 throw processException(e);
2765 }
2766 finally {
2767 closeSession(session);
2768 }
2769 }
2770
2771 public List<JournalArticle> findAll() throws SystemException {
2772 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2773 }
2774
2775 public List<JournalArticle> findAll(int start, int end)
2776 throws SystemException {
2777 return findAll(start, end, null);
2778 }
2779
2780 public List<JournalArticle> findAll(int start, int end,
2781 OrderByComparator obc) throws SystemException {
2782 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
2783 String finderClassName = JournalArticle.class.getName();
2784 String finderMethodName = "findAll";
2785 String[] finderParams = new String[] {
2786 "java.lang.Integer", "java.lang.Integer",
2787 "com.liferay.portal.kernel.util.OrderByComparator"
2788 };
2789 Object[] finderArgs = new Object[] {
2790 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
2791 };
2792
2793 Object result = null;
2794
2795 if (finderClassNameCacheEnabled) {
2796 result = FinderCacheUtil.getResult(finderClassName,
2797 finderMethodName, finderParams, finderArgs, this);
2798 }
2799
2800 if (result == null) {
2801 Session session = null;
2802
2803 try {
2804 session = openSession();
2805
2806 StringBuilder query = new StringBuilder();
2807
2808 query.append(
2809 "FROM com.liferay.portlet.journal.model.JournalArticle ");
2810
2811 if (obc != null) {
2812 query.append("ORDER BY ");
2813 query.append(obc.getOrderBy());
2814 }
2815
2816 else {
2817 query.append("ORDER BY ");
2818
2819 query.append("articleId ASC, ");
2820 query.append("version DESC");
2821 }
2822
2823 Query q = session.createQuery(query.toString());
2824
2825 List<JournalArticle> list = (List<JournalArticle>)QueryUtil.list(q,
2826 getDialect(), start, end);
2827
2828 if (obc == null) {
2829 Collections.sort(list);
2830 }
2831
2832 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2833 finderClassName, finderMethodName, finderParams,
2834 finderArgs, list);
2835
2836 return list;
2837 }
2838 catch (Exception e) {
2839 throw processException(e);
2840 }
2841 finally {
2842 closeSession(session);
2843 }
2844 }
2845 else {
2846 return (List<JournalArticle>)result;
2847 }
2848 }
2849
2850 public void removeByUuid(String uuid) throws SystemException {
2851 for (JournalArticle journalArticle : findByUuid(uuid)) {
2852 remove(journalArticle);
2853 }
2854 }
2855
2856 public void removeByUUID_G(String uuid, long groupId)
2857 throws NoSuchArticleException, SystemException {
2858 JournalArticle journalArticle = findByUUID_G(uuid, groupId);
2859
2860 remove(journalArticle);
2861 }
2862
2863 public void removeByGroupId(long groupId) throws SystemException {
2864 for (JournalArticle journalArticle : findByGroupId(groupId)) {
2865 remove(journalArticle);
2866 }
2867 }
2868
2869 public void removeByCompanyId(long companyId) throws SystemException {
2870 for (JournalArticle journalArticle : findByCompanyId(companyId)) {
2871 remove(journalArticle);
2872 }
2873 }
2874
2875 public void removeBySmallImageId(long smallImageId)
2876 throws SystemException {
2877 for (JournalArticle journalArticle : findBySmallImageId(smallImageId)) {
2878 remove(journalArticle);
2879 }
2880 }
2881
2882 public void removeByG_A(long groupId, String articleId)
2883 throws SystemException {
2884 for (JournalArticle journalArticle : findByG_A(groupId, articleId)) {
2885 remove(journalArticle);
2886 }
2887 }
2888
2889 public void removeByG_S(long groupId, String structureId)
2890 throws SystemException {
2891 for (JournalArticle journalArticle : findByG_S(groupId, structureId)) {
2892 remove(journalArticle);
2893 }
2894 }
2895
2896 public void removeByG_T(long groupId, String templateId)
2897 throws SystemException {
2898 for (JournalArticle journalArticle : findByG_T(groupId, templateId)) {
2899 remove(journalArticle);
2900 }
2901 }
2902
2903 public void removeByG_A_V(long groupId, String articleId, double version)
2904 throws NoSuchArticleException, SystemException {
2905 JournalArticle journalArticle = findByG_A_V(groupId, articleId, version);
2906
2907 remove(journalArticle);
2908 }
2909
2910 public void removeByG_A_A(long groupId, String articleId, boolean approved)
2911 throws SystemException {
2912 for (JournalArticle journalArticle : findByG_A_A(groupId, articleId,
2913 approved)) {
2914 remove(journalArticle);
2915 }
2916 }
2917
2918 public void removeAll() throws SystemException {
2919 for (JournalArticle journalArticle : findAll()) {
2920 remove(journalArticle);
2921 }
2922 }
2923
2924 public int countByUuid(String uuid) throws SystemException {
2925 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
2926 String finderClassName = JournalArticle.class.getName();
2927 String finderMethodName = "countByUuid";
2928 String[] finderParams = new String[] { String.class.getName() };
2929 Object[] finderArgs = new Object[] { uuid };
2930
2931 Object result = null;
2932
2933 if (finderClassNameCacheEnabled) {
2934 result = FinderCacheUtil.getResult(finderClassName,
2935 finderMethodName, finderParams, finderArgs, this);
2936 }
2937
2938 if (result == null) {
2939 Session session = null;
2940
2941 try {
2942 session = openSession();
2943
2944 StringBuilder query = new StringBuilder();
2945
2946 query.append("SELECT COUNT(*) ");
2947 query.append(
2948 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
2949
2950 if (uuid == null) {
2951 query.append("uuid_ IS NULL");
2952 }
2953 else {
2954 query.append("uuid_ = ?");
2955 }
2956
2957 query.append(" ");
2958
2959 Query q = session.createQuery(query.toString());
2960
2961 QueryPos qPos = QueryPos.getInstance(q);
2962
2963 if (uuid != null) {
2964 qPos.add(uuid);
2965 }
2966
2967 Long count = null;
2968
2969 Iterator<Long> itr = q.list().iterator();
2970
2971 if (itr.hasNext()) {
2972 count = itr.next();
2973 }
2974
2975 if (count == null) {
2976 count = new Long(0);
2977 }
2978
2979 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2980 finderClassName, finderMethodName, finderParams,
2981 finderArgs, count);
2982
2983 return count.intValue();
2984 }
2985 catch (Exception e) {
2986 throw processException(e);
2987 }
2988 finally {
2989 closeSession(session);
2990 }
2991 }
2992 else {
2993 return ((Long)result).intValue();
2994 }
2995 }
2996
2997 public int countByUUID_G(String uuid, long groupId)
2998 throws SystemException {
2999 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3000 String finderClassName = JournalArticle.class.getName();
3001 String finderMethodName = "countByUUID_G";
3002 String[] finderParams = new String[] {
3003 String.class.getName(), Long.class.getName()
3004 };
3005 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
3006
3007 Object result = null;
3008
3009 if (finderClassNameCacheEnabled) {
3010 result = FinderCacheUtil.getResult(finderClassName,
3011 finderMethodName, finderParams, finderArgs, this);
3012 }
3013
3014 if (result == null) {
3015 Session session = null;
3016
3017 try {
3018 session = openSession();
3019
3020 StringBuilder query = new StringBuilder();
3021
3022 query.append("SELECT COUNT(*) ");
3023 query.append(
3024 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3025
3026 if (uuid == null) {
3027 query.append("uuid_ IS NULL");
3028 }
3029 else {
3030 query.append("uuid_ = ?");
3031 }
3032
3033 query.append(" AND ");
3034
3035 query.append("groupId = ?");
3036
3037 query.append(" ");
3038
3039 Query q = session.createQuery(query.toString());
3040
3041 QueryPos qPos = QueryPos.getInstance(q);
3042
3043 if (uuid != null) {
3044 qPos.add(uuid);
3045 }
3046
3047 qPos.add(groupId);
3048
3049 Long count = null;
3050
3051 Iterator<Long> itr = q.list().iterator();
3052
3053 if (itr.hasNext()) {
3054 count = itr.next();
3055 }
3056
3057 if (count == null) {
3058 count = new Long(0);
3059 }
3060
3061 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3062 finderClassName, finderMethodName, finderParams,
3063 finderArgs, count);
3064
3065 return count.intValue();
3066 }
3067 catch (Exception e) {
3068 throw processException(e);
3069 }
3070 finally {
3071 closeSession(session);
3072 }
3073 }
3074 else {
3075 return ((Long)result).intValue();
3076 }
3077 }
3078
3079 public int countByGroupId(long groupId) throws SystemException {
3080 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3081 String finderClassName = JournalArticle.class.getName();
3082 String finderMethodName = "countByGroupId";
3083 String[] finderParams = new String[] { Long.class.getName() };
3084 Object[] finderArgs = new Object[] { new Long(groupId) };
3085
3086 Object result = null;
3087
3088 if (finderClassNameCacheEnabled) {
3089 result = FinderCacheUtil.getResult(finderClassName,
3090 finderMethodName, finderParams, finderArgs, this);
3091 }
3092
3093 if (result == null) {
3094 Session session = null;
3095
3096 try {
3097 session = openSession();
3098
3099 StringBuilder query = new StringBuilder();
3100
3101 query.append("SELECT COUNT(*) ");
3102 query.append(
3103 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3104
3105 query.append("groupId = ?");
3106
3107 query.append(" ");
3108
3109 Query q = session.createQuery(query.toString());
3110
3111 QueryPos qPos = QueryPos.getInstance(q);
3112
3113 qPos.add(groupId);
3114
3115 Long count = null;
3116
3117 Iterator<Long> itr = q.list().iterator();
3118
3119 if (itr.hasNext()) {
3120 count = itr.next();
3121 }
3122
3123 if (count == null) {
3124 count = new Long(0);
3125 }
3126
3127 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3128 finderClassName, finderMethodName, finderParams,
3129 finderArgs, count);
3130
3131 return count.intValue();
3132 }
3133 catch (Exception e) {
3134 throw processException(e);
3135 }
3136 finally {
3137 closeSession(session);
3138 }
3139 }
3140 else {
3141 return ((Long)result).intValue();
3142 }
3143 }
3144
3145 public int countByCompanyId(long companyId) throws SystemException {
3146 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3147 String finderClassName = JournalArticle.class.getName();
3148 String finderMethodName = "countByCompanyId";
3149 String[] finderParams = new String[] { Long.class.getName() };
3150 Object[] finderArgs = new Object[] { new Long(companyId) };
3151
3152 Object result = null;
3153
3154 if (finderClassNameCacheEnabled) {
3155 result = FinderCacheUtil.getResult(finderClassName,
3156 finderMethodName, finderParams, finderArgs, this);
3157 }
3158
3159 if (result == null) {
3160 Session session = null;
3161
3162 try {
3163 session = openSession();
3164
3165 StringBuilder query = new StringBuilder();
3166
3167 query.append("SELECT COUNT(*) ");
3168 query.append(
3169 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3170
3171 query.append("companyId = ?");
3172
3173 query.append(" ");
3174
3175 Query q = session.createQuery(query.toString());
3176
3177 QueryPos qPos = QueryPos.getInstance(q);
3178
3179 qPos.add(companyId);
3180
3181 Long count = null;
3182
3183 Iterator<Long> itr = q.list().iterator();
3184
3185 if (itr.hasNext()) {
3186 count = itr.next();
3187 }
3188
3189 if (count == null) {
3190 count = new Long(0);
3191 }
3192
3193 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3194 finderClassName, finderMethodName, finderParams,
3195 finderArgs, count);
3196
3197 return count.intValue();
3198 }
3199 catch (Exception e) {
3200 throw processException(e);
3201 }
3202 finally {
3203 closeSession(session);
3204 }
3205 }
3206 else {
3207 return ((Long)result).intValue();
3208 }
3209 }
3210
3211 public int countBySmallImageId(long smallImageId) throws SystemException {
3212 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3213 String finderClassName = JournalArticle.class.getName();
3214 String finderMethodName = "countBySmallImageId";
3215 String[] finderParams = new String[] { Long.class.getName() };
3216 Object[] finderArgs = new Object[] { new Long(smallImageId) };
3217
3218 Object result = null;
3219
3220 if (finderClassNameCacheEnabled) {
3221 result = FinderCacheUtil.getResult(finderClassName,
3222 finderMethodName, finderParams, finderArgs, this);
3223 }
3224
3225 if (result == null) {
3226 Session session = null;
3227
3228 try {
3229 session = openSession();
3230
3231 StringBuilder query = new StringBuilder();
3232
3233 query.append("SELECT COUNT(*) ");
3234 query.append(
3235 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3236
3237 query.append("smallImageId = ?");
3238
3239 query.append(" ");
3240
3241 Query q = session.createQuery(query.toString());
3242
3243 QueryPos qPos = QueryPos.getInstance(q);
3244
3245 qPos.add(smallImageId);
3246
3247 Long count = null;
3248
3249 Iterator<Long> itr = q.list().iterator();
3250
3251 if (itr.hasNext()) {
3252 count = itr.next();
3253 }
3254
3255 if (count == null) {
3256 count = new Long(0);
3257 }
3258
3259 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3260 finderClassName, finderMethodName, finderParams,
3261 finderArgs, count);
3262
3263 return count.intValue();
3264 }
3265 catch (Exception e) {
3266 throw processException(e);
3267 }
3268 finally {
3269 closeSession(session);
3270 }
3271 }
3272 else {
3273 return ((Long)result).intValue();
3274 }
3275 }
3276
3277 public int countByG_A(long groupId, String articleId)
3278 throws SystemException {
3279 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3280 String finderClassName = JournalArticle.class.getName();
3281 String finderMethodName = "countByG_A";
3282 String[] finderParams = new String[] {
3283 Long.class.getName(), String.class.getName()
3284 };
3285 Object[] finderArgs = new Object[] { new Long(groupId), articleId };
3286
3287 Object result = null;
3288
3289 if (finderClassNameCacheEnabled) {
3290 result = FinderCacheUtil.getResult(finderClassName,
3291 finderMethodName, finderParams, finderArgs, this);
3292 }
3293
3294 if (result == null) {
3295 Session session = null;
3296
3297 try {
3298 session = openSession();
3299
3300 StringBuilder query = new StringBuilder();
3301
3302 query.append("SELECT COUNT(*) ");
3303 query.append(
3304 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3305
3306 query.append("groupId = ?");
3307
3308 query.append(" AND ");
3309
3310 if (articleId == null) {
3311 query.append("articleId IS NULL");
3312 }
3313 else {
3314 query.append("articleId = ?");
3315 }
3316
3317 query.append(" ");
3318
3319 Query q = session.createQuery(query.toString());
3320
3321 QueryPos qPos = QueryPos.getInstance(q);
3322
3323 qPos.add(groupId);
3324
3325 if (articleId != null) {
3326 qPos.add(articleId);
3327 }
3328
3329 Long count = null;
3330
3331 Iterator<Long> itr = q.list().iterator();
3332
3333 if (itr.hasNext()) {
3334 count = itr.next();
3335 }
3336
3337 if (count == null) {
3338 count = new Long(0);
3339 }
3340
3341 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3342 finderClassName, finderMethodName, finderParams,
3343 finderArgs, count);
3344
3345 return count.intValue();
3346 }
3347 catch (Exception e) {
3348 throw processException(e);
3349 }
3350 finally {
3351 closeSession(session);
3352 }
3353 }
3354 else {
3355 return ((Long)result).intValue();
3356 }
3357 }
3358
3359 public int countByG_S(long groupId, String structureId)
3360 throws SystemException {
3361 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3362 String finderClassName = JournalArticle.class.getName();
3363 String finderMethodName = "countByG_S";
3364 String[] finderParams = new String[] {
3365 Long.class.getName(), String.class.getName()
3366 };
3367 Object[] finderArgs = new Object[] { new Long(groupId), structureId };
3368
3369 Object result = null;
3370
3371 if (finderClassNameCacheEnabled) {
3372 result = FinderCacheUtil.getResult(finderClassName,
3373 finderMethodName, finderParams, finderArgs, this);
3374 }
3375
3376 if (result == null) {
3377 Session session = null;
3378
3379 try {
3380 session = openSession();
3381
3382 StringBuilder query = new StringBuilder();
3383
3384 query.append("SELECT COUNT(*) ");
3385 query.append(
3386 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3387
3388 query.append("groupId = ?");
3389
3390 query.append(" AND ");
3391
3392 if (structureId == null) {
3393 query.append("structureId IS NULL");
3394 }
3395 else {
3396 query.append("structureId = ?");
3397 }
3398
3399 query.append(" ");
3400
3401 Query q = session.createQuery(query.toString());
3402
3403 QueryPos qPos = QueryPos.getInstance(q);
3404
3405 qPos.add(groupId);
3406
3407 if (structureId != null) {
3408 qPos.add(structureId);
3409 }
3410
3411 Long count = null;
3412
3413 Iterator<Long> itr = q.list().iterator();
3414
3415 if (itr.hasNext()) {
3416 count = itr.next();
3417 }
3418
3419 if (count == null) {
3420 count = new Long(0);
3421 }
3422
3423 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3424 finderClassName, finderMethodName, finderParams,
3425 finderArgs, count);
3426
3427 return count.intValue();
3428 }
3429 catch (Exception e) {
3430 throw processException(e);
3431 }
3432 finally {
3433 closeSession(session);
3434 }
3435 }
3436 else {
3437 return ((Long)result).intValue();
3438 }
3439 }
3440
3441 public int countByG_T(long groupId, String templateId)
3442 throws SystemException {
3443 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3444 String finderClassName = JournalArticle.class.getName();
3445 String finderMethodName = "countByG_T";
3446 String[] finderParams = new String[] {
3447 Long.class.getName(), String.class.getName()
3448 };
3449 Object[] finderArgs = new Object[] { new Long(groupId), templateId };
3450
3451 Object result = null;
3452
3453 if (finderClassNameCacheEnabled) {
3454 result = FinderCacheUtil.getResult(finderClassName,
3455 finderMethodName, finderParams, finderArgs, this);
3456 }
3457
3458 if (result == null) {
3459 Session session = null;
3460
3461 try {
3462 session = openSession();
3463
3464 StringBuilder query = new StringBuilder();
3465
3466 query.append("SELECT COUNT(*) ");
3467 query.append(
3468 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3469
3470 query.append("groupId = ?");
3471
3472 query.append(" AND ");
3473
3474 if (templateId == null) {
3475 query.append("templateId IS NULL");
3476 }
3477 else {
3478 query.append("templateId = ?");
3479 }
3480
3481 query.append(" ");
3482
3483 Query q = session.createQuery(query.toString());
3484
3485 QueryPos qPos = QueryPos.getInstance(q);
3486
3487 qPos.add(groupId);
3488
3489 if (templateId != null) {
3490 qPos.add(templateId);
3491 }
3492
3493 Long count = null;
3494
3495 Iterator<Long> itr = q.list().iterator();
3496
3497 if (itr.hasNext()) {
3498 count = itr.next();
3499 }
3500
3501 if (count == null) {
3502 count = new Long(0);
3503 }
3504
3505 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3506 finderClassName, finderMethodName, finderParams,
3507 finderArgs, count);
3508
3509 return count.intValue();
3510 }
3511 catch (Exception e) {
3512 throw processException(e);
3513 }
3514 finally {
3515 closeSession(session);
3516 }
3517 }
3518 else {
3519 return ((Long)result).intValue();
3520 }
3521 }
3522
3523 public int countByG_A_V(long groupId, String articleId, double version)
3524 throws SystemException {
3525 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3526 String finderClassName = JournalArticle.class.getName();
3527 String finderMethodName = "countByG_A_V";
3528 String[] finderParams = new String[] {
3529 Long.class.getName(), String.class.getName(),
3530 Double.class.getName()
3531 };
3532 Object[] finderArgs = new Object[] {
3533 new Long(groupId),
3534
3535 articleId, new Double(version)
3536 };
3537
3538 Object result = null;
3539
3540 if (finderClassNameCacheEnabled) {
3541 result = FinderCacheUtil.getResult(finderClassName,
3542 finderMethodName, finderParams, finderArgs, this);
3543 }
3544
3545 if (result == null) {
3546 Session session = null;
3547
3548 try {
3549 session = openSession();
3550
3551 StringBuilder query = new StringBuilder();
3552
3553 query.append("SELECT COUNT(*) ");
3554 query.append(
3555 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3556
3557 query.append("groupId = ?");
3558
3559 query.append(" AND ");
3560
3561 if (articleId == null) {
3562 query.append("articleId IS NULL");
3563 }
3564 else {
3565 query.append("articleId = ?");
3566 }
3567
3568 query.append(" AND ");
3569
3570 query.append("version = ?");
3571
3572 query.append(" ");
3573
3574 Query q = session.createQuery(query.toString());
3575
3576 QueryPos qPos = QueryPos.getInstance(q);
3577
3578 qPos.add(groupId);
3579
3580 if (articleId != null) {
3581 qPos.add(articleId);
3582 }
3583
3584 qPos.add(version);
3585
3586 Long count = null;
3587
3588 Iterator<Long> itr = q.list().iterator();
3589
3590 if (itr.hasNext()) {
3591 count = itr.next();
3592 }
3593
3594 if (count == null) {
3595 count = new Long(0);
3596 }
3597
3598 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3599 finderClassName, finderMethodName, finderParams,
3600 finderArgs, count);
3601
3602 return count.intValue();
3603 }
3604 catch (Exception e) {
3605 throw processException(e);
3606 }
3607 finally {
3608 closeSession(session);
3609 }
3610 }
3611 else {
3612 return ((Long)result).intValue();
3613 }
3614 }
3615
3616 public int countByG_A_A(long groupId, String articleId, boolean approved)
3617 throws SystemException {
3618 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3619 String finderClassName = JournalArticle.class.getName();
3620 String finderMethodName = "countByG_A_A";
3621 String[] finderParams = new String[] {
3622 Long.class.getName(), String.class.getName(),
3623 Boolean.class.getName()
3624 };
3625 Object[] finderArgs = new Object[] {
3626 new Long(groupId),
3627
3628 articleId, Boolean.valueOf(approved)
3629 };
3630
3631 Object result = null;
3632
3633 if (finderClassNameCacheEnabled) {
3634 result = FinderCacheUtil.getResult(finderClassName,
3635 finderMethodName, finderParams, finderArgs, this);
3636 }
3637
3638 if (result == null) {
3639 Session session = null;
3640
3641 try {
3642 session = openSession();
3643
3644 StringBuilder query = new StringBuilder();
3645
3646 query.append("SELECT COUNT(*) ");
3647 query.append(
3648 "FROM com.liferay.portlet.journal.model.JournalArticle WHERE ");
3649
3650 query.append("groupId = ?");
3651
3652 query.append(" AND ");
3653
3654 if (articleId == null) {
3655 query.append("articleId IS NULL");
3656 }
3657 else {
3658 query.append("articleId = ?");
3659 }
3660
3661 query.append(" AND ");
3662
3663 query.append("approved = ?");
3664
3665 query.append(" ");
3666
3667 Query q = session.createQuery(query.toString());
3668
3669 QueryPos qPos = QueryPos.getInstance(q);
3670
3671 qPos.add(groupId);
3672
3673 if (articleId != null) {
3674 qPos.add(articleId);
3675 }
3676
3677 qPos.add(approved);
3678
3679 Long count = null;
3680
3681 Iterator<Long> itr = q.list().iterator();
3682
3683 if (itr.hasNext()) {
3684 count = itr.next();
3685 }
3686
3687 if (count == null) {
3688 count = new Long(0);
3689 }
3690
3691 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3692 finderClassName, finderMethodName, finderParams,
3693 finderArgs, count);
3694
3695 return count.intValue();
3696 }
3697 catch (Exception e) {
3698 throw processException(e);
3699 }
3700 finally {
3701 closeSession(session);
3702 }
3703 }
3704 else {
3705 return ((Long)result).intValue();
3706 }
3707 }
3708
3709 public int countAll() throws SystemException {
3710 boolean finderClassNameCacheEnabled = JournalArticleModelImpl.CACHE_ENABLED;
3711 String finderClassName = JournalArticle.class.getName();
3712 String finderMethodName = "countAll";
3713 String[] finderParams = new String[] { };
3714 Object[] finderArgs = new Object[] { };
3715
3716 Object result = null;
3717
3718 if (finderClassNameCacheEnabled) {
3719 result = FinderCacheUtil.getResult(finderClassName,
3720 finderMethodName, finderParams, finderArgs, this);
3721 }
3722
3723 if (result == null) {
3724 Session session = null;
3725
3726 try {
3727 session = openSession();
3728
3729 Query q = session.createQuery(
3730 "SELECT COUNT(*) FROM com.liferay.portlet.journal.model.JournalArticle");
3731
3732 Long count = null;
3733
3734 Iterator<Long> itr = q.list().iterator();
3735
3736 if (itr.hasNext()) {
3737 count = itr.next();
3738 }
3739
3740 if (count == null) {
3741 count = new Long(0);
3742 }
3743
3744 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
3745 finderClassName, finderMethodName, finderParams,
3746 finderArgs, count);
3747
3748 return count.intValue();
3749 }
3750 catch (Exception e) {
3751 throw processException(e);
3752 }
3753 finally {
3754 closeSession(session);
3755 }
3756 }
3757 else {
3758 return ((Long)result).intValue();
3759 }
3760 }
3761
3762 public void registerListener(ModelListener listener) {
3763 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
3764
3765 listeners.add(listener);
3766
3767 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
3768 }
3769
3770 public void unregisterListener(ModelListener listener) {
3771 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
3772
3773 listeners.remove(listener);
3774
3775 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
3776 }
3777
3778 public void afterPropertiesSet() {
3779 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3780 com.liferay.portal.util.PropsUtil.get(
3781 "value.object.listener.com.liferay.portlet.journal.model.JournalArticle")));
3782
3783 if (listenerClassNames.length > 0) {
3784 try {
3785 List<ModelListener> listeners = new ArrayList<ModelListener>();
3786
3787 for (String listenerClassName : listenerClassNames) {
3788 listeners.add((ModelListener)Class.forName(
3789 listenerClassName).newInstance());
3790 }
3791
3792 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
3793 }
3794 catch (Exception e) {
3795 _log.error(e);
3796 }
3797 }
3798 }
3799
3800 private static Log _log = LogFactory.getLog(JournalArticlePersistenceImpl.class);
3801 private ModelListener[] _listeners = new ModelListener[0];
3802}