use of uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm in project goci by EBISPOT.
the class StudyNoteController method viewStudyNotes.
@RequestMapping(value = "/studies/{studyId}/notes", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewStudyNotes(Model model, @PathVariable Long studyId, HttpServletRequest request) {
// get the study
Study study = studyRepository.findOne(studyId);
model.addAttribute("study", study);
SecureUser user = currentUserDetailsService.getUserFromRequest(request);
// an form object mapped from the studyNote object, it contains a list of notes
MultiStudyNoteForm msnf = studyNoteOperationsService.generateMultiStudyNoteForm(study.getNotes(), study, user);
model.addAttribute("multiStudyNoteForm", msnf);
return "study_notes";
}
use of uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm in project goci by EBISPOT.
the class StudyNoteController method enableEditNote.
// This will enable save/remove button for a study note and disable all other action for other notes
@RequestMapping(value = "/studies/{studyId}/notes", method = RequestMethod.POST, params = { "editNote" })
public String enableEditNote(Model model, @PathVariable Long studyId, HttpServletRequest req) {
// Index of value to remove
final Integer rowId = Integer.valueOf(req.getParameter("editNote"));
// get the study
Study study = studyRepository.findOne(studyId);
model.addAttribute("study", study);
// get All note subjects for dropdown
// remove subjects including 'Imported from previous system' 'SystemNote'
Collection<NoteSubject> noteSubjects = noteSubjectService.findAvailableNoteSubjectForStudy(study);
model.addAttribute("availableNoteSubject", noteSubjects);
SecureUser user = currentUserDetailsService.getUserFromRequest(req);
// an form object mapped from the studyNote object, it contains a list of notes
MultiStudyNoteForm msnf = studyNoteOperationsService.generateMultiStudyNoteForm(study.getNotes(), study, user);
// enable the edit for the note and disable all edit for other notes
msnf.startEdit(rowId);
model.addAttribute("multiStudyNoteForm", msnf);
return "study_notes";
}
use of uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm in project goci by EBISPOT.
the class StudyNoteController method EnableEditNote.
//This will enable save/remove button for a study note and disable all other action for other notes
@RequestMapping(value = "/studies/{studyId}/notes", method = RequestMethod.POST, params = { "editNote" })
public String EnableEditNote(Model model, @PathVariable Long studyId, HttpServletRequest req) {
//Index of value to remove
final Integer rowId = Integer.valueOf(req.getParameter("editNote"));
//get the study
Study study = studyRepository.findOne(studyId);
model.addAttribute("study", study);
//get All note subjects for dropdown
//remove subjects including 'Imported from previous system' 'SystemNote'
Collection<NoteSubject> noteSubjects = noteSubjectService.findNonSystemNoteSubject();
model.addAttribute("availableNoteSubject", noteSubjects);
// an form object mapped from the studyNote object, it contains a list of notes
MultiStudyNoteForm msnf = studyNoteOperationsService.generateMultiStudyNoteForm(study.getNotes(), study);
//enable the edit for the note and disable all edit for other notes
msnf.startEdit(rowId);
model.addAttribute("multiStudyNoteForm", msnf);
return "study_notes";
}
use of uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm in project goci by EBISPOT.
the class StudyNoteController method viewStudyNotes.
@RequestMapping(value = "/studies/{studyId}/notes", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewStudyNotes(Model model, @PathVariable Long studyId) {
//get the study
Study study = studyRepository.findOne(studyId);
model.addAttribute("study", study);
// an form object mapped from the studyNote object, it contains a list of notes
MultiStudyNoteForm msnf = studyNoteOperationsService.generateMultiStudyNoteForm(study.getNotes(), study);
model.addAttribute("multiStudyNoteForm", msnf);
return "study_notes";
}
use of uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm in project goci by EBISPOT.
the class StudyNoteController method saveNote.
@RequestMapping(value = "/studies/{studyId}/notes", method = RequestMethod.POST, params = { "saveNote" })
public String saveNote(@ModelAttribute("multiStudyNoteForm") @Valid MultiStudyNoteForm multiStudyNoteForm, BindingResult bindingResult, Model model, @PathVariable Long studyId, HttpServletRequest req) {
// Index of value to save
final Integer rowId = Integer.valueOf(req.getParameter("saveNote"));
// get the study
Study study = studyRepository.findOne(studyId);
model.addAttribute("study", study);
// the newly added note can only be assigned one of the availlable subject, not including system note subjects.
Collection<NoteSubject> noteSubjects = noteSubjectService.findAvailableNoteSubjectForStudy(study);
model.addAttribute("availableNoteSubject", noteSubjects);
// form validation
if (bindingResult.hasErrors()) {
// reload system notes because they are not part of the input
multiStudyNoteForm.setSystemNoteForms(studyNoteOperationsService.generateSystemNoteForms(study.getNotes()));
model.addAttribute("availableNoteSubject", noteSubjects);
model.addAttribute("multiStudyNoteForm", multiStudyNoteForm);
return "study_notes";
}
// convert studynoteform to studynote domain object and save
StudyNoteForm snf = multiStudyNoteForm.getNomalNoteForms().get(rowId.intValue());
StudyNote noteToEdit = studyNoteOperationsService.convertToStudyNote(snf, study);
SecureUser user = currentUserDetailsService.getUserFromRequest(req);
ErrorNotification notification = studyOperationsService.addStudyNote(study, noteToEdit, user);
if (!notification.hasErrors()) {
return "redirect:/studies/" + studyId + "/notes";
} else {
// deal with error
// 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", "Update FAIL! " + notification.errorMessage());
multiStudyNoteForm.setSystemNoteForms(studyNoteOperationsService.generateSystemNoteForms(study.getNotes()));
model.addAttribute("availableNoteSubject", noteSubjects);
model.addAttribute("multiStudyNoteForm", multiStudyNoteForm);
}
return "study_notes";
}
Aggregations