use of uk.ac.ebi.spot.goci.model.YearlyTotalsSummaryView 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";
}
Aggregations