Search in sources :

Example 1 with ResourceNotFoundException

use of uk.ac.ebi.spot.goci.curation.exception.ResourceNotFoundException in project goci by EBISPOT.

the class StudyDataService method updateStudyDiseaseTraitByAccessionId.

public Study updateStudyDiseaseTraitByAccessionId(String trait, String accessionId) {
    Study study = this.getStudyByAccessionId(accessionId).orElseThrow(() -> new ResourceNotFoundException("Study", accessionId));
    DiseaseTrait diseaseTrait = Optional.ofNullable(diseaseTraitRepository.findByTraitIgnoreCase(trait)).orElseThrow(() -> new ResourceNotFoundException("Disease Trait", trait));
    study.setDiseaseTrait(diseaseTrait);
    studyRepository.save(study);
    log.info("Study with accession Id: {} found and updated", accessionId);
    return study;
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) DiseaseTrait(uk.ac.ebi.spot.goci.model.DiseaseTrait) ResourceNotFoundException(uk.ac.ebi.spot.goci.curation.exception.ResourceNotFoundException)

Aggregations

ResourceNotFoundException (uk.ac.ebi.spot.goci.curation.exception.ResourceNotFoundException)1 DiseaseTrait (uk.ac.ebi.spot.goci.model.DiseaseTrait)1 Study (uk.ac.ebi.spot.goci.model.Study)1