use of org.pmiops.workbench.model.CohortListResponse in project workbench by all-of-us.
the class CohortsController method getCohortsInWorkspace.
@Override
public ResponseEntity<CohortListResponse> getCohortsInWorkspace(String workspaceNamespace, String workspaceId) {
// This also enforces registered auth domain.
workspaceService.enforceWorkspaceAccessLevel(workspaceNamespace, workspaceId, WorkspaceAccessLevel.READER);
Workspace workspace = workspaceService.getRequiredWithCohorts(workspaceNamespace, workspaceId);
CohortListResponse response = new CohortListResponse();
Set<org.pmiops.workbench.db.model.Cohort> cohorts = workspace.getCohorts();
if (cohorts != null) {
response.setItems(cohorts.stream().map(TO_CLIENT_COHORT).sorted(Comparator.comparing(c -> c.getName())).collect(Collectors.toList()));
}
return ResponseEntity.ok(response);
}
Aggregations