Search in sources :

Example 1 with StudySearchFilter

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

the class MonthlyReportController method getOverview.

// Returns overview
@RequestMapping(produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String getOverview(Model model, @RequestParam(required = false) Long status, @RequestParam(required = false) Long curator, @RequestParam(required = false) Integer year, @RequestParam(required = false) Integer month) {
    List<MonthlyTotalsSummaryView> monthlyTotalsSummaryViews = new ArrayList<>();
    // This will be returned to view and store what curator has searched for
    StudySearchFilter studySearchFilter = new StudySearchFilter();
    // Need to convert status and curator to a string
    String curatorName = null;
    String statusName = null;
    if (curator != null) {
        curatorName = curatorRepository.findOne(curator).getLastName();
    }
    if (status != null) {
        statusName = curationStatusRepository.findOne(status).getStatus();
    }
    //Search database for various filter options
    if (status != null && curator != null && year != null && month != null) {
        // all filter options
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByCuratorAndCurationStatusAndYearAndMonthOrderByYearDesc(curatorName, statusName, year, month);
    } else if (status != null && curator != null && year != null) {
        // status, curator and year
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByCuratorAndCurationStatusAndYearOrderByYearDesc(curatorName, statusName, year);
    } else if (status != null && curator != null && month != null) {
        // status, curator and month
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByCuratorAndCurationStatusAndMonthOrderByYearDesc(curatorName, statusName, month);
    } else if (status != null && year != null && month != null) {
        // status, year, month
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByCurationStatusAndYearAndMonthOrderByYearDesc(statusName, year, month);
    } else if (status != null && curator != null) {
        // status and curator
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByCuratorAndCurationStatus(curatorName, statusName);
    } else if (status != null && year != null) {
        // status and year
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByCurationStatusAndYearOrderByYearDesc(statusName, year);
    } else if (status != null && month != null) {
        // status and year
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByCurationStatusAndMonthOrderByYearDesc(statusName, month);
    } else if (status != null) {
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByCurationStatus(statusName);
    } else if (curator != null && year != null && month != null) {
        // curator, year and month
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByCuratorAndYearAndMonthOrderByYearDesc(curatorName, year, month);
    } else if (curator != null && year != null) {
        // curator and year
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByCuratorAndYearOrderByYearDesc(curatorName, year);
    } else if (curator != null && month != null) {
        // curator and month
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByCuratorAndMonthOrderByYearDesc(curatorName, month);
    } else if (curator != null) {
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByCurator(curatorName);
    } else if (year != null && month != null) {
        // year and month
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByYearAndMonthOrderByYearDesc(year, month);
    } else if (year != null) {
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByYearOrderByYearDesc(year);
    } else if (month != null) {
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findByMonthOrderByYearDesc(month);
    } else {
        // no filters
        monthlyTotalsSummaryViews = monthlyTotalsSummaryViewRepository.findAll();
    }
    studySearchFilter.setCuratorSearchFilterId(curator);
    studySearchFilter.setStatusSearchFilterId(status);
    studySearchFilter.setYearFilter(year);
    studySearchFilter.setMonthFilter(month);
    // Add studySearchFilter to model so user can filter table
    model.addAttribute("studySearchFilter", studySearchFilter);
    model.addAttribute("monthlyTotalsSummaryViews", monthlyTotalsSummaryViews);
    return "reports_monthly";
}
Also used : MonthlyTotalsSummaryView(uk.ac.ebi.spot.goci.model.MonthlyTotalsSummaryView) StudySearchFilter(uk.ac.ebi.spot.goci.curation.model.StudySearchFilter) ArrayList(java.util.ArrayList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with StudySearchFilter

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

the class YearlyReportController method getYearlyOverview.

// Return yearly overview
@RequestMapping(produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String getYearlyOverview(Model model, @RequestParam(required = false) Long status, @RequestParam(required = false) Long curator, @RequestParam(required = false) Integer year) {
    List<YearlyTotalsSummaryView> yearlyTotalsSummaryViews = new ArrayList<>();
    // This will be returned to view and store what curator has searched for
    StudySearchFilter studySearchFilter = new StudySearchFilter();
    // Need to convert status and curator to a string
    String curatorName = null;
    String statusName = null;
    if (curator != null) {
        curatorName = curatorRepository.findOne(curator).getLastName();
    }
    if (status != null) {
        statusName = curationStatusRepository.findOne(status).getStatus();
    }
    //Search database for various filter options
    if (status != null && curator != null && year != null) {
        // all filter options supplied
        yearlyTotalsSummaryViews = yearlyTotalsSummaryViewRepository.findByCuratorAndCurationStatusAndYearOrderByYearDesc(curatorName, statusName, year);
    } else if (status != null && curator != null) {
        // status and curator
        yearlyTotalsSummaryViews = yearlyTotalsSummaryViewRepository.findByCuratorAndCurationStatus(curatorName, statusName);
    } else if (status != null && year != null) {
        // status and year
        yearlyTotalsSummaryViews = yearlyTotalsSummaryViewRepository.findByCurationStatusAndYearOrderByYearDesc(statusName, year);
    } else if (status != null) {
        yearlyTotalsSummaryViews = yearlyTotalsSummaryViewRepository.findByCurationStatus(statusName);
    } else if (curator != null && year != null) {
        // curator and year
        yearlyTotalsSummaryViews = yearlyTotalsSummaryViewRepository.findByCuratorAndYearOrderByYearDesc(curatorName, year);
    } else if (curator != null) {
        yearlyTotalsSummaryViews = yearlyTotalsSummaryViewRepository.findByCurator(curatorName);
    } else if (year != null) {
        yearlyTotalsSummaryViews = yearlyTotalsSummaryViewRepository.findByYearOrderByYearDesc(year);
    } else {
        // no filters
        yearlyTotalsSummaryViews = yearlyTotalsSummaryViewRepository.findAll();
    }
    studySearchFilter.setCuratorSearchFilterId(curator);
    studySearchFilter.setStatusSearchFilterId(status);
    studySearchFilter.setYearFilter(year);
    // Add studySearchFilter to model so user can filter table
    model.addAttribute("studySearchFilter", studySearchFilter);
    model.addAttribute("yearlyTotalsSummaryViews", yearlyTotalsSummaryViews);
    return "reports_yearly";
}
Also used : YearlyTotalsSummaryView(uk.ac.ebi.spot.goci.model.YearlyTotalsSummaryView) StudySearchFilter(uk.ac.ebi.spot.goci.curation.model.StudySearchFilter) ArrayList(java.util.ArrayList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with StudySearchFilter

use of uk.ac.ebi.spot.goci.curation.model.StudySearchFilter 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

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 StudySearchFilter (uk.ac.ebi.spot.goci.curation.model.StudySearchFilter)3 ArrayList (java.util.ArrayList)2 Sort (org.springframework.data.domain.Sort)1 Assignee (uk.ac.ebi.spot.goci.curation.model.Assignee)1 StatusAssignment (uk.ac.ebi.spot.goci.curation.model.StatusAssignment)1 CurationStatus (uk.ac.ebi.spot.goci.model.CurationStatus)1 MonthlyTotalsSummaryView (uk.ac.ebi.spot.goci.model.MonthlyTotalsSummaryView)1 Study (uk.ac.ebi.spot.goci.model.Study)1 YearlyTotalsSummaryView (uk.ac.ebi.spot.goci.model.YearlyTotalsSummaryView)1