use of io.arlas.server.core.model.request.MixedRequest in project ARLAS-server by gisaia.
the class GeoSearchRESTService method geosearchPost.
@Timed
@Path("{collection}/_geosearch")
@POST
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "GeoSearch", produces = UTF8JSON, notes = Documentation.GEOSEARCH_OPERATION, consumes = UTF8JSON, response = FeatureCollection.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation", response = FeatureCollection.class, responseContainer = "FeatureCollection"), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class) })
public Response geosearchPost(// --------------------------------------------------------
@ApiParam(name = "collection", value = "collection", required = true) @PathParam(value = "collection") String collection, // --------------------------------------------------------
Search search, @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);
}
String includes = search.projection != null ? search.projection.includes : null;
String excludes = search.projection != null ? search.projection.excludes : null;
CheckParams.checkReturnedGeometries(collectionReference, includes, excludes, search.returned_geometries);
Search searchHeader = new Search();
searchHeader.filter = ParamsParser.getFilter(partitionFilter);
exploreService.setValidGeoFilters(collectionReference, search);
exploreService.setValidGeoFilters(collectionReference, searchHeader);
ColumnFilterUtil.assertRequestAllowed(columnFilter, collectionReference, search);
search.projection = ParamsParser.enrichIncludes(search.projection, search.returned_geometries);
MixedRequest request = new MixedRequest();
request.basicRequest = search;
request.headerRequest = searchHeader;
request.columnFilter = ColumnFilterUtil.getCollectionRelatedColumnFilter(columnFilter, collectionReference);
FeatureCollection fc = exploreService.getFeatures(request, collectionReference, (search.form != null && search.form.flat));
return cache(Response.ok(fc), maxagecache);
}
use of io.arlas.server.core.model.request.MixedRequest in project ARLAS-server by gisaia.
the class GeoSearchRESTService method geosearch.
private Response geosearch(CollectionReference collectionReference, Filter filter, String partitionFilter, Optional<String> columnFilter, Boolean flat, String include, String exclude, IntParam size, IntParam from, String sort, String after, String before, Integer maxagecache, String returned_geometries, boolean asShapeFile) throws ArlasException {
CheckParams.checkReturnedGeometries(collectionReference, include, exclude, returned_geometries);
Search search = new Search();
search.filter = filter;
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);
FeatureCollection fc = exploreService.getFeatures(request, collectionReference, (flat != null && flat));
if (asShapeFile) {
File result = toShapefile(fc);
try {
return Response.ok(result).header("Content-Disposition", "attachment; filename=" + result.getName()).build();
} finally {
try {
FileUtils.forceDeleteOnExit(result);
} catch (IOException e) {
}
}
} else {
return cache(Response.ok(fc), maxagecache);
}
}
use of io.arlas.server.core.model.request.MixedRequest in project ARLAS-server by gisaia.
the class GeoSearchRESTService method shapesearchPost.
@Timed
@Path("{collection}/_shapesearch")
@POST
@Produces(ZIPFILE)
@Consumes(UTF8JSON)
@ApiOperation(value = "ShapeSearch", produces = ZIPFILE, notes = Documentation.SHAPESEARCH_OPERATION, consumes = UTF8JSON)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"), @ApiResponse(code = 500, message = "Arlas Server Error.", response = Error.class), @ApiResponse(code = 400, message = "Bad request.", response = Error.class) })
public Response shapesearchPost(// --------------------------------------------------------
@ApiParam(name = "collection", value = "collection", required = true) @PathParam(value = "collection") String collection, // --------------------------------------------------------
Search search, @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);
}
String includes = search.projection != null ? search.projection.includes : null;
String excludes = search.projection != null ? search.projection.excludes : null;
CheckParams.checkReturnedGeometries(collectionReference, includes, excludes, search.returned_geometries);
Search searchHeader = new Search();
searchHeader.filter = ParamsParser.getFilter(partitionFilter);
exploreService.setValidGeoFilters(collectionReference, search);
exploreService.setValidGeoFilters(collectionReference, searchHeader);
ColumnFilterUtil.assertRequestAllowed(columnFilter, collectionReference, search);
search.projection = ParamsParser.enrichIncludes(search.projection, search.returned_geometries);
MixedRequest request = new MixedRequest();
request.basicRequest = search;
request.headerRequest = searchHeader;
request.columnFilter = ColumnFilterUtil.getCollectionRelatedColumnFilter(columnFilter, collectionReference);
FeatureCollection fc = exploreService.getFeatures(request, collectionReference, true);
File result = toShapefile(fc);
try {
return Response.ok(result).header("Content-Disposition", "attachment; filename=" + result.getName()).build();
} finally {
try {
FileUtils.forceDeleteOnExit(result);
} catch (IOException e) {
}
}
}
use of io.arlas.server.core.model.request.MixedRequest in project ARLAS-server by gisaia.
the class SearchRESTService method searchPost.
@Timed
@Path("{collection}/_search")
@POST
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "Search", produces = UTF8JSON, 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 searchPost(@Context UriInfo uriInfo, // --------------------------------------------------------
@ApiParam(name = "collection", value = "collection", required = true) @PathParam(value = "collection") String collection, // --------------------------------------------------------
Search search, @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);
}
String includes = search.projection != null ? search.projection.includes : null;
String excludes = search.projection != null ? search.projection.excludes : null;
Search searchHeader = new Search();
searchHeader.filter = ParamsParser.getFilter(partitionFilter);
exploreService.setValidGeoFilters(collectionReference, search);
exploreService.setValidGeoFilters(collectionReference, searchHeader);
ColumnFilterUtil.assertRequestAllowed(columnFilter, collectionReference, search);
CheckParams.checkReturnedGeometries(collectionReference, includes, excludes, search.returned_geometries);
search.projection = ParamsParser.enrichIncludes(search.projection, search.returned_geometries);
MixedRequest request = new MixedRequest();
request.basicRequest = search;
request.headerRequest = searchHeader;
request.columnFilter = ColumnFilterUtil.getCollectionRelatedColumnFilter(columnFilter, collectionReference);
Hits hits = exploreService.search(request, collectionReference, (search.form != null && Boolean.TRUE.equals(search.form.flat)), uriInfo, "POST");
return cache(Response.ok(hits), maxagecache);
}
use of io.arlas.server.core.model.request.MixedRequest in project ARLAS-server by gisaia.
the class AggregateRESTService method aggregate.
@Timed
@Path("{collection}/_aggregate")
@GET
@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 aggregate(// --------------------------------------------------------
@ApiParam(name = "collection", value = "collection", required = true) @PathParam(value = "collection") String collection, // --------------------------------------------------------
@ApiParam(name = "agg", value = Documentation.AGGREGATION_PARAM_AGG, required = true) @QueryParam(value = "agg") List<String> agg, // --------------------------------------------------------
@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(name = "flat", value = Documentation.FORM_FLAT, defaultValue = "false") @QueryParam(value = "flat") Boolean flat, // --------------------------------------------------------
@ApiParam(value = "max-age-cache") @QueryParam(value = "max-age-cache") Integer maxagecache) throws ArlasException {
long startArlasTime = System.nanoTime();
CollectionReference collectionReference = exploreService.getCollectionReferenceService().getCollectionReference(collection);
if (collectionReference == null) {
throw new NotFoundException(collection);
}
AggregationsRequest aggregationsRequest = new AggregationsRequest();
aggregationsRequest.filter = ParamsParser.getFilter(collectionReference, f, q, dateformat);
aggregationsRequest.aggregations = ParamsParser.getAggregations(collectionReference, agg);
exploreService.setValidGeoFilters(collectionReference, aggregationsRequest);
ColumnFilterUtil.assertRequestAllowed(columnFilter, collectionReference, aggregationsRequest);
AggregationsRequest aggregationsRequestHeader = new AggregationsRequest();
aggregationsRequestHeader.filter = ParamsParser.getFilter(partitionFilter);
MixedRequest request = new MixedRequest();
request.basicRequest = aggregationsRequest;
exploreService.setValidGeoFilters(collectionReference, aggregationsRequestHeader);
request.headerRequest = aggregationsRequestHeader;
request.columnFilter = ColumnFilterUtil.getCollectionRelatedColumnFilter(columnFilter, collectionReference);
AggregationResponse aggregationResponse = getArlasAggregation(request, collectionReference, Boolean.TRUE.equals(flat));
aggregationResponse.totalTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startArlasTime);
return cache(Response.ok(aggregationResponse), maxagecache);
}
Aggregations