Search in sources :

Example 1 with CohortListResponse

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);
}
Also used : CohortReview(org.pmiops.workbench.db.model.CohortReview) Provider(javax.inject.Provider) Autowired(org.springframework.beans.factory.annotation.Autowired) Function(java.util.function.Function) Level(java.util.logging.Level) CohortReviewDao(org.pmiops.workbench.db.dao.CohortReviewDao) Strings(com.google.common.base.Strings) MaterializeCohortRequest(org.pmiops.workbench.model.MaterializeCohortRequest) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) CdrVersionDao(org.pmiops.workbench.db.dao.CdrVersionDao) Gson(com.google.gson.Gson) MaterializeCohortResponse(org.pmiops.workbench.model.MaterializeCohortResponse) Workspace(org.pmiops.workbench.db.model.Workspace) User(org.pmiops.workbench.db.model.User) CdrVersionContext(org.pmiops.workbench.cdr.CdrVersionContext) BadRequestException(org.pmiops.workbench.exceptions.BadRequestException) JsonSyntaxException(com.google.gson.JsonSyntaxException) CohortListResponse(org.pmiops.workbench.model.CohortListResponse) OptimisticLockException(javax.persistence.OptimisticLockException) WorkspaceService(org.pmiops.workbench.db.dao.WorkspaceService) Timestamp(java.sql.Timestamp) CdrVersion(org.pmiops.workbench.db.model.CdrVersion) Set(java.util.Set) Cohort(org.pmiops.workbench.model.Cohort) CohortDao(org.pmiops.workbench.db.dao.CohortDao) ConflictException(org.pmiops.workbench.exceptions.ConflictException) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) SearchRequest(org.pmiops.workbench.model.SearchRequest) List(java.util.List) CohortMaterializationService(org.pmiops.workbench.cohorts.CohortMaterializationService) CohortStatus(org.pmiops.workbench.model.CohortStatus) EmptyResponse(org.pmiops.workbench.model.EmptyResponse) NotFoundException(org.pmiops.workbench.exceptions.NotFoundException) Clock(java.time.Clock) WorkspaceAccessLevel(org.pmiops.workbench.model.WorkspaceAccessLevel) ResponseEntity(org.springframework.http.ResponseEntity) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Comparator(java.util.Comparator) Cohort(org.pmiops.workbench.model.Cohort) CohortListResponse(org.pmiops.workbench.model.CohortListResponse) Workspace(org.pmiops.workbench.db.model.Workspace)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Strings (com.google.common.base.Strings)1 Gson (com.google.gson.Gson)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 Timestamp (java.sql.Timestamp)1 Clock (java.time.Clock)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Set (java.util.Set)1 Function (java.util.function.Function)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 Collectors (java.util.stream.Collectors)1 Provider (javax.inject.Provider)1 OptimisticLockException (javax.persistence.OptimisticLockException)1 CdrVersionContext (org.pmiops.workbench.cdr.CdrVersionContext)1 CohortMaterializationService (org.pmiops.workbench.cohorts.CohortMaterializationService)1 CdrVersionDao (org.pmiops.workbench.db.dao.CdrVersionDao)1 CohortDao (org.pmiops.workbench.db.dao.CohortDao)1 CohortReviewDao (org.pmiops.workbench.db.dao.CohortReviewDao)1