use of uk.ac.ebi.spot.goci.curation.dto.StudyPatchRequest in project goci by EBISPOT.
the class FileHandler method getStudyPatchRequests.
public static List<StudyPatchRequest> getStudyPatchRequests(FileUploadRequest fileUploadRequest) {
CsvMapper mapper = new CsvMapper();
CsvSchema schema = getSchemaFromMultiPartFile(fileUploadRequest.getMultipartFile());
List<StudyPatchRequest> studyPatchRequests;
try {
InputStream inputStream = fileUploadRequest.getMultipartFile().getInputStream();
MappingIterator<StudyPatchRequest> iterator = mapper.readerFor(StudyPatchRequest.class).with(schema).readValues(inputStream);
studyPatchRequests = iterator.readAll();
} catch (IOException e) {
throw new FileUploadException("Could not read the file");
}
return studyPatchRequests;
}
use of uk.ac.ebi.spot.goci.curation.dto.StudyPatchRequest 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);
}
Aggregations