1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchOrgGroupPermissionException;
26 import com.liferay.portal.SystemException;
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.model.ModelListener;
39 import com.liferay.portal.model.OrgGroupPermission;
40 import com.liferay.portal.model.impl.OrgGroupPermissionImpl;
41 import com.liferay.portal.model.impl.OrgGroupPermissionModelImpl;
42 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
43
44 import org.apache.commons.logging.Log;
45 import org.apache.commons.logging.LogFactory;
46
47 import java.util.ArrayList;
48 import java.util.Collections;
49 import java.util.Iterator;
50 import java.util.List;
51
52
58 public class OrgGroupPermissionPersistenceImpl extends BasePersistenceImpl
59 implements OrgGroupPermissionPersistence {
60 public OrgGroupPermission create(OrgGroupPermissionPK orgGroupPermissionPK) {
61 OrgGroupPermission orgGroupPermission = new OrgGroupPermissionImpl();
62
63 orgGroupPermission.setNew(true);
64 orgGroupPermission.setPrimaryKey(orgGroupPermissionPK);
65
66 return orgGroupPermission;
67 }
68
69 public OrgGroupPermission remove(OrgGroupPermissionPK orgGroupPermissionPK)
70 throws NoSuchOrgGroupPermissionException, SystemException {
71 Session session = null;
72
73 try {
74 session = openSession();
75
76 OrgGroupPermission orgGroupPermission = (OrgGroupPermission)session.get(OrgGroupPermissionImpl.class,
77 orgGroupPermissionPK);
78
79 if (orgGroupPermission == null) {
80 if (_log.isWarnEnabled()) {
81 _log.warn(
82 "No OrgGroupPermission exists with the primary key " +
83 orgGroupPermissionPK);
84 }
85
86 throw new NoSuchOrgGroupPermissionException(
87 "No OrgGroupPermission exists with the primary key " +
88 orgGroupPermissionPK);
89 }
90
91 return remove(orgGroupPermission);
92 }
93 catch (NoSuchOrgGroupPermissionException nsee) {
94 throw nsee;
95 }
96 catch (Exception e) {
97 throw processException(e);
98 }
99 finally {
100 closeSession(session);
101 }
102 }
103
104 public OrgGroupPermission remove(OrgGroupPermission orgGroupPermission)
105 throws SystemException {
106 if (_listeners.length > 0) {
107 for (ModelListener listener : _listeners) {
108 listener.onBeforeRemove(orgGroupPermission);
109 }
110 }
111
112 orgGroupPermission = removeImpl(orgGroupPermission);
113
114 if (_listeners.length > 0) {
115 for (ModelListener listener : _listeners) {
116 listener.onAfterRemove(orgGroupPermission);
117 }
118 }
119
120 return orgGroupPermission;
121 }
122
123 protected OrgGroupPermission removeImpl(
124 OrgGroupPermission orgGroupPermission) throws SystemException {
125 Session session = null;
126
127 try {
128 session = openSession();
129
130 if (BatchSessionUtil.isEnabled()) {
131 Object staleObject = session.get(OrgGroupPermissionImpl.class,
132 orgGroupPermission.getPrimaryKeyObj());
133
134 if (staleObject != null) {
135 session.evict(staleObject);
136 }
137 }
138
139 session.delete(orgGroupPermission);
140
141 session.flush();
142
143 return orgGroupPermission;
144 }
145 catch (Exception e) {
146 throw processException(e);
147 }
148 finally {
149 closeSession(session);
150
151 FinderCacheUtil.clearCache(OrgGroupPermission.class.getName());
152 }
153 }
154
155
158 public OrgGroupPermission update(OrgGroupPermission orgGroupPermission)
159 throws SystemException {
160 if (_log.isWarnEnabled()) {
161 _log.warn(
162 "Using the deprecated update(OrgGroupPermission orgGroupPermission) method. Use update(OrgGroupPermission orgGroupPermission, boolean merge) instead.");
163 }
164
165 return update(orgGroupPermission, false);
166 }
167
168
181 public OrgGroupPermission update(OrgGroupPermission orgGroupPermission,
182 boolean merge) throws SystemException {
183 boolean isNew = orgGroupPermission.isNew();
184
185 if (_listeners.length > 0) {
186 for (ModelListener listener : _listeners) {
187 if (isNew) {
188 listener.onBeforeCreate(orgGroupPermission);
189 }
190 else {
191 listener.onBeforeUpdate(orgGroupPermission);
192 }
193 }
194 }
195
196 orgGroupPermission = updateImpl(orgGroupPermission, merge);
197
198 if (_listeners.length > 0) {
199 for (ModelListener listener : _listeners) {
200 if (isNew) {
201 listener.onAfterCreate(orgGroupPermission);
202 }
203 else {
204 listener.onAfterUpdate(orgGroupPermission);
205 }
206 }
207 }
208
209 return orgGroupPermission;
210 }
211
212 public OrgGroupPermission updateImpl(
213 com.liferay.portal.model.OrgGroupPermission orgGroupPermission,
214 boolean merge) throws SystemException {
215 Session session = null;
216
217 try {
218 session = openSession();
219
220 BatchSessionUtil.update(session, orgGroupPermission, merge);
221
222 orgGroupPermission.setNew(false);
223
224 return orgGroupPermission;
225 }
226 catch (Exception e) {
227 throw processException(e);
228 }
229 finally {
230 closeSession(session);
231
232 FinderCacheUtil.clearCache(OrgGroupPermission.class.getName());
233 }
234 }
235
236 public OrgGroupPermission findByPrimaryKey(
237 OrgGroupPermissionPK orgGroupPermissionPK)
238 throws NoSuchOrgGroupPermissionException, SystemException {
239 OrgGroupPermission orgGroupPermission = fetchByPrimaryKey(orgGroupPermissionPK);
240
241 if (orgGroupPermission == null) {
242 if (_log.isWarnEnabled()) {
243 _log.warn("No OrgGroupPermission exists with the primary key " +
244 orgGroupPermissionPK);
245 }
246
247 throw new NoSuchOrgGroupPermissionException(
248 "No OrgGroupPermission exists with the primary key " +
249 orgGroupPermissionPK);
250 }
251
252 return orgGroupPermission;
253 }
254
255 public OrgGroupPermission fetchByPrimaryKey(
256 OrgGroupPermissionPK orgGroupPermissionPK) throws SystemException {
257 Session session = null;
258
259 try {
260 session = openSession();
261
262 return (OrgGroupPermission)session.get(OrgGroupPermissionImpl.class,
263 orgGroupPermissionPK);
264 }
265 catch (Exception e) {
266 throw processException(e);
267 }
268 finally {
269 closeSession(session);
270 }
271 }
272
273 public List<OrgGroupPermission> findByGroupId(long groupId)
274 throws SystemException {
275 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
276 String finderClassName = OrgGroupPermission.class.getName();
277 String finderMethodName = "findByGroupId";
278 String[] finderParams = new String[] { Long.class.getName() };
279 Object[] finderArgs = new Object[] { new Long(groupId) };
280
281 Object result = null;
282
283 if (finderClassNameCacheEnabled) {
284 result = FinderCacheUtil.getResult(finderClassName,
285 finderMethodName, finderParams, finderArgs, this);
286 }
287
288 if (result == null) {
289 Session session = null;
290
291 try {
292 session = openSession();
293
294 StringBuilder query = new StringBuilder();
295
296 query.append(
297 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
298
299 query.append("groupId = ?");
300
301 query.append(" ");
302
303 Query q = session.createQuery(query.toString());
304
305 QueryPos qPos = QueryPos.getInstance(q);
306
307 qPos.add(groupId);
308
309 List<OrgGroupPermission> list = q.list();
310
311 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
312 finderClassName, finderMethodName, finderParams,
313 finderArgs, list);
314
315 return list;
316 }
317 catch (Exception e) {
318 throw processException(e);
319 }
320 finally {
321 closeSession(session);
322 }
323 }
324 else {
325 return (List<OrgGroupPermission>)result;
326 }
327 }
328
329 public List<OrgGroupPermission> findByGroupId(long groupId, int start,
330 int end) throws SystemException {
331 return findByGroupId(groupId, start, end, null);
332 }
333
334 public List<OrgGroupPermission> findByGroupId(long groupId, int start,
335 int end, OrderByComparator obc) throws SystemException {
336 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
337 String finderClassName = OrgGroupPermission.class.getName();
338 String finderMethodName = "findByGroupId";
339 String[] finderParams = new String[] {
340 Long.class.getName(),
341
342 "java.lang.Integer", "java.lang.Integer",
343 "com.liferay.portal.kernel.util.OrderByComparator"
344 };
345 Object[] finderArgs = new Object[] {
346 new Long(groupId),
347
348 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
349 };
350
351 Object result = null;
352
353 if (finderClassNameCacheEnabled) {
354 result = FinderCacheUtil.getResult(finderClassName,
355 finderMethodName, finderParams, finderArgs, this);
356 }
357
358 if (result == null) {
359 Session session = null;
360
361 try {
362 session = openSession();
363
364 StringBuilder query = new StringBuilder();
365
366 query.append(
367 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
368
369 query.append("groupId = ?");
370
371 query.append(" ");
372
373 if (obc != null) {
374 query.append("ORDER BY ");
375 query.append(obc.getOrderBy());
376 }
377
378 Query q = session.createQuery(query.toString());
379
380 QueryPos qPos = QueryPos.getInstance(q);
381
382 qPos.add(groupId);
383
384 List<OrgGroupPermission> list = (List<OrgGroupPermission>)QueryUtil.list(q,
385 getDialect(), start, end);
386
387 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
388 finderClassName, finderMethodName, finderParams,
389 finderArgs, list);
390
391 return list;
392 }
393 catch (Exception e) {
394 throw processException(e);
395 }
396 finally {
397 closeSession(session);
398 }
399 }
400 else {
401 return (List<OrgGroupPermission>)result;
402 }
403 }
404
405 public OrgGroupPermission findByGroupId_First(long groupId,
406 OrderByComparator obc)
407 throws NoSuchOrgGroupPermissionException, SystemException {
408 List<OrgGroupPermission> list = findByGroupId(groupId, 0, 1, obc);
409
410 if (list.size() == 0) {
411 StringBuilder msg = new StringBuilder();
412
413 msg.append("No OrgGroupPermission exists with the key {");
414
415 msg.append("groupId=" + groupId);
416
417 msg.append(StringPool.CLOSE_CURLY_BRACE);
418
419 throw new NoSuchOrgGroupPermissionException(msg.toString());
420 }
421 else {
422 return list.get(0);
423 }
424 }
425
426 public OrgGroupPermission findByGroupId_Last(long groupId,
427 OrderByComparator obc)
428 throws NoSuchOrgGroupPermissionException, SystemException {
429 int count = countByGroupId(groupId);
430
431 List<OrgGroupPermission> list = findByGroupId(groupId, count - 1,
432 count, obc);
433
434 if (list.size() == 0) {
435 StringBuilder msg = new StringBuilder();
436
437 msg.append("No OrgGroupPermission exists with the key {");
438
439 msg.append("groupId=" + groupId);
440
441 msg.append(StringPool.CLOSE_CURLY_BRACE);
442
443 throw new NoSuchOrgGroupPermissionException(msg.toString());
444 }
445 else {
446 return list.get(0);
447 }
448 }
449
450 public OrgGroupPermission[] findByGroupId_PrevAndNext(
451 OrgGroupPermissionPK orgGroupPermissionPK, long groupId,
452 OrderByComparator obc)
453 throws NoSuchOrgGroupPermissionException, SystemException {
454 OrgGroupPermission orgGroupPermission = findByPrimaryKey(orgGroupPermissionPK);
455
456 int count = countByGroupId(groupId);
457
458 Session session = null;
459
460 try {
461 session = openSession();
462
463 StringBuilder query = new StringBuilder();
464
465 query.append(
466 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
467
468 query.append("groupId = ?");
469
470 query.append(" ");
471
472 if (obc != null) {
473 query.append("ORDER BY ");
474 query.append(obc.getOrderBy());
475 }
476
477 Query q = session.createQuery(query.toString());
478
479 QueryPos qPos = QueryPos.getInstance(q);
480
481 qPos.add(groupId);
482
483 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
484 orgGroupPermission);
485
486 OrgGroupPermission[] array = new OrgGroupPermissionImpl[3];
487
488 array[0] = (OrgGroupPermission)objArray[0];
489 array[1] = (OrgGroupPermission)objArray[1];
490 array[2] = (OrgGroupPermission)objArray[2];
491
492 return array;
493 }
494 catch (Exception e) {
495 throw processException(e);
496 }
497 finally {
498 closeSession(session);
499 }
500 }
501
502 public List<OrgGroupPermission> findByPermissionId(long permissionId)
503 throws SystemException {
504 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
505 String finderClassName = OrgGroupPermission.class.getName();
506 String finderMethodName = "findByPermissionId";
507 String[] finderParams = new String[] { Long.class.getName() };
508 Object[] finderArgs = new Object[] { new Long(permissionId) };
509
510 Object result = null;
511
512 if (finderClassNameCacheEnabled) {
513 result = FinderCacheUtil.getResult(finderClassName,
514 finderMethodName, finderParams, finderArgs, this);
515 }
516
517 if (result == null) {
518 Session session = null;
519
520 try {
521 session = openSession();
522
523 StringBuilder query = new StringBuilder();
524
525 query.append(
526 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
527
528 query.append("permissionId = ?");
529
530 query.append(" ");
531
532 Query q = session.createQuery(query.toString());
533
534 QueryPos qPos = QueryPos.getInstance(q);
535
536 qPos.add(permissionId);
537
538 List<OrgGroupPermission> list = q.list();
539
540 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
541 finderClassName, finderMethodName, finderParams,
542 finderArgs, list);
543
544 return list;
545 }
546 catch (Exception e) {
547 throw processException(e);
548 }
549 finally {
550 closeSession(session);
551 }
552 }
553 else {
554 return (List<OrgGroupPermission>)result;
555 }
556 }
557
558 public List<OrgGroupPermission> findByPermissionId(long permissionId,
559 int start, int end) throws SystemException {
560 return findByPermissionId(permissionId, start, end, null);
561 }
562
563 public List<OrgGroupPermission> findByPermissionId(long permissionId,
564 int start, int end, OrderByComparator obc) throws SystemException {
565 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
566 String finderClassName = OrgGroupPermission.class.getName();
567 String finderMethodName = "findByPermissionId";
568 String[] finderParams = new String[] {
569 Long.class.getName(),
570
571 "java.lang.Integer", "java.lang.Integer",
572 "com.liferay.portal.kernel.util.OrderByComparator"
573 };
574 Object[] finderArgs = new Object[] {
575 new Long(permissionId),
576
577 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
578 };
579
580 Object result = null;
581
582 if (finderClassNameCacheEnabled) {
583 result = FinderCacheUtil.getResult(finderClassName,
584 finderMethodName, finderParams, finderArgs, this);
585 }
586
587 if (result == null) {
588 Session session = null;
589
590 try {
591 session = openSession();
592
593 StringBuilder query = new StringBuilder();
594
595 query.append(
596 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
597
598 query.append("permissionId = ?");
599
600 query.append(" ");
601
602 if (obc != null) {
603 query.append("ORDER BY ");
604 query.append(obc.getOrderBy());
605 }
606
607 Query q = session.createQuery(query.toString());
608
609 QueryPos qPos = QueryPos.getInstance(q);
610
611 qPos.add(permissionId);
612
613 List<OrgGroupPermission> list = (List<OrgGroupPermission>)QueryUtil.list(q,
614 getDialect(), start, end);
615
616 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
617 finderClassName, finderMethodName, finderParams,
618 finderArgs, list);
619
620 return list;
621 }
622 catch (Exception e) {
623 throw processException(e);
624 }
625 finally {
626 closeSession(session);
627 }
628 }
629 else {
630 return (List<OrgGroupPermission>)result;
631 }
632 }
633
634 public OrgGroupPermission findByPermissionId_First(long permissionId,
635 OrderByComparator obc)
636 throws NoSuchOrgGroupPermissionException, SystemException {
637 List<OrgGroupPermission> list = findByPermissionId(permissionId, 0, 1,
638 obc);
639
640 if (list.size() == 0) {
641 StringBuilder msg = new StringBuilder();
642
643 msg.append("No OrgGroupPermission exists with the key {");
644
645 msg.append("permissionId=" + permissionId);
646
647 msg.append(StringPool.CLOSE_CURLY_BRACE);
648
649 throw new NoSuchOrgGroupPermissionException(msg.toString());
650 }
651 else {
652 return list.get(0);
653 }
654 }
655
656 public OrgGroupPermission findByPermissionId_Last(long permissionId,
657 OrderByComparator obc)
658 throws NoSuchOrgGroupPermissionException, SystemException {
659 int count = countByPermissionId(permissionId);
660
661 List<OrgGroupPermission> list = findByPermissionId(permissionId,
662 count - 1, count, obc);
663
664 if (list.size() == 0) {
665 StringBuilder msg = new StringBuilder();
666
667 msg.append("No OrgGroupPermission exists with the key {");
668
669 msg.append("permissionId=" + permissionId);
670
671 msg.append(StringPool.CLOSE_CURLY_BRACE);
672
673 throw new NoSuchOrgGroupPermissionException(msg.toString());
674 }
675 else {
676 return list.get(0);
677 }
678 }
679
680 public OrgGroupPermission[] findByPermissionId_PrevAndNext(
681 OrgGroupPermissionPK orgGroupPermissionPK, long permissionId,
682 OrderByComparator obc)
683 throws NoSuchOrgGroupPermissionException, SystemException {
684 OrgGroupPermission orgGroupPermission = findByPrimaryKey(orgGroupPermissionPK);
685
686 int count = countByPermissionId(permissionId);
687
688 Session session = null;
689
690 try {
691 session = openSession();
692
693 StringBuilder query = new StringBuilder();
694
695 query.append(
696 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
697
698 query.append("permissionId = ?");
699
700 query.append(" ");
701
702 if (obc != null) {
703 query.append("ORDER BY ");
704 query.append(obc.getOrderBy());
705 }
706
707 Query q = session.createQuery(query.toString());
708
709 QueryPos qPos = QueryPos.getInstance(q);
710
711 qPos.add(permissionId);
712
713 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
714 orgGroupPermission);
715
716 OrgGroupPermission[] array = new OrgGroupPermissionImpl[3];
717
718 array[0] = (OrgGroupPermission)objArray[0];
719 array[1] = (OrgGroupPermission)objArray[1];
720 array[2] = (OrgGroupPermission)objArray[2];
721
722 return array;
723 }
724 catch (Exception e) {
725 throw processException(e);
726 }
727 finally {
728 closeSession(session);
729 }
730 }
731
732 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
733 throws SystemException {
734 Session session = null;
735
736 try {
737 session = openSession();
738
739 dynamicQuery.compile(session);
740
741 return dynamicQuery.list();
742 }
743 catch (Exception e) {
744 throw processException(e);
745 }
746 finally {
747 closeSession(session);
748 }
749 }
750
751 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
752 int start, int end) throws SystemException {
753 Session session = null;
754
755 try {
756 session = openSession();
757
758 dynamicQuery.setLimit(start, end);
759
760 dynamicQuery.compile(session);
761
762 return dynamicQuery.list();
763 }
764 catch (Exception e) {
765 throw processException(e);
766 }
767 finally {
768 closeSession(session);
769 }
770 }
771
772 public List<OrgGroupPermission> findAll() throws SystemException {
773 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
774 }
775
776 public List<OrgGroupPermission> findAll(int start, int end)
777 throws SystemException {
778 return findAll(start, end, null);
779 }
780
781 public List<OrgGroupPermission> findAll(int start, int end,
782 OrderByComparator obc) throws SystemException {
783 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
784 String finderClassName = OrgGroupPermission.class.getName();
785 String finderMethodName = "findAll";
786 String[] finderParams = new String[] {
787 "java.lang.Integer", "java.lang.Integer",
788 "com.liferay.portal.kernel.util.OrderByComparator"
789 };
790 Object[] finderArgs = new Object[] {
791 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
792 };
793
794 Object result = null;
795
796 if (finderClassNameCacheEnabled) {
797 result = FinderCacheUtil.getResult(finderClassName,
798 finderMethodName, finderParams, finderArgs, this);
799 }
800
801 if (result == null) {
802 Session session = null;
803
804 try {
805 session = openSession();
806
807 StringBuilder query = new StringBuilder();
808
809 query.append(
810 "FROM com.liferay.portal.model.OrgGroupPermission ");
811
812 if (obc != null) {
813 query.append("ORDER BY ");
814 query.append(obc.getOrderBy());
815 }
816
817 Query q = session.createQuery(query.toString());
818
819 List<OrgGroupPermission> list = null;
820
821 if (obc == null) {
822 list = (List<OrgGroupPermission>)QueryUtil.list(q,
823 getDialect(), start, end, false);
824
825 Collections.sort(list);
826 }
827 else {
828 list = (List<OrgGroupPermission>)QueryUtil.list(q,
829 getDialect(), start, end);
830 }
831
832 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
833 finderClassName, finderMethodName, finderParams,
834 finderArgs, list);
835
836 return list;
837 }
838 catch (Exception e) {
839 throw processException(e);
840 }
841 finally {
842 closeSession(session);
843 }
844 }
845 else {
846 return (List<OrgGroupPermission>)result;
847 }
848 }
849
850 public void removeByGroupId(long groupId) throws SystemException {
851 for (OrgGroupPermission orgGroupPermission : findByGroupId(groupId)) {
852 remove(orgGroupPermission);
853 }
854 }
855
856 public void removeByPermissionId(long permissionId)
857 throws SystemException {
858 for (OrgGroupPermission orgGroupPermission : findByPermissionId(
859 permissionId)) {
860 remove(orgGroupPermission);
861 }
862 }
863
864 public void removeAll() throws SystemException {
865 for (OrgGroupPermission orgGroupPermission : findAll()) {
866 remove(orgGroupPermission);
867 }
868 }
869
870 public int countByGroupId(long groupId) throws SystemException {
871 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
872 String finderClassName = OrgGroupPermission.class.getName();
873 String finderMethodName = "countByGroupId";
874 String[] finderParams = new String[] { Long.class.getName() };
875 Object[] finderArgs = new Object[] { new Long(groupId) };
876
877 Object result = null;
878
879 if (finderClassNameCacheEnabled) {
880 result = FinderCacheUtil.getResult(finderClassName,
881 finderMethodName, finderParams, finderArgs, this);
882 }
883
884 if (result == null) {
885 Session session = null;
886
887 try {
888 session = openSession();
889
890 StringBuilder query = new StringBuilder();
891
892 query.append("SELECT COUNT(*) ");
893 query.append(
894 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
895
896 query.append("groupId = ?");
897
898 query.append(" ");
899
900 Query q = session.createQuery(query.toString());
901
902 QueryPos qPos = QueryPos.getInstance(q);
903
904 qPos.add(groupId);
905
906 Long count = null;
907
908 Iterator<Long> itr = q.list().iterator();
909
910 if (itr.hasNext()) {
911 count = itr.next();
912 }
913
914 if (count == null) {
915 count = new Long(0);
916 }
917
918 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
919 finderClassName, finderMethodName, finderParams,
920 finderArgs, count);
921
922 return count.intValue();
923 }
924 catch (Exception e) {
925 throw processException(e);
926 }
927 finally {
928 closeSession(session);
929 }
930 }
931 else {
932 return ((Long)result).intValue();
933 }
934 }
935
936 public int countByPermissionId(long permissionId) throws SystemException {
937 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
938 String finderClassName = OrgGroupPermission.class.getName();
939 String finderMethodName = "countByPermissionId";
940 String[] finderParams = new String[] { Long.class.getName() };
941 Object[] finderArgs = new Object[] { new Long(permissionId) };
942
943 Object result = null;
944
945 if (finderClassNameCacheEnabled) {
946 result = FinderCacheUtil.getResult(finderClassName,
947 finderMethodName, finderParams, finderArgs, this);
948 }
949
950 if (result == null) {
951 Session session = null;
952
953 try {
954 session = openSession();
955
956 StringBuilder query = new StringBuilder();
957
958 query.append("SELECT COUNT(*) ");
959 query.append(
960 "FROM com.liferay.portal.model.OrgGroupPermission WHERE ");
961
962 query.append("permissionId = ?");
963
964 query.append(" ");
965
966 Query q = session.createQuery(query.toString());
967
968 QueryPos qPos = QueryPos.getInstance(q);
969
970 qPos.add(permissionId);
971
972 Long count = null;
973
974 Iterator<Long> itr = q.list().iterator();
975
976 if (itr.hasNext()) {
977 count = itr.next();
978 }
979
980 if (count == null) {
981 count = new Long(0);
982 }
983
984 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
985 finderClassName, finderMethodName, finderParams,
986 finderArgs, count);
987
988 return count.intValue();
989 }
990 catch (Exception e) {
991 throw processException(e);
992 }
993 finally {
994 closeSession(session);
995 }
996 }
997 else {
998 return ((Long)result).intValue();
999 }
1000 }
1001
1002 public int countAll() throws SystemException {
1003 boolean finderClassNameCacheEnabled = OrgGroupPermissionModelImpl.CACHE_ENABLED;
1004 String finderClassName = OrgGroupPermission.class.getName();
1005 String finderMethodName = "countAll";
1006 String[] finderParams = new String[] { };
1007 Object[] finderArgs = new Object[] { };
1008
1009 Object result = null;
1010
1011 if (finderClassNameCacheEnabled) {
1012 result = FinderCacheUtil.getResult(finderClassName,
1013 finderMethodName, finderParams, finderArgs, this);
1014 }
1015
1016 if (result == null) {
1017 Session session = null;
1018
1019 try {
1020 session = openSession();
1021
1022 Query q = session.createQuery(
1023 "SELECT COUNT(*) FROM com.liferay.portal.model.OrgGroupPermission");
1024
1025 Long count = null;
1026
1027 Iterator<Long> itr = q.list().iterator();
1028
1029 if (itr.hasNext()) {
1030 count = itr.next();
1031 }
1032
1033 if (count == null) {
1034 count = new Long(0);
1035 }
1036
1037 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1038 finderClassName, finderMethodName, finderParams,
1039 finderArgs, count);
1040
1041 return count.intValue();
1042 }
1043 catch (Exception e) {
1044 throw processException(e);
1045 }
1046 finally {
1047 closeSession(session);
1048 }
1049 }
1050 else {
1051 return ((Long)result).intValue();
1052 }
1053 }
1054
1055 public void registerListener(ModelListener listener) {
1056 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
1057
1058 listeners.add(listener);
1059
1060 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1061 }
1062
1063 public void unregisterListener(ModelListener listener) {
1064 List<ModelListener> listeners = ListUtil.fromArray(_listeners);
1065
1066 listeners.remove(listener);
1067
1068 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1069 }
1070
1071 public void afterPropertiesSet() {
1072 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1073 com.liferay.portal.util.PropsUtil.get(
1074 "value.object.listener.com.liferay.portal.model.OrgGroupPermission")));
1075
1076 if (listenerClassNames.length > 0) {
1077 try {
1078 List<ModelListener> listeners = new ArrayList<ModelListener>();
1079
1080 for (String listenerClassName : listenerClassNames) {
1081 listeners.add((ModelListener)Class.forName(
1082 listenerClassName).newInstance());
1083 }
1084
1085 _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1086 }
1087 catch (Exception e) {
1088 _log.error(e);
1089 }
1090 }
1091 }
1092
1093 private static Log _log = LogFactory.getLog(OrgGroupPermissionPersistenceImpl.class);
1094 private ModelListener[] _listeners = new ModelListener[0];
1095}