use of uk.ac.ebi.spot.goci.model.NoteSubject in project goci by EBISPOT.
the class NoteSubjectService method findNonSystemNoteSubject.
public Collection<NoteSubject> findNonSystemNoteSubject() {
List<NoteSubject> allNoteSubject = noteSubjectRepository.findAll();
SYSTEM_NOTES.forEach(s -> {
NoteSubject noteSubject = noteSubjectRepository.findBySubjectIgnoreCase(s);
if (noteSubject != null) {
allNoteSubject.remove(noteSubject);
}
});
return allNoteSubject;
}
use of uk.ac.ebi.spot.goci.model.NoteSubject in project goci by EBISPOT.
the class StudyNoteOperationsService method createGeneralNote.
public StudyNote createGeneralNote(Study study, SecureUser user) {
StudyNote note = createEmptyStudyNote(study, user);
// general note subject
NoteSubject subject = noteSubjectService.findGeneralNote();
note.setNoteSubject(subject);
return note;
}
use of uk.ac.ebi.spot.goci.model.NoteSubject in project goci by EBISPOT.
the class StudyNoteOperationsService method createAutomaticNote.
public StudyNote createAutomaticNote(String textNote, Study study, SecureUser user) {
StudyNote note = createEmptyStudyNote(study, user);
// System note subject
note.setTextNote(textNote);
NoteSubject subject = noteSubjectService.findAutomaticNote();
note.setNoteSubject(subject);
return note;
}
use of uk.ac.ebi.spot.goci.model.NoteSubject 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.model.NoteSubject 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.findNonSystemNoteSubject();
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