test_class.declarator: tenderPercentagesController
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private TenderPercentagesController tenderPercentagesController;
test_class.type: TenderPercentagesController
test_class.var_name: tenderPercentagesController
test_class.file: web/src/test/java/org/devgateway/ocds/web/rest/controller/TenderPercentagesControllerTest.java
test_class.identifier: TenderPercentagesControllerTest
test_class.superclass: extends AbstractEndPointControllerTest
test_case.body: @Test
      public void percentTendersWithLinkedProcurementPlan() throws Exception {
          final List<Document> percentTendersWithLinkedProcurementPlan = tenderPercentagesController
                  .percentTendersWithLinkedProcurementPlan(new YearFilterPagingRequest());
  
          final Document first = percentTendersWithLinkedProcurementPlan.get(0);
          int year = (int) first.get(TenderPercentagesController.Keys.YEAR);
          int totalTendersWithLinkedProcurementPlan = (int) first
                  .get(TenderPercentagesController.Keys.TOTAL_TENDERS_WITH_LINKED_PROCUREMENT_PLAN);
          int totalTenders = (int) first
                  .get(TenderPercentagesController.Keys.TOTAL_TENDERS);
          double percentTenders = (double) first.get(TenderPercentagesController.Keys.PERCENT_TENDERS);
          Assert.assertEquals(2014, year);
          Assert.assertEquals(1, totalTendersWithLinkedProcurementPlan);
          Assert.assertEquals(1, totalTenders);
          Assert.assertEquals(100.0, percentTenders, 0);
  
          final Document second = percentTendersWithLinkedProcurementPlan.get(1);
          year = (int) second.get(TenderPercentagesController.Keys.YEAR);
          totalTendersWithLinkedProcurementPlan = (int) second
                  .get(TenderPercentagesController.Keys.TOTAL_TENDERS_WITH_LINKED_PROCUREMENT_PLAN);
          totalTenders = (int) second
                  .get(TenderPercentagesController.Keys.TOTAL_TENDERS);
          percentTenders = (double) second.get(TenderPercentagesController.Keys.PERCENT_TENDERS);
          Assert.assertEquals(2015, year);
          Assert.assertEquals(2, totalTendersWithLinkedProcurementPlan);
          Assert.assertEquals(2, totalTenders);
          Assert.assertEquals(100.0, percentTenders, 0);
      }
test_case.class_method_signature: TenderPercentagesControllerTest.percentTendersWithLinkedProcurementPlan()
test_case.full_signature: @Test public void percentTendersWithLinkedProcurementPlan()
test_case.identifier: percentTendersWithLinkedProcurementPlan
test_case.invocations: percentTendersWithLinkedProcurementPlan get get get get get assertEquals assertEquals assertEquals assertEquals get get get get get assertEquals assertEquals assertEquals assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void percentTendersWithLinkedProcurementPlan()
focal_class.file: web/src/main/java/org/devgateway/ocds/web/rest/controller/TenderPercentagesController.java
focal_class.identifier: TenderPercentagesController
focal_class.class_method_signature: TenderPercentagesController.percentTendersCancelled(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.full_signature: @ApiOperation("Returns the percent of tenders that were cancelled, grouped by year." + " The year is taken from tender.tenderPeriod.startDate. The response also contains the" + " total number of tenders and total number of cancelled tenders for each year.") @RequestMapping(value = "/api/percentTendersCancelled", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public List<Document> percentTendersCancelled(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.identifier: percentTendersCancelled
focal_class.modifiers: @ApiOperation("Returns the percent of tenders that were cancelled, grouped by year." + " The year is taken from tender.tenderPeriod.startDate. The response also contains the" + " total number of tenders and total number of cancelled tenders for each year.") @RequestMapping(value = "/api/percentTendersCancelled", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public
focal_class.parameters: (@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.return: List<Document>
focal_class.signature: List<Document> percentTendersCancelled(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.class_method_signature: TenderPercentagesController.percentTendersWithTwoOrMoreTenderers(@ModelAttribute
                                                                 @Valid final YearFilterPagingRequest filter)
focal_class.full_signature: @ApiOperation("Percentage of tenders with >1 tenderer/bidder): " + "Count of tenders with numberOfTenderers >1 divided by total count of tenders." + "This endpoint uses tender.tenderPeriod.startDate to calculate the tender year.") @RequestMapping(value = "/api/percentTendersWithTwoOrMoreTenderers", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public List<Document> percentTendersWithTwoOrMoreTenderers(@ModelAttribute
                                                                 @Valid final YearFilterPagingRequest filter)
focal_class.identifier: percentTendersWithTwoOrMoreTenderers
focal_class.modifiers: @ApiOperation("Percentage of tenders with >1 tenderer/bidder): " + "Count of tenders with numberOfTenderers >1 divided by total count of tenders." + "This endpoint uses tender.tenderPeriod.startDate to calculate the tender year.") @RequestMapping(value = "/api/percentTendersWithTwoOrMoreTenderers", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public
focal_class.parameters: (@ModelAttribute
                                                                 @Valid final YearFilterPagingRequest filter)
focal_class.return: List<Document>
focal_class.signature: List<Document> percentTendersWithTwoOrMoreTenderers(@ModelAttribute
                                                                 @Valid final YearFilterPagingRequest filter)
focal_class.class_method_signature: TenderPercentagesController.percentTendersAwarded(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.full_signature: @ApiOperation("Percent of awarded tenders with >1 tenderer/bidder" + "Count of tenders with numberOfTenderers >1 divided by total count of tenders with numberOfTenderers >0" + "This endpoint uses tender.tenderPeriod.startDate to calculate the tender year.") @RequestMapping(value = "/api/percentTendersAwardedWithTwoOrMoreTenderers", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public List<Document> percentTendersAwarded(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.identifier: percentTendersAwarded
focal_class.modifiers: @ApiOperation("Percent of awarded tenders with >1 tenderer/bidder" + "Count of tenders with numberOfTenderers >1 divided by total count of tenders with numberOfTenderers >0" + "This endpoint uses tender.tenderPeriod.startDate to calculate the tender year.") @RequestMapping(value = "/api/percentTendersAwardedWithTwoOrMoreTenderers", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public
focal_class.parameters: (@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.return: List<Document>
focal_class.signature: List<Document> percentTendersAwarded(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.class_method_signature: TenderPercentagesController.percentTendersUsingEBid(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.full_signature: @ApiOperation("Returns the percent of tenders with active awards, " + "with tender.submissionMethod='electronicSubmission'." + "The endpoint also returns the total tenderds with active awards and the count of tenders with " + "tender.submissionMethod='electronicSubmission") @RequestMapping(value = "/api/percentTendersUsingEBid", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public List<Document> percentTendersUsingEBid(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.identifier: percentTendersUsingEBid
focal_class.modifiers: @ApiOperation("Returns the percent of tenders with active awards, " + "with tender.submissionMethod='electronicSubmission'." + "The endpoint also returns the total tenderds with active awards and the count of tenders with " + "tender.submissionMethod='electronicSubmission") @RequestMapping(value = "/api/percentTendersUsingEBid", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public
focal_class.parameters: (@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.return: List<Document>
focal_class.signature: List<Document> percentTendersUsingEBid(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.class_method_signature: TenderPercentagesController.percentTendersWithLinkedProcurementPlan(@ModelAttribute
                                                                    @Valid final YearFilterPagingRequest filter)
focal_class.full_signature: @ApiOperation("Percentage of tenders that are associated in releases that " + "have the planning.budget.amount non empty," + "meaning there really is a planning entity correlated with the tender entity." + "This endpoint uses tender.tenderPeriod.startDate to calculate the tender year.") @RequestMapping(value = "/api/percentTendersWithLinkedProcurementPlan", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public List<Document> percentTendersWithLinkedProcurementPlan(@ModelAttribute
                                                                    @Valid final YearFilterPagingRequest filter)
focal_class.identifier: percentTendersWithLinkedProcurementPlan
focal_class.modifiers: @ApiOperation("Percentage of tenders that are associated in releases that " + "have the planning.budget.amount non empty," + "meaning there really is a planning entity correlated with the tender entity." + "This endpoint uses tender.tenderPeriod.startDate to calculate the tender year.") @RequestMapping(value = "/api/percentTendersWithLinkedProcurementPlan", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public
focal_class.parameters: (@ModelAttribute
                                                                    @Valid final YearFilterPagingRequest filter)
focal_class.return: List<Document>
focal_class.signature: List<Document> percentTendersWithLinkedProcurementPlan(@ModelAttribute
                                                                    @Valid final YearFilterPagingRequest filter)
focal_class.superclass: extends GenericOCDSController
focal_method.body: @ApiOperation("Percentage of tenders that are associated in releases that "
              + "have the planning.budget.amount non empty,"
              + "meaning there really is a planning entity correlated with the tender entity."
              + "This endpoint uses tender.tenderPeriod.startDate to calculate the tender year.")
      @RequestMapping(value = "/api/percentTendersWithLinkedProcurementPlan",
              method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
      public List<Document> percentTendersWithLinkedProcurementPlan(@ModelAttribute
                                                                    @Valid final YearFilterPagingRequest filter) {
  
          DBObject project1 = new BasicDBObject();
          addYearlyMonthlyProjection(filter, project1, "$tender.tenderPeriod.startDate");
          project1.put("tender._id", 1);
          project1.put("planning.budget.amount", 1);
  
          DBObject group = new BasicDBObject();
          addYearlyMonthlyReferenceToGroup(filter, group);
          group.put(Keys.TOTAL_TENDERS, new BasicDBObject("$sum", 1));
          group.put(Keys.TOTAL_TENDERS_WITH_LINKED_PROCUREMENT_PLAN, new BasicDBObject("$sum", new BasicDBObject(
                  "$cond",
                  Arrays.asList(new BasicDBObject("$gt", Arrays.asList("$planning.budget.amount", null)), 1, 0)
          )));
  
          DBObject project2 = new BasicDBObject();
          project2.put(Keys.YEAR, 1);
          project2.put("month", 1);
          project2.put(Keys.TOTAL_TENDERS, 1);
          project2.put(Keys.TOTAL_TENDERS_WITH_LINKED_PROCUREMENT_PLAN, 1);
          project2.put(
                  Keys.PERCENT_TENDERS,
                  new BasicDBObject(
                          "$multiply",
                          Arrays.asList(
                                  new BasicDBObject("$divide", Arrays.asList(
                                          "$" + Keys.TOTAL_TENDERS_WITH_LINKED_PROCUREMENT_PLAN,
                                          "$" + Keys.TOTAL_TENDERS
                                  )),
                                  100
                          )
                  )
          );
  
          Aggregation agg = newAggregation(
                  match(where("tender.tenderPeriod.startDate").exists(true)
                          .andOperator(getYearDefaultFilterCriteria(filter, "tender.tenderPeriod.startDate"))),
                  new CustomProjectionOperation(project1), new CustomGroupingOperation(group),
                  transformYearlyGrouping(filter).andInclude(Keys.TOTAL_TENDERS,
                          Keys.TOTAL_TENDERS_WITH_LINKED_PROCUREMENT_PLAN, Keys.PERCENT_TENDERS
                  ),
                  new CustomProjectionOperation(project2),
                  getSortByYearMonth(filter), skip(filter.getSkip()), limit(filter.getPageSize())
          );
  
          return releaseAgg(agg);
      }
focal_method.class_method_signature: TenderPercentagesController.percentTendersWithLinkedProcurementPlan(@ModelAttribute
                                                                    @Valid final YearFilterPagingRequest filter)
focal_method.full_signature: @ApiOperation("Percentage of tenders that are associated in releases that " + "have the planning.budget.amount non empty," + "meaning there really is a planning entity correlated with the tender entity." + "This endpoint uses tender.tenderPeriod.startDate to calculate the tender year.") @RequestMapping(value = "/api/percentTendersWithLinkedProcurementPlan", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public List<Document> percentTendersWithLinkedProcurementPlan(@ModelAttribute
                                                                    @Valid final YearFilterPagingRequest filter)
focal_method.identifier: percentTendersWithLinkedProcurementPlan
focal_method.invocations: addYearlyMonthlyProjection put put addYearlyMonthlyReferenceToGroup put put asList asList put put put put put asList asList newAggregation match andOperator exists where getYearDefaultFilterCriteria andInclude transformYearlyGrouping getSortByYearMonth skip getSkip limit getPageSize releaseAgg
focal_method.modifiers: @ApiOperation("Percentage of tenders that are associated in releases that " + "have the planning.budget.amount non empty," + "meaning there really is a planning entity correlated with the tender entity." + "This endpoint uses tender.tenderPeriod.startDate to calculate the tender year.") @RequestMapping(value = "/api/percentTendersWithLinkedProcurementPlan", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public
focal_method.parameters: (@ModelAttribute
                                                                    @Valid final YearFilterPagingRequest filter)
focal_method.return: List<Document>
focal_method.signature: List<Document> percentTendersWithLinkedProcurementPlan(@ModelAttribute
                                                                    @Valid final YearFilterPagingRequest filter)