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();
}
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);
}
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);
}
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);
}
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);
}
Aggregations