Search in sources :

Example 16 with CollectionReference

use of io.arlas.server.core.model.CollectionReference 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();
}
Also used : MixedRequest(io.arlas.server.core.model.request.MixedRequest) Hits(io.arlas.server.core.model.response.Hits) Count(io.arlas.server.core.model.request.Count) CollectionReference(io.arlas.server.core.model.CollectionReference) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 17 with CollectionReference

use of io.arlas.server.core.model.CollectionReference 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);
}
Also used : MixedRequest(io.arlas.server.core.model.request.MixedRequest) Hits(io.arlas.server.core.model.response.Hits) Count(io.arlas.server.core.model.request.Count) CollectionReference(io.arlas.server.core.model.CollectionReference) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 18 with CollectionReference

use of io.arlas.server.core.model.CollectionReference in project ARLAS-server by gisaia.

the class DescribeCollectionRESTService method describe.

@Timed
@Path("{collection}/_describe")
@GET
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "Describe", produces = UTF8JSON, notes = "Describe the structure and the content of the given collection. ", consumes = UTF8JSON, response = CollectionReferenceDescription.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = CollectionReferenceDescription.class, responseContainer = "CollectionReferenceDescription"), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class) })
public Response describe(// --------------------------------------------------------
@ApiParam(name = "collection", value = "collection", required = true) @PathParam(value = "collection") String collection, @ApiParam(hidden = true) @HeaderParam(value = "Column-Filter") Optional<String> columnFilter, // --------------------------------------------------------
@ApiParam(name = "pretty", value = "Pretty print", defaultValue = "false") @QueryParam(value = "pretty") Boolean pretty, // --------------------------------------------------------
@ApiParam(value = "max-age-cache") @QueryParam(value = "max-age-cache") Integer maxagecache) throws ArlasException {
    CollectionReference collectionReference = exploreService.getCollectionReferenceService().getCollectionReference(collection);
    if (collectionReference == null) {
        throw new NotFoundException(collection);
    }
    ColumnFilterUtil.assertCollectionsAllowed(columnFilter, Collections.singletonList(collectionReference));
    CollectionReferenceDescription collectionReferenceDescription = exploreService.describeCollection(collectionReference, columnFilter);
    return cache(Response.ok(collectionReferenceDescription), maxagecache);
}
Also used : CollectionReferenceDescription(io.arlas.server.core.model.response.CollectionReferenceDescription) CollectionReference(io.arlas.server.core.model.CollectionReference) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 19 with CollectionReference

use of io.arlas.server.core.model.CollectionReference in project ARLAS-server by gisaia.

the class SearchRESTService method search.

@Timed
@Path("{collection}/_search")
@GET
@Produces({ UTF8JSON, ATOM.APPLICATION_ATOM_XML })
@Consumes(UTF8JSON)
@ApiOperation(value = "Search", produces = UTF8JSON + "," + ATOM.APPLICATION_ATOM_XML, notes = Documentation.SEARCH_OPERATION, 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 search(@Context UriInfo uriInfo, // --------------------------------------------------------
@ApiParam(name = "collection", value = "collection", 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") @DefaultValue("false") @QueryParam(value = "pretty") Boolean pretty, @ApiParam(name = "flat", value = Documentation.FORM_FLAT, defaultValue = "false") @QueryParam(value = "flat") Boolean flat, @ApiParam(name = "include", value = Documentation.PROJECTION_PARAM_INCLUDE, allowMultiple = true, defaultValue = "*") @QueryParam(value = "include") String include, @ApiParam(name = "exclude", value = Documentation.PROJECTION_PARAM_EXCLUDE, allowMultiple = true, defaultValue = "") @QueryParam(value = "exclude") String exclude, @ApiParam(name = "returned_geometries", value = Documentation.PROJECTION_PARAM_RETURNED_GEOMETRIES, defaultValue = "") @QueryParam(value = "returned_geometries") String returned_geometries, @ApiParam(name = "size", value = Documentation.PAGE_PARAM_SIZE, defaultValue = "10", allowableValues = "range[1, infinity]", type = "integer") @DefaultValue("10") @QueryParam(value = "size") IntParam size, @ApiParam(name = "from", value = Documentation.PAGE_PARAM_FROM, defaultValue = "0", allowableValues = "range[0, infinity]", type = "integer") @DefaultValue("0") @QueryParam(value = "from") IntParam from, @ApiParam(name = "sort", value = Documentation.PAGE_PARAM_SORT) @QueryParam(value = "sort") String sort, @ApiParam(name = "after", value = Documentation.PAGE_PARAM_AFTER) @QueryParam(value = "after") String after, @ApiParam(name = "before", value = Documentation.PAGE_PARAM_BEFORE) @QueryParam(value = "before") String before, // --------------------------------------------------------
@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);
    }
    CheckParams.checkReturnedGeometries(collectionReference, include, exclude, returned_geometries);
    Search search = new Search();
    search.filter = ParamsParser.getFilter(collectionReference, f, q, dateformat);
    search.page = ParamsParser.getPage(size, from, sort, after, before);
    search.projection = ParamsParser.getProjection(include, exclude);
    search.returned_geometries = returned_geometries;
    exploreService.setValidGeoFilters(collectionReference, search);
    ColumnFilterUtil.assertRequestAllowed(columnFilter, collectionReference, search);
    search.projection = ParamsParser.enrichIncludes(search.projection, returned_geometries);
    Search searchHeader = new Search();
    searchHeader.filter = ParamsParser.getFilter(partitionFilter);
    MixedRequest request = new MixedRequest();
    request.basicRequest = search;
    exploreService.setValidGeoFilters(collectionReference, searchHeader);
    request.headerRequest = searchHeader;
    request.columnFilter = ColumnFilterUtil.getCollectionRelatedColumnFilter(columnFilter, collectionReference);
    Hits hits = exploreService.search(request, collectionReference, Boolean.TRUE.equals(flat), uriInfo, "GET");
    return cache(Response.ok(hits), maxagecache);
}
Also used : MixedRequest(io.arlas.server.core.model.request.MixedRequest) Hits(io.arlas.server.core.model.response.Hits) Search(io.arlas.server.core.model.request.Search) CollectionReference(io.arlas.server.core.model.CollectionReference) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 20 with CollectionReference

use of io.arlas.server.core.model.CollectionReference in project ARLAS-server by gisaia.

the class AggregateRESTService method aggregatePost.

@Timed
@Path("{collection}/_aggregate")
@POST
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "Aggregate", produces = UTF8JSON, notes = Documentation.AGGREGATION_OPERATION, consumes = UTF8JSON, response = AggregationResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = AggregationResponse.class, responseContainer = "ArlasAggregation"), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class) })
public Response aggregatePost(// --------------------------------------------------------
@ApiParam(name = "collection", value = "collection", required = true) @PathParam(value = "collection") String collection, // --------------------------------------------------------
AggregationsRequest aggregationsRequest, @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 {
    long startArlasTime = System.nanoTime();
    CollectionReference collectionReference = exploreService.getCollectionReferenceService().getCollectionReference(collection);
    if (collectionReference == null) {
        throw new NotFoundException(collection);
    }
    AggregationsRequest aggregationsRequestHeader = new AggregationsRequest();
    aggregationsRequestHeader.filter = ParamsParser.getFilter(partitionFilter);
    MixedRequest request = new MixedRequest();
    exploreService.setValidGeoFilters(collectionReference, aggregationsRequest);
    exploreService.setValidGeoFilters(collectionReference, aggregationsRequestHeader);
    ColumnFilterUtil.assertRequestAllowed(columnFilter, collectionReference, aggregationsRequest);
    request.basicRequest = aggregationsRequest;
    request.headerRequest = aggregationsRequestHeader;
    request.columnFilter = ColumnFilterUtil.getCollectionRelatedColumnFilter(columnFilter, collectionReference);
    AggregationResponse aggregationResponse = getArlasAggregation(request, collectionReference, (aggregationsRequest.form != null && Boolean.TRUE.equals(aggregationsRequest.form.flat)));
    aggregationResponse.totalTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startArlasTime);
    return cache(Response.ok(aggregationResponse), maxagecache);
}
Also used : AggregationsRequest(io.arlas.server.core.model.request.AggregationsRequest) MixedRequest(io.arlas.server.core.model.request.MixedRequest) AggregationResponse(io.arlas.server.core.model.response.AggregationResponse) CollectionReference(io.arlas.server.core.model.CollectionReference) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

CollectionReference (io.arlas.server.core.model.CollectionReference)40 Timed (com.codahale.metrics.annotation.Timed)23 ApiOperation (io.swagger.annotations.ApiOperation)21 ApiResponses (io.swagger.annotations.ApiResponses)21 ArlasException (io.arlas.server.core.exceptions.ArlasException)14 MixedRequest (io.arlas.server.core.model.request.MixedRequest)13 Search (io.arlas.server.core.model.request.Search)7 Collectors (java.util.stream.Collectors)7 FeatureCollection (org.geojson.FeatureCollection)7 NotFoundException (io.arlas.server.core.exceptions.NotFoundException)6 CollectionReferenceService (io.arlas.server.core.services.CollectionReferenceService)6 ExploreService (io.arlas.server.core.services.ExploreService)6 IOException (java.io.IOException)6 java.util (java.util)5 Response (javax.ws.rs.core.Response)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 CollectionReferenceParameters (io.arlas.server.core.model.CollectionReferenceParameters)4 AggregationResponse (io.arlas.server.core.model.response.AggregationResponse)4 CollectionReferenceDescription (io.arlas.server.core.model.response.CollectionReferenceDescription)4 io.arlas.server.core.utils (io.arlas.server.core.utils)4