use of org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsMetadataImpl in project ddf by codice.
the class WfsSource method buildFeatureFilters.
private void buildFeatureFilters(List<FeatureTypeType> featureTypes, List<String> supportedSpatialOperators, List<QName> supportedGeometryOperands) {
ExtendedWfs wfs = factory.getClient();
// Use local Map for metacardtype registrations and once they are populated with latest
// MetacardTypes, then do actual registration
Map<String, FeatureMetacardType> mcTypeRegs = new HashMap<>();
this.featureTypeFilters.clear();
for (FeatureTypeType featureTypeType : featureTypes) {
String ftSimpleName = featureTypeType.getName().getLocalPart();
if (StringUtils.isNotBlank(forcedFeatureType) && !StringUtils.equals(forcedFeatureType, ftSimpleName)) {
continue;
}
if (mcTypeRegs.containsKey(ftSimpleName)) {
LOGGER.debug("WfsSource {}: MetacardType {} is already registered - skipping to next metacard type", getId(), ftSimpleName);
continue;
}
LOGGER.debug("ftName: {}", ftSimpleName);
try {
XmlSchema schema = wfs.describeFeatureType(new DescribeFeatureTypeRequest(featureTypeType.getName()));
if (schema == null) {
schema = wfs.describeFeatureType(new DescribeFeatureTypeRequest(new QName(featureTypeType.getName().getNamespaceURI(), featureTypeType.getName().getLocalPart(), "")));
}
if (schema != null) {
FeatureMetacardType featureMetacardType = createFeatureMetacardTypeRegistration(featureTypeType, ftSimpleName, schema);
MetacardMapper metacardMapper = getMetacardMapper(featureTypeType.getName());
this.featureTypeFilters.put(featureMetacardType.getFeatureType(), new WfsFilterDelegate(featureMetacardType, metacardMapper, supportedSpatialOperators, supportedGeometryOperands, getCoordinateStrategy(), wildcardChar, singleChar, escapeChar));
mcTypeRegs.put(ftSimpleName, featureMetacardType);
((WfsMetadataImpl<FeatureTypeType>) wfsMetadata).addEntry(featureTypeType);
}
} catch (WfsException | IllegalArgumentException wfse) {
LOGGER.debug(WFS_ERROR_MESSAGE, wfse);
} catch (WebApplicationException wae) {
LOGGER.debug(handleWebApplicationException(wae), wae);
}
}
registerFeatureMetacardTypes(mcTypeRegs);
if (featureTypeFilters.isEmpty()) {
LOGGER.debug("Wfs Source {}: No Feature Type schemas validated.", getId());
}
LOGGER.debug("Wfs Source {}: Number of validated Features = {}", getId(), featureTypeFilters.size());
}
use of org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsMetadataImpl in project ddf by codice.
the class WfsSource method registerFeatureMetacardTypes.
private void registerFeatureMetacardTypes(Map<String, FeatureMetacardType> mcTypeRegs) {
// Unregister all MetacardType services - the DescribeFeatureTypeRequest should
// have returned all of the most current metacard types that will now be registered.
// As Source(s) are added/removed from this instance or to other Source(s)
// that this instance is federated to, the list of metacard types will change.
// This is done here vs. inside the above loop so that minimal time is spent clearing and
// registering the MetacardTypes - the concern is that if this registration is too lengthy
// a query could come in that is handled while the MetacardType registrations are
// in a state of flux.
wfsMetacardTypeRegistry.clear(getId());
List<String> featureNames = new ArrayList<>();
if (!mcTypeRegs.isEmpty()) {
for (FeatureMetacardType metacardType : mcTypeRegs.values()) {
String simpleName = metacardType.getFeatureType().getLocalPart();
featureNames.add(simpleName);
wfsMetacardTypeRegistry.registerMetacardType(metacardType, this.getId(), simpleName);
}
}
WfsMetadataImpl wfsMetadataImpl = new WfsMetadataImpl<>(this::getId, this::getCoordinateOrder, featureNames, FeatureTypeType.class);
this.wfsMetadata.getDescriptors().forEach(wfsMetadataImpl::addEntry);
this.wfsMetadata = wfsMetadataImpl;
}
Aggregations