Search in sources :

Example 1 with PubmedIdForImport

use of uk.ac.ebi.spot.goci.curation.model.PubmedIdForImport 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();
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) PubmedIdForImport(uk.ac.ebi.spot.goci.curation.model.PubmedIdForImport) NoStudyDirectoryException(uk.ac.ebi.spot.goci.curation.exception.NoStudyDirectoryException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with PubmedIdForImport

use of uk.ac.ebi.spot.goci.curation.model.PubmedIdForImport in project goci by EBISPOT.

the class StudyController method newStudyForm.

/* New Study:
   *
   * Adding a study is synchronised to ensure the method can only be accessed once.
   *
   * */
// Add a new study
// Directs user to an empty form to which they can create a new study
@RequestMapping(value = "/new", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String newStudyForm(Model model) {
    model.addAttribute("study", new Study());
    // Return an empty pubmedIdForImport object to store user entered pubmed id
    model.addAttribute("pubmedIdForImport", new PubmedIdForImport());
    return "add_study";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) PubmedIdForImport(uk.ac.ebi.spot.goci.curation.model.PubmedIdForImport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 PubmedIdForImport (uk.ac.ebi.spot.goci.curation.model.PubmedIdForImport)2 Study (uk.ac.ebi.spot.goci.model.Study)2 NoStudyDirectoryException (uk.ac.ebi.spot.goci.curation.exception.NoStudyDirectoryException)1