Skip to content
Snippets Groups Projects
Commit 94cdff92 authored by srosse's avatar srosse
Browse files

OO-2220: pass the parameters of the search and enhance the query

parent c7f28c55
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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,
......
......@@ -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);
......
......@@ -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
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment