Search in sources :

Example 1 with EmptyResponse

use of org.pmiops.workbench.model.EmptyResponse in project workbench by all-of-us.

the class WorkspacesController method reviewWorkspace.

/**
 * Record approval or rejection of research purpose.
 */
@Override
@AuthorityRequired({ Authority.REVIEW_RESEARCH_PURPOSE })
public ResponseEntity<EmptyResponse> reviewWorkspace(String ns, String id, ResearchPurposeReviewRequest review) {
    org.pmiops.workbench.db.model.Workspace workspace = workspaceService.get(ns, id);
    userService.logAdminWorkspaceAction(workspace.getWorkspaceId(), "research purpose approval", workspace.getApproved(), review.getApproved());
    workspaceService.setResearchPurposeApproved(ns, id, review.getApproved());
    return ResponseEntity.ok(new EmptyResponse());
}
Also used : EmptyResponse(org.pmiops.workbench.model.EmptyResponse) AuthorityRequired(org.pmiops.workbench.annotations.AuthorityRequired)

Example 2 with EmptyResponse

use of org.pmiops.workbench.model.EmptyResponse in project workbench by all-of-us.

the class CohortAnnotationDefinitionControllerTest method deleteCohortAnnotationDefinition.

@Test
public void deleteCohortAnnotationDefinition() throws Exception {
    String namespace = "aou-test";
    String name = "test";
    long cohortId = 1;
    long workspaceId = 1;
    long annotationDefinitionId = 1;
    String columnName = "name";
    Cohort cohort = createCohort(workspaceId);
    Workspace workspace = createWorkspace(namespace, name, workspaceId);
    org.pmiops.workbench.db.model.CohortAnnotationDefinition cohortAnnotationDefinition = createDBCohortAnnotationDefinition(cohortId, annotationDefinitionId, AnnotationType.STRING, columnName);
    WorkspaceAccessLevel owner = WorkspaceAccessLevel.OWNER;
    when(workspaceService.enforceWorkspaceAccessLevel(namespace, name, WorkspaceAccessLevel.WRITER)).thenReturn(owner);
    when(cohortDao.findOne(cohortId)).thenReturn(cohort);
    when(workspaceService.getRequired(namespace, name)).thenReturn(workspace);
    when(cohortAnnotationDefinitionDao.findByCohortIdAndCohortAnnotationDefinitionId(cohortId, annotationDefinitionId)).thenReturn(cohortAnnotationDefinition);
    doNothing().when(cohortAnnotationDefinitionDao).delete(annotationDefinitionId);
    EmptyResponse response = cohortAnnotationDefinitionController.deleteCohortAnnotationDefinition(namespace, name, cohortId, annotationDefinitionId).getBody();
    assertEquals(new EmptyResponse(), response);
    verify(cohortDao, times(1)).findOne(cohortId);
    verify(workspaceService, times(1)).getRequired(namespace, name);
    verify(cohortAnnotationDefinitionDao, times(1)).findByCohortIdAndCohortAnnotationDefinitionId(cohortId, annotationDefinitionId);
    verify(cohortAnnotationDefinitionDao, times(1)).delete(annotationDefinitionId);
    verify(workspaceService).enforceWorkspaceAccessLevel(namespace, name, WorkspaceAccessLevel.WRITER);
    verifyNoMoreMockInteractions();
}
Also used : Cohort(org.pmiops.workbench.db.model.Cohort) EmptyResponse(org.pmiops.workbench.model.EmptyResponse) WorkspaceAccessLevel(org.pmiops.workbench.model.WorkspaceAccessLevel) Workspace(org.pmiops.workbench.db.model.Workspace) Test(org.junit.Test)

Example 3 with EmptyResponse

use of org.pmiops.workbench.model.EmptyResponse in project workbench by all-of-us.

the class CohortAnnotationDefinitionController method deleteCohortAnnotationDefinition.

@Override
public ResponseEntity<EmptyResponse> deleteCohortAnnotationDefinition(String workspaceNamespace, String workspaceId, Long cohortId, Long annotationDefinitionId) {
    // This also enforces registered auth domain.
    workspaceService.enforceWorkspaceAccessLevel(workspaceNamespace, workspaceId, WorkspaceAccessLevel.WRITER);
    Cohort cohort = findCohort(cohortId);
    // this validates that the user is in the proper workspace
    validateMatchingWorkspace(workspaceNamespace, workspaceId, cohort.getWorkspaceId());
    findCohortAnnotationDefinition(cohortId, annotationDefinitionId);
    cohortAnnotationDefinitionDao.delete(annotationDefinitionId);
    return ResponseEntity.ok(new EmptyResponse());
}
Also used : Cohort(org.pmiops.workbench.db.model.Cohort) EmptyResponse(org.pmiops.workbench.model.EmptyResponse)

Example 4 with EmptyResponse

use of org.pmiops.workbench.model.EmptyResponse in project workbench by all-of-us.

the class WorkspacesController method deleteWorkspace.

@Override
public ResponseEntity<EmptyResponse> deleteWorkspace(String workspaceNamespace, String workspaceId) {
    org.pmiops.workbench.db.model.Workspace dbWorkspace = workspaceService.getRequired(workspaceNamespace, workspaceId);
    try {
        // This automatically handles access control to the workspace.
        fireCloudService.deleteWorkspace(workspaceNamespace, workspaceId);
    } catch (org.pmiops.workbench.firecloud.ApiException e) {
        throw ExceptionUtils.convertFirecloudException(e);
    }
    workspaceService.getDao().delete(dbWorkspace);
    return ResponseEntity.ok(new EmptyResponse());
}
Also used : ApiException(org.pmiops.workbench.firecloud.ApiException) EmptyResponse(org.pmiops.workbench.model.EmptyResponse)

Aggregations

EmptyResponse (org.pmiops.workbench.model.EmptyResponse)4 Cohort (org.pmiops.workbench.db.model.Cohort)2 Test (org.junit.Test)1 AuthorityRequired (org.pmiops.workbench.annotations.AuthorityRequired)1 Workspace (org.pmiops.workbench.db.model.Workspace)1 ApiException (org.pmiops.workbench.firecloud.ApiException)1 WorkspaceAccessLevel (org.pmiops.workbench.model.WorkspaceAccessLevel)1