use of org.pmiops.workbench.db.model.Workspace 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);
}
use of org.pmiops.workbench.db.model.Workspace in project workbench by all-of-us.
the class CohortMaterializationServiceTest method setUp.
@Before
public void setUp() {
cdrVersion = new CdrVersion();
cdrVersion.setBigqueryDataset(testWorkbenchConfig.bigquery.dataSetId);
cdrVersion.setBigqueryProject(testWorkbenchConfig.bigquery.projectId);
cdrVersionDao.save(cdrVersion);
CdrVersionContext.setCdrVersion(cdrVersion);
Criteria icd9CriteriaGroup = new Criteria().group(true).name("group").selectable(true).code(SearchRequests.ICD9_GROUP_CODE).type(SearchRequests.ICD9_TYPE).parentId(0);
criteriaDao.save(icd9CriteriaGroup);
Criteria icd9CriteriaChild = new Criteria().group(false).name("child").selectable(true).code(SearchRequests.ICD9_GROUP_CODE + ".1").type(SearchRequests.ICD9_TYPE).domainId("Condition").parentId(icd9CriteriaGroup.getId());
criteriaDao.save(icd9CriteriaChild);
Workspace workspace = new Workspace();
workspace.setCdrVersion(cdrVersion);
workspace.setName("name");
workspace.setDataAccessLevel(DataAccessLevel.PROTECTED);
workspaceDao.save(workspace);
Cohort cohort = new Cohort();
cohort.setWorkspaceId(workspace.getWorkspaceId());
cohort.setName("males");
cohort.setType("AOU");
Gson gson = new Gson();
cohort.setCriteria(gson.toJson(SearchRequests.males()));
cohortDao.save(cohort);
Cohort cohort2 = new Cohort();
cohort2.setWorkspaceId(workspace.getWorkspaceId());
cohort2.setName("all genders");
cohort2.setType("AOU");
cohort2.setCriteria(gson.toJson(SearchRequests.allGenders()));
cohortDao.save(cohort2);
cohortReview = new CohortReview();
cohortReview.setCdrVersionId(cdrVersion.getCdrVersionId());
cohortReview.setCohortId(cohort2.getCohortId());
cohortReview.setMatchedParticipantCount(3);
cohortReview.setReviewedCount(2);
cohortReview.setReviewSize(3);
cohortReviewDao.save(cohortReview);
participantCohortStatusDao.save(makeStatus(cohortReview.getCohortReviewId(), 1L, CohortStatus.INCLUDED));
participantCohortStatusDao.save(makeStatus(cohortReview.getCohortReviewId(), 2L, CohortStatus.EXCLUDED));
}
use of org.pmiops.workbench.db.model.Workspace in project workbench by all-of-us.
the class CohortReviewServiceImpl method validateMatchingWorkspace.
@Override
public Workspace validateMatchingWorkspace(String workspaceNamespace, String workspaceName, long workspaceId, WorkspaceAccessLevel accessRequired) {
// This also enforces registered auth domain.
workspaceService.enforceWorkspaceAccessLevel(workspaceNamespace, workspaceName, accessRequired);
Workspace workspace = workspaceService.getRequired(workspaceNamespace, workspaceName);
if (workspace.getWorkspaceId() != workspaceId) {
throw new NotFoundException(String.format("Not Found: No workspace matching workspaceNamespace: %s, workspaceId: %s", workspaceNamespace, workspaceName));
}
return workspace;
}
Aggregations