Search in sources :

Example 46 with YearFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest in project oc-explorer by devgateway.

the class CorruptionRiskDashboardCrosstabTest method testI038CrossTab.

@Test
public void testI038CrossTab() {
    List<DBObject> flagStats = flagI038CrosstabController.flagStats(new YearFilterPagingRequest());
    Assert.assertEquals(0, flagStats.size());
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test) AbstractEndPointControllerTest(org.devgateway.ocds.web.rest.controller.AbstractEndPointControllerTest)

Example 47 with YearFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest in project oc-explorer by devgateway.

the class CorruptionRiskDashboardCrosstabTest method test180CrossTab.

@Test
public void test180CrossTab() {
    List<DBObject> flagStats = flagI180CrosstabController.flagStats(new YearFilterPagingRequest());
    Assert.assertEquals(0, flagStats.size());
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test) AbstractEndPointControllerTest(org.devgateway.ocds.web.rest.controller.AbstractEndPointControllerTest)

Example 48 with YearFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest in project oc-explorer by devgateway.

the class CorruptionRiskDashboardCrosstabTest method testI007CrossTab.

@Test
public void testI007CrossTab() {
    List<DBObject> flagStats = flagI007CrosstabController.flagStats(new YearFilterPagingRequest());
    Assert.assertEquals(1, flagStats.get(0).get(flagI007CrosstabController.getFlagDesignation(FlagsConstants.I007_VALUE)));
    Assert.assertEquals(1, flagStats.get(0).get(flagI007CrosstabController.getFlagDesignation(FlagsConstants.I019_VALUE)));
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test) AbstractEndPointControllerTest(org.devgateway.ocds.web.rest.controller.AbstractEndPointControllerTest)

Example 49 with YearFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest in project ocvn by devgateway.

the class TenderPriceByTypeYearController method tenderPriceByAllBidSelectionMethods.

@ApiOperation(value = "Same as /api/tenderPriceByBidSelectionMethod, but it always returns " + "all bidSelectionMethods (it adds the missing bid selection methods with zero totals")
@RequestMapping(value = "/api/tenderPriceByAllBidSelectionMethods", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json")
public List<DBObject> tenderPriceByAllBidSelectionMethods(@ModelAttribute @Valid final YearFilterPagingRequest filter) {
    List<DBObject> tenderPriceByBidSelectionMethod = tenderPriceByBidSelectionMethod(filter);
    // create a treeset ordered by procurment method details key
    Collection<DBObject> ret = new TreeSet<>((DBObject o1, DBObject o2) -> o1.get(Keys.PROCUREMENT_METHOD_DETAILS).toString().compareTo(o2.get(Keys.PROCUREMENT_METHOD_DETAILS).toString()));
    // add them all to sorted set
    for (DBObject o : tenderPriceByBidSelectionMethod) {
        if (o.containsField(Keys.PROCUREMENT_METHOD_DETAILS) && o.get(Keys.PROCUREMENT_METHOD_DETAILS) != null) {
            ret.add(o);
        } else {
            o.put(Keys.PROCUREMENT_METHOD_DETAILS, UNSPECIFIED);
            ret.add(o);
        }
    }
    // get all the non null bid selection methods
    Set<Object> bidSelectionMethods = bidSelectionMethodSearchController.bidSelectionMethods().stream().filter(e -> e.get(Fields.UNDERSCORE_ID) != null).map(e -> e.get(Fields.UNDERSCORE_ID)).collect(Collectors.toCollection(LinkedHashSet::new));
    bidSelectionMethods.add(UNSPECIFIED);
    // remove elements that already are in the result
    bidSelectionMethods.removeAll(ret.stream().map(e -> e.get(Keys.PROCUREMENT_METHOD_DETAILS)).collect(Collectors.toSet()));
    // add the missing procurementmethoddetails with zero amounts
    bidSelectionMethods.forEach(e -> {
        DBObject obj = new BasicDBObject(Keys.PROCUREMENT_METHOD_DETAILS, e.toString());
        obj.put(Keys.TOTAL_TENDER_AMOUNT, BigDecimal.ZERO);
        ret.add(obj);
    });
    return new ArrayList<>(ret);
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) Aggregation.group(org.springframework.data.mongodb.core.aggregation.Aggregation.group) Aggregation.newAggregation(org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation) Cacheable(org.springframework.cache.annotation.Cacheable) Aggregation.sort(org.springframework.data.mongodb.core.aggregation.Aggregation.sort) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Aggregation.match(org.springframework.data.mongodb.core.aggregation.Aggregation.match) Fields(org.springframework.data.mongodb.core.aggregation.Fields) MongoConstants(org.devgateway.ocds.persistence.mongo.constants.MongoConstants) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Valid(javax.validation.Valid) ApiOperation(io.swagger.annotations.ApiOperation) BigDecimal(java.math.BigDecimal) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) DBObject(com.mongodb.DBObject) Direction(org.springframework.data.domain.Sort.Direction) LinkedHashSet(java.util.LinkedHashSet) Criteria.where(org.springframework.data.mongodb.core.query.Criteria.where) Collection(java.util.Collection) BasicDBObject(com.mongodb.BasicDBObject) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) Set(java.util.Set) BidSelectionMethodSearchController(org.devgateway.ocds.web.rest.controller.selector.BidSelectionMethodSearchController) AggregationResults(org.springframework.data.mongodb.core.aggregation.AggregationResults) Aggregation(org.springframework.data.mongodb.core.aggregation.Aggregation) RestController(org.springframework.web.bind.annotation.RestController) Collectors(java.util.stream.Collectors) List(java.util.List) Aggregation.project(org.springframework.data.mongodb.core.aggregation.Aggregation.project) CacheConfig(org.springframework.cache.annotation.CacheConfig) CustomProjectionOperation(org.devgateway.toolkit.persistence.mongo.aggregate.CustomProjectionOperation) BasicDBObject(com.mongodb.BasicDBObject) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) DBObject(com.mongodb.DBObject) BasicDBObject(com.mongodb.BasicDBObject) DBObject(com.mongodb.DBObject) BasicDBObject(com.mongodb.BasicDBObject) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 50 with YearFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest in project ocvn by devgateway.

the class OcdsControllerTest method ocdsReleases.

@Test
public void ocdsReleases() throws Exception {
    final List<Release> releases = ocdsController.ocdsReleases(new YearFilterPagingRequest());
    Assert.assertEquals(3, releases.size());
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test)

Aggregations

YearFilterPagingRequest (org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest)100 Test (org.junit.Test)98 DBObject (com.mongodb.DBObject)96 BasicDBObject (com.mongodb.BasicDBObject)13 AbstractEndPointControllerTest (org.devgateway.ocds.web.rest.controller.AbstractEndPointControllerTest)10 ArrayList (java.util.ArrayList)5 List (java.util.List)5 AbstractWebTest (org.devgateway.toolkit.web.AbstractWebTest)4 Collection (java.util.Collection)3 ApiOperation (io.swagger.annotations.ApiOperation)2 BigDecimal (java.math.BigDecimal)2 Valid (javax.validation.Valid)2 Release (org.devgateway.ocds.persistence.mongo.Release)2 ReleasePackage (org.devgateway.ocds.persistence.mongo.ReleasePackage)2 MongoConstants (org.devgateway.ocds.persistence.mongo.constants.MongoConstants)2 CacheConfig (org.springframework.cache.annotation.CacheConfig)2 Cacheable (org.springframework.cache.annotation.Cacheable)2 Aggregation (org.springframework.data.mongodb.core.aggregation.Aggregation)2 Aggregation.group (org.springframework.data.mongodb.core.aggregation.Aggregation.group)2 Aggregation.match (org.springframework.data.mongodb.core.aggregation.Aggregation.match)2