Search in sources :

Example 1 with MultiStudyNoteForm

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";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) MultiStudyNoteForm(uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm) SecureUser(uk.ac.ebi.spot.goci.model.SecureUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with MultiStudyNoteForm

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";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) NoteSubject(uk.ac.ebi.spot.goci.model.NoteSubject) MultiStudyNoteForm(uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm) SecureUser(uk.ac.ebi.spot.goci.model.SecureUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with MultiStudyNoteForm

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";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) NoteSubject(uk.ac.ebi.spot.goci.model.NoteSubject) MultiStudyNoteForm(uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with MultiStudyNoteForm

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

Example 5 with MultiStudyNoteForm

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";
}
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) SecureUser(uk.ac.ebi.spot.goci.model.SecureUser) ErrorNotification(uk.ac.ebi.spot.goci.curation.model.errors.ErrorNotification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 MultiStudyNoteForm (uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm)7 Study (uk.ac.ebi.spot.goci.model.Study)7 NoteSubject (uk.ac.ebi.spot.goci.model.NoteSubject)5 SecureUser (uk.ac.ebi.spot.goci.model.SecureUser)4 StudyNoteForm (uk.ac.ebi.spot.goci.curation.model.StudyNoteForm)3 StudyNote (uk.ac.ebi.spot.goci.model.StudyNote)3 ErrorNotification (uk.ac.ebi.spot.goci.curation.model.errors.ErrorNotification)2