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