use of io.arlas.server.core.model.request.Count in project ARLAS-server by gisaia.
the class CountRESTService method countPost.
@Timed
@Path("{collection}/_count")
@POST
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "Count", produces = UTF8JSON, notes = "Count the number of elements found in the collection(s), given the filters", consumes = UTF8JSON, response = Hits.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = Hits.class, responseContainer = "ArlasHits"), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class) })
public Response countPost(// --------------------------------------------------------
@ApiParam(name = "collection", value = "collections", required = true) @PathParam(value = "collection") String collection, @ApiParam(hidden = true) @HeaderParam(value = "partition-filter") String partitionfilter, @ApiParam(hidden = true) @HeaderParam(value = "Column-Filter") Optional<String> columnFilter, // --------------------------------------------------------
@ApiParam(name = "pretty", value = Documentation.FORM_PRETTY, defaultValue = "false") @QueryParam(value = "pretty") Boolean pretty, // --------------------------------------------------------
Count count) throws NotFoundException, ArlasException {
CollectionReference collectionReference = exploreService.getCollectionReferenceService().getCollectionReference(collection);
if (collectionReference == null) {
throw new NotFoundException(collection);
}
MixedRequest request = new MixedRequest();
exploreService.setValidGeoFilters(collectionReference, count);
ColumnFilterUtil.assertRequestAllowed(columnFilter, collectionReference, count);
request.basicRequest = count;
Count countHeader = new Count();
countHeader.filter = ParamsParser.getFilter(partitionfilter);
exploreService.setValidGeoFilters(collectionReference, countHeader);
request.headerRequest = countHeader;
request.columnFilter = ColumnFilterUtil.getCollectionRelatedColumnFilter(columnFilter, collectionReference);
Hits hits = exploreService.count(request, collectionReference);
return Response.ok(hits).build();
}
use of io.arlas.server.core.model.request.Count in project ARLAS-server by gisaia.
the class CountRESTService method count.
@Timed
@Path("{collection}/_count")
@GET
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "Count", produces = UTF8JSON, notes = "Count the number of elements found in the collection(s), given the filters", consumes = UTF8JSON, response = Hits.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = Hits.class, responseContainer = "ArlasHits"), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class) })
public Response count(// --------------------------------------------------------
@ApiParam(name = "collection", value = "collections", required = true) @PathParam(value = "collection") String collection, // --------------------------------------------------------
@ApiParam(name = "f", value = Documentation.FILTER_PARAM_F, allowMultiple = true) @QueryParam(value = "f") List<String> f, @ApiParam(name = "q", value = Documentation.FILTER_PARAM_Q, allowMultiple = true) @QueryParam(value = "q") List<String> q, @ApiParam(name = "dateformat", value = Documentation.FILTER_DATE_FORMAT) @QueryParam(value = "dateformat") String dateformat, @ApiParam(hidden = true) @HeaderParam(value = "partition-filter") String partitionfilter, @ApiParam(hidden = true) @HeaderParam(value = "Column-Filter") Optional<String> columnFilter, // --------------------------------------------------------
@ApiParam(name = "pretty", value = Documentation.FORM_PRETTY, defaultValue = "false") @QueryParam(value = "pretty") Boolean pretty, // --------------------------------------------------------
@ApiParam(value = "max-age-cache") @QueryParam(value = "max-age-cache") Integer maxagecache) throws NotFoundException, ArlasException {
CollectionReference collectionReference = exploreService.getCollectionReferenceService().getCollectionReference(collection);
if (collectionReference == null) {
throw new NotFoundException(collection);
}
Count count = new Count();
count.filter = ParamsParser.getFilter(collectionReference, f, q, dateformat);
exploreService.setValidGeoFilters(collectionReference, count);
ColumnFilterUtil.assertRequestAllowed(columnFilter, collectionReference, count);
MixedRequest request = new MixedRequest();
request.basicRequest = count;
Count countHeader = new Count();
countHeader.filter = ParamsParser.getFilter(partitionfilter);
exploreService.setValidGeoFilters(collectionReference, countHeader);
request.headerRequest = countHeader;
request.columnFilter = ColumnFilterUtil.getCollectionRelatedColumnFilter(columnFilter, collectionReference);
Hits hits = exploreService.count(request, collectionReference);
return cache(Response.ok(hits), maxagecache);
}
Aggregations