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