use of uk.ac.ebi.spot.goci.curation.exception.NoStudyDirectoryException in project goci by EBISPOT.
the class StudyController method addStudy.
// Save newly added study details
// @ModelAttribute is a reference to the object holding the data entered in the form
@RequestMapping(value = "/new", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST)
public synchronized String addStudy(@Valid @ModelAttribute Study study, BindingResult bindingResult, Model model, HttpServletRequest request) throws NoStudyDirectoryException {
// If we have errors in the fields entered, i.e they are blank, then return these to form so user can fix
if (bindingResult.hasErrors()) {
model.addAttribute("study", study);
// Return an empty pubmedIdForImport object to store user entered pubmed id
model.addAttribute("pubmedIdForImport", new PubmedIdForImport());
return "add_study";
}
Study savedStudy = studyOperationsService.createStudy(study, currentUserDetailsService.getUserFromRequest(request));
// Create directory to store associated files
try {
studyFileService.createStudyDir(savedStudy.getId());
} catch (NoStudyDirectoryException e) {
getLog().error("No study directory exception");
model.addAttribute("study", savedStudy);
return "error_pages/study_dir_failure";
}
return "redirect:/studies/" + savedStudy.getId();
}
use of uk.ac.ebi.spot.goci.curation.exception.NoStudyDirectoryException in project goci by EBISPOT.
the class StudyController method importStudy.
// Save study found by Pubmed Id
// @ModelAttribute is a reference to the object holding the data entered in the form
@RequestMapping(value = "/new/import", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST)
public synchronized String importStudy(@ModelAttribute PubmedIdForImport pubmedIdForImport, HttpServletRequest request, Model model) throws PubmedImportException, NoStudyDirectoryException {
// Remove whitespace
String pubmedId = pubmedIdForImport.getPubmedId().trim();
// Check if there is an existing study with the same pubmed id
Collection<Study> existingStudies = studyRepository.findByPubmedId(pubmedId);
if (existingStudies.size() > 0) {
throw new PubmedImportException();
} else {
// Pass to importer
Study importedStudy = defaultPubMedSearchService.findPublicationSummary(pubmedId);
Study savedStudy = studyOperationsService.createStudy(importedStudy, currentUserDetailsService.getUserFromRequest(request));
// Create directory to store associated files
try {
studyFileService.createStudyDir(savedStudy.getId());
} catch (NoStudyDirectoryException e) {
getLog().error("No study directory exception");
model.addAttribute("study", savedStudy);
return "error_pages/study_dir_failure";
}
return "redirect:/studies/" + savedStudy.getId();
}
}
Aggregations