Search in sources :

Example 36 with Study

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

the class StudyController method updateStudyHousekeeping.

// Update page with housekeeping/curator information linked to a study
@RequestMapping(value = "/{studyId}/housekeeping", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST)
public String updateStudyHousekeeping(@ModelAttribute Housekeeping housekeeping, @PathVariable Long studyId, RedirectAttributes redirectAttributes, HttpServletRequest request) {
    // Establish linked study
    Study study = studyRepository.findOne(studyId);
    // Update housekeeping
    String message = studyOperationsService.updateHousekeeping(housekeeping, study, currentUserDetailsService.getUserFromRequest(request));
    // Add save message
    if (message == null) {
        message = "Changes saved successfully";
        redirectAttributes.addFlashAttribute("changesSaved", message);
    } else {
        redirectAttributes.addFlashAttribute("publishError", message);
    }
    //        redirectAttributes.addFlashAttribute("changesSaved", message);
    return "redirect:/studies/" + study.getId() + "/housekeeping";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 37 with Study

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

the class StudyController method deleteStudy.

@RequestMapping(value = "/{studyId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST)
public String deleteStudy(@PathVariable Long studyId, HttpServletRequest request) {
    // Find our study based on the ID
    Study studyToDelete = studyRepository.findOne(studyId);
    studyDeletionService.deleteStudy(studyToDelete, currentUserDetailsService.getUserFromRequest(request));
    return "redirect:/studies";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 38 with Study

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

the class StudyController method viewStudy.

/* Existing study*/
// View a study
@RequestMapping(value = "/{studyId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewStudy(Model model, @PathVariable Long studyId) {
    Study studyToView = studyRepository.findOne(studyId);
    model.addAttribute("study", studyToView);
    return "study";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 39 with Study

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

the class StudyController method importStudy.

// Save study found by Pubmed Id
// @ModelAttribute is a reference to the object holding the data entered in the form
@RequestMapping(value = "/new/import", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST)
public synchronized String importStudy(@ModelAttribute PubmedIdForImport pubmedIdForImport, HttpServletRequest request, Model model) throws PubmedImportException, NoStudyDirectoryException {
    // Remove whitespace
    String pubmedId = pubmedIdForImport.getPubmedId().trim();
    // Check if there is an existing study with the same pubmed id
    Collection<Study> existingStudies = studyRepository.findByPubmedId(pubmedId);
    if (existingStudies.size() > 0) {
        throw new PubmedImportException();
    } else {
        // Pass to importer
        Study importedStudy = defaultPubMedSearchService.findPublicationSummary(pubmedId);
        Study savedStudy = studyOperationsService.createStudy(importedStudy, currentUserDetailsService.getUserFromRequest(request));
        // Create directory to store associated files
        try {
            studyFileService.createStudyDir(savedStudy.getId());
        } catch (NoStudyDirectoryException e) {
            getLog().error("No study directory exception");
            model.addAttribute("study", savedStudy);
            return "error_pages/study_dir_failure";
        }
        return "redirect:/studies/" + savedStudy.getId();
    }
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) NoStudyDirectoryException(uk.ac.ebi.spot.goci.curation.exception.NoStudyDirectoryException) PubmedImportException(uk.ac.ebi.spot.goci.curation.exception.PubmedImportException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 40 with Study

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

the class StudyController method allStudiesPage.

/* All studies and various filtered lists */
@RequestMapping(produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String allStudiesPage(Model model, @RequestParam(required = false) Integer page, @RequestParam(required = false) String pubmed, @RequestParam(required = false) String author, @RequestParam(value = "studytype", required = false) String studyType, @RequestParam(value = "efotraitid", required = false) Long efoTraitId, @RequestParam(value = "notesquery", required = false) String notesQuery, @RequestParam(required = false) Long status, @RequestParam(required = false) Long curator, @RequestParam(value = "sorttype", required = false) String sortType, @RequestParam(value = "diseasetraitid", required = false) Long diseaseTraitId, @RequestParam(required = false) Integer year, @RequestParam(required = false) Integer month) {
    // This is passed back to model and determines if pagination is applied
    Boolean pagination = true;
    // Return all studies ordered by date if no page number given
    if (page == null) {
        // Find all studies ordered by study date and only display first page
        return "redirect:/studies?page=1";
    }
    // This will be returned to view and store what curator has searched for
    StudySearchFilter studySearchFilter = new StudySearchFilter();
    // Store filters which will be need for pagination bar and to build URI passed back to view
    String filters = "";
    // Set sort object and sort string for URI
    Sort sort = findSort(sortType);
    String sortString = "";
    if (sortType != null && !sortType.isEmpty()) {
        sortString = "&sorttype=" + sortType;
    }
    // This is the default study page will all studies
    Page<Study> studyPage = studyRepository.findAll(constructPageSpecification(page - 1, sort));
    // For multi-snp and snp interaction studies pagination is not applied as the query leads to duplicates
    List<Study> studies = null;
    // Search by pubmed ID option available from landing page
    if (pubmed != null && !pubmed.isEmpty()) {
        studyPage = studyRepository.findByPubmedId(pubmed, constructPageSpecification(page - 1, sort));
        filters = filters + "&pubmed=" + pubmed;
        studySearchFilter.setPubmedId(pubmed);
    }
    // Search by author option available from landing page
    if (author != null && !author.isEmpty()) {
        studyPage = studyRepository.findByAuthorContainingIgnoreCase(author, constructPageSpecification(page - 1, sort));
        filters = filters + "&author=" + author;
        studySearchFilter.setAuthor(author);
    }
    // Search by study type
    if (studyType != null && !studyType.isEmpty()) {
        if (studyType.equals("GXE")) {
            studyPage = studyRepository.findByGxe(true, constructPageSpecification(page - 1, sort));
        }
        if (studyType.equals("GXG")) {
            studyPage = studyRepository.findByGxg(true, constructPageSpecification(page - 1, sort));
        }
        if (studyType.equals("CNV")) {
            studyPage = studyRepository.findByCnv(true, constructPageSpecification(page - 1, sort));
        }
        if (studyType.equals("Genomewide array studies")) {
            studyPage = studyRepository.findByGenomewideArray(true, constructPageSpecification(page - 1, sort));
        }
        if (studyType.equals("Targeted array studies")) {
            studyPage = studyRepository.findByTargetedArray(true, constructPageSpecification(page - 1, sort));
        }
        if (studyType.equals("Studies in curation queue")) {
            CurationStatus errorStatus = curationStatusRepository.findByStatus("Publish study");
            Long errorStatusId = errorStatus.getId();
            studyPage = studyRepository.findByHousekeepingCurationStatusIdNot(errorStatusId, constructPageSpecification(page - 1, sort));
        }
        if (studyType.equals("p-Value Set")) {
            studyPage = studyRepository.findByFullPvalueSet(true, constructPageSpecification(page - 1, sort));
        }
        if (studyType.equals("Multi-SNP haplotype studies")) {
            studies = studyRepository.findStudyDistinctByAssociationsMultiSnpHaplotypeTrue(sort);
            pagination = false;
        }
        if (studyType.equals("SNP Interaction studies")) {
            studies = studyRepository.findStudyDistinctByAssociationsSnpInteractionTrue(sort);
            pagination = false;
        }
        studySearchFilter.setStudyType(studyType);
        filters = filters + "&studytype=" + studyType;
    }
    // Search by efo trait id
    if (efoTraitId != null) {
        studyPage = studyRepository.findByEfoTraitsId(efoTraitId, constructPageSpecification(page - 1, sort));
        studySearchFilter.setEfoTraitSearchFilterId(efoTraitId);
        filters = filters + "&efotraitid=" + efoTraitId;
    }
    // Search by disease trait id
    if (diseaseTraitId != null) {
        studyPage = studyRepository.findByDiseaseTraitId(diseaseTraitId, constructPageSpecification(page - 1, sort));
        studySearchFilter.setDiseaseTraitSearchFilterId(diseaseTraitId);
        filters = filters + "&diseasetraitid=" + diseaseTraitId;
    }
    // Search by notes for entered string
    if (notesQuery != null && !notesQuery.isEmpty()) {
        studyPage = studyRepository.findDistinctByNotesTextNoteContainingIgnoreCase(notesQuery, constructPageSpecification(page - 1, sort));
        studySearchFilter.setNotesQuery(notesQuery);
        filters = filters + "&notesquery=" + notesQuery;
    }
    // If user entered a status
    if (status != null) {
        // If we have curator and status find by both
        if (curator != null) {
            // This is just used to link from reports tab
            if (year != null && month != null) {
                studyPage = studyRepository.findByPublicationDateAndCuratorAndStatus(curator, status, year, month, constructPageSpecification(page - 1, sort));
                studySearchFilter.setMonthFilter(month);
                studySearchFilter.setYearFilter(year);
                filters = filters + "&status=" + status + "&curator=" + curator + "&year=" + year + "&month=" + month;
            } else {
                studyPage = studyRepository.findByHousekeepingCurationStatusIdAndHousekeepingCuratorId(status, curator, constructPageSpecification(page - 1, sort));
                filters = filters + "&status=" + status + "&curator=" + curator;
            }
            // Return these values so they appear in filter results
            studySearchFilter.setCuratorSearchFilterId(curator);
            studySearchFilter.setStatusSearchFilterId(status);
        } else {
            studyPage = studyRepository.findByHousekeepingCurationStatusId(status, constructPageSpecification(page - 1, sort));
            filters = filters + "&status=" + status;
            // Return this value so it appears in filter result
            studySearchFilter.setStatusSearchFilterId(status);
        }
    } else // If user entered curator
    {
        if (curator != null) {
            studyPage = studyRepository.findByHousekeepingCuratorId(curator, constructPageSpecification(page - 1, sort));
            filters = filters + "&curator=" + curator;
            // Return this value so it appears in filter result
            studySearchFilter.setCuratorSearchFilterId(curator);
        }
    }
    // Return URI, this will build thymeleaf links using by sort buttons.
    // At present, do not add the current sort to the URI,
    // just maintain any filter values (pubmed id, author etc) used by curator
    String uri = "/studies?page=1";
    if (!filters.isEmpty()) {
        uri = uri + filters;
    }
    model.addAttribute("uri", uri);
    // filters will be used by pagination bar
    if (!filters.isEmpty()) {
        if (!sortString.isEmpty()) {
            filters = filters + sortString;
        }
    } else // If user has just sorted without any filter we need
    // to pass this back to pagination bar
    {
        if (!sortString.isEmpty()) {
            filters = sortString;
        }
    }
    model.addAttribute("filters", filters);
    long totalStudies;
    int current = 1;
    // Construct table using pagination
    if (studies == null) {
        model.addAttribute("studies", studyPage);
        //Pagination variables
        totalStudies = studyPage.getTotalElements();
        current = studyPage.getNumber() + 1;
        // Returns the greater of two values
        int begin = Math.max(1, current - 5);
        int end = // how many pages to display in the pagination bar
        Math.min(begin + 10, studyPage.getTotalPages());
        model.addAttribute("beginIndex", begin);
        model.addAttribute("endIndex", end);
        model.addAttribute("currentIndex", current);
    } else {
        model.addAttribute("studies", studies);
        totalStudies = studies.size();
    }
    model.addAttribute("totalStudies", totalStudies);
    model.addAttribute("pagination", pagination);
    // Add studySearchFilter to model so user can filter table
    model.addAttribute("studySearchFilter", studySearchFilter);
    // Add assignee and status assignment so user can assign
    // study to curator or assign a status
    // Also set uri so we can redirect to page user was on
    Assignee assignee = new Assignee();
    StatusAssignment statusAssignment = new StatusAssignment();
    assignee.setUri("/studies?page=" + current + filters);
    statusAssignment.setUri("/studies?page=" + current + filters);
    model.addAttribute("assignee", assignee);
    model.addAttribute("statusAssignment", statusAssignment);
    return "studies";
}
Also used : Study(uk.ac.ebi.spot.goci.model.Study) Assignee(uk.ac.ebi.spot.goci.curation.model.Assignee) StudySearchFilter(uk.ac.ebi.spot.goci.curation.model.StudySearchFilter) CurationStatus(uk.ac.ebi.spot.goci.model.CurationStatus) StatusAssignment(uk.ac.ebi.spot.goci.curation.model.StatusAssignment) Sort(org.springframework.data.domain.Sort) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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