use of de.ii.xtraplatform.features.domain.FeatureQueries in project ldproxy by interactive-instruments.
the class CapabilityFeaturesCore method onStartup.
@Override
public ValidationResult onStartup(OgcApi api, MODE apiValidation) {
// TODO: add capability to periodically reinitialize metadata from the feature data (to account
// for lost notifications,
// because extent changes because of deletes are not taken into account, etc.)
// initialize dynamic collection metadata
OgcApiDataV2 apiData = api.getData();
apiData.getCollections().entrySet().forEach(entry -> {
final String collectionId = entry.getKey();
final Optional<CollectionExtent> optionalExtent = apiData.getExtent(collectionId);
Optional<BoundingBox> optionalBoundingBox;
if (optionalExtent.isEmpty() || optionalExtent.get().getSpatialComputed().orElse(true)) {
optionalBoundingBox = computeBbox(apiData, collectionId);
} else {
optionalBoundingBox = optionalExtent.get().getSpatial();
}
optionalBoundingBox.ifPresent(bbox -> api.updateSpatialExtent(collectionId, bbox));
Optional<TemporalExtent> optionalTemporalExtent;
if (optionalExtent.isEmpty() || optionalExtent.get().getTemporalComputed().orElse(true)) {
optionalTemporalExtent = computeInterval(apiData, collectionId);
} else {
optionalTemporalExtent = optionalExtent.get().getTemporal();
}
optionalTemporalExtent.ifPresent(interval -> api.updateTemporalExtent(collectionId, interval));
final FeatureTypeConfigurationOgcApi collectionData = apiData.getCollections().get(collectionId);
final Optional<FeatureProvider2> provider = providers.getFeatureProvider(apiData, collectionData);
if (provider.map(FeatureProvider2::supportsQueries).orElse(false)) {
final String featureTypeId = collectionData.getExtension(FeaturesCoreConfiguration.class).map(cfg -> cfg.getFeatureType().orElse(collectionId)).orElse(collectionId);
final long count = ((FeatureQueries) provider.get()).getFeatureCount(featureTypeId);
api.updateItemCount(collectionId, count);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Number of items in collection '{}': {}", collectionId, count);
}
}
});
providers.getFeatureProvider(apiData).ifPresent(provider -> provider.getFeatureChangeHandler().addListener(onFeatureChange(api)));
return ValidationResult.of();
}
Aggregations