Search in sources :

Example 1 with ReplicationSampleDescription

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

the class AncestryController method viewStudySampleDescription.

/* Ancestry/Sample information associated with a study */
// Generate view of ancestry/sample information linked to a study
@RequestMapping(value = "/studies/{studyId}/sampledescription", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewStudySampleDescription(Model model, @PathVariable Long studyId) {
    // Two types of ancestry information which the view needs to form two different tables
    Collection<Ancestry> initialStudyAncestryDescriptions = new ArrayList<>();
    Collection<Ancestry> replicationStudyAncestryDescriptions = new ArrayList<>();
    String initialType = "initial";
    String replicationType = "replication";
    initialStudyAncestryDescriptions.addAll(ancestryRepository.findByStudyIdAndType(studyId, initialType));
    replicationStudyAncestryDescriptions.addAll(ancestryRepository.findByStudyIdAndType(studyId, replicationType));
    Collection<Ancestry> allAncestry = new ArrayList<>();
    allAncestry.addAll(initialStudyAncestryDescriptions);
    allAncestry.addAll(replicationStudyAncestryDescriptions);
    for (Ancestry ancestry : allAncestry) {
        if (ancestry.getCountryOfRecruitment() == null || ancestry.getCountryOfRecruitment().isEmpty()) {
            String message = "No country of recruitment recorded for at least one ancestry entry!";
            model.addAttribute("noCountryRecruitment", message);
            break;
        }
    }
    // Add all ancestry/sample information for the study to our model
    model.addAttribute("initialStudyAncestryDescriptions", initialStudyAncestryDescriptions);
    model.addAttribute("replicationStudyAncestryDescriptions", replicationStudyAncestryDescriptions);
    // Return an empty ancestry object so curators can add new ancestry/sample information to study
    model.addAttribute("ancestry", new Ancestry());
    // Return an SampleDescription object for each type
    Study study = studyRepository.findOne(studyId);
    if (study.getInitialSampleSize() != null && !study.getInitialSampleSize().isEmpty()) {
        InitialSampleDescription initialSampleDescription = new InitialSampleDescription();
        initialSampleDescription.setInitialSampleDescription(study.getInitialSampleSize());
        model.addAttribute("initialSampleDescription", initialSampleDescription);
    } else {
        model.addAttribute("initialSampleDescription", new InitialSampleDescription());
    }
    if (study.getReplicateSampleSize() != null && !study.getReplicateSampleSize().isEmpty()) {
        ReplicationSampleDescription replicationSampleDescription = new ReplicationSampleDescription();
        replicationSampleDescription.setReplicationSampleDescription(study.getReplicateSampleSize());
        model.addAttribute("replicationSampleDescription", replicationSampleDescription);
    } else {
        model.addAttribute("replicationSampleDescription", new ReplicationSampleDescription());
    }
    // Also passes back study object to view so we can create links back to main study page
    model.addAttribute("study", study);
    return "study_sample_description";
}
Also used : InitialSampleDescription(uk.ac.ebi.spot.goci.curation.model.InitialSampleDescription) Study(uk.ac.ebi.spot.goci.model.Study) Ancestry(uk.ac.ebi.spot.goci.model.Ancestry) ReplicationSampleDescription(uk.ac.ebi.spot.goci.curation.model.ReplicationSampleDescription) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 InitialSampleDescription (uk.ac.ebi.spot.goci.curation.model.InitialSampleDescription)1 ReplicationSampleDescription (uk.ac.ebi.spot.goci.curation.model.ReplicationSampleDescription)1 Ancestry (uk.ac.ebi.spot.goci.model.Ancestry)1 Study (uk.ac.ebi.spot.goci.model.Study)1