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.NoSuchTemplateException;
44 import com.liferay.portlet.journal.model.JournalTemplate;
45 import com.liferay.portlet.journal.model.impl.JournalTemplateImpl;
46 import com.liferay.portlet.journal.model.impl.JournalTemplateModelImpl;
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 JournalTemplatePersistenceImpl extends BasePersistenceImpl
63 implements JournalTemplatePersistence, InitializingBean {
64 public JournalTemplate create(long id) {
65 JournalTemplate journalTemplate = new JournalTemplateImpl();
66
67 journalTemplate.setNew(true);
68 journalTemplate.setPrimaryKey(id);
69
70 String uuid = PortalUUIDUtil.generate();
71
72 journalTemplate.setUuid(uuid);
73
74 return journalTemplate;
75 }
76
77 public JournalTemplate remove(long id)
78 throws NoSuchTemplateException, SystemException {
79 Session session = null;
80
81 try {
82 session = openSession();
83
84 JournalTemplate journalTemplate = (JournalTemplate)session.get(JournalTemplateImpl.class,
85 new Long(id));
86
87 if (journalTemplate == null) {
88 if (_log.isWarnEnabled()) {
89 _log.warn("No JournalTemplate exists with the primary key " +
90 id);
91 }
92
93 throw new NoSuchTemplateException(
94 "No JournalTemplate exists with the primary key " + id);
95 }
96
97 return remove(journalTemplate);
98 }
99 catch (NoSuchTemplateException nsee) {
100 throw nsee;
101 }
102 catch (Exception e) {
103 throw processException(e);
104 }
105 finally {
106 closeSession(session);
107 }
108 }
109
110 public JournalTemplate remove(JournalTemplate journalTemplate)
111 throws SystemException {
112 if (_listeners.length > 0) {
113 for (ModelListener listener : _listeners) {
114 listener.onBeforeRemove(journalTemplate);
115 }
116 }
117
118 journalTemplate = removeImpl(journalTemplate);
119
120 if (_listeners.length > 0) {
121 for (ModelListener listener : _listeners) {
122 listener.onAfterRemove(journalTemplate);
123 }
124 }
125
126 return journalTemplate;
127 }
128
129 protected JournalTemplate removeImpl(JournalTemplate journalTemplate)
130 throws SystemException {
131 Session session = null;
132
133 try {
134 session = openSession();
135
136 session.delete(journalTemplate);
137
138 session.flush();
139
140 return journalTemplate;
141 }
142 catch (Exception e) {
143 throw processException(e);
144 }
145 finally {
146 closeSession(session);
147
148 FinderCacheUtil.clearCache(JournalTemplate.class.getName());
149 }
150 }
151
152
155 public JournalTemplate update(JournalTemplate journalTemplate)
156 throws SystemException {
157 if (_log.isWarnEnabled()) {
158 _log.warn(
159 "Using the deprecated update(JournalTemplate journalTemplate) method. Use update(JournalTemplate journalTemplate, boolean merge) instead.");
160 }
161
162 return update(journalTemplate, false);
163 }
164
165
178 public JournalTemplate update(JournalTemplate journalTemplate, boolean merge)
179 throws SystemException {
180 boolean isNew = journalTemplate.isNew();
181
182 if (_listeners.length > 0) {
183 for (ModelListener listener : _listeners) {
184 if (isNew) {
185 listener.onBeforeCreate(journalTemplate);
186 }
187 else {
188 listener.onBeforeUpdate(journalTemplate);
189 }
190 }
191 }
192
193 journalTemplate = updateImpl(journalTemplate, merge);
194
195 if (_listeners.length > 0) {
196 for (ModelListener listener : _listeners) {
197 if (isNew) {
198 listener.onAfterCreate(journalTemplate);
199 }
200 else {
201 listener.onAfterUpdate(journalTemplate);
202 }
203 }
204 }
205
206 return journalTemplate;
207 }
208
209 public JournalTemplate updateImpl(
210 com.liferay.portlet.journal.model.JournalTemplate journalTemplate,
211 boolean merge) throws SystemException {
212 if (Validator.isNull(journalTemplate.getUuid())) {
213 String uuid = PortalUUIDUtil.generate();
214
215 journalTemplate.setUuid(uuid);
216 }
217
218 Session session = null;
219
220 try {
221 session = openSession();
222
223 if (merge) {
224 session.merge(journalTemplate);
225 }
226 else {
227 if (journalTemplate.isNew()) {
228 session.save(journalTemplate);
229 }
230 }
231
232 session.flush();
233
234 journalTemplate.setNew(false);
235
236 return journalTemplate;
237 }
238 catch (Exception e) {
239 throw processException(e);
240 }
241 finally {
242 closeSession(session);
243
244 FinderCacheUtil.clearCache(JournalTemplate.class.getName());
245 }
246 }
247
248 public JournalTemplate findByPrimaryKey(long id)
249 throws NoSuchTemplateException, SystemException {
250 JournalTemplate journalTemplate = fetchByPrimaryKey(id);
251
252 if (journalTemplate == null) {
253 if (_log.isWarnEnabled()) {
254 _log.warn("No JournalTemplate exists with the primary key " +
255 id);
256 }
257
258 throw new NoSuchTemplateException(
259 "No JournalTemplate exists with the primary key " + id);
260 }
261
262 return journalTemplate;
263 }
264
265 public JournalTemplate fetchByPrimaryKey(long id) throws SystemException {
266 Session session = null;
267
268 try {
269 session = openSession();
270
271 return (JournalTemplate)session.get(JournalTemplateImpl.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<JournalTemplate> findByUuid(String uuid)
283 throws SystemException {
284 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
285 String finderClassName = JournalTemplate.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.JournalTemplate 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("templateId ASC");
320
321 Query q = session.createQuery(query.toString());
322
323 QueryPos qPos = QueryPos.getInstance(q);
324
325 if (uuid != null) {
326 qPos.add(uuid);
327 }
328
329 List<JournalTemplate> list = q.list();
330
331 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
332 finderClassName, finderMethodName, finderParams,
333 finderArgs, list);
334
335 return list;
336 }
337 catch (Exception e) {
338 throw processException(e);
339 }
340 finally {
341 closeSession(session);
342 }
343 }
344 else {
345 return (List<JournalTemplate>)result;
346 }
347 }
348
349 public List<JournalTemplate> findByUuid(String uuid, int start, int end)
350 throws SystemException {
351 return findByUuid(uuid, start, end, null);
352 }
353
354 public List<JournalTemplate> findByUuid(String uuid, int start, int end,
355 OrderByComparator obc) throws SystemException {
356 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
357 String finderClassName = JournalTemplate.class.getName();
358 String finderMethodName = "findByUuid";
359 String[] finderParams = new String[] {
360 String.class.getName(),
361
362 "java.lang.Integer", "java.lang.Integer",
363 "com.liferay.portal.kernel.util.OrderByComparator"
364 };
365 Object[] finderArgs = new Object[] {
366 uuid,
367
368 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
369 };
370
371 Object result = null;
372
373 if (finderClassNameCacheEnabled) {
374 result = FinderCacheUtil.getResult(finderClassName,
375 finderMethodName, finderParams, finderArgs, this);
376 }
377
378 if (result == null) {
379 Session session = null;
380
381 try {
382 session = openSession();
383
384 StringBuilder query = new StringBuilder();
385
386 query.append(
387 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
388
389 if (uuid == null) {
390 query.append("uuid_ IS NULL");
391 }
392 else {
393 query.append("uuid_ = ?");
394 }
395
396 query.append(" ");
397
398 if (obc != null) {
399 query.append("ORDER BY ");
400 query.append(obc.getOrderBy());
401 }
402
403 else {
404 query.append("ORDER BY ");
405
406 query.append("templateId ASC");
407 }
408
409 Query q = session.createQuery(query.toString());
410
411 QueryPos qPos = QueryPos.getInstance(q);
412
413 if (uuid != null) {
414 qPos.add(uuid);
415 }
416
417 List<JournalTemplate> list = (List<JournalTemplate>)QueryUtil.list(q,
418 getDialect(), start, end);
419
420 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
421 finderClassName, finderMethodName, finderParams,
422 finderArgs, list);
423
424 return list;
425 }
426 catch (Exception e) {
427 throw processException(e);
428 }
429 finally {
430 closeSession(session);
431 }
432 }
433 else {
434 return (List<JournalTemplate>)result;
435 }
436 }
437
438 public JournalTemplate findByUuid_First(String uuid, OrderByComparator obc)
439 throws NoSuchTemplateException, SystemException {
440 List<JournalTemplate> list = findByUuid(uuid, 0, 1, obc);
441
442 if (list.size() == 0) {
443 StringBuilder msg = new StringBuilder();
444
445 msg.append("No JournalTemplate exists with the key {");
446
447 msg.append("uuid=" + uuid);
448
449 msg.append(StringPool.CLOSE_CURLY_BRACE);
450
451 throw new NoSuchTemplateException(msg.toString());
452 }
453 else {
454 return list.get(0);
455 }
456 }
457
458 public JournalTemplate findByUuid_Last(String uuid, OrderByComparator obc)
459 throws NoSuchTemplateException, SystemException {
460 int count = countByUuid(uuid);
461
462 List<JournalTemplate> list = findByUuid(uuid, count - 1, count, obc);
463
464 if (list.size() == 0) {
465 StringBuilder msg = new StringBuilder();
466
467 msg.append("No JournalTemplate exists with the key {");
468
469 msg.append("uuid=" + uuid);
470
471 msg.append(StringPool.CLOSE_CURLY_BRACE);
472
473 throw new NoSuchTemplateException(msg.toString());
474 }
475 else {
476 return list.get(0);
477 }
478 }
479
480 public JournalTemplate[] findByUuid_PrevAndNext(long id, String uuid,
481 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
482 JournalTemplate journalTemplate = findByPrimaryKey(id);
483
484 int count = countByUuid(uuid);
485
486 Session session = null;
487
488 try {
489 session = openSession();
490
491 StringBuilder query = new StringBuilder();
492
493 query.append(
494 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
495
496 if (uuid == null) {
497 query.append("uuid_ IS NULL");
498 }
499 else {
500 query.append("uuid_ = ?");
501 }
502
503 query.append(" ");
504
505 if (obc != null) {
506 query.append("ORDER BY ");
507 query.append(obc.getOrderBy());
508 }
509
510 else {
511 query.append("ORDER BY ");
512
513 query.append("templateId ASC");
514 }
515
516 Query q = session.createQuery(query.toString());
517
518 QueryPos qPos = QueryPos.getInstance(q);
519
520 if (uuid != null) {
521 qPos.add(uuid);
522 }
523
524 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
525 journalTemplate);
526
527 JournalTemplate[] array = new JournalTemplateImpl[3];
528
529 array[0] = (JournalTemplate)objArray[0];
530 array[1] = (JournalTemplate)objArray[1];
531 array[2] = (JournalTemplate)objArray[2];
532
533 return array;
534 }
535 catch (Exception e) {
536 throw processException(e);
537 }
538 finally {
539 closeSession(session);
540 }
541 }
542
543 public JournalTemplate findByUUID_G(String uuid, long groupId)
544 throws NoSuchTemplateException, SystemException {
545 JournalTemplate journalTemplate = fetchByUUID_G(uuid, groupId);
546
547 if (journalTemplate == null) {
548 StringBuilder msg = new StringBuilder();
549
550 msg.append("No JournalTemplate exists with the key {");
551
552 msg.append("uuid=" + uuid);
553
554 msg.append(", ");
555 msg.append("groupId=" + groupId);
556
557 msg.append(StringPool.CLOSE_CURLY_BRACE);
558
559 if (_log.isWarnEnabled()) {
560 _log.warn(msg.toString());
561 }
562
563 throw new NoSuchTemplateException(msg.toString());
564 }
565
566 return journalTemplate;
567 }
568
569 public JournalTemplate fetchByUUID_G(String uuid, long groupId)
570 throws SystemException {
571 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
572 String finderClassName = JournalTemplate.class.getName();
573 String finderMethodName = "fetchByUUID_G";
574 String[] finderParams = new String[] {
575 String.class.getName(), Long.class.getName()
576 };
577 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
578
579 Object result = null;
580
581 if (finderClassNameCacheEnabled) {
582 result = FinderCacheUtil.getResult(finderClassName,
583 finderMethodName, finderParams, finderArgs, this);
584 }
585
586 if (result == null) {
587 Session session = null;
588
589 try {
590 session = openSession();
591
592 StringBuilder query = new StringBuilder();
593
594 query.append(
595 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
596
597 if (uuid == null) {
598 query.append("uuid_ IS NULL");
599 }
600 else {
601 query.append("uuid_ = ?");
602 }
603
604 query.append(" AND ");
605
606 query.append("groupId = ?");
607
608 query.append(" ");
609
610 query.append("ORDER BY ");
611
612 query.append("templateId ASC");
613
614 Query q = session.createQuery(query.toString());
615
616 QueryPos qPos = QueryPos.getInstance(q);
617
618 if (uuid != null) {
619 qPos.add(uuid);
620 }
621
622 qPos.add(groupId);
623
624 List<JournalTemplate> list = q.list();
625
626 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
627 finderClassName, finderMethodName, finderParams,
628 finderArgs, list);
629
630 if (list.size() == 0) {
631 return null;
632 }
633 else {
634 return list.get(0);
635 }
636 }
637 catch (Exception e) {
638 throw processException(e);
639 }
640 finally {
641 closeSession(session);
642 }
643 }
644 else {
645 List<JournalTemplate> list = (List<JournalTemplate>)result;
646
647 if (list.size() == 0) {
648 return null;
649 }
650 else {
651 return list.get(0);
652 }
653 }
654 }
655
656 public List<JournalTemplate> findByGroupId(long groupId)
657 throws SystemException {
658 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
659 String finderClassName = JournalTemplate.class.getName();
660 String finderMethodName = "findByGroupId";
661 String[] finderParams = new String[] { Long.class.getName() };
662 Object[] finderArgs = new Object[] { new Long(groupId) };
663
664 Object result = null;
665
666 if (finderClassNameCacheEnabled) {
667 result = FinderCacheUtil.getResult(finderClassName,
668 finderMethodName, finderParams, finderArgs, this);
669 }
670
671 if (result == null) {
672 Session session = null;
673
674 try {
675 session = openSession();
676
677 StringBuilder query = new StringBuilder();
678
679 query.append(
680 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
681
682 query.append("groupId = ?");
683
684 query.append(" ");
685
686 query.append("ORDER BY ");
687
688 query.append("templateId ASC");
689
690 Query q = session.createQuery(query.toString());
691
692 QueryPos qPos = QueryPos.getInstance(q);
693
694 qPos.add(groupId);
695
696 List<JournalTemplate> list = q.list();
697
698 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
699 finderClassName, finderMethodName, finderParams,
700 finderArgs, list);
701
702 return list;
703 }
704 catch (Exception e) {
705 throw processException(e);
706 }
707 finally {
708 closeSession(session);
709 }
710 }
711 else {
712 return (List<JournalTemplate>)result;
713 }
714 }
715
716 public List<JournalTemplate> findByGroupId(long groupId, int start, int end)
717 throws SystemException {
718 return findByGroupId(groupId, start, end, null);
719 }
720
721 public List<JournalTemplate> findByGroupId(long groupId, int start,
722 int end, OrderByComparator obc) throws SystemException {
723 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
724 String finderClassName = JournalTemplate.class.getName();
725 String finderMethodName = "findByGroupId";
726 String[] finderParams = new String[] {
727 Long.class.getName(),
728
729 "java.lang.Integer", "java.lang.Integer",
730 "com.liferay.portal.kernel.util.OrderByComparator"
731 };
732 Object[] finderArgs = new Object[] {
733 new Long(groupId),
734
735 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
736 };
737
738 Object result = null;
739
740 if (finderClassNameCacheEnabled) {
741 result = FinderCacheUtil.getResult(finderClassName,
742 finderMethodName, finderParams, finderArgs, this);
743 }
744
745 if (result == null) {
746 Session session = null;
747
748 try {
749 session = openSession();
750
751 StringBuilder query = new StringBuilder();
752
753 query.append(
754 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
755
756 query.append("groupId = ?");
757
758 query.append(" ");
759
760 if (obc != null) {
761 query.append("ORDER BY ");
762 query.append(obc.getOrderBy());
763 }
764
765 else {
766 query.append("ORDER BY ");
767
768 query.append("templateId ASC");
769 }
770
771 Query q = session.createQuery(query.toString());
772
773 QueryPos qPos = QueryPos.getInstance(q);
774
775 qPos.add(groupId);
776
777 List<JournalTemplate> list = (List<JournalTemplate>)QueryUtil.list(q,
778 getDialect(), start, end);
779
780 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
781 finderClassName, finderMethodName, finderParams,
782 finderArgs, list);
783
784 return list;
785 }
786 catch (Exception e) {
787 throw processException(e);
788 }
789 finally {
790 closeSession(session);
791 }
792 }
793 else {
794 return (List<JournalTemplate>)result;
795 }
796 }
797
798 public JournalTemplate findByGroupId_First(long groupId,
799 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
800 List<JournalTemplate> list = findByGroupId(groupId, 0, 1, obc);
801
802 if (list.size() == 0) {
803 StringBuilder msg = new StringBuilder();
804
805 msg.append("No JournalTemplate exists with the key {");
806
807 msg.append("groupId=" + groupId);
808
809 msg.append(StringPool.CLOSE_CURLY_BRACE);
810
811 throw new NoSuchTemplateException(msg.toString());
812 }
813 else {
814 return list.get(0);
815 }
816 }
817
818 public JournalTemplate findByGroupId_Last(long groupId,
819 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
820 int count = countByGroupId(groupId);
821
822 List<JournalTemplate> list = findByGroupId(groupId, count - 1, count,
823 obc);
824
825 if (list.size() == 0) {
826 StringBuilder msg = new StringBuilder();
827
828 msg.append("No JournalTemplate exists with the key {");
829
830 msg.append("groupId=" + groupId);
831
832 msg.append(StringPool.CLOSE_CURLY_BRACE);
833
834 throw new NoSuchTemplateException(msg.toString());
835 }
836 else {
837 return list.get(0);
838 }
839 }
840
841 public JournalTemplate[] findByGroupId_PrevAndNext(long id, long groupId,
842 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
843 JournalTemplate journalTemplate = findByPrimaryKey(id);
844
845 int count = countByGroupId(groupId);
846
847 Session session = null;
848
849 try {
850 session = openSession();
851
852 StringBuilder query = new StringBuilder();
853
854 query.append(
855 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
856
857 query.append("groupId = ?");
858
859 query.append(" ");
860
861 if (obc != null) {
862 query.append("ORDER BY ");
863 query.append(obc.getOrderBy());
864 }
865
866 else {
867 query.append("ORDER BY ");
868
869 query.append("templateId ASC");
870 }
871
872 Query q = session.createQuery(query.toString());
873
874 QueryPos qPos = QueryPos.getInstance(q);
875
876 qPos.add(groupId);
877
878 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
879 journalTemplate);
880
881 JournalTemplate[] array = new JournalTemplateImpl[3];
882
883 array[0] = (JournalTemplate)objArray[0];
884 array[1] = (JournalTemplate)objArray[1];
885 array[2] = (JournalTemplate)objArray[2];
886
887 return array;
888 }
889 catch (Exception e) {
890 throw processException(e);
891 }
892 finally {
893 closeSession(session);
894 }
895 }
896
897 public List<JournalTemplate> findByTemplateId(String templateId)
898 throws SystemException {
899 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
900 String finderClassName = JournalTemplate.class.getName();
901 String finderMethodName = "findByTemplateId";
902 String[] finderParams = new String[] { String.class.getName() };
903 Object[] finderArgs = new Object[] { templateId };
904
905 Object result = null;
906
907 if (finderClassNameCacheEnabled) {
908 result = FinderCacheUtil.getResult(finderClassName,
909 finderMethodName, finderParams, finderArgs, this);
910 }
911
912 if (result == null) {
913 Session session = null;
914
915 try {
916 session = openSession();
917
918 StringBuilder query = new StringBuilder();
919
920 query.append(
921 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
922
923 if (templateId == null) {
924 query.append("templateId IS NULL");
925 }
926 else {
927 query.append("templateId = ?");
928 }
929
930 query.append(" ");
931
932 query.append("ORDER BY ");
933
934 query.append("templateId ASC");
935
936 Query q = session.createQuery(query.toString());
937
938 QueryPos qPos = QueryPos.getInstance(q);
939
940 if (templateId != null) {
941 qPos.add(templateId);
942 }
943
944 List<JournalTemplate> 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<JournalTemplate>)result;
961 }
962 }
963
964 public List<JournalTemplate> findByTemplateId(String templateId, int start,
965 int end) throws SystemException {
966 return findByTemplateId(templateId, start, end, null);
967 }
968
969 public List<JournalTemplate> findByTemplateId(String templateId, int start,
970 int end, OrderByComparator obc) throws SystemException {
971 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
972 String finderClassName = JournalTemplate.class.getName();
973 String finderMethodName = "findByTemplateId";
974 String[] finderParams = new String[] {
975 String.class.getName(),
976
977 "java.lang.Integer", "java.lang.Integer",
978 "com.liferay.portal.kernel.util.OrderByComparator"
979 };
980 Object[] finderArgs = new Object[] {
981 templateId,
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.JournalTemplate WHERE ");
1003
1004 if (templateId == null) {
1005 query.append("templateId IS NULL");
1006 }
1007 else {
1008 query.append("templateId = ?");
1009 }
1010
1011 query.append(" ");
1012
1013 if (obc != null) {
1014 query.append("ORDER BY ");
1015 query.append(obc.getOrderBy());
1016 }
1017
1018 else {
1019 query.append("ORDER BY ");
1020
1021 query.append("templateId ASC");
1022 }
1023
1024 Query q = session.createQuery(query.toString());
1025
1026 QueryPos qPos = QueryPos.getInstance(q);
1027
1028 if (templateId != null) {
1029 qPos.add(templateId);
1030 }
1031
1032 List<JournalTemplate> list = (List<JournalTemplate>)QueryUtil.list(q,
1033 getDialect(), start, end);
1034
1035 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1036 finderClassName, finderMethodName, finderParams,
1037 finderArgs, list);
1038
1039 return list;
1040 }
1041 catch (Exception e) {
1042 throw processException(e);
1043 }
1044 finally {
1045 closeSession(session);
1046 }
1047 }
1048 else {
1049 return (List<JournalTemplate>)result;
1050 }
1051 }
1052
1053 public JournalTemplate findByTemplateId_First(String templateId,
1054 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
1055 List<JournalTemplate> list = findByTemplateId(templateId, 0, 1, obc);
1056
1057 if (list.size() == 0) {
1058 StringBuilder msg = new StringBuilder();
1059
1060 msg.append("No JournalTemplate exists with the key {");
1061
1062 msg.append("templateId=" + templateId);
1063
1064 msg.append(StringPool.CLOSE_CURLY_BRACE);
1065
1066 throw new NoSuchTemplateException(msg.toString());
1067 }
1068 else {
1069 return list.get(0);
1070 }
1071 }
1072
1073 public JournalTemplate findByTemplateId_Last(String templateId,
1074 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
1075 int count = countByTemplateId(templateId);
1076
1077 List<JournalTemplate> list = findByTemplateId(templateId, count - 1,
1078 count, obc);
1079
1080 if (list.size() == 0) {
1081 StringBuilder msg = new StringBuilder();
1082
1083 msg.append("No JournalTemplate exists with the key {");
1084
1085 msg.append("templateId=" + templateId);
1086
1087 msg.append(StringPool.CLOSE_CURLY_BRACE);
1088
1089 throw new NoSuchTemplateException(msg.toString());
1090 }
1091 else {
1092 return list.get(0);
1093 }
1094 }
1095
1096 public JournalTemplate[] findByTemplateId_PrevAndNext(long id,
1097 String templateId, OrderByComparator obc)
1098 throws NoSuchTemplateException, SystemException {
1099 JournalTemplate journalTemplate = findByPrimaryKey(id);
1100
1101 int count = countByTemplateId(templateId);
1102
1103 Session session = null;
1104
1105 try {
1106 session = openSession();
1107
1108 StringBuilder query = new StringBuilder();
1109
1110 query.append(
1111 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1112
1113 if (templateId == null) {
1114 query.append("templateId IS NULL");
1115 }
1116 else {
1117 query.append("templateId = ?");
1118 }
1119
1120 query.append(" ");
1121
1122 if (obc != null) {
1123 query.append("ORDER BY ");
1124 query.append(obc.getOrderBy());
1125 }
1126
1127 else {
1128 query.append("ORDER BY ");
1129
1130 query.append("templateId ASC");
1131 }
1132
1133 Query q = session.createQuery(query.toString());
1134
1135 QueryPos qPos = QueryPos.getInstance(q);
1136
1137 if (templateId != null) {
1138 qPos.add(templateId);
1139 }
1140
1141 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1142 journalTemplate);
1143
1144 JournalTemplate[] array = new JournalTemplateImpl[3];
1145
1146 array[0] = (JournalTemplate)objArray[0];
1147 array[1] = (JournalTemplate)objArray[1];
1148 array[2] = (JournalTemplate)objArray[2];
1149
1150 return array;
1151 }
1152 catch (Exception e) {
1153 throw processException(e);
1154 }
1155 finally {
1156 closeSession(session);
1157 }
1158 }
1159
1160 public JournalTemplate findBySmallImageId(long smallImageId)
1161 throws NoSuchTemplateException, SystemException {
1162 JournalTemplate journalTemplate = fetchBySmallImageId(smallImageId);
1163
1164 if (journalTemplate == null) {
1165 StringBuilder msg = new StringBuilder();
1166
1167 msg.append("No JournalTemplate exists with the key {");
1168
1169 msg.append("smallImageId=" + smallImageId);
1170
1171 msg.append(StringPool.CLOSE_CURLY_BRACE);
1172
1173 if (_log.isWarnEnabled()) {
1174 _log.warn(msg.toString());
1175 }
1176
1177 throw new NoSuchTemplateException(msg.toString());
1178 }
1179
1180 return journalTemplate;
1181 }
1182
1183 public JournalTemplate fetchBySmallImageId(long smallImageId)
1184 throws SystemException {
1185 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1186 String finderClassName = JournalTemplate.class.getName();
1187 String finderMethodName = "fetchBySmallImageId";
1188 String[] finderParams = new String[] { Long.class.getName() };
1189 Object[] finderArgs = new Object[] { new Long(smallImageId) };
1190
1191 Object result = null;
1192
1193 if (finderClassNameCacheEnabled) {
1194 result = FinderCacheUtil.getResult(finderClassName,
1195 finderMethodName, finderParams, finderArgs, this);
1196 }
1197
1198 if (result == null) {
1199 Session session = null;
1200
1201 try {
1202 session = openSession();
1203
1204 StringBuilder query = new StringBuilder();
1205
1206 query.append(
1207 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1208
1209 query.append("smallImageId = ?");
1210
1211 query.append(" ");
1212
1213 query.append("ORDER BY ");
1214
1215 query.append("templateId ASC");
1216
1217 Query q = session.createQuery(query.toString());
1218
1219 QueryPos qPos = QueryPos.getInstance(q);
1220
1221 qPos.add(smallImageId);
1222
1223 List<JournalTemplate> list = q.list();
1224
1225 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1226 finderClassName, finderMethodName, finderParams,
1227 finderArgs, list);
1228
1229 if (list.size() == 0) {
1230 return null;
1231 }
1232 else {
1233 return list.get(0);
1234 }
1235 }
1236 catch (Exception e) {
1237 throw processException(e);
1238 }
1239 finally {
1240 closeSession(session);
1241 }
1242 }
1243 else {
1244 List<JournalTemplate> list = (List<JournalTemplate>)result;
1245
1246 if (list.size() == 0) {
1247 return null;
1248 }
1249 else {
1250 return list.get(0);
1251 }
1252 }
1253 }
1254
1255 public JournalTemplate findByG_T(long groupId, String templateId)
1256 throws NoSuchTemplateException, SystemException {
1257 JournalTemplate journalTemplate = fetchByG_T(groupId, templateId);
1258
1259 if (journalTemplate == null) {
1260 StringBuilder msg = new StringBuilder();
1261
1262 msg.append("No JournalTemplate exists with the key {");
1263
1264 msg.append("groupId=" + groupId);
1265
1266 msg.append(", ");
1267 msg.append("templateId=" + templateId);
1268
1269 msg.append(StringPool.CLOSE_CURLY_BRACE);
1270
1271 if (_log.isWarnEnabled()) {
1272 _log.warn(msg.toString());
1273 }
1274
1275 throw new NoSuchTemplateException(msg.toString());
1276 }
1277
1278 return journalTemplate;
1279 }
1280
1281 public JournalTemplate fetchByG_T(long groupId, String templateId)
1282 throws SystemException {
1283 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1284 String finderClassName = JournalTemplate.class.getName();
1285 String finderMethodName = "fetchByG_T";
1286 String[] finderParams = new String[] {
1287 Long.class.getName(), String.class.getName()
1288 };
1289 Object[] finderArgs = new Object[] { new Long(groupId), templateId };
1290
1291 Object result = null;
1292
1293 if (finderClassNameCacheEnabled) {
1294 result = FinderCacheUtil.getResult(finderClassName,
1295 finderMethodName, finderParams, finderArgs, this);
1296 }
1297
1298 if (result == null) {
1299 Session session = null;
1300
1301 try {
1302 session = openSession();
1303
1304 StringBuilder query = new StringBuilder();
1305
1306 query.append(
1307 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1308
1309 query.append("groupId = ?");
1310
1311 query.append(" AND ");
1312
1313 if (templateId == null) {
1314 query.append("templateId IS NULL");
1315 }
1316 else {
1317 query.append("templateId = ?");
1318 }
1319
1320 query.append(" ");
1321
1322 query.append("ORDER BY ");
1323
1324 query.append("templateId ASC");
1325
1326 Query q = session.createQuery(query.toString());
1327
1328 QueryPos qPos = QueryPos.getInstance(q);
1329
1330 qPos.add(groupId);
1331
1332 if (templateId != null) {
1333 qPos.add(templateId);
1334 }
1335
1336 List<JournalTemplate> list = q.list();
1337
1338 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1339 finderClassName, finderMethodName, finderParams,
1340 finderArgs, list);
1341
1342 if (list.size() == 0) {
1343 return null;
1344 }
1345 else {
1346 return list.get(0);
1347 }
1348 }
1349 catch (Exception e) {
1350 throw processException(e);
1351 }
1352 finally {
1353 closeSession(session);
1354 }
1355 }
1356 else {
1357 List<JournalTemplate> list = (List<JournalTemplate>)result;
1358
1359 if (list.size() == 0) {
1360 return null;
1361 }
1362 else {
1363 return list.get(0);
1364 }
1365 }
1366 }
1367
1368 public List<JournalTemplate> findByG_S(long groupId, String structureId)
1369 throws SystemException {
1370 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1371 String finderClassName = JournalTemplate.class.getName();
1372 String finderMethodName = "findByG_S";
1373 String[] finderParams = new String[] {
1374 Long.class.getName(), String.class.getName()
1375 };
1376 Object[] finderArgs = new Object[] { new Long(groupId), structureId };
1377
1378 Object result = null;
1379
1380 if (finderClassNameCacheEnabled) {
1381 result = FinderCacheUtil.getResult(finderClassName,
1382 finderMethodName, finderParams, finderArgs, this);
1383 }
1384
1385 if (result == null) {
1386 Session session = null;
1387
1388 try {
1389 session = openSession();
1390
1391 StringBuilder query = new StringBuilder();
1392
1393 query.append(
1394 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1395
1396 query.append("groupId = ?");
1397
1398 query.append(" AND ");
1399
1400 if (structureId == null) {
1401 query.append("structureId IS NULL");
1402 }
1403 else {
1404 query.append("structureId = ?");
1405 }
1406
1407 query.append(" ");
1408
1409 query.append("ORDER BY ");
1410
1411 query.append("templateId ASC");
1412
1413 Query q = session.createQuery(query.toString());
1414
1415 QueryPos qPos = QueryPos.getInstance(q);
1416
1417 qPos.add(groupId);
1418
1419 if (structureId != null) {
1420 qPos.add(structureId);
1421 }
1422
1423 List<JournalTemplate> list = q.list();
1424
1425 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1426 finderClassName, finderMethodName, finderParams,
1427 finderArgs, list);
1428
1429 return list;
1430 }
1431 catch (Exception e) {
1432 throw processException(e);
1433 }
1434 finally {
1435 closeSession(session);
1436 }
1437 }
1438 else {
1439 return (List<JournalTemplate>)result;
1440 }
1441 }
1442
1443 public List<JournalTemplate> findByG_S(long groupId, String structureId,
1444 int start, int end) throws SystemException {
1445 return findByG_S(groupId, structureId, start, end, null);
1446 }
1447
1448 public List<JournalTemplate> findByG_S(long groupId, String structureId,
1449 int start, int end, OrderByComparator obc) throws SystemException {
1450 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1451 String finderClassName = JournalTemplate.class.getName();
1452 String finderMethodName = "findByG_S";
1453 String[] finderParams = new String[] {
1454 Long.class.getName(), String.class.getName(),
1455
1456 "java.lang.Integer", "java.lang.Integer",
1457 "com.liferay.portal.kernel.util.OrderByComparator"
1458 };
1459 Object[] finderArgs = new Object[] {
1460 new Long(groupId),
1461
1462 structureId,
1463
1464 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1465 };
1466
1467 Object result = null;
1468
1469 if (finderClassNameCacheEnabled) {
1470 result = FinderCacheUtil.getResult(finderClassName,
1471 finderMethodName, finderParams, finderArgs, this);
1472 }
1473
1474 if (result == null) {
1475 Session session = null;
1476
1477 try {
1478 session = openSession();
1479
1480 StringBuilder query = new StringBuilder();
1481
1482 query.append(
1483 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1484
1485 query.append("groupId = ?");
1486
1487 query.append(" AND ");
1488
1489 if (structureId == null) {
1490 query.append("structureId IS NULL");
1491 }
1492 else {
1493 query.append("structureId = ?");
1494 }
1495
1496 query.append(" ");
1497
1498 if (obc != null) {
1499 query.append("ORDER BY ");
1500 query.append(obc.getOrderBy());
1501 }
1502
1503 else {
1504 query.append("ORDER BY ");
1505
1506 query.append("templateId ASC");
1507 }
1508
1509 Query q = session.createQuery(query.toString());
1510
1511 QueryPos qPos = QueryPos.getInstance(q);
1512
1513 qPos.add(groupId);
1514
1515 if (structureId != null) {
1516 qPos.add(structureId);
1517 }
1518
1519 List<JournalTemplate> list = (List<JournalTemplate>)QueryUtil.list(q,
1520 getDialect(), start, end);
1521
1522 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1523 finderClassName, finderMethodName, finderParams,
1524 finderArgs, list);
1525
1526 return list;
1527 }
1528 catch (Exception e) {
1529 throw processException(e);
1530 }
1531 finally {
1532 closeSession(session);
1533 }
1534 }
1535 else {
1536 return (List<JournalTemplate>)result;
1537 }
1538 }
1539
1540 public JournalTemplate findByG_S_First(long groupId, String structureId,
1541 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
1542 List<JournalTemplate> list = findByG_S(groupId, structureId, 0, 1, obc);
1543
1544 if (list.size() == 0) {
1545 StringBuilder msg = new StringBuilder();
1546
1547 msg.append("No JournalTemplate exists with the key {");
1548
1549 msg.append("groupId=" + groupId);
1550
1551 msg.append(", ");
1552 msg.append("structureId=" + structureId);
1553
1554 msg.append(StringPool.CLOSE_CURLY_BRACE);
1555
1556 throw new NoSuchTemplateException(msg.toString());
1557 }
1558 else {
1559 return list.get(0);
1560 }
1561 }
1562
1563 public JournalTemplate findByG_S_Last(long groupId, String structureId,
1564 OrderByComparator obc) throws NoSuchTemplateException, SystemException {
1565 int count = countByG_S(groupId, structureId);
1566
1567 List<JournalTemplate> list = findByG_S(groupId, structureId, count - 1,
1568 count, obc);
1569
1570 if (list.size() == 0) {
1571 StringBuilder msg = new StringBuilder();
1572
1573 msg.append("No JournalTemplate exists with the key {");
1574
1575 msg.append("groupId=" + groupId);
1576
1577 msg.append(", ");
1578 msg.append("structureId=" + structureId);
1579
1580 msg.append(StringPool.CLOSE_CURLY_BRACE);
1581
1582 throw new NoSuchTemplateException(msg.toString());
1583 }
1584 else {
1585 return list.get(0);
1586 }
1587 }
1588
1589 public JournalTemplate[] findByG_S_PrevAndNext(long id, long groupId,
1590 String structureId, OrderByComparator obc)
1591 throws NoSuchTemplateException, SystemException {
1592 JournalTemplate journalTemplate = findByPrimaryKey(id);
1593
1594 int count = countByG_S(groupId, structureId);
1595
1596 Session session = null;
1597
1598 try {
1599 session = openSession();
1600
1601 StringBuilder query = new StringBuilder();
1602
1603 query.append(
1604 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1605
1606 query.append("groupId = ?");
1607
1608 query.append(" AND ");
1609
1610 if (structureId == null) {
1611 query.append("structureId IS NULL");
1612 }
1613 else {
1614 query.append("structureId = ?");
1615 }
1616
1617 query.append(" ");
1618
1619 if (obc != null) {
1620 query.append("ORDER BY ");
1621 query.append(obc.getOrderBy());
1622 }
1623
1624 else {
1625 query.append("ORDER BY ");
1626
1627 query.append("templateId ASC");
1628 }
1629
1630 Query q = session.createQuery(query.toString());
1631
1632 QueryPos qPos = QueryPos.getInstance(q);
1633
1634 qPos.add(groupId);
1635
1636 if (structureId != null) {
1637 qPos.add(structureId);
1638 }
1639
1640 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1641 journalTemplate);
1642
1643 JournalTemplate[] array = new JournalTemplateImpl[3];
1644
1645 array[0] = (JournalTemplate)objArray[0];
1646 array[1] = (JournalTemplate)objArray[1];
1647 array[2] = (JournalTemplate)objArray[2];
1648
1649 return array;
1650 }
1651 catch (Exception e) {
1652 throw processException(e);
1653 }
1654 finally {
1655 closeSession(session);
1656 }
1657 }
1658
1659 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1660 throws SystemException {
1661 Session session = null;
1662
1663 try {
1664 session = openSession();
1665
1666 dynamicQuery.compile(session);
1667
1668 return dynamicQuery.list();
1669 }
1670 catch (Exception e) {
1671 throw processException(e);
1672 }
1673 finally {
1674 closeSession(session);
1675 }
1676 }
1677
1678 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1679 int start, int end) throws SystemException {
1680 Session session = null;
1681
1682 try {
1683 session = openSession();
1684
1685 dynamicQuery.setLimit(start, end);
1686
1687 dynamicQuery.compile(session);
1688
1689 return dynamicQuery.list();
1690 }
1691 catch (Exception e) {
1692 throw processException(e);
1693 }
1694 finally {
1695 closeSession(session);
1696 }
1697 }
1698
1699 public List<JournalTemplate> findAll() throws SystemException {
1700 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1701 }
1702
1703 public List<JournalTemplate> findAll(int start, int end)
1704 throws SystemException {
1705 return findAll(start, end, null);
1706 }
1707
1708 public List<JournalTemplate> findAll(int start, int end,
1709 OrderByComparator obc) throws SystemException {
1710 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1711 String finderClassName = JournalTemplate.class.getName();
1712 String finderMethodName = "findAll";
1713 String[] finderParams = new String[] {
1714 "java.lang.Integer", "java.lang.Integer",
1715 "com.liferay.portal.kernel.util.OrderByComparator"
1716 };
1717 Object[] finderArgs = new Object[] {
1718 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1719 };
1720
1721 Object result = null;
1722
1723 if (finderClassNameCacheEnabled) {
1724 result = FinderCacheUtil.getResult(finderClassName,
1725 finderMethodName, finderParams, finderArgs, this);
1726 }
1727
1728 if (result == null) {
1729 Session session = null;
1730
1731 try {
1732 session = openSession();
1733
1734 StringBuilder query = new StringBuilder();
1735
1736 query.append(
1737 "FROM com.liferay.portlet.journal.model.JournalTemplate ");
1738
1739 if (obc != null) {
1740 query.append("ORDER BY ");
1741 query.append(obc.getOrderBy());
1742 }
1743
1744 else {
1745 query.append("ORDER BY ");
1746
1747 query.append("templateId ASC");
1748 }
1749
1750 Query q = session.createQuery(query.toString());
1751
1752 List<JournalTemplate> list = (List<JournalTemplate>)QueryUtil.list(q,
1753 getDialect(), start, end);
1754
1755 if (obc == null) {
1756 Collections.sort(list);
1757 }
1758
1759 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1760 finderClassName, finderMethodName, finderParams,
1761 finderArgs, list);
1762
1763 return list;
1764 }
1765 catch (Exception e) {
1766 throw processException(e);
1767 }
1768 finally {
1769 closeSession(session);
1770 }
1771 }
1772 else {
1773 return (List<JournalTemplate>)result;
1774 }
1775 }
1776
1777 public void removeByUuid(String uuid) throws SystemException {
1778 for (JournalTemplate journalTemplate : findByUuid(uuid)) {
1779 remove(journalTemplate);
1780 }
1781 }
1782
1783 public void removeByUUID_G(String uuid, long groupId)
1784 throws NoSuchTemplateException, SystemException {
1785 JournalTemplate journalTemplate = findByUUID_G(uuid, groupId);
1786
1787 remove(journalTemplate);
1788 }
1789
1790 public void removeByGroupId(long groupId) throws SystemException {
1791 for (JournalTemplate journalTemplate : findByGroupId(groupId)) {
1792 remove(journalTemplate);
1793 }
1794 }
1795
1796 public void removeByTemplateId(String templateId) throws SystemException {
1797 for (JournalTemplate journalTemplate : findByTemplateId(templateId)) {
1798 remove(journalTemplate);
1799 }
1800 }
1801
1802 public void removeBySmallImageId(long smallImageId)
1803 throws NoSuchTemplateException, SystemException {
1804 JournalTemplate journalTemplate = findBySmallImageId(smallImageId);
1805
1806 remove(journalTemplate);
1807 }
1808
1809 public void removeByG_T(long groupId, String templateId)
1810 throws NoSuchTemplateException, SystemException {
1811 JournalTemplate journalTemplate = findByG_T(groupId, templateId);
1812
1813 remove(journalTemplate);
1814 }
1815
1816 public void removeByG_S(long groupId, String structureId)
1817 throws SystemException {
1818 for (JournalTemplate journalTemplate : findByG_S(groupId, structureId)) {
1819 remove(journalTemplate);
1820 }
1821 }
1822
1823 public void removeAll() throws SystemException {
1824 for (JournalTemplate journalTemplate : findAll()) {
1825 remove(journalTemplate);
1826 }
1827 }
1828
1829 public int countByUuid(String uuid) throws SystemException {
1830 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1831 String finderClassName = JournalTemplate.class.getName();
1832 String finderMethodName = "countByUuid";
1833 String[] finderParams = new String[] { String.class.getName() };
1834 Object[] finderArgs = new Object[] { uuid };
1835
1836 Object result = null;
1837
1838 if (finderClassNameCacheEnabled) {
1839 result = FinderCacheUtil.getResult(finderClassName,
1840 finderMethodName, finderParams, finderArgs, this);
1841 }
1842
1843 if (result == null) {
1844 Session session = null;
1845
1846 try {
1847 session = openSession();
1848
1849 StringBuilder query = new StringBuilder();
1850
1851 query.append("SELECT COUNT(*) ");
1852 query.append(
1853 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1854
1855 if (uuid == null) {
1856 query.append("uuid_ IS NULL");
1857 }
1858 else {
1859 query.append("uuid_ = ?");
1860 }
1861
1862 query.append(" ");
1863
1864 Query q = session.createQuery(query.toString());
1865
1866 QueryPos qPos = QueryPos.getInstance(q);
1867
1868 if (uuid != null) {
1869 qPos.add(uuid);
1870 }
1871
1872 Long count = null;
1873
1874 Iterator<Long> itr = q.list().iterator();
1875
1876 if (itr.hasNext()) {
1877 count = itr.next();
1878 }
1879
1880 if (count == null) {
1881 count = new Long(0);
1882 }
1883
1884 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1885 finderClassName, finderMethodName, finderParams,
1886 finderArgs, count);
1887
1888 return count.intValue();
1889 }
1890 catch (Exception e) {
1891 throw processException(e);
1892 }
1893 finally {
1894 closeSession(session);
1895 }
1896 }
1897 else {
1898 return ((Long)result).intValue();
1899 }
1900 }
1901
1902 public int countByUUID_G(String uuid, long groupId)
1903 throws SystemException {
1904 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1905 String finderClassName = JournalTemplate.class.getName();
1906 String finderMethodName = "countByUUID_G";
1907 String[] finderParams = new String[] {
1908 String.class.getName(), Long.class.getName()
1909 };
1910 Object[] finderArgs = new Object[] { uuid, new Long(groupId) };
1911
1912 Object result = null;
1913
1914 if (finderClassNameCacheEnabled) {
1915 result = FinderCacheUtil.getResult(finderClassName,
1916 finderMethodName, finderParams, finderArgs, this);
1917 }
1918
1919 if (result == null) {
1920 Session session = null;
1921
1922 try {
1923 session = openSession();
1924
1925 StringBuilder query = new StringBuilder();
1926
1927 query.append("SELECT COUNT(*) ");
1928 query.append(
1929 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
1930
1931 if (uuid == null) {
1932 query.append("uuid_ IS NULL");
1933 }
1934 else {
1935 query.append("uuid_ = ?");
1936 }
1937
1938 query.append(" AND ");
1939
1940 query.append("groupId = ?");
1941
1942 query.append(" ");
1943
1944 Query q = session.createQuery(query.toString());
1945
1946 QueryPos qPos = QueryPos.getInstance(q);
1947
1948 if (uuid != null) {
1949 qPos.add(uuid);
1950 }
1951
1952 qPos.add(groupId);
1953
1954 Long count = null;
1955
1956 Iterator<Long> itr = q.list().iterator();
1957
1958 if (itr.hasNext()) {
1959 count = itr.next();
1960 }
1961
1962 if (count == null) {
1963 count = new Long(0);
1964 }
1965
1966 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1967 finderClassName, finderMethodName, finderParams,
1968 finderArgs, count);
1969
1970 return count.intValue();
1971 }
1972 catch (Exception e) {
1973 throw processException(e);
1974 }
1975 finally {
1976 closeSession(session);
1977 }
1978 }
1979 else {
1980 return ((Long)result).intValue();
1981 }
1982 }
1983
1984 public int countByGroupId(long groupId) throws SystemException {
1985 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
1986 String finderClassName = JournalTemplate.class.getName();
1987 String finderMethodName = "countByGroupId";
1988 String[] finderParams = new String[] { Long.class.getName() };
1989 Object[] finderArgs = new Object[] { new Long(groupId) };
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("SELECT COUNT(*) ");
2007 query.append(
2008 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2009
2010 query.append("groupId = ?");
2011
2012 query.append(" ");
2013
2014 Query q = session.createQuery(query.toString());
2015
2016 QueryPos qPos = QueryPos.getInstance(q);
2017
2018 qPos.add(groupId);
2019
2020 Long count = null;
2021
2022 Iterator<Long> itr = q.list().iterator();
2023
2024 if (itr.hasNext()) {
2025 count = itr.next();
2026 }
2027
2028 if (count == null) {
2029 count = new Long(0);
2030 }
2031
2032 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2033 finderClassName, finderMethodName, finderParams,
2034 finderArgs, count);
2035
2036 return count.intValue();
2037 }
2038 catch (Exception e) {
2039 throw processException(e);
2040 }
2041 finally {
2042 closeSession(session);
2043 }
2044 }
2045 else {
2046 return ((Long)result).intValue();
2047 }
2048 }
2049
2050 public int countByTemplateId(String templateId) throws SystemException {
2051 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
2052 String finderClassName = JournalTemplate.class.getName();
2053 String finderMethodName = "countByTemplateId";
2054 String[] finderParams = new String[] { String.class.getName() };
2055 Object[] finderArgs = new Object[] { templateId };
2056
2057 Object result = null;
2058
2059 if (finderClassNameCacheEnabled) {
2060 result = FinderCacheUtil.getResult(finderClassName,
2061 finderMethodName, finderParams, finderArgs, this);
2062 }
2063
2064 if (result == null) {
2065 Session session = null;
2066
2067 try {
2068 session = openSession();
2069
2070 StringBuilder query = new StringBuilder();
2071
2072 query.append("SELECT COUNT(*) ");
2073 query.append(
2074 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2075
2076 if (templateId == null) {
2077 query.append("templateId IS NULL");
2078 }
2079 else {
2080 query.append("templateId = ?");
2081 }
2082
2083 query.append(" ");
2084
2085 Query q = session.createQuery(query.toString());
2086
2087 QueryPos qPos = QueryPos.getInstance(q);
2088
2089 if (templateId != null) {
2090 qPos.add(templateId);
2091 }
2092
2093 Long count = null;
2094
2095 Iterator<Long> itr = q.list().iterator();
2096
2097 if (itr.hasNext()) {
2098 count = itr.next();
2099 }
2100
2101 if (count == null) {
2102 count = new Long(0);
2103 }
2104
2105 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2106 finderClassName, finderMethodName, finderParams,
2107 finderArgs, count);
2108
2109 return count.intValue();
2110 }
2111 catch (Exception e) {
2112 throw processException(e);
2113 }
2114 finally {
2115 closeSession(session);
2116 }
2117 }
2118 else {
2119 return ((Long)result).intValue();
2120 }
2121 }
2122
2123 public int countBySmallImageId(long smallImageId) throws SystemException {
2124 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
2125 String finderClassName = JournalTemplate.class.getName();
2126 String finderMethodName = "countBySmallImageId";
2127 String[] finderParams = new String[] { Long.class.getName() };
2128 Object[] finderArgs = new Object[] { new Long(smallImageId) };
2129
2130 Object result = null;
2131
2132 if (finderClassNameCacheEnabled) {
2133 result = FinderCacheUtil.getResult(finderClassName,
2134 finderMethodName, finderParams, finderArgs, this);
2135 }
2136
2137 if (result == null) {
2138 Session session = null;
2139
2140 try {
2141 session = openSession();
2142
2143 StringBuilder query = new StringBuilder();
2144
2145 query.append("SELECT COUNT(*) ");
2146 query.append(
2147 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2148
2149 query.append("smallImageId = ?");
2150
2151 query.append(" ");
2152
2153 Query q = session.createQuery(query.toString());
2154
2155 QueryPos qPos = QueryPos.getInstance(q);
2156
2157 qPos.add(smallImageId);
2158
2159 Long count = null;
2160
2161 Iterator<Long> itr = q.list().iterator();
2162
2163 if (itr.hasNext()) {
2164 count = itr.next();
2165 }
2166
2167 if (count == null) {
2168 count = new Long(0);
2169 }
2170
2171 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2172 finderClassName, finderMethodName, finderParams,
2173 finderArgs, count);
2174
2175 return count.intValue();
2176 }
2177 catch (Exception e) {
2178 throw processException(e);
2179 }
2180 finally {
2181 closeSession(session);
2182 }
2183 }
2184 else {
2185 return ((Long)result).intValue();
2186 }
2187 }
2188
2189 public int countByG_T(long groupId, String templateId)
2190 throws SystemException {
2191 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
2192 String finderClassName = JournalTemplate.class.getName();
2193 String finderMethodName = "countByG_T";
2194 String[] finderParams = new String[] {
2195 Long.class.getName(), String.class.getName()
2196 };
2197 Object[] finderArgs = new Object[] { new Long(groupId), templateId };
2198
2199 Object result = null;
2200
2201 if (finderClassNameCacheEnabled) {
2202 result = FinderCacheUtil.getResult(finderClassName,
2203 finderMethodName, finderParams, finderArgs, this);
2204 }
2205
2206 if (result == null) {
2207 Session session = null;
2208
2209 try {
2210 session = openSession();
2211
2212 StringBuilder query = new StringBuilder();
2213
2214 query.append("SELECT COUNT(*) ");
2215 query.append(
2216 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2217
2218 query.append("groupId = ?");
2219
2220 query.append(" AND ");
2221
2222 if (templateId == null) {
2223 query.append("templateId IS NULL");
2224 }
2225 else {
2226 query.append("templateId = ?");
2227 }
2228
2229 query.append(" ");
2230
2231 Query q = session.createQuery(query.toString());
2232
2233 QueryPos qPos = QueryPos.getInstance(q);
2234
2235 qPos.add(groupId);
2236
2237 if (templateId != null) {
2238 qPos.add(templateId);
2239 }
2240
2241 Long count = null;
2242
2243 Iterator<Long> itr = q.list().iterator();
2244
2245 if (itr.hasNext()) {
2246 count = itr.next();
2247 }
2248
2249 if (count == null) {
2250 count = new Long(0);
2251 }
2252
2253 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2254 finderClassName, finderMethodName, finderParams,
2255 finderArgs, count);
2256
2257 return count.intValue();
2258 }
2259 catch (Exception e) {
2260 throw processException(e);
2261 }
2262 finally {
2263 closeSession(session);
2264 }
2265 }
2266 else {
2267 return ((Long)result).intValue();
2268 }
2269 }
2270
2271 public int countByG_S(long groupId, String structureId)
2272 throws SystemException {
2273 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
2274 String finderClassName = JournalTemplate.class.getName();
2275 String finderMethodName = "countByG_S";
2276 String[] finderParams = new String[] {
2277 Long.class.getName(), String.class.getName()
2278 };
2279 Object[] finderArgs = new Object[] { new Long(groupId), structureId };
2280
2281 Object result = null;
2282
2283 if (finderClassNameCacheEnabled) {
2284 result = FinderCacheUtil.getResult(finderClassName,
2285 finderMethodName, finderParams, finderArgs, this);
2286 }
2287
2288 if (result == null) {
2289 Session session = null;
2290
2291 try {
2292 session = openSession();
2293
2294 StringBuilder query = new StringBuilder();
2295
2296 query.append("SELECT COUNT(*) ");
2297 query.append(
2298 "FROM com.liferay.portlet.journal.model.JournalTemplate WHERE ");
2299
2300 query.append("groupId = ?");
2301
2302 query.append(" AND ");
2303
2304 if (structureId == null) {
2305 query.append("structureId IS NULL");
2306 }
2307 else {
2308 query.append("structureId = ?");
2309 }
2310
2311 query.append(" ");
2312
2313 Query q = session.createQuery(query.toString());
2314
2315 QueryPos qPos = QueryPos.getInstance(q);
2316
2317 qPos.add(groupId);
2318
2319 if (structureId != null) {
2320 qPos.add(structureId);
2321 }
2322
2323 Long count = null;
2324
2325 Iterator<Long> itr = q.list().iterator();
2326
2327 if (itr.hasNext()) {
2328 count = itr.next();
2329 }
2330
2331 if (count == null) {
2332 count = new Long(0);
2333 }
2334
2335 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2336 finderClassName, finderMethodName, finderParams,
2337 finderArgs, count);
2338
2339 return count.intValue();
2340 }
2341 catch (Exception e) {
2342 throw processException(e);
2343 }
2344 finally {
2345 closeSession(session);
2346 }
2347 }
2348 else {
2349 return ((Long)result).intValue();
2350 }
2351 }
2352
2353 public int countAll() throws SystemException {
2354 boolean finderClassNameCacheEnabled = JournalTemplateModelImpl.CACHE_ENABLED;
2355 String finderClassName = JournalTemplate.class.getName();
2356 String finderMethodName = "countAll";
2357 String[] finderParams = new String[] { };
2358 Object[] finderArgs = new Object[] { };
2359
2360 Object result = null;
2361
2362 if (finderClassNameCacheEnabled) {
2363 result = FinderCacheUtil.getResult(finderClassName,
2364 finderMethodName, finderParams, finderArgs, this);
2365 }
2366
2367 if (result == null) {
2368 Session session = null;
2369
2370 try {
2371 session = openSession();
2372
2373 Query q = session.createQuery(
2374 "SELECT COUNT(*) FROM com.liferay.portlet.journal.model.JournalTemplate");
2375
2376 Long count = null;
2377
2378 Iterator<Long> itr = q.list().iterator();
2379
2380 if (itr.hasNext()) {
2381 count = itr.next();
2382 }
2383
2384 if (count == null) {
2385 count = new Long(0);
2386 }
2387
2388 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
2389 finderClassName, finderMethodName, finderParams,
2390 finderArgs, count);
2391
2392 return count.intValue();
2393 }
2394 catch (Exception e) {
2395 throw processException(e);
2396 }
2397 finally {
2398 closeSession(session);
2399 }
2400 }
2401 else {
2402 return ((Long)result).intValue();
2403 }
2404 }
2405
2406 public void registerListener(ModelListener listener) {
2407 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
2408
2409 listeners.add(listener);
2410
2411 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
2412 }
2413
2414 public void unregisterListener(ModelListener listener) {
2415 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
2416
2417 listeners.remove(listener);
2418
2419 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
2420 }
2421
2422 public void afterPropertiesSet() {
2423 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2424 com.liferay.portal.util.PropsUtil.get(
2425 "value.object.listener.com.liferay.portlet.journal.model.JournalTemplate")));
2426
2427 if (listenerClassNames.length > 0) {
2428 try {
2429 List<ModelListener> listeners = new ArrayList<ModelListener>();
2430
2431 for (String listenerClassName : listenerClassNames) {
2432 listeners.add((ModelListener)Class.forName(
2433 listenerClassName).newInstance());
2434 }
2435
2436 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
2437 }
2438 catch (Exception e) {
2439 _log.error(e);
2440 }
2441 }
2442 }
2443
2444 private static Log _log = LogFactory.getLog(JournalTemplatePersistenceImpl.class);
2445 private ModelListener[] _listeners = new ModelListener[0];
2446}