Search in sources :

Example 11 with StudyNote

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

the class StudyNoteController method removeNote.

@RequestMapping(value = "/studies/{studyId}/notes", method = RequestMethod.POST, params = { "removeNote" })
public String removeNote(@ModelAttribute("multiStudyNoteForm") MultiStudyNoteForm multiStudyNoteForm, BindingResult bindingResult, Model model, @PathVariable Long studyId, HttpServletRequest req) {
    // Index of value to remove
    final Integer rowId = Integer.valueOf(req.getParameter("removeNote"));
    // get the study
    Study study = studyRepository.findOne(studyId);
    model.addAttribute("study", study);
    StudyNoteForm snf = multiStudyNoteForm.getNomalNoteForms().get(rowId.intValue());
    StudyNote noteToRemove = studyNoteOperationsService.convertToStudyNote(snf, study);
    // if not removing empty row
    if (noteToRemove.getId() != null) {
        ErrorNotification notification = studyOperationsService.deleteStudyNote(study, noteToRemove);
        if (notification.hasErrors()) {
            // we want to display the error to the user simply on top of the form
            getLog().warn("Request: " + req.getRequestURL() + " raised an error." + notification.errorMessage());
            model.addAttribute("errors", "Delete FAIL! " + notification.errorMessage());
            Collection<NoteSubject> noteSubjects = noteSubjectService.findAvailableNoteSubjectForStudy(study);
            model.addAttribute("availableNoteSubject", noteSubjects);
            model.addAttribute("multiStudyNoteForm", multiStudyNoteForm);
            return "study_notes";
        } else {
            return "redirect:/studies/" + studyId + "/notes";
        }
    }
    return "redirect:/studies/" + studyId + "/notes";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) StudyNoteForm(uk.ac.ebi.spot.goci.curation.model.StudyNoteForm) MultiStudyNoteForm(uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm) NoteSubject(uk.ac.ebi.spot.goci.model.NoteSubject) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote) ErrorNotification(uk.ac.ebi.spot.goci.curation.model.errors.ErrorNotification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

StudyNote (uk.ac.ebi.spot.goci.model.StudyNote)11 NoteSubject (uk.ac.ebi.spot.goci.model.NoteSubject)6 Study (uk.ac.ebi.spot.goci.model.Study)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 MultiStudyNoteForm (uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm)3 StudyNoteForm (uk.ac.ebi.spot.goci.curation.model.StudyNoteForm)3 ErrorNotification (uk.ac.ebi.spot.goci.curation.model.errors.ErrorNotification)2 Curator (uk.ac.ebi.spot.goci.model.Curator)2 SecureUser (uk.ac.ebi.spot.goci.model.SecureUser)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 SnpAssociationTableView (uk.ac.ebi.spot.goci.curation.model.SnpAssociationTableView)1 Housekeeping (uk.ac.ebi.spot.goci.model.Housekeeping)1 Publication (uk.ac.ebi.spot.goci.model.Publication)1