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