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 percentTendersAwarded() throws Exception {
          final List<Document> percentTendersAwarded = tenderPercentagesController
                  .percentTendersAwarded(new YearFilterPagingRequest());
  
          final Document first = percentTendersAwarded.get(0);
          int year = (int) first.get(TenderPercentagesController.Keys.YEAR);
          int totalTendersWithOneOrMoreTenderers = (int) first
                  .get(TenderPercentagesController.Keys.TOTAL_TENDERS_WITH_ONE_OR_MORE_TENDERERS);
          int totalTendersWithTwoOrMoreTenderers = (int) first
                  .get(TenderPercentagesController.Keys.TOTAL_TENDERS_WITH_TWO_OR_MORE_TENDERERS);
          double percentTenders = (double) first.get(TenderPercentagesController.Keys.PERCENT_TENDERS);
          Assert.assertEquals(2014, year);
          Assert.assertEquals(1, totalTendersWithOneOrMoreTenderers);
          Assert.assertEquals(1, totalTendersWithTwoOrMoreTenderers);
          Assert.assertEquals(100.0, percentTenders, 0);
  
          final Document second = percentTendersAwarded.get(1);
          year = (int) second.get(TenderPercentagesController.Keys.YEAR);
          totalTendersWithOneOrMoreTenderers = (int) second
                  .get(TenderPercentagesController.Keys.TOTAL_TENDERS_WITH_ONE_OR_MORE_TENDERERS);
          totalTendersWithTwoOrMoreTenderers = (int) second
                  .get(TenderPercentagesController.Keys.TOTAL_TENDERS_WITH_TWO_OR_MORE_TENDERERS);
          percentTenders = (double) second.get(TenderPercentagesController.Keys.PERCENT_TENDERS);
          Assert.assertEquals(2015, year);
          Assert.assertEquals(2, totalTendersWithOneOrMoreTenderers);
          Assert.assertEquals(1, totalTendersWithTwoOrMoreTenderers);
          Assert.assertEquals(50.0, percentTenders, 0);
      }
test_case.class_method_signature: TenderPercentagesControllerTest.percentTendersAwarded()
test_case.full_signature: @Test public void percentTendersAwarded()
test_case.identifier: percentTendersAwarded
test_case.invocations: percentTendersAwarded 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 percentTendersAwarded()
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("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) {
  
          DBObject project1 = new BasicDBObject();
          addYearlyMonthlyProjection(filter, project1, ref(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE));
          project1.put(MongoConstants.FieldNames.TENDER_NO_TENDERERS, 1);
  
          DBObject group = new BasicDBObject();
          addYearlyMonthlyReferenceToGroup(filter, group);
          group.put(Keys.TOTAL_TENDERS_WITH_ONE_OR_MORE_TENDERERS, new BasicDBObject("$sum", new BasicDBObject(
                  "$cond",
                  Arrays.asList(
                          new BasicDBObject("$gt", Arrays.asList(ref(MongoConstants.FieldNames.TENDER_NO_TENDERERS), 0)),
                          1, 0
                  )
          )));
  
          group.put(Keys.TOTAL_TENDERS_WITH_TWO_OR_MORE_TENDERERS, new BasicDBObject("$sum", new BasicDBObject(
                  "$cond",
                  Arrays.asList(
                          new BasicDBObject("$gt", Arrays.asList(ref(MongoConstants.FieldNames.TENDER_NO_TENDERERS), 1)),
                          1, 0
                  )
          )));
  
          DBObject project2 = new BasicDBObject();
          project2.put(Keys.TOTAL_TENDERS_WITH_ONE_OR_MORE_TENDERERS, 1);
          project2.put(Keys.TOTAL_TENDERS_WITH_TWO_OR_MORE_TENDERERS, 1);
          project2.put(
                  Keys.PERCENT_TENDERS,
                  new BasicDBObject("$multiply", Arrays.asList(
                          new BasicDBObject(
                                  "$divide",
                                  Arrays.asList(
                                          "$totalTendersWithTwoOrMoreTenderers",
                                          "$totalTendersWithOneOrMoreTenderers"
                                  )
                          ),
                          100
                  ))
          );
  
          Aggregation agg = newAggregation(
                  match(where(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE)
                          .exists(true).and(MongoConstants.FieldNames.TENDER_NO_TENDERERS).gt(0)
                          .andOperator(getYearDefaultFilterCriteria(
                                  filter,
                                  MongoConstants.FieldNames.TENDER_PERIOD_START_DATE
                          ))),
                  new CustomProjectionOperation(project1), new CustomGroupingOperation(group),
                  new CustomProjectionOperation(project2),
                  transformYearlyGrouping(filter).andInclude(Keys.TOTAL_TENDERS_WITH_ONE_OR_MORE_TENDERERS,
                          Keys.TOTAL_TENDERS_WITH_TWO_OR_MORE_TENDERERS, Keys.PERCENT_TENDERS
                  ),
                  getSortByYearMonth(filter), skip(filter.getSkip()), limit(filter.getPageSize())
          );
  
          return releaseAgg(agg);
      }
focal_method.class_method_signature: TenderPercentagesController.percentTendersAwarded(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_method.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_method.identifier: percentTendersAwarded
focal_method.invocations: addYearlyMonthlyProjection ref put addYearlyMonthlyReferenceToGroup put asList asList ref put asList asList ref put put put asList asList newAggregation match andOperator gt and exists where getYearDefaultFilterCriteria andInclude transformYearlyGrouping getSortByYearMonth skip getSkip limit getPageSize releaseAgg
focal_method.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_method.parameters: (@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_method.return: List<Document>
focal_method.signature: List<Document> percentTendersAwarded(@ModelAttribute @Valid final YearFilterPagingRequest filter)