use of uk.ac.ebi.spot.goci.curation.exception.FileUploadException in project goci by EBISPOT.
the class AssociationController method getValidationResult.
@RequestMapping(value = "/studies/{studyId}/associations/getValidationResults", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String getValidationResult(@PathVariable Long studyId, HttpSession session, Model model, RedirectAttributes redirectAttributes) throws ExecutionException, InterruptedException, SheetProcessingException, FileUploadException, IOException {
Study study = studyRepository.findOne(studyId);
model.addAttribute("study", study);
Future<Boolean> f = (Future<Boolean>) session.getAttribute("future");
f.get();
Exception exception = (Exception) session.getAttribute("exception");
if (exception == null) {
model.addAttribute("status", "OK");
} else {
model.addAttribute("status", exception.getMessage());
}
// if an association has critical errors, go straight to that association
if (session.getAttribute("criticalErrorsFound") != null) {
Association association = associationRepository.getOne((Long) session.getAttribute("associationId"));
model.addAttribute("study", study);
model.addAttribute("measurementType", session.getAttribute("measurementType"));
// Get mapping details
model.addAttribute("mappingDetails", associationOperationsService.createMappingDetails(association));
// Return any association errors
model.addAttribute("errors", session.getAttribute("errors"));
model.addAttribute("criticalErrorsFound", true);
if (association.getSnpInteraction()) {
model.addAttribute("form", associationOperationsService.generateForm(association));
return "redirect:/associations/" + association.getId();
} else {
model.addAttribute("form", associationOperationsService.generateForm(association));
// Determine view
if (association.getMultiSnpHaplotype()) {
return "redirect:/associations/" + association.getId();
} else {
return "redirect:/associations/" + association.getId();
}
}
} else {
String message = "Mapping complete, please check for any errors displayed in the 'Errors' column";
redirectAttributes.addFlashAttribute("mappingComplete", message);
return "redirect:/studies/" + studyId + "/associations";
}
}
use of uk.ac.ebi.spot.goci.curation.exception.FileUploadException in project goci by EBISPOT.
the class DiseaseTraitDtoAssembler method disassemble.
public static List<DiseaseTrait> disassemble(MultipartFile multipartFile) {
CsvMapper mapper = new CsvMapper();
CsvSchema schema = FileHandler.getSchemaFromMultiPartFile(multipartFile);
List<DiseaseTraitDto> diseaseTraitDtos;
try {
InputStream inputStream = multipartFile.getInputStream();
MappingIterator<DiseaseTraitDto> iterator = mapper.readerFor(DiseaseTraitDto.class).with(schema).readValues(inputStream);
diseaseTraitDtos = iterator.readAll();
} catch (IOException ex) {
throw new FileUploadException("Could not read the file");
}
List<DiseaseTrait> diseaseTraits = new ArrayList<>();
diseaseTraitDtos.forEach(diseaseTraitDTO -> {
DiseaseTrait diseaseTrait = new DiseaseTrait();
diseaseTrait.setTrait(diseaseTraitDTO.getTrait());
diseaseTraits.add(diseaseTrait);
});
return diseaseTraits;
}
use of uk.ac.ebi.spot.goci.curation.exception.FileUploadException in project goci by EBISPOT.
the class AssociationUploadServiceTest method uploadBlankFile.
@Test(expected = FileUploadException.class)
public void uploadBlankFile() throws Exception {
MockMultipartFile blankFile = new MockMultipartFile("data", "filename.txt", "text/plain", "".getBytes());
doThrow(new FileUploadException()).when(studyFileService).upload(blankFile, STUDY.getId());
associationUploadService.upload(blankFile, STUDY, SECURE_USER);
}
use of uk.ac.ebi.spot.goci.curation.exception.FileUploadException in project goci by EBISPOT.
the class AssociationController method getUploadResult.
@RequestMapping(value = "/studies/{studyId}/associations/getUploadResults", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String getUploadResult(@PathVariable Long studyId, HttpSession session, Model model) throws ExecutionException, InterruptedException, SheetProcessingException, FileUploadException, IOException {
Study study = studyRepository.findOne(studyId);
model.addAttribute("study", study);
Future<Boolean> f = (Future<Boolean>) session.getAttribute("future");
f.get();
Exception exception = (Exception) session.getAttribute("exception");
if (exception == null) {
model.addAttribute("status", "OK");
} else {
model.addAttribute("status", exception.getMessage());
}
if (session.getAttribute("ensemblMappingFailure") != null) {
return "ensembl_mapping_failure";
}
List<AssociationUploadErrorView> fileErrors = (List<AssociationUploadErrorView>) session.getAttribute("fileErrors");
List<AssociationUploadErrorView> xlsErrors = (List<AssociationUploadErrorView>) session.getAttribute("xlsErrors");
if ((session.getAttribute("fileErrors") != null && !fileErrors.isEmpty()) || ((session.getAttribute("xlsErrors") != null && !xlsErrors.isEmpty()))) {
getLog().debug("Shutting down executor service...");
model.addAttribute("fileName", session.getAttribute("fileName"));
model.addAttribute("fileErrors", fileErrors);
model.addAttribute("xlsErrors", xlsErrors);
return "error_pages/association_file_upload_error";
} else {
return "redirect:/studies/" + studyId + "/associations";
}
}
Aggregations