Search in sources :

Example 31 with Study

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

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

the class StudyAncestryService method addAncestry.

public void addAncestry(Long studyId, Ancestry ancestry, SecureUser user) {
    Study study = studyRepository.findOne(studyId);
    // Set the study for our ancestry and save
    ancestry.setStudy(study);
    trackingOperationService.create(ancestry, user);
    ancestryRepository.save(ancestry);
    getLog().info("Ancestry ".concat(ancestry.getId().toString()).concat(" created"));
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study)

Example 33 with Study

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

the class StudyAncestryService method deleteAll.

public void deleteAll(Long studyId, SecureUser user) {
    // Get all study ancestry's
    Study study = studyRepository.findOne(studyId);
    Collection<Ancestry> studyAncestry = ancestryRepository.findByStudyId(studyId);
    // Delete ancestry
    studyAncestry.forEach(ancestry -> deleteAncestry(ancestry, user));
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) DeletedAncestry(uk.ac.ebi.spot.goci.model.DeletedAncestry) Ancestry(uk.ac.ebi.spot.goci.model.Ancestry)

Example 34 with Study

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

the class StudySampleDescriptionsDownloadService method generateStudySampleDescriptions.

public Collection<StudySampleDescription> generateStudySampleDescriptions() {
    // Get all ancestries, this will also find all studies with ancestry information
    Collection<Ancestry> ancestries = ancestryRepository.findAll(sortByPublicationDateDesc());
    Collection<StudySampleDescription> studySampleDescriptions = new ArrayList<>();
    for (Ancestry ancestry : ancestries) {
        // Make sure ancestry has an attached study
        if (ancestry.getStudy() != null) {
            Study study = ancestry.getStudy();
            // Study attributes
            Long studyId = study.getId();
            String author = study.getAuthor();
            Date publicationDate = study.getPublicationDate();
            String pubmedId = study.getPubmedId();
            String initialSampleSize = study.getInitialSampleSize();
            String replicateSampleSize = study.getReplicateSampleSize();
            // Housekeeping attributes
            Boolean ancestryCheckedLevelOne = false;
            Boolean ancestryCheckedLevelTwo = false;
            if (study.getHousekeeping() != null) {
                ancestryCheckedLevelOne = study.getHousekeeping().getAncestryCheckedLevelOne();
                ancestryCheckedLevelTwo = study.getHousekeeping().getAncestryCheckedLevelTwo();
            }
            // Ancestry attributes
            String type = ancestry.getType();
            Integer numberOfIndividuals = ancestry.getNumberOfIndividuals();
            Collection<AncestralGroup> ancestralGroup = ancestry.getAncestralGroups();
            Collection<Country> countryOfOrigin = ancestry.getCountryOfOrigin();
            Collection<Country> countryOfRecruitment = ancestry.getCountryOfRecruitment();
            String sampleSizesMatch = ancestry.getSampleSizesMatch();
            String description = ancestry.getDescription();
            String notes = ancestry.getNotes();
            StudySampleDescription studySampleDescription = new StudySampleDescription(studyId, author, publicationDate, pubmedId, initialSampleSize, replicateSampleSize, ancestryCheckedLevelOne, ancestryCheckedLevelTwo, type, numberOfIndividuals, ancestralGroup, countryOfOrigin, countryOfRecruitment, description, sampleSizesMatch, notes);
            studySampleDescriptions.add(studySampleDescription);
        }
    }
    return studySampleDescriptions;
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) AncestralGroup(uk.ac.ebi.spot.goci.model.AncestralGroup) StudySampleDescription(uk.ac.ebi.spot.goci.curation.model.StudySampleDescription) ArrayList(java.util.ArrayList) Date(java.util.Date) Ancestry(uk.ac.ebi.spot.goci.model.Ancestry) Country(uk.ac.ebi.spot.goci.model.Country)

Example 35 with Study

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

the class StudyUpdateService method updateStudy.

/**
     * Update a study entry in the database
     *
     * @param existingStudyId ID of study being edited
     * @param study           Study to update
     * @param user            User performing request
     */
public void updateStudy(Long existingStudyId, Study study, SecureUser user) {
    // Use id in URL to get study and then its associated housekeeping
    Study existingStudy = studyRepository.findOne(existingStudyId);
    Housekeeping existingHousekeeping = existingStudy.getHousekeeping();
    // Check changes and record update details
    String updateDescription = generateUpdateDescription(existingStudy, study);
    // Set the housekeeping of the study returned to one already linked to it in database
    // Need to do this as we don't return housekeeping in form
    study.setHousekeeping(existingHousekeeping);
    trackingOperationService.update(study, user, "STUDY_UPDATE", updateDescription);
    studyRepository.save(study);
    getLog().info("Study ".concat(String.valueOf(study.getId())).concat(" updated"));
}
Also used : Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) Study(uk.ac.ebi.spot.goci.model.Study)

Aggregations

Study (uk.ac.ebi.spot.goci.model.Study)44 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)20 ArrayList (java.util.ArrayList)7 Association (uk.ac.ebi.spot.goci.model.Association)7 Housekeeping (uk.ac.ebi.spot.goci.model.Housekeeping)6 MultiStudyNoteForm (uk.ac.ebi.spot.goci.curation.model.MultiStudyNoteForm)5 Date (java.util.Date)4 Test (org.junit.Test)4 Ancestry (uk.ac.ebi.spot.goci.model.Ancestry)4 NoteSubject (uk.ac.ebi.spot.goci.model.NoteSubject)4 SecureUser (uk.ac.ebi.spot.goci.model.SecureUser)4 SingleNucleotidePolymorphism (uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism)4 ParseException (java.text.ParseException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Service (org.springframework.stereotype.Service)3 StudyNoteForm (uk.ac.ebi.spot.goci.curation.model.StudyNoteForm)3 RiskAllele (uk.ac.ebi.spot.goci.model.RiskAllele)3 StudyNote (uk.ac.ebi.spot.goci.model.StudyNote)3 IOException (java.io.IOException)2