diff --git a/roster2/tool/src/java/org/sakaiproject/roster/tool/entityprovider/RosterPOIEntityProvider.java b/roster2/tool/src/java/org/sakaiproject/roster/tool/entityprovider/RosterPOIEntityProvider.java index a8911f217006..26caa11c58c5 100644 --- a/roster2/tool/src/java/org/sakaiproject/roster/tool/entityprovider/RosterPOIEntityProvider.java +++ b/roster2/tool/src/java/org/sakaiproject/roster/tool/entityprovider/RosterPOIEntityProvider.java @@ -314,7 +314,7 @@ private Workbook getExportData(final String currentUserId, final RosterSite site createSpreadsheetTitle(rosterRows, site, groupId, viewType); final String siteID = site.getId(); - List header = createColumnHeader(viewType, siteID, false); + List header = createColumnHeader(viewType, siteID, true); List rosterMembers = Collections.EMPTY_LIST; if (VIEW_OVERVIEW.equals(viewType)) { @@ -322,7 +322,7 @@ private Workbook getExportData(final String currentUserId, final RosterSite site rosterMembers = getMembership(currentUserId, siteID, groupId, roleId); if (CollectionUtils.isNotEmpty(rosterMembers)) { - addOverviewRows(rosterRows, rosterMembers, header, siteID); + addOverviewRows(rosterRows, rosterMembers, header, siteID, true); } } else if (VIEW_ENROLLMENT_STATUS.equals(viewType)) { @@ -453,7 +453,7 @@ private List getEnrolledMembership(final String currentUserId, fin } private void addOverviewRows(final List> dataInRows, - final List rosterMembers, final List header, final String siteId) { + final List rosterMembers, final List header, final String siteId, final boolean isGroupsSheetHeader) { final String userId = this.developerHelperService.getCurrentUserId(); @@ -486,6 +486,14 @@ private void addOverviewRows(final List> dataInRows, row.add(member.getRole()); + if (isGroupsSheetHeader && this.sakaiProxy.hasUserSitePermission(userId, RosterFunctions.ROSTER_FUNCTION_VIEWGROUP, siteId)) { + List groups = member.getGroups().entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .map(e -> e.getValue()) + .collect(Collectors.toList()); + row.add(String.join(",", groups)); + } + dataInRows.add(row); } }