Search in sources :

Example 1 with WithTransformationsApplied

use of de.ii.xtraplatform.features.domain.transform.WithTransformationsApplied in project ldproxy by interactive-instruments.

the class SchemaGeneratorFeatureOpenApi method getProperty.

@Override
public Optional<Schema<?>> getProperty(FeatureSchema featureSchema, FeatureTypeConfigurationOgcApi collectionData, String propertyName) {
    WithTransformationsApplied schemaFlattener = new WithTransformationsApplied(ImmutableMap.of(PropertyTransformations.WILDCARD, new Builder().flatten(DEFAULT_FLATTENING_SEPARATOR).build()));
    String flatteningSeparator = schemaFlattener.getFlatteningSeparator(featureSchema).orElse(DEFAULT_FLATTENING_SEPARATOR);
    String propertyWithSeparator = Objects.equals(flatteningSeparator, DEFAULT_FLATTENING_SEPARATOR) ? propertyName : propertyName.replaceAll(Pattern.quote(DEFAULT_FLATTENING_SEPARATOR), flatteningSeparator);
    SchemaDeriverOpenApi schemaDeriver = new SchemaDeriverOpenApiCollectionProperties(collectionData.getLabel(), collectionData.getDescription(), entityRegistry.getEntitiesForType(Codelist.class), ImmutableList.of(propertyWithSeparator));
    Schema<?> schema = featureSchema.accept(schemaFlattener).accept(schemaDeriver);
    if (schema.getProperties().containsKey(propertyWithSeparator)) {
        return Optional.ofNullable((Schema<?>) schema.getProperties().get(propertyWithSeparator));
    }
    return Optional.empty();
}
Also used : Codelist(de.ii.xtraplatform.codelists.domain.Codelist) Builder(de.ii.xtraplatform.features.domain.transform.ImmutablePropertyTransformation.Builder) WithTransformationsApplied(de.ii.xtraplatform.features.domain.transform.WithTransformationsApplied)

Example 2 with WithTransformationsApplied

use of de.ii.xtraplatform.features.domain.transform.WithTransformationsApplied in project ldproxy by interactive-instruments.

the class SchemaCacheFlatgeobuf method deriveSchema.

@Override
protected FeatureSchema deriveSchema(FeatureSchema schema, OgcApiDataV2 apiData, FeatureTypeConfigurationOgcApi collectionData) {
    Optional<PropertyTransformations> propertyTransformations = collectionData.getExtension(FlatgeobufConfiguration.class).map(configuration -> (PropertyTransformations) configuration);
    WithTransformationsApplied schemaTransformer = propertyTransformations.map(WithTransformationsApplied::new).orElse(new WithTransformationsApplied());
    Optional<String> separator = schemaTransformer.getFlatteningSeparator(schema);
    if (separator.isEmpty())
        return schema.accept(schemaTransformer);
    int maxMultiplicity = collectionData.getExtension(FlatgeobufConfiguration.class).map(FlatgeobufConfiguration::getMaxMultiplicity).orElse(DEFAULT_MULTIPLICITY);
    FanOutArrays arrayTransformer = new FanOutArrays(separator.get(), maxMultiplicity);
    return schema.accept(schemaTransformer).accept(arrayTransformer).get(0);
}
Also used : PropertyTransformations(de.ii.xtraplatform.features.domain.transform.PropertyTransformations) WithTransformationsApplied(de.ii.xtraplatform.features.domain.transform.WithTransformationsApplied) FlatgeobufConfiguration(de.ii.ogcapi.features.flatgeobuf.domain.FlatgeobufConfiguration) FanOutArrays(de.ii.ogcapi.features.core.domain.FanOutArrays)

Example 3 with WithTransformationsApplied

use of de.ii.xtraplatform.features.domain.transform.WithTransformationsApplied in project ldproxy by interactive-instruments.

the class SchemaCacheReturnables method deriveSchema.

@Override
protected JsonSchemaDocument deriveSchema(FeatureSchema schema, OgcApiDataV2 apiData, FeatureTypeConfigurationOgcApi collectionData, Optional<String> schemaUri, VERSION version) {
    Optional<PropertyTransformations> propertyTransformations = collectionData.getExtension(GeoJsonConfiguration.class).map(geoJsonConfiguration -> (PropertyTransformations) geoJsonConfiguration);
    WithTransformationsApplied schemaTransformer = propertyTransformations.map(WithTransformationsApplied::new).orElse(new WithTransformationsApplied());
    SchemaDeriverReturnables schemaDeriverReturnables = new SchemaDeriverReturnables(version, schemaUri, collectionData.getLabel(), Optional.empty(), codelistSupplier.get());
    return (JsonSchemaDocument) schema.accept(schemaTransformer).accept(schemaDeriverReturnables);
}
Also used : JsonSchemaDocument(de.ii.ogcapi.features.core.domain.JsonSchemaDocument) GeoJsonConfiguration(de.ii.ogcapi.features.geojson.domain.GeoJsonConfiguration) PropertyTransformations(de.ii.xtraplatform.features.domain.transform.PropertyTransformations) SchemaDeriverReturnables(de.ii.ogcapi.features.geojson.domain.SchemaDeriverReturnables) WithTransformationsApplied(de.ii.xtraplatform.features.domain.transform.WithTransformationsApplied)

Example 4 with WithTransformationsApplied

use of de.ii.xtraplatform.features.domain.transform.WithTransformationsApplied in project ldproxy by interactive-instruments.

the class SchemaCacheTileSet method deriveSchema.

@Override
protected JsonSchemaDocument deriveSchema(FeatureSchema schema, OgcApiDataV2 apiData, FeatureTypeConfigurationOgcApi collectionData, Optional<String> schemaUri, VERSION version) {
    WithTransformationsApplied schemaFlattener = new WithTransformationsApplied(ImmutableMap.of(PropertyTransformations.WILDCARD, new Builder().flatten(DEFAULT_FLATTENING_SEPARATOR).build()));
    SchemaDeriverReturnables schemaDeriverReturnables = new SchemaDeriverReturnables(version, schemaUri, collectionData.getLabel(), Optional.empty(), codelistSupplier.get());
    return (JsonSchemaDocument) schema.accept(schemaFlattener).accept(schemaDeriverReturnables);
}
Also used : JsonSchemaDocument(de.ii.ogcapi.features.core.domain.JsonSchemaDocument) SchemaDeriverReturnables(de.ii.ogcapi.features.geojson.domain.SchemaDeriverReturnables) Builder(de.ii.xtraplatform.features.domain.transform.ImmutablePropertyTransformation.Builder) WithTransformationsApplied(de.ii.xtraplatform.features.domain.transform.WithTransformationsApplied)

Example 5 with WithTransformationsApplied

use of de.ii.xtraplatform.features.domain.transform.WithTransformationsApplied in project ldproxy by interactive-instruments.

the class SchemaCacheSortables method deriveSchema.

@Override
protected JsonSchemaDocument deriveSchema(FeatureSchema schema, OgcApiDataV2 apiData, FeatureTypeConfigurationOgcApi collectionData, Optional<String> schemaUri, VERSION version) {
    List<String> sortables = collectionData.getExtension(SortingConfiguration.class).map(SortingConfiguration::getSortables).orElse(ImmutableList.of());
    WithTransformationsApplied schemaFlattener = new WithTransformationsApplied(ImmutableMap.of(PropertyTransformations.WILDCARD, new Builder().flatten(DEFAULT_FLATTENING_SEPARATOR).build()));
    String flatteningSeparator = schemaFlattener.getFlatteningSeparator(schema).orElse(DEFAULT_FLATTENING_SEPARATOR);
    List<String> sortablesWithSeparator = Objects.equals(flatteningSeparator, DEFAULT_FLATTENING_SEPARATOR) ? sortables : sortables.stream().map(sortable -> sortable.replaceAll(Pattern.quote(DEFAULT_FLATTENING_SEPARATOR), flatteningSeparator)).collect(Collectors.toList());
    SchemaDeriverCollectionProperties schemaDeriverCollectionProperties = new SchemaDeriverCollectionProperties(version, schemaUri, collectionData.getLabel(), Optional.empty(), ImmutableList.of(), sortablesWithSeparator);
    return (JsonSchemaDocument) schema.accept(schemaFlattener).accept(schemaDeriverCollectionProperties);
}
Also used : SchemaDeriverCollectionProperties(de.ii.ogcapi.features.core.domain.SchemaDeriverCollectionProperties) JsonSchemaDocument(de.ii.ogcapi.features.core.domain.JsonSchemaDocument) Builder(de.ii.xtraplatform.features.domain.transform.ImmutablePropertyTransformation.Builder) WithTransformationsApplied(de.ii.xtraplatform.features.domain.transform.WithTransformationsApplied)

Aggregations

WithTransformationsApplied (de.ii.xtraplatform.features.domain.transform.WithTransformationsApplied)7 JsonSchemaDocument (de.ii.ogcapi.features.core.domain.JsonSchemaDocument)5 Builder (de.ii.xtraplatform.features.domain.transform.ImmutablePropertyTransformation.Builder)4 SchemaDeriverReturnables (de.ii.ogcapi.features.geojson.domain.SchemaDeriverReturnables)3 SchemaDeriverCollectionProperties (de.ii.ogcapi.features.core.domain.SchemaDeriverCollectionProperties)2 PropertyTransformations (de.ii.xtraplatform.features.domain.transform.PropertyTransformations)2 FanOutArrays (de.ii.ogcapi.features.core.domain.FanOutArrays)1 FeaturesCoreConfiguration (de.ii.ogcapi.features.core.domain.FeaturesCoreConfiguration)1 FlatgeobufConfiguration (de.ii.ogcapi.features.flatgeobuf.domain.FlatgeobufConfiguration)1 GeoJsonConfiguration (de.ii.ogcapi.features.geojson.domain.GeoJsonConfiguration)1 Codelist (de.ii.xtraplatform.codelists.domain.Codelist)1