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