Search in sources :

Example 1 with NoteSubject

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;
}
Also used : NoteSubject(uk.ac.ebi.spot.goci.model.NoteSubject)

Example 2 with NoteSubject

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;
}
Also used : NoteSubject(uk.ac.ebi.spot.goci.model.NoteSubject) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote)

Example 3 with NoteSubject

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;
}
Also used : NoteSubject(uk.ac.ebi.spot.goci.model.NoteSubject) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote)

Example 4 with NoteSubject

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";
}
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 5 with NoteSubject

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";
}
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

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