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