Search in sources :

Example 1 with FeaturesCoreConfiguration

use of de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration in project ldproxy by interactive-instruments.

the class TileProviderFeatures method getQueryInput.

@Override
@JsonIgnore
@Value.Derived
public QueryInput getQueryInput(OgcApiDataV2 apiData, URICustomizer uriCustomizer, Map<String, String> queryParameters, List<OgcApiQueryParameter> allowedParameters, QueryInput genericInput, Tile tile) {
    if (!tile.getFeatureProvider().map(FeatureProvider2::supportsQueries).orElse(false)) {
        throw new IllegalStateException("Tile cannot be generated. The feature provider does not support feature queries.");
    }
    TileFormatExtension outputFormat = tile.getOutputFormat();
    List<String> collections = tile.getCollectionIds();
    if (collections.isEmpty()) {
        return new ImmutableQueryInputTileEmpty.Builder().from(genericInput).tile(tile).build();
    }
    if (!(outputFormat instanceof TileFormatWithQuerySupportExtension))
        throw new RuntimeException(String.format("Unexpected tile format without query support. Found: %s", outputFormat.getClass().getSimpleName()));
    // first execute the information that is passed as processing parameters (e.g., "properties")
    Map<String, Object> processingParameters = new HashMap<>();
    for (OgcApiQueryParameter parameter : allowedParameters) {
        processingParameters = parameter.transformContext(null, processingParameters, queryParameters, apiData);
    }
    if (tile.isDatasetTile()) {
        if (!outputFormat.canMultiLayer() && collections.size() > 1)
            throw new NotAcceptableException("The requested tile format supports only a single layer. Please select only a single collection.");
        Map<String, Tile> singleLayerTileMap = collections.stream().collect(ImmutableMap.toImmutableMap(collectionId -> collectionId, collectionId -> new ImmutableTile.Builder().from(tile).collectionIds(ImmutableList.of(collectionId)).isDatasetTile(false).build()));
        Map<String, FeatureQuery> queryMap = collections.stream().filter(collectionId -> {
            Optional<FeaturesCoreConfiguration> featuresConfiguration = apiData.getCollections().get(collectionId).getExtension(FeaturesCoreConfiguration.class);
            return featuresConfiguration.isPresent() && featuresConfiguration.get().getQueryables().isPresent() && !featuresConfiguration.get().getQueryables().get().getSpatial().isEmpty();
        }).collect(ImmutableMap.toImmutableMap(collectionId -> collectionId, collectionId -> {
            String featureTypeId = apiData.getCollections().get(collectionId).getExtension(FeaturesCoreConfiguration.class).map(cfg -> cfg.getFeatureType().orElse(collectionId)).orElse(collectionId);
            TilesConfiguration layerConfiguration = apiData.getExtension(TilesConfiguration.class, collectionId).orElseThrow();
            FeatureQuery query = ((TileFormatWithQuerySupportExtension) outputFormat).getQuery(singleLayerTileMap.get(collectionId), allowedParameters, queryParameters, layerConfiguration, uriCustomizer);
            return ImmutableFeatureQuery.builder().from(query).type(featureTypeId).build();
        }));
        FeaturesCoreConfiguration coreConfiguration = apiData.getExtension(FeaturesCoreConfiguration.class).orElseThrow();
        return new ImmutableQueryInputTileMultiLayer.Builder().from(genericInput).tile(tile).singleLayerTileMap(singleLayerTileMap).queryMap(queryMap).processingParameters(processingParameters).defaultCrs(apiData.getExtension(FeaturesCoreConfiguration.class).map(FeaturesCoreConfiguration::getDefaultEpsgCrs).orElseThrow()).build();
    } else {
        String collectionId = tile.getCollectionId();
        FeatureTypeConfigurationOgcApi featureType = apiData.getCollectionData(collectionId).orElseThrow();
        TilesConfiguration layerConfiguration = apiData.getExtension(TilesConfiguration.class, collectionId).orElseThrow();
        FeatureQuery query = ((TileFromFeatureQuery) outputFormat).getQuery(tile, allowedParameters, queryParameters, layerConfiguration, uriCustomizer);
        FeaturesCoreConfiguration coreConfiguration = featureType.getExtension(FeaturesCoreConfiguration.class).orElseThrow();
        return new ImmutableQueryInputTileSingleLayer.Builder().from(genericInput).tile(tile).query(query).processingParameters(processingParameters).defaultCrs(featureType.getExtension(FeaturesCoreConfiguration.class).map(FeaturesCoreConfiguration::getDefaultEpsgCrs).orElseThrow()).build();
    }
}
Also used : FeatureQuery(de.ii.xtraplatform.features.domain.FeatureQuery) TileFormatWithQuerySupportExtension(de.ii.ogcapi.tiles.domain.TileFormatWithQuerySupportExtension) TileFromFeatureQuery(de.ii.ogcapi.tiles.domain.TileFromFeatureQuery) QueryInput(de.ii.ogcapi.foundation.domain.QueryInput) HashMap(java.util.HashMap) TilesConfiguration(de.ii.ogcapi.tiles.domain.TilesConfiguration) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) Value(org.immutables.value.Value) PredefinedFilter(de.ii.ogcapi.tiles.domain.PredefinedFilter) SeedingOptions(de.ii.ogcapi.tiles.domain.SeedingOptions) Rule(de.ii.ogcapi.tiles.domain.Rule) Map(java.util.Map) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) Tile(de.ii.ogcapi.tiles.domain.Tile) Nullable(javax.annotation.Nullable) ImmutableQueryInputTileSingleLayer(de.ii.ogcapi.tiles.domain.ImmutableQueryInputTileSingleLayer) OgcApiQueryParameter(de.ii.ogcapi.foundation.domain.OgcApiQueryParameter) NotAcceptableException(javax.ws.rs.NotAcceptableException) ImmutableMap(com.google.common.collect.ImmutableMap) MinMax(de.ii.ogcapi.tiles.domain.MinMax) URICustomizer(de.ii.ogcapi.foundation.domain.URICustomizer) Maps(com.google.common.collect.Maps) FeatureProvider2(de.ii.xtraplatform.features.domain.FeatureProvider2) FeaturesCoreConfiguration(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration) Objects(java.util.Objects) ImmutableQueryInputTileEmpty(de.ii.ogcapi.tiles.domain.ImmutableQueryInputTileEmpty) List(java.util.List) OgcApiDataV2(de.ii.ogcapi.foundation.domain.OgcApiDataV2) TileFormatExtension(de.ii.ogcapi.tiles.domain.TileFormatExtension) TileProvider(de.ii.ogcapi.tiles.domain.TileProvider) ImmutableFeatureQuery(de.ii.xtraplatform.features.domain.ImmutableFeatureQuery) Optional(java.util.Optional) ImmutableTile(de.ii.ogcapi.tiles.domain.ImmutableTile) JsonDeserialize(com.fasterxml.jackson.databind.annotation.JsonDeserialize) FeatureTypeConfigurationOgcApi(de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi) ImmutableQueryInputTileMultiLayer(de.ii.ogcapi.tiles.domain.ImmutableQueryInputTileMultiLayer) HashMap(java.util.HashMap) FeatureProvider2(de.ii.xtraplatform.features.domain.FeatureProvider2) ImmutableQueryInputTileMultiLayer(de.ii.ogcapi.tiles.domain.ImmutableQueryInputTileMultiLayer) TilesConfiguration(de.ii.ogcapi.tiles.domain.TilesConfiguration) FeatureQuery(de.ii.xtraplatform.features.domain.FeatureQuery) TileFromFeatureQuery(de.ii.ogcapi.tiles.domain.TileFromFeatureQuery) ImmutableFeatureQuery(de.ii.xtraplatform.features.domain.ImmutableFeatureQuery) ImmutableQueryInputTileEmpty(de.ii.ogcapi.tiles.domain.ImmutableQueryInputTileEmpty) FeatureTypeConfigurationOgcApi(de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi) FeaturesCoreConfiguration(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration) TileFromFeatureQuery(de.ii.ogcapi.tiles.domain.TileFromFeatureQuery) TileFormatExtension(de.ii.ogcapi.tiles.domain.TileFormatExtension) Optional(java.util.Optional) Tile(de.ii.ogcapi.tiles.domain.Tile) ImmutableTile(de.ii.ogcapi.tiles.domain.ImmutableTile) OgcApiQueryParameter(de.ii.ogcapi.foundation.domain.OgcApiQueryParameter) NotAcceptableException(javax.ws.rs.NotAcceptableException) TileFormatWithQuerySupportExtension(de.ii.ogcapi.tiles.domain.TileFormatWithQuerySupportExtension) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Example 2 with FeaturesCoreConfiguration

use of de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration in project ldproxy by interactive-instruments.

the class FeaturesFormatHtml method getFeatureEncoder.

@Override
public Optional<FeatureTokenEncoder<?>> getFeatureEncoder(FeatureTransformationContext transformationContext, Optional<Locale> language) {
    OgcApi api = transformationContext.getApi();
    OgcApiDataV2 apiData = transformationContext.getApiData();
    String collectionName = transformationContext.getCollectionId();
    String staticUrlPrefix = transformationContext.getOgcApiRequest().getStaticUrlPrefix();
    URICustomizer uriCustomizer = transformationContext.getOgcApiRequest().getUriCustomizer();
    FeatureCollectionView featureTypeDataset;
    boolean bare = transformationContext.getOgcApiRequest().getUriCustomizer().getQueryParams().stream().anyMatch(nameValuePair -> nameValuePair.getName().equals("bare") && nameValuePair.getValue().equals("true"));
    if (transformationContext.isFeatureCollection()) {
        FeatureTypeConfigurationOgcApi collectionData = apiData.getCollections().get(collectionName);
        Integer htmlMaxLimit = collectionData.getExtension(FeaturesHtmlConfiguration.class).map(FeaturesHtmlConfiguration::getMaximumPageSize).orElse(null);
        if (Objects.nonNull(htmlMaxLimit) && htmlMaxLimit < transformationContext.getLimit())
            throw new IllegalArgumentException(String.format("The HTML output has a maximum page size (parameter 'limit') of %d. Found: %d", htmlMaxLimit, transformationContext.getLimit()));
        Optional<FeaturesCoreConfiguration> featuresCoreConfiguration = collectionData.getExtension(FeaturesCoreConfiguration.class);
        List<String> queryables = featuresCoreConfiguration.map(FeaturesCoreConfiguration::getQOrOtherFilterParameters).orElse(ImmutableList.of());
        Map<String, String> filterableFields = transformationContext.getFeatureSchema().map(schema -> schema.accept(SCHEMA_FLATTENER)).map(schema -> schema.getProperties().stream().filter(property -> queryables.contains(property.getName())).map(property -> new SimpleImmutableEntry<>(property.getName(), property.getLabel().orElse(property.getName()))).collect(ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue))).orElse(ImmutableMap.of());
        featureTypeDataset = createFeatureCollectionView(api, apiData.getCollections().get(collectionName), uriCustomizer.copy(), filterableFields, staticUrlPrefix, bare, language, isNoIndexEnabledForApi(apiData), getMapPosition(apiData, collectionName), getGeometryProperties(apiData, collectionName));
        addDatasetNavigation(featureTypeDataset, apiData.getLabel(), apiData.getCollections().get(collectionName).getLabel(), transformationContext.getLinks(), uriCustomizer.copy(), language, apiData.getSubPath());
    } else {
        featureTypeDataset = createFeatureDetailsView(api, apiData.getCollections().get(collectionName), uriCustomizer.copy(), transformationContext.getLinks(), apiData.getLabel(), uriCustomizer.getLastPathSegment(), staticUrlPrefix, language, isNoIndexEnabledForApi(apiData), apiData.getSubPath(), getMapPosition(apiData, collectionName), getGeometryProperties(apiData, collectionName));
    }
    ImmutableFeatureTransformationContextHtml transformationContextHtml = ImmutableFeatureTransformationContextHtml.builder().from(transformationContext).collectionView(featureTypeDataset).codelists(entityRegistry.getEntitiesForType(Codelist.class).stream().collect(Collectors.toMap(c -> c.getId(), c -> c))).mustacheRenderer(mustacheRenderer).i18n(i18n).language(language).build();
    return Optional.of(new FeatureEncoderHtml(transformationContextHtml));
}
Also used : ImmutableApiMediaTypeContent(de.ii.ogcapi.foundation.domain.ImmutableApiMediaTypeContent) MustacheRenderer(de.ii.xtraplatform.web.domain.MustacheRenderer) URISyntaxException(java.net.URISyntaxException) Link(de.ii.ogcapi.foundation.domain.Link) ImmutableValidationResult(de.ii.xtraplatform.store.domain.entities.ImmutableValidationResult) MODE(de.ii.xtraplatform.store.domain.entities.ValidationResult.MODE) ApiMediaType(de.ii.ogcapi.foundation.domain.ApiMediaType) ImmutableApiMediaType(de.ii.ogcapi.foundation.domain.ImmutableApiMediaType) MediaType(javax.ws.rs.core.MediaType) Builder(de.ii.xtraplatform.features.domain.transform.ImmutablePropertyTransformation.Builder) Locale(java.util.Locale) Map(java.util.Map) URI(java.net.URI) FeatureSchema(de.ii.xtraplatform.features.domain.FeatureSchema) HtmlConfiguration(de.ii.ogcapi.html.domain.HtmlConfiguration) WithTransformationsApplied(de.ii.xtraplatform.features.domain.transform.WithTransformationsApplied) ApiMediaTypeContent(de.ii.ogcapi.foundation.domain.ApiMediaTypeContent) FeaturesCoreProviders(de.ii.ogcapi.features.core.domain.FeaturesCoreProviders) ImmutableMap(com.google.common.collect.ImmutableMap) FeatureTokenEncoder(de.ii.xtraplatform.features.domain.FeatureTokenEncoder) Collection(java.util.Collection) OgcApi(de.ii.ogcapi.foundation.domain.OgcApi) Codelist(de.ii.xtraplatform.codelists.domain.Codelist) Set(java.util.Set) Collectors(java.util.stream.Collectors) PropertyTransformation(de.ii.xtraplatform.features.domain.transform.PropertyTransformation) Objects(java.util.Objects) MapClient(de.ii.ogcapi.html.domain.MapClient) List(java.util.List) StringTemplateFilters(de.ii.xtraplatform.strings.domain.StringTemplateFilters) StringSchema(io.swagger.v3.oas.models.media.StringSchema) OgcApiDataV2(de.ii.ogcapi.foundation.domain.OgcApiDataV2) Entry(java.util.Map.Entry) Optional(java.util.Optional) FeaturesCoreValidation(de.ii.ogcapi.features.core.domain.FeaturesCoreValidation) FeatureTypeConfigurationOgcApi(de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi) EntityRegistry(de.ii.xtraplatform.store.domain.entities.EntityRegistry) ServicesContext(de.ii.xtraplatform.services.domain.ServicesContext) ItemTypeSpecificConformanceClass(de.ii.ogcapi.features.core.domain.ItemTypeSpecificConformanceClass) ExtensionConfiguration(de.ii.ogcapi.foundation.domain.ExtensionConfiguration) PropertyTransformations(de.ii.xtraplatform.features.domain.transform.PropertyTransformations) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) Singleton(javax.inject.Singleton) AutoBind(com.github.azahnen.dagger.annotations.AutoBind) POSITION(de.ii.ogcapi.features.html.domain.FeaturesHtmlConfiguration.POSITION) MessageFormat(java.text.MessageFormat) Inject(javax.inject.Inject) ImmutableList(com.google.common.collect.ImmutableList) ValidationResult(de.ii.xtraplatform.store.domain.entities.ValidationResult) Schema(io.swagger.v3.oas.models.media.Schema) NavigationDTO(de.ii.ogcapi.html.domain.NavigationDTO) FeaturesHtmlConfiguration(de.ii.ogcapi.features.html.domain.FeaturesHtmlConfiguration) FeatureFormatExtension(de.ii.ogcapi.features.core.domain.FeatureFormatExtension) I18n(de.ii.ogcapi.foundation.domain.I18n) URICustomizer(de.ii.ogcapi.foundation.domain.URICustomizer) FeaturesCoreConfiguration(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration) AbstractMap(java.util.AbstractMap) DEFAULT_FLATTENING_SEPARATOR(de.ii.ogcapi.features.core.domain.SchemaGeneratorFeatureOpenApi.DEFAULT_FLATTENING_SEPARATOR) FeatureTransformationContext(de.ii.ogcapi.features.core.domain.FeatureTransformationContext) Metadata(de.ii.ogcapi.foundation.domain.Metadata) Comparator(java.util.Comparator) Codelist(de.ii.xtraplatform.codelists.domain.Codelist) OgcApi(de.ii.ogcapi.foundation.domain.OgcApi) FeatureTypeConfigurationOgcApi(de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi) URICustomizer(de.ii.ogcapi.foundation.domain.URICustomizer) OgcApiDataV2(de.ii.ogcapi.foundation.domain.OgcApiDataV2) FeatureTypeConfigurationOgcApi(de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) FeaturesCoreConfiguration(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration)

Example 3 with FeaturesCoreConfiguration

use of de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration in project ldproxy by interactive-instruments.

the class EndpointFeatures method getItems.

@GET
@Path("/{collectionId}/items")
public Response getItems(@Auth Optional<User> optionalUser, @Context OgcApi api, @Context ApiRequestContext requestContext, @Context UriInfo uriInfo, @PathParam("collectionId") String collectionId) {
    checkCollectionExists(api.getData(), collectionId);
    FeatureTypeConfigurationOgcApi collectionData = api.getData().getCollections().get(collectionId);
    FeaturesCoreConfiguration coreConfiguration = collectionData.getExtension(FeaturesCoreConfiguration.class).filter(ExtensionConfiguration::isEnabled).filter(cfg -> cfg.getItemType().orElse(FeaturesCoreConfiguration.ItemType.feature) != FeaturesCoreConfiguration.ItemType.unknown).orElseThrow(() -> new NotFoundException(MessageFormat.format("Features are not supported in API ''{0}'', collection ''{1}''.", api.getId(), collectionId)));
    int minimumPageSize = coreConfiguration.getMinimumPageSize();
    int defaultPageSize = coreConfiguration.getDefaultPageSize();
    int maxPageSize = coreConfiguration.getMaximumPageSize();
    boolean showsFeatureSelfLink = coreConfiguration.getShowsFeatureSelfLink();
    List<OgcApiQueryParameter> allowedParameters = getQueryParameters(extensionRegistry, api.getData(), "/collections/{collectionId}/items", collectionId);
    FeatureQuery query = ogcApiFeaturesQuery.requestToFeatureQuery(api.getData(), collectionData, coreConfiguration.getDefaultEpsgCrs(), coreConfiguration.getCoordinatePrecision(), minimumPageSize, defaultPageSize, maxPageSize, toFlatMap(uriInfo.getQueryParameters()), allowedParameters);
    FeaturesCoreQueriesHandler.QueryInputFeatures queryInput = new ImmutableQueryInputFeatures.Builder().from(getGenericQueryInput(api.getData())).collectionId(collectionId).query(query).featureProvider(providers.getFeatureProviderOrThrow(api.getData(), collectionData)).defaultCrs(coreConfiguration.getDefaultEpsgCrs()).defaultPageSize(Optional.of(defaultPageSize)).showsFeatureSelfLink(showsFeatureSelfLink).build();
    return queryHandler.handle(FeaturesCoreQueriesHandlerImpl.Query.FEATURES, queryInput, requestContext);
}
Also used : User(de.ii.xtraplatform.auth.domain.User) Path(javax.ws.rs.Path) LoggerFactory(org.slf4j.LoggerFactory) ImmutableValidationResult(de.ii.xtraplatform.store.domain.entities.ImmutableValidationResult) MODE(de.ii.xtraplatform.store.domain.entities.ValidationResult.MODE) EndpointSubCollection(de.ii.ogcapi.collections.domain.EndpointSubCollection) Map(java.util.Map) ImmutableOgcApiResourceData(de.ii.ogcapi.collections.domain.ImmutableOgcApiResourceData) SchemaGeneratorOpenApi(de.ii.ogcapi.features.core.domain.SchemaGeneratorOpenApi) ExtensionRegistry(de.ii.ogcapi.foundation.domain.ExtensionRegistry) ApiOperation(de.ii.ogcapi.foundation.domain.ApiOperation) FeatureSchema(de.ii.xtraplatform.features.domain.FeatureSchema) ApiRequestContext(de.ii.ogcapi.foundation.domain.ApiRequestContext) ImmutableQueryInputFeature(de.ii.ogcapi.features.core.domain.ImmutableQueryInputFeature) Context(javax.ws.rs.core.Context) FeaturesCoreProviders(de.ii.ogcapi.features.core.domain.FeaturesCoreProviders) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) OgcApi(de.ii.ogcapi.foundation.domain.OgcApi) Codelist(de.ii.xtraplatform.codelists.domain.Codelist) HttpMethods(de.ii.ogcapi.foundation.domain.HttpMethods) Set(java.util.Set) Collectors(java.util.stream.Collectors) NotFoundException(javax.ws.rs.NotFoundException) ImmutableApiEndpointDefinition(de.ii.ogcapi.foundation.domain.ImmutableApiEndpointDefinition) PropertyTransformation(de.ii.xtraplatform.features.domain.transform.PropertyTransformation) Objects(java.util.Objects) ApiEndpointDefinition(de.ii.ogcapi.foundation.domain.ApiEndpointDefinition) List(java.util.List) ImmutableQueryInputFeatures(de.ii.ogcapi.features.core.domain.ImmutableQueryInputFeatures) Stream(java.util.stream.Stream) Response(javax.ws.rs.core.Response) ImmutableQueryParameterTemplateQueryable(de.ii.ogcapi.collections.domain.ImmutableQueryParameterTemplateQueryable) OgcApiDataV2(de.ii.ogcapi.foundation.domain.OgcApiDataV2) Optional(java.util.Optional) FormatExtension(de.ii.ogcapi.foundation.domain.FormatExtension) UriInfo(javax.ws.rs.core.UriInfo) FeaturesCoreValidation(de.ii.ogcapi.features.core.domain.FeaturesCoreValidation) FeatureTypeConfigurationOgcApi(de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi) EntityRegistry(de.ii.xtraplatform.store.domain.entities.EntityRegistry) FeatureQuery(de.ii.xtraplatform.features.domain.FeatureQuery) PathParam(javax.ws.rs.PathParam) ExtensionConfiguration(de.ii.ogcapi.foundation.domain.ExtensionConfiguration) GET(javax.ws.rs.GET) OgcApiPathParameter(de.ii.ogcapi.foundation.domain.OgcApiPathParameter) Auth(io.dropwizard.auth.Auth) Singleton(javax.inject.Singleton) AutoBind(com.github.azahnen.dagger.annotations.AutoBind) MessageFormat(java.text.MessageFormat) FeaturesQuery(de.ii.ogcapi.features.core.domain.FeaturesQuery) Inject(javax.inject.Inject) ImmutableList(com.google.common.collect.ImmutableList) ValidationResult(de.ii.xtraplatform.store.domain.entities.ValidationResult) Schema(io.swagger.v3.oas.models.media.Schema) OgcApiQueryParameter(de.ii.ogcapi.foundation.domain.OgcApiQueryParameter) Logger(org.slf4j.Logger) FeatureFormatExtension(de.ii.ogcapi.features.core.domain.FeatureFormatExtension) FeaturesCollectionQueryables(de.ii.ogcapi.features.core.domain.FeaturesCollectionQueryables) ParameterExtension(de.ii.ogcapi.foundation.domain.ParameterExtension) FeaturesCoreConfiguration(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration) AbstractMap(java.util.AbstractMap) FeaturesCoreQueriesHandler(de.ii.ogcapi.features.core.domain.FeaturesCoreQueriesHandler) Comparator(java.util.Comparator) NotFoundException(javax.ws.rs.NotFoundException) FeatureQuery(de.ii.xtraplatform.features.domain.FeatureQuery) FeaturesCoreQueriesHandler(de.ii.ogcapi.features.core.domain.FeaturesCoreQueriesHandler) OgcApiQueryParameter(de.ii.ogcapi.foundation.domain.OgcApiQueryParameter) FeatureTypeConfigurationOgcApi(de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi) FeaturesCoreConfiguration(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration) ExtensionConfiguration(de.ii.ogcapi.foundation.domain.ExtensionConfiguration) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 4 with FeaturesCoreConfiguration

use of de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration in project ldproxy by interactive-instruments.

the class QueryParameterLimitFeatures method getSchema.

@Override
public Schema getSchema(OgcApiDataV2 apiData) {
    int apiHashCode = apiData.hashCode();
    if (!schemaMap.containsKey(apiHashCode))
        schemaMap.put(apiHashCode, new ConcurrentHashMap<>());
    String collectionId = "*";
    if (!schemaMap.get(apiHashCode).containsKey(collectionId)) {
        Schema schema = new IntegerSchema();
        Optional<Integer> minimumPageSize = apiData.getExtension(FeaturesCoreConfiguration.class).map(FeaturesCoreConfiguration::getMinimumPageSize);
        if (minimumPageSize.isPresent())
            schema.minimum(BigDecimal.valueOf(minimumPageSize.get()));
        Optional<Integer> maxPageSize = apiData.getExtension(FeaturesCoreConfiguration.class).map(FeaturesCoreConfiguration::getMaximumPageSize);
        if (maxPageSize.isPresent())
            schema.maximum(BigDecimal.valueOf(maxPageSize.get()));
        Optional<Integer> defaultPageSize = apiData.getExtension(FeaturesCoreConfiguration.class).map(FeaturesCoreConfiguration::getDefaultPageSize);
        if (defaultPageSize.isPresent())
            schema.setDefault(BigDecimal.valueOf(defaultPageSize.get()));
        schemaMap.get(apiHashCode).put(collectionId, schema);
    }
    return schemaMap.get(apiHashCode).get(collectionId);
}
Also used : IntegerSchema(io.swagger.v3.oas.models.media.IntegerSchema) Schema(io.swagger.v3.oas.models.media.Schema) IntegerSchema(io.swagger.v3.oas.models.media.IntegerSchema) FeaturesCoreConfiguration(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 5 with FeaturesCoreConfiguration

use of de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration in project ldproxy by interactive-instruments.

the class QueryParameterLimitFeatures method validateSchema.

@Override
public Optional<String> validateSchema(OgcApiDataV2 apiData, Optional<String> collectionId, List<String> values) {
    if (values.size() != 1)
        return Optional.of(String.format("Parameter value '%s' is invalid for parameter '%s': The must be a single value.", values, getName()));
    int limit;
    try {
        limit = Integer.parseInt(values.get(0));
    } catch (NumberFormatException exception) {
        return Optional.of(String.format("Parameter value '%s' is invalid for parameter '%s': The value is not an integer.", values, getName()));
    }
    ExtendableConfiguration context = collectionId.isPresent() ? apiData.getCollections().get(collectionId.get()) : apiData;
    Optional<Integer> minimumPageSize = context.getExtension(FeaturesCoreConfiguration.class).map(FeaturesCoreConfiguration::getMinimumPageSize);
    if (minimumPageSize.isPresent() && limit < minimumPageSize.get())
        return Optional.of(String.format("Parameter value '%s' is invalid for parameter '%s': The value is smaller than the minimum value '%d'.", values, getName(), minimumPageSize.get()));
    return Optional.empty();
}
Also used : ExtendableConfiguration(de.ii.ogcapi.foundation.domain.ExtendableConfiguration) FeaturesCoreConfiguration(de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration)

Aggregations

FeaturesCoreConfiguration (de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration)19 FeatureTypeConfigurationOgcApi (de.ii.ogcapi.foundation.domain.FeatureTypeConfigurationOgcApi)12 Optional (java.util.Optional)11 AutoBind (com.github.azahnen.dagger.annotations.AutoBind)10 ImmutableList (com.google.common.collect.ImmutableList)10 ImmutableMap (com.google.common.collect.ImmutableMap)10 OgcApiDataV2 (de.ii.ogcapi.foundation.domain.OgcApiDataV2)10 List (java.util.List)10 Map (java.util.Map)10 Inject (javax.inject.Inject)10 Singleton (javax.inject.Singleton)10 FeaturesCoreProviders (de.ii.ogcapi.features.core.domain.FeaturesCoreProviders)9 ExtensionConfiguration (de.ii.ogcapi.foundation.domain.ExtensionConfiguration)9 Objects (java.util.Objects)9 Collectors (java.util.stream.Collectors)9 OgcApi (de.ii.ogcapi.foundation.domain.OgcApi)8 FeatureQuery (de.ii.xtraplatform.features.domain.FeatureQuery)8 OgcApiQueryParameter (de.ii.ogcapi.foundation.domain.OgcApiQueryParameter)7 Schema (io.swagger.v3.oas.models.media.Schema)7 FeatureFormatExtension (de.ii.ogcapi.features.core.domain.FeatureFormatExtension)6