diff --git a/src/main/java/org/olat/course/member/CourseBusinessGroupListController.java b/src/main/java/org/olat/course/member/CourseBusinessGroupListController.java index b17c8147643ef0c1edfa651f89539b7cbe9d4543..b141c8095224c47e6728a0c7529ade541c17624f 100644 --- a/src/main/java/org/olat/course/member/CourseBusinessGroupListController.java +++ b/src/main/java/org/olat/course/member/CourseBusinessGroupListController.java @@ -163,7 +163,7 @@ public class CourseBusinessGroupListController extends AbstractBusinessGroupList @Override protected List<BGTableItem> searchTableItems(BusinessGroupQueryParams params) { - List<StatisticsBusinessGroupRow> rows = businessGroupService.findBusinessGroupsFromRepositoryEntry(params, getResource()); + List<StatisticsBusinessGroupRow> rows = businessGroupService.findBusinessGroupsFromRepositoryEntry(params, getIdentity(), getResource()); List<BGTableItem> items = new ArrayList<>(rows.size()); for(StatisticsBusinessGroupRow row:rows) { BusinessGroupMembership membership = row.getMember(); @@ -338,12 +338,16 @@ public class CourseBusinessGroupListController extends AbstractBusinessGroupList @Override protected BusinessGroupQueryParams getSearchParams(SearchEvent event) { - return new BusinessGroupQueryParams(); + BusinessGroupQueryParams params = event.convertToBusinessGroupQueriesParams(); + params.setRepositoryEntry(re); + return params; } @Override protected BusinessGroupQueryParams getDefaultSearchParams() { - return new BusinessGroupQueryParams(); + BusinessGroupQueryParams params = new BusinessGroupQueryParams(); + params.setRepositoryEntry(re); + return params; } @Override diff --git a/src/main/java/org/olat/group/BusinessGroupService.java b/src/main/java/org/olat/group/BusinessGroupService.java index 31c4d12acfb4d9f1973d6b70740e451e80247737..b4f99ae764ab40d601d518671d8279488c142778 100644 --- a/src/main/java/org/olat/group/BusinessGroupService.java +++ b/src/main/java/org/olat/group/BusinessGroupService.java @@ -290,7 +290,7 @@ public interface BusinessGroupService { * @param entryRef * @return */ - public List<StatisticsBusinessGroupRow> findBusinessGroupsFromRepositoryEntry(BusinessGroupQueryParams params, RepositoryEntryRef entry); + public List<StatisticsBusinessGroupRow> findBusinessGroupsFromRepositoryEntry(BusinessGroupQueryParams params, IdentityRef identity, RepositoryEntryRef entry); /** * Retrieve the business groups of a repository entry with the number of coaches, participants, diff --git a/src/main/java/org/olat/group/manager/BusinessGroupDAO.java b/src/main/java/org/olat/group/manager/BusinessGroupDAO.java index 395ecf78b1f5e0514f0a00110d34028104787cd2..9b8b2bc15cd5c0fea9749ea47afe39cb1d8e67cd 100644 --- a/src/main/java/org/olat/group/manager/BusinessGroupDAO.java +++ b/src/main/java/org/olat/group/manager/BusinessGroupDAO.java @@ -820,7 +820,7 @@ public class BusinessGroupDAO { * @param entry * @return */ - public List<StatisticsBusinessGroupRow> searchBusinessGroupsForRepositoryEntry(RepositoryEntryRef entry) { + public List<StatisticsBusinessGroupRow> searchBusinessGroupsForRepositoryEntry(BusinessGroupQueryParams params, IdentityRef identity, RepositoryEntryRef entry) { //name, externalId, description, resources, tutors, participants, free places, waiting, access StringBuilder sb = new StringBuilder(); @@ -839,16 +839,17 @@ public class BusinessGroupDAO { .append(" ) as numOfReservations") .append(" from businessgrouptosearch as bgi") .append(" inner join fetch bgi.resource as bgResource ") - .append(" inner join bgi.baseGroup as bGroup ") - .append(" where bgi.baseGroup.key in (") - .append(" select relation.group.key from repoentrytogroup relation where relation.entry.key=:resourceKey") - .append(" )"); + .append(" inner join bgi.baseGroup as bGroup "); + if(params.getRepositoryEntry() == null) { + params.setRepositoryEntry(entry);//make sur the restricition is applied + } + filterBusinessGroupToSearch(sb, params, false); - List<Object[]> objects = dbInstance.getCurrentEntityManager() - .createQuery(sb.toString(), Object[].class) - .setParameter("resourceKey", entry.getKey()) - .getResultList(); + TypedQuery<Object[]> objectsQuery = dbInstance.getCurrentEntityManager() + .createQuery(sb.toString(), Object[].class); + filterBusinessGroupToSearchParameters(objectsQuery, params, identity, false); + List<Object[]> objects = objectsQuery.getResultList(); List<StatisticsBusinessGroupRow> groups = new ArrayList<>(objects.size()); Map<Long,BusinessGroupRow> keyToGroup = new HashMap<>(); Map<Long,BusinessGroupRow> resourceKeyToGroup = new HashMap<>(); @@ -858,8 +859,7 @@ public class BusinessGroupDAO { Number numOfParticipants = (Number)object[2]; Number numWaiting = (Number)object[3]; Number numPending = (Number)object[4]; - - + StatisticsBusinessGroupRow row = new StatisticsBusinessGroupRow(businessGroup, numOfCoaches, numOfParticipants, numWaiting, numPending); groups.add(row); diff --git a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java index b992c7e49f9f0641aa14f71c332e18d1ab7b9e41..8a259bf38116deeae6e57f2142d20a431f638bbd 100644 --- a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java +++ b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java @@ -98,8 +98,8 @@ import org.olat.group.model.IdentityGroupKey; import org.olat.group.model.LeaveOption; import org.olat.group.model.MembershipModification; import org.olat.group.model.OpenBusinessGroupRow; -import org.olat.group.model.StatisticsBusinessGroupRow; import org.olat.group.model.SearchBusinessGroupParams; +import org.olat.group.model.StatisticsBusinessGroupRow; import org.olat.group.right.BGRightManager; import org.olat.group.right.BGRightsRole; import org.olat.group.ui.BGMailHelper; @@ -702,8 +702,8 @@ public class BusinessGroupServiceImpl implements BusinessGroupService, UserDataD } @Override - public List<StatisticsBusinessGroupRow> findBusinessGroupsFromRepositoryEntry(BusinessGroupQueryParams params, RepositoryEntryRef entry) { - return businessGroupDAO.searchBusinessGroupsForRepositoryEntry(entry); + public List<StatisticsBusinessGroupRow> findBusinessGroupsFromRepositoryEntry(BusinessGroupQueryParams params, IdentityRef identity, RepositoryEntryRef entry) { + return businessGroupDAO.searchBusinessGroupsForRepositoryEntry(params, identity, entry); } @Override diff --git a/src/main/java/org/olat/group/model/BusinessGroupQueryParams.java b/src/main/java/org/olat/group/model/BusinessGroupQueryParams.java index f0886770f826a022d02b50e84e7f3f9d8332e8ad..4c9c9a6ad9c96a6ef805ee418e0e5a38e158b06a 100644 --- a/src/main/java/org/olat/group/model/BusinessGroupQueryParams.java +++ b/src/main/java/org/olat/group/model/BusinessGroupQueryParams.java @@ -19,7 +19,7 @@ **/ package org.olat.group.model; -import org.olat.repository.RepositoryEntry; +import org.olat.repository.RepositoryEntryRef; /** * @@ -47,7 +47,7 @@ public class BusinessGroupQueryParams { private boolean authorConnection; private Long businessGroupKey; - private RepositoryEntry repositoryEntry; + private RepositoryEntryRef repositoryEntry; public BusinessGroupQueryParams() { // @@ -182,11 +182,11 @@ public class BusinessGroupQueryParams { this.businessGroupKey = businessGroupKey; } - public RepositoryEntry getRepositoryEntry() { + public RepositoryEntryRef getRepositoryEntry() { return repositoryEntry; } - public void setRepositoryEntry(RepositoryEntry repositoryEntry) { + public void setRepositoryEntry(RepositoryEntryRef repositoryEntry) { this.repositoryEntry = repositoryEntry; }