Search in sources :

Example 31 with NotFoundException

use of org.pmiops.workbench.exceptions.NotFoundException in project workbench by all-of-us.

the class CohortReviewServiceImpl method updateParticipantCohortAnnotation.

@Override
public ParticipantCohortAnnotation updateParticipantCohortAnnotation(Long annotationId, Long cohortReviewId, Long participantId, ModifyParticipantCohortAnnotationRequest modifyRequest) {
    ParticipantCohortAnnotation participantCohortAnnotation = participantCohortAnnotationDao.findByAnnotationIdAndCohortReviewIdAndParticipantId(annotationId, cohortReviewId, participantId);
    if (participantCohortAnnotation == null) {
        throw new NotFoundException(String.format("Not Found: Participant Cohort Annotation does not exist for annotationId: %s, cohortReviewId: %s, participantId: %s", annotationId, cohortReviewId, participantId));
    }
    participantCohortAnnotation.annotationValueString(modifyRequest.getAnnotationValueString()).annotationValueEnum(modifyRequest.getAnnotationValueEnum()).annotationValueDateString(modifyRequest.getAnnotationValueDate()).annotationValueBoolean(modifyRequest.getAnnotationValueBoolean()).annotationValueInteger(modifyRequest.getAnnotationValueInteger());
    CohortAnnotationDefinition cohortAnnotationDefinition = findCohortAnnotationDefinition(participantCohortAnnotation.getCohortAnnotationDefinitionId());
    validateParticipantCohortAnnotation(participantCohortAnnotation, cohortAnnotationDefinition);
    return participantCohortAnnotationDao.save(participantCohortAnnotation);
}
Also used : CohortAnnotationDefinition(org.pmiops.workbench.db.model.CohortAnnotationDefinition) NotFoundException(org.pmiops.workbench.exceptions.NotFoundException) ParticipantCohortAnnotation(org.pmiops.workbench.db.model.ParticipantCohortAnnotation)

Example 32 with NotFoundException

use of org.pmiops.workbench.exceptions.NotFoundException in project workbench by all-of-us.

the class CohortReviewServiceImpl method deleteParticipantCohortAnnotation.

@Override
public void deleteParticipantCohortAnnotation(Long annotationId, Long cohortReviewId, Long participantId) {
    ParticipantCohortAnnotation participantCohortAnnotation = participantCohortAnnotationDao.findByAnnotationIdAndCohortReviewIdAndParticipantId(annotationId, cohortReviewId, participantId);
    if (participantCohortAnnotation == null) {
        throw new NotFoundException(String.format("Not Found: No participant cohort annotation found for annotationId: %s," + " cohortReviewId: %s, participantId: %s", annotationId, cohortReviewId, participantId));
    }
    participantCohortAnnotationDao.delete(participantCohortAnnotation);
}
Also used : NotFoundException(org.pmiops.workbench.exceptions.NotFoundException) ParticipantCohortAnnotation(org.pmiops.workbench.db.model.ParticipantCohortAnnotation)

Aggregations

NotFoundException (org.pmiops.workbench.exceptions.NotFoundException)32 Test (org.junit.Test)18 WorkspaceAccessLevel (org.pmiops.workbench.model.WorkspaceAccessLevel)16 Workspace (org.pmiops.workbench.db.model.Workspace)14 Cohort (org.pmiops.workbench.db.model.Cohort)10 ApiException (org.pmiops.workbench.firecloud.ApiException)5 ParticipantCohortAnnotation (org.pmiops.workbench.db.model.ParticipantCohortAnnotation)4 BadRequestException (org.pmiops.workbench.exceptions.BadRequestException)4 ServerErrorException (org.pmiops.workbench.exceptions.ServerErrorException)4 CohortReview (org.pmiops.workbench.db.model.CohortReview)3 Blob (com.google.cloud.storage.Blob)2 Gson (com.google.gson.Gson)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ParticipantCohortStatus (org.pmiops.workbench.db.model.ParticipantCohortStatus)2 User (org.pmiops.workbench.db.model.User)2 WorkspaceUserRole (org.pmiops.workbench.db.model.WorkspaceUserRole)2 org.pmiops.workbench.model (org.pmiops.workbench.model)2 ClusterListResponse (org.pmiops.workbench.model.ClusterListResponse)2 ModifyCohortAnnotationDefinitionRequest (org.pmiops.workbench.model.ModifyCohortAnnotationDefinitionRequest)2