Search in sources :

Example 1 with WfsMetadataImpl

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());
}
Also used : FeatureTypeType(net.opengis.wfs.v_1_1_0.FeatureTypeType) WebApplicationException(javax.ws.rs.WebApplicationException) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) WfsMetadataImpl(org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsMetadataImpl) XmlSchema(org.apache.ws.commons.schema.XmlSchema) WfsException(org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsException) DescribeFeatureTypeRequest(org.codice.ddf.spatial.ogc.wfs.v110.catalog.common.DescribeFeatureTypeRequest) FeatureMetacardType(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType) MetacardMapper(org.codice.ddf.spatial.ogc.wfs.catalog.mapper.MetacardMapper)

Example 2 with WfsMetadataImpl

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;
}
Also used : WfsMetadataImpl(org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsMetadataImpl) ArrayList(java.util.ArrayList) FeatureMetacardType(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)

Aggregations

FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)2 WfsMetadataImpl (org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsMetadataImpl)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 QName (javax.xml.namespace.QName)1 FeatureTypeType (net.opengis.wfs.v_1_1_0.FeatureTypeType)1 XmlSchema (org.apache.ws.commons.schema.XmlSchema)1 WfsException (org.codice.ddf.spatial.ogc.wfs.catalog.common.WfsException)1 MetacardMapper (org.codice.ddf.spatial.ogc.wfs.catalog.mapper.MetacardMapper)1 DescribeFeatureTypeRequest (org.codice.ddf.spatial.ogc.wfs.v110.catalog.common.DescribeFeatureTypeRequest)1