Search in sources :

Example 1 with MonthlyTotalsSummaryView

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

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

the class MonthlyReportController method getStudies.

// Redirect to studies page
@RequestMapping(value = "/{id}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String getStudies(Model model, @PathVariable Long id) {
    // Get redirect variables
    MonthlyTotalsSummaryView monthlyTotalsSummaryView = monthlyTotalsSummaryViewRepository.findOne(id);
    String curator = monthlyTotalsSummaryView.getCurator();
    Long curatorId = curatorRepository.findByLastName(curator).getId();
    String status = monthlyTotalsSummaryView.getCurationStatus();
    Long statusId = curationStatusRepository.findByStatus(status).getId();
    Integer year = monthlyTotalsSummaryView.getYear();
    Integer month = monthlyTotalsSummaryView.getMonth();
    return "redirect:/studies?page=1&status=" + statusId + "&curator=" + curatorId + "&year=" + year + "&month=" + month;
}
Also used : MonthlyTotalsSummaryView(uk.ac.ebi.spot.goci.model.MonthlyTotalsSummaryView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 MonthlyTotalsSummaryView (uk.ac.ebi.spot.goci.model.MonthlyTotalsSummaryView)2 ArrayList (java.util.ArrayList)1 StudySearchFilter (uk.ac.ebi.spot.goci.curation.model.StudySearchFilter)1