test_class.declarator: procurementActivityByYearController
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private ProcurementActivityByYearController procurementActivityByYearController;
test_class.type: ProcurementActivityByYearController
test_class.var_name: procurementActivityByYearController
test_class.file: web/src/test/java/org/devgateway/ocds/web/rest/controller/excelchart/ProcurementActivityByYearControllerTest.java
test_class.identifier: ProcurementActivityByYearControllerTest
test_class.superclass: extends AbstractExcelControllerTest
test_case.body: @Test
      public void procurementActivityExcelChart() throws Exception {
          LangYearFilterPagingRequest filter = getLangYearFilterMockRequest();
          procurementActivityByYearController.procurementActivityExcelChart(
                  filter,
                  mockHttpServletResponse);
  
          final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray();
          final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput));
          Assert.assertNotNull(workbook);
  
          final Sheet sheet = workbook.getSheet(ChartType.line.toString());
          Assert.assertNotNull("check chart type, sheet name should be the same as the type", sheet);
  
          final XSSFDrawing drawing = (XSSFDrawing) sheet.getDrawingPatriarch();
          final List<XSSFChart> charts =  drawing.getCharts();
          Assert.assertEquals("number of charts", 1, charts.size());
  
          final XSSFChart chart = charts.get(0);
          Assert.assertEquals("chart title",
                  translationService.getValue(filter.getLanguage(), "charts:overview:title"),
                  chart.getTitle().getString());
  
          final List<? extends XSSFChartAxis> axis = chart.getAxis();
          Assert.assertEquals("number of axis", 2, axis.size());
  
          final CTChart ctChart = chart.getCTChart();
          Assert.assertEquals("Check if we have 1 line chart", 1, ctChart.getPlotArea().getLineChartArray().length);
      }
test_case.class_method_signature: ProcurementActivityByYearControllerTest.procurementActivityExcelChart()
test_case.full_signature: @Test public void procurementActivityExcelChart()
test_case.identifier: procurementActivityExcelChart
test_case.invocations: getLangYearFilterMockRequest procurementActivityExcelChart getContentAsByteArray assertNotNull getSheet toString assertNotNull getDrawingPatriarch getCharts assertEquals size get assertEquals getValue getLanguage getString getTitle getAxis assertEquals size getCTChart assertEquals getLineChartArray getPlotArea
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void procurementActivityExcelChart()
focal_class.declarator: excelChartGenerator
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private ExcelChartGenerator excelChartGenerator;
focal_class.type: ExcelChartGenerator
focal_class.var_name: excelChartGenerator
focal_class.declarator: excelChartHelper
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private ExcelChartHelper excelChartHelper;
focal_class.type: ExcelChartHelper
focal_class.var_name: excelChartHelper
focal_class.declarator: countPlansTendersAwardsController
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private CountPlansTendersAwardsController countPlansTendersAwardsController;
focal_class.type: CountPlansTendersAwardsController
focal_class.var_name: countPlansTendersAwardsController
focal_class.file: web/src/main/java/org/devgateway/ocds/web/rest/controller/excelchart/ProcurementActivityByYearController.java
focal_class.identifier: ProcurementActivityByYearController
focal_class.class_method_signature: ProcurementActivityByYearController.procurementActivityExcelChart(@ModelAttribute @Valid final LangYearFilterPagingRequest filter,
                                                final HttpServletResponse response)
focal_class.full_signature: @ApiOperation(value = "Exports *Procurement activity by year* dashboard in Excel format.") @RequestMapping(value = "/api/ocds/procurementActivityExcelChart", method = {RequestMethod.GET, RequestMethod.POST}) public void procurementActivityExcelChart(@ModelAttribute @Valid final LangYearFilterPagingRequest filter,
                                                final HttpServletResponse response)
focal_class.identifier: procurementActivityExcelChart
focal_class.modifiers: @ApiOperation(value = "Exports *Procurement activity by year* dashboard in Excel format.") @RequestMapping(value = "/api/ocds/procurementActivityExcelChart", method = {RequestMethod.GET, RequestMethod.POST}) public
focal_class.parameters: (@ModelAttribute @Valid final LangYearFilterPagingRequest filter,
                                                final HttpServletResponse response)
focal_class.return: void
focal_class.signature: void procurementActivityExcelChart(@ModelAttribute @Valid final LangYearFilterPagingRequest filter,
                                                final HttpServletResponse response)
focal_class.superclass: extends ExcelChartOCDSController
focal_method.body: @ApiOperation(value = "Exports *Procurement activity by year* dashboard in Excel format.")
      @RequestMapping(value = "/api/ocds/procurementActivityExcelChart", method = {RequestMethod.GET, RequestMethod.POST})
      public void procurementActivityExcelChart(@ModelAttribute @Valid final LangYearFilterPagingRequest filter,
                                                final HttpServletResponse response) throws IOException {
          final String chartTitle = translationService.getValue(filter.getLanguage(), "charts:overview:title");
  
          // fetch the data that will be displayed in the chart (we have multiple sources for this dashboard)
          final List<Document> countAwardsByYear = countPlansTendersAwardsController.countAwardsByYear(filter);
          final List<Document> countTendersByYear = countPlansTendersAwardsController.countTendersByYear(filter);
  
          final List<?> categories = excelChartHelper.getCategoriesFromDBObject(
                  getExportYearMonthXAxis(filter),
                  countAwardsByYear, countTendersByYear);
          final List<List<? extends Number>> values = new ArrayList<>();
  
          final List<Number> valueAwards = excelChartHelper.getValuesFromDBObject(countAwardsByYear, categories,
                  getExportYearMonthXAxis(filter), CountPlansTendersAwardsController.Keys.COUNT);
          final List<Number> valueTenders = excelChartHelper.getValuesFromDBObject(countTendersByYear, categories,
                  getExportYearMonthXAxis(filter), CountPlansTendersAwardsController.Keys.COUNT);
          if (!valueAwards.isEmpty()) {
              values.add(valueAwards);
          }
          if (!valueTenders.isEmpty()) {
              values.add(valueTenders);
          }
  
  
          // check if we have anything to display before setting the *seriesTitle*.
          final List<String> seriesTitle;
          if (!values.isEmpty()) {
              seriesTitle = Arrays.asList(
                      translationService.getValue(filter.getLanguage(), "charts:overview:traces:award"),
                      translationService.getValue(filter.getLanguage(), "charts:overview:traces:tender"));
          } else {
              seriesTitle = new ArrayList<>();
          }
  
          response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
          response.setHeader("Content-Disposition", "attachment; filename=" + chartTitle + ".xlsx");
          response.getOutputStream().write(
                  excelChartGenerator.getExcelChart(
                          ChartType.line,
                          chartTitle,
                          seriesTitle,
                          categories, values));
      }
focal_method.class_method_signature: ProcurementActivityByYearController.procurementActivityExcelChart(@ModelAttribute @Valid final LangYearFilterPagingRequest filter,
                                                final HttpServletResponse response)
focal_method.full_signature: @ApiOperation(value = "Exports *Procurement activity by year* dashboard in Excel format.") @RequestMapping(value = "/api/ocds/procurementActivityExcelChart", method = {RequestMethod.GET, RequestMethod.POST}) public void procurementActivityExcelChart(@ModelAttribute @Valid final LangYearFilterPagingRequest filter,
                                                final HttpServletResponse response)
focal_method.identifier: procurementActivityExcelChart
focal_method.invocations: getValue getLanguage countAwardsByYear countTendersByYear getCategoriesFromDBObject getExportYearMonthXAxis getValuesFromDBObject getExportYearMonthXAxis getValuesFromDBObject getExportYearMonthXAxis isEmpty add isEmpty add isEmpty asList getValue getLanguage getValue getLanguage setContentType setHeader write getOutputStream getExcelChart
focal_method.modifiers: @ApiOperation(value = "Exports *Procurement activity by year* dashboard in Excel format.") @RequestMapping(value = "/api/ocds/procurementActivityExcelChart", method = {RequestMethod.GET, RequestMethod.POST}) public
focal_method.parameters: (@ModelAttribute @Valid final LangYearFilterPagingRequest filter,
                                                final HttpServletResponse response)
focal_method.return: void
focal_method.signature: void procurementActivityExcelChart(@ModelAttribute @Valid final LangYearFilterPagingRequest filter,
                                                final HttpServletResponse response)