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