Search in sources :

Example 1 with FileValidationException

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

the class DiseaseTraitUploadController method updloadDiseaseTraits.

@PostMapping("/uploads")
public Object updloadDiseaseTraits(@Valid FileUploadRequest fileUploadRequest, BindingResult result) {
    if (result.hasErrors()) {
        throw new FileValidationException(result);
    }
    MultipartFile multipartFile = fileUploadRequest.getMultipartFile();
    List<DiseaseTrait> diseaseTraits = DiseaseTraitDtoAssembler.disassemble(multipartFile);
    diseaseTraits = diseaseTraitService.createDiseaseTraits(diseaseTraits);
    log.info("{} {} were created", diseaseTraits.size(), EntityType.DISEASE_TRAIT);
    return new ResponseEntity<>(DiseaseTraitDtoAssembler.assemble(diseaseTraits), HttpStatus.CREATED);
}
Also used : MultipartFile(org.springframework.web.multipart.MultipartFile) ResponseEntity(org.springframework.http.ResponseEntity) DiseaseTrait(uk.ac.ebi.spot.goci.model.DiseaseTrait) FileValidationException(uk.ac.ebi.spot.goci.curation.exception.FileValidationException)

Example 2 with FileValidationException

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

the class StudyRestController method multiUploadFileModel.

@PostMapping(Endpoint.STUDIES)
public Object multiUploadFileModel(@Valid FileUploadRequest fileUploadRequest, BindingResult result) {
    if (result.hasErrors()) {
        throw new FileValidationException(result);
    }
    List<StudyPatchRequest> studyPatchRequests = FileHandler.getStudyPatchRequests(fileUploadRequest);
    List<Study> updatedStudies = new ArrayList<>();
    for (StudyPatchRequest request : studyPatchRequests) {
        log.info("Dataset with GCST {} and Curated Trait {} was loaded from file", request.getGcst(), request.getCuratedReportedTrait());
        String gcst = request.getGcst().trim();
        String curatedReportedTrait = request.getCuratedReportedTrait().trim();
        updatedStudies.add(studyDataService.updateStudyDiseaseTraitByAccessionId(curatedReportedTrait, gcst));
    }
    return new ResponseEntity<>(updatedStudies, HttpStatus.OK);
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) ResponseEntity(org.springframework.http.ResponseEntity) ArrayList(java.util.ArrayList) FileValidationException(uk.ac.ebi.spot.goci.curation.exception.FileValidationException) StudyPatchRequest(uk.ac.ebi.spot.goci.curation.dto.StudyPatchRequest)

Example 3 with FileValidationException

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

the class DiseaseTraitUploadController method similaritySearchAnalysis.

@PostMapping("/analysis")
public AnalysisCacheDto similaritySearchAnalysis(@Valid FileUploadRequest fileUploadRequest, BindingResult result) {
    if (result.hasErrors()) {
        throw new FileValidationException(result);
    }
    List<AnalysisDTO> analysisDTO = FileHandler.serializeDiseaseTraitAnalysisFile(fileUploadRequest);
    log.info("{} disease traits were ingested for analysis", analysisDTO.size());
    String analysisId = UUID.randomUUID().toString();
    AnalysisCacheDto analysisCacheDto = diseaseTraitService.similaritySearch(analysisDTO, analysisId, 50.0);
    log.info("Analysis done, retrievable in future with id {}", analysisId);
    return analysisCacheDto;
}
Also used : FileValidationException(uk.ac.ebi.spot.goci.curation.exception.FileValidationException) AnalysisDTO(uk.ac.ebi.spot.goci.curation.dto.AnalysisDTO) AnalysisCacheDto(uk.ac.ebi.spot.goci.curation.dto.AnalysisCacheDto)

Aggregations

FileValidationException (uk.ac.ebi.spot.goci.curation.exception.FileValidationException)3 ResponseEntity (org.springframework.http.ResponseEntity)2 ArrayList (java.util.ArrayList)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1 AnalysisCacheDto (uk.ac.ebi.spot.goci.curation.dto.AnalysisCacheDto)1 AnalysisDTO (uk.ac.ebi.spot.goci.curation.dto.AnalysisDTO)1 StudyPatchRequest (uk.ac.ebi.spot.goci.curation.dto.StudyPatchRequest)1 DiseaseTrait (uk.ac.ebi.spot.goci.model.DiseaseTrait)1 Study (uk.ac.ebi.spot.goci.model.Study)1