Search in sources :

Example 11 with JsonView

use of com.fasterxml.jackson.annotation.JsonView in project ocvn by devgateway.

the class OcdsController method ocdsReleases.

/**
     * Returns a list of OCDS Releases, order by Id, using pagination
     *
     * @return the release data
     */
@ApiOperation(value = "Resturns all available releases, filtered by the given criteria.")
@RequestMapping(value = "/api/ocds/release/all", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json")
@JsonView(Views.Public.class)
public List<Release> ocdsReleases(@ModelAttribute @Valid final YearFilterPagingRequest releaseRequest) {
    Pageable pageRequest = new PageRequest(releaseRequest.getPageNumber(), releaseRequest.getPageSize(), Direction.ASC, "id");
    List<Release> find = mongoTemplate.find(query(getYearFilterCriteria(releaseRequest, "planning.bidPlanProjectDateApprove").andOperator(getDefaultFilterCriteria(releaseRequest))).with(pageRequest), Release.class);
    return find;
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Release(org.devgateway.ocds.persistence.mongo.Release) ApiOperation(io.swagger.annotations.ApiOperation) JsonView(com.fasterxml.jackson.annotation.JsonView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with JsonView

use of com.fasterxml.jackson.annotation.JsonView in project ocvn by devgateway.

the class AbstractFlagReleaseSearchController method releaseFlagSearch.

@JsonView(Views.Internal.class)
public List<DBObject> releaseFlagSearch(@ModelAttribute @Valid final YearFilterPagingRequest filter) {
    Aggregation agg = newAggregation(match(where("flags.flaggedStats.0").exists(true).and(getFlagProperty()).is(true).andOperator(getYearDefaultFilterCriteria(filter, MongoConstants.FieldNames.TENDER_PERIOD_START_DATE))), unwind("flags.flaggedStats"), match(where(getFlagProperty()).is(true)), project("ocid", "tender.procuringEntity.name", "tender.tenderPeriod", "flags", "tender.title", "tag").and("tender.value").as("tender.value").and("awards.value").as("awards.value").andExclude(Fields.UNDERSCORE_ID), sort(Sort.Direction.DESC, "flags.flaggedStats.count"), skip(filter.getSkip()), limit(filter.getPageSize()));
    AggregationResults<DBObject> results = mongoTemplate.aggregate(agg, "release", DBObject.class);
    List<DBObject> list = results.getMappedResults();
    return list;
}
Also used : Aggregation.newAggregation(org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation) Aggregation(org.springframework.data.mongodb.core.aggregation.Aggregation) DBObject(com.mongodb.DBObject) JsonView(com.fasterxml.jackson.annotation.JsonView)

Aggregations

JsonView (com.fasterxml.jackson.annotation.JsonView)12 ApiOperation (io.swagger.annotations.ApiOperation)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 DBObject (com.mongodb.DBObject)4 MethodParameter (org.springframework.core.MethodParameter)4 Aggregation (org.springframework.data.mongodb.core.aggregation.Aggregation)4 Aggregation.newAggregation (org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation)4 Release (org.devgateway.ocds.persistence.mongo.Release)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ReleasePackage (org.devgateway.ocds.persistence.mongo.ReleasePackage)1 PageRequest (org.springframework.data.domain.PageRequest)1 Pageable (org.springframework.data.domain.Pageable)1 MappingJacksonInputMessage (org.springframework.http.converter.json.MappingJacksonInputMessage)1