Search in sources :

Example 6 with StudyNote

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

the class StudyNoteOperationsService method convertToStudyNote.

public StudyNote convertToStudyNote(StudyNoteForm studyNoteForm, Study study) {
    StudyNote studyNote = new StudyNote(study);
    studyNote.setId(studyNoteForm.getId());
    studyNote.setNoteSubject(studyNoteForm.getNoteSubject());
    studyNote.setCurator(studyNoteForm.getCurator());
    studyNote.setStatus(studyNoteForm.getStatus());
    studyNote.setTextNote(studyNoteForm.getTextNote());
    return studyNote;
}
Also used : StudyNote(uk.ac.ebi.spot.goci.model.StudyNote)

Example 7 with StudyNote

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

the class StudyNoteOperationsService method createTagDuplicateNote.

public StudyNote createTagDuplicateNote(String textNote, Study study, SecureUser user) {
    StudyNote note = createEmptyStudyNote(study, user);
    note.setTextNote(textNote);
    NoteSubject subject = noteSubjectService.findTagDuplicateNote();
    note.setNoteSubject(subject);
    return note;
}
Also used : NoteSubject(uk.ac.ebi.spot.goci.model.NoteSubject) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote)

Example 8 with StudyNote

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

the class PrintController method getStudyInfoToPrint.

protected ArrayList<Object> getStudyInfoToPrint(Study studyToPrint) {
    // Get relevant study details
    Long studyId = studyToPrint.getId();
    // Get association information
    Collection<SnpAssociationTableView> snpAssociationTableViews = studyPrintService.generatePrintView(studyId);
    // Get housekeeping and ancestry information
    Housekeeping housekeeping = studyToPrint.getHousekeeping();
    Collection<StudyNote> studyNotes = studyToPrint.getNotes();
    String initialSampleDescription = studyToPrint.getInitialSampleSize();
    String replicateSampleDescription = studyToPrint.getReplicateSampleSize();
    // Creating a Hashtable
    ArrayList<Object> infoToPrint = new ArrayList<Object>();
    infoToPrint.add(studyToPrint);
    infoToPrint.add(housekeeping);
    infoToPrint.add(initialSampleDescription);
    infoToPrint.add(replicateSampleDescription);
    infoToPrint.add(ancestryRepository.findByStudyIdAndType(studyId, "initial"));
    infoToPrint.add(ancestryRepository.findByStudyIdAndType(studyId, "replication"));
    infoToPrint.add(snpAssociationTableViews);
    infoToPrint.add(studyNotes);
    return infoToPrint;
}
Also used : Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) ArrayList(java.util.ArrayList) SnpAssociationTableView(uk.ac.ebi.spot.goci.curation.model.SnpAssociationTableView) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote)

Example 9 with StudyNote

use of uk.ac.ebi.spot.goci.model.StudyNote 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)

Example 10 with StudyNote

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

the class StudyNoteController method addNoteToTable.

@RequestMapping(value = "/studies/{studyId}/notes", method = RequestMethod.POST, params = { "addNote" })
public String addNoteToTable(Model model, @PathVariable Long studyId, HttpServletRequest request) {
    // get the study
    Study study = studyRepository.findOne(studyId);
    model.addAttribute("study", study);
    // disabled the check because we want to add note to the table
    // if(study.getHousekeeping().getIsPublished()){
    // return "redirect:/studies/" + studyId + "/notes";
    // }
    // 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);
    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);
    // create a default study note with default setting
    StudyNote emptyNote = studyNoteOperationsService.createEmptyStudyNote(study, user);
    StudyNoteForm emptyNoteForm = studyNoteOperationsService.convertToStudyNoteForm(emptyNote);
    // attach the empty form
    msnf.getNomalNoteForms().add(0, emptyNoteForm);
    // Index of value to add
    // final Integer rowId = msnf.getNomalNoteForms().size()-1;
    // enable the edit for the new note and disable all edit for other notes
    msnf.startEdit(0);
    // reload system notes because they are not part of the input
    msnf.setSystemNoteForms(studyNoteOperationsService.generateSystemNoteForms(study.getNotes()));
    model.addAttribute("multiStudyNoteForm", msnf);
    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) MultiStudyNoteForm(uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm) SecureUser(uk.ac.ebi.spot.goci.model.SecureUser) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote) 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