Search in sources :

Example 1 with StudyNote

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

the class StudyNoteOperationsService method createEmptyStudyNote.

/**
 * Creat empty study note and set its subject base on the publish status of the study
 * @param study
 * @param user
 * @return
 */
public StudyNote createEmptyStudyNote(Study study, SecureUser user) {
    StudyNote note = new StudyNote();
    note.setStudy(study);
    // defult curator will be the one who is currently adding the note
    // #xintodo this needs to be change when a forgin key is added the curator table from the user table
    Curator curator = curatorService.getCuratorIdByEmail(user.getEmail());
    note.setCurator(curator);
    note.setStatus(false);
    note.setGenericId(study.getId());
    if (study.getHousekeeping().getIsPublished()) {
        // general note subject
        note.setNoteSubject(noteSubjectService.findBySubject("Post-publishing review"));
    } else {
        note.setNoteSubject(noteSubjectService.findGeneralNote());
    }
    return note;
}
Also used : Curator(uk.ac.ebi.spot.goci.model.Curator) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote)

Example 2 with StudyNote

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

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

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

the class StudyNoteOperationsService method duplicateNote.

public StudyNote duplicateNote(Study targetStudy, StudyNote noteToDuplicate, SecureUser user) {
    Study sourceStudy = noteToDuplicate.getStudy();
    StudyNote note = createEmptyStudyNote(targetStudy, user);
    note.setCurator(noteToDuplicate.getCurator());
    note.setNoteSubject(noteToDuplicate.getNoteSubject());
    Curator curator = curatorService.getCuratorIdByEmail(user.getEmail());
    note.setCurator(curator);
    // we added some text to indicate that this is a duplicated note.
    // This is just a hack to distinguish dulicated note since we have study-note one to many as out note model atm
    note.setTextNote("Duplicated from study: ".concat(sourceStudy.getId().toString()).concat(" by ").concat(curator.getLastName()).concat("\n").concat(noteToDuplicate.getTextNote()));
    note.setStatus(noteToDuplicate.getStatus());
    return note;
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) Curator(uk.ac.ebi.spot.goci.model.Curator) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote)

Example 5 with StudyNote

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

the class CurationSystemEmailToCurator method createBody.

public void createBody(Study study, String status) {
    // Set up some of the values used in mail body
    Publication publication = study.getPublicationId();
    String studyTitle = publication.getTitle();
    String pubmedLink = "http://europepmc.org/abstract/MED/" + publication.getPubmedId();
    String currentCurator = study.getHousekeeping().getCurator().getLastName();
    // These could be null so catch this case
    String studyTrait = null;
    if (study.getDiseaseTrait() != null && !study.getDiseaseTrait().getTrait().isEmpty()) {
        studyTrait = study.getDiseaseTrait().getTrait();
    }
    StringBuilder notes = new StringBuilder();
    Collection<StudyNote> studyNotes = study.getNotes();
    if (!studyNotes.isEmpty()) {
        studyNotes.forEach(studyNote -> {
            notes.append(studyNote.toStringForEamil()).append("\n");
            notes.append("-------------------------------------------------------------\n\n");
        });
    }
    // Format dates
    Date studyDate = publication.getPublicationDate();
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
    String bodyStudyDate = dateFormat.format(studyDate);
    Date publishDate = study.getHousekeeping().getCatalogPublishDate();
    String bodyPublishDate = null;
    if (publishDate != null) {
        bodyPublishDate = dateFormat.format(publishDate);
    }
    String editStudyLink = getLink() + "studies/" + study.getId();
    this.setSubject(publication.getFirstAuthor().getFullnameShort(50) + " - " + status);
    this.setBody("The GWAS paper by " + publication.getFirstAuthor().getFullname() + " with study date " + bodyStudyDate + " now has status " + status + "\n" + "Title: " + studyTitle + "\n" + "Trait: " + studyTrait + "\n" + "Pubmed link: " + pubmedLink + "\n" + "Edit link: " + editStudyLink + "\n" + "Current curator: " + currentCurator + "\n" + "Publish Date: " + bodyPublishDate + "\n" + "Notes: \n" + notes + "\n\n");
}
Also used : Publication(uk.ac.ebi.spot.goci.model.Publication) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) StudyNote(uk.ac.ebi.spot.goci.model.StudyNote)

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