use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType in project ddf by codice.
the class FeatureMetacardTypeTest method testFeatureMetacardTypeFindTaxonomyMetacardAttributes.
@Test
public void testFeatureMetacardTypeFindTaxonomyMetacardAttributes() {
XmlSchema schema = new XmlSchema();
XmlSchemaElement element = new XmlSchemaElement(schema, true);
element.setSchemaType(new XmlSchemaSimpleType(schema, false));
element.setSchemaTypeName(Constants.XSD_STRING);
element.setName(ELEMENT_NAME);
schema.getElements().put(new QName(ELEMENT_NAME), element);
FeatureMetacardType fmt = new FeatureMetacardType(schema, FEATURE_TYPE, NON_QUERYABLE_PROPS, Wfs20Constants.GML_3_2_NAMESPACE);
Set<AttributeDescriptor> descriptors = initDescriptors();
for (AttributeDescriptor ad : descriptors) {
assertBasicAttributeDescriptor(fmt, ad.getName(), ad.getType());
assertFalse(fmt.getAttributeDescriptor(ad.getName()).isStored());
}
// +1 to account for one element added to schema.
assertThat(fmt.getAttributeDescriptors().size(), is(descriptors.size() + 1));
}
use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType in project ddf by codice.
the class FeatureMetacardTypeTest method testfeatureMetacardTypeFindShortProperties.
@Test
public void testfeatureMetacardTypeFindShortProperties() {
XmlSchema schema = new XmlSchema();
XmlSchemaElement shortElement = new XmlSchemaElement(schema, true);
shortElement.setSchemaType(new XmlSchemaSimpleType(schema, false));
shortElement.setSchemaTypeName(Constants.XSD_SHORT);
shortElement.setName(ELEMENT_NAME_1);
schema.getElements().put(new QName(ELEMENT_NAME_1), shortElement);
FeatureMetacardType featureMetacardType = new FeatureMetacardType(schema, FEATURE_TYPE, NON_QUERYABLE_PROPS, Wfs20Constants.GML_3_2_NAMESPACE);
assertAttributeDescriptor(featureMetacardType, ELEMENT_NAME_1, BasicTypes.SHORT_TYPE);
}
use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType in project ddf by codice.
the class FeatureMetacardTypeTest method testfeatureMetacardTypeFindLongProperties.
@Test
public void testfeatureMetacardTypeFindLongProperties() {
XmlSchema schema = new XmlSchema();
XmlSchemaElement longElement = new XmlSchemaElement(schema, true);
longElement.setSchemaType(new XmlSchemaSimpleType(schema, false));
longElement.setSchemaTypeName(Constants.XSD_LONG);
longElement.setName(ELEMENT_NAME_1);
schema.getElements().put(new QName(ELEMENT_NAME_1), longElement);
FeatureMetacardType featureMetacardType = new FeatureMetacardType(schema, FEATURE_TYPE, NON_QUERYABLE_PROPS, Wfs20Constants.GML_3_2_NAMESPACE);
assertAttributeDescriptor(featureMetacardType, ELEMENT_NAME_1, BasicTypes.LONG_TYPE);
}
use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType in project ddf by codice.
the class WfsSource method buildFeatureFilters.
private void buildFeatureFilters(List<FeatureTypeType> featureTypes, List<String> supportedGeo) throws SecurityServiceException {
// Use local Map for metacardtype registrations and once they are populated with latest
// MetacardTypes, then do actual registration
Map<String, MetacardTypeRegistration> mcTypeRegs = new HashMap<String, MetacardTypeRegistration>();
Wfs wfs = factory.getClient();
for (FeatureTypeType featureTypeType : featureTypes) {
String ftName = featureTypeType.getName().getLocalPart();
if (StringUtils.isNotBlank(forcedFeatureType) && !StringUtils.equals(forcedFeatureType, ftName)) {
continue;
}
if (mcTypeRegs.containsKey(ftName)) {
LOGGER.debug("WfsSource {}: MetacardType {} is already registered - skipping to next metacard type", getId(), ftName);
continue;
}
LOGGER.debug("ftName: {}", ftName);
try {
XmlSchema schema = wfs.describeFeatureType(new DescribeFeatureTypeRequest(featureTypeType.getName()));
if ((schema != null)) {
FeatureMetacardType ftMetacard = new FeatureMetacardType(schema, featureTypeType.getName(), nonQueryableProperties != null ? Arrays.asList(nonQueryableProperties) : new ArrayList<String>(), Wfs10Constants.GML_NAMESPACE);
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put(Metacard.CONTENT_TYPE, new String[] { ftName });
LOGGER.debug("WfsSource {}: Registering MetacardType: {}", getId(), ftName);
// Update local map with enough info to create actual MetacardType registrations
// later
mcTypeRegs.put(ftName, new MetacardTypeRegistration(ftMetacard, props, featureTypeType.getSRS()));
FeatureConverter featureConverter = null;
if (!CollectionUtils.isEmpty(featureConverterFactories)) {
for (FeatureConverterFactory factory : featureConverterFactories) {
if (ftName.equalsIgnoreCase(factory.getFeatureType())) {
featureConverter = factory.createConverter();
LOGGER.debug("WFS Source {}: Features of type: {} will be converted using {}", getId(), ftName, featureConverter.getClass().getSimpleName());
break;
}
}
if (featureConverter == null) {
LOGGER.debug("WfsSource {}: Unable to find a feature specific converter; {} will be converted using the GenericFeatureConverter", getId(), ftName);
featureConverter = new GenericFeatureConverter(featureTypeType.getSRS());
}
} else {
LOGGER.debug("WfsSource {}: Unable to find a feature specific converter; {} will be converted using the GenericFeatureConverter", getId(), ftName);
featureConverter = new GenericFeatureConverter(featureTypeType.getSRS());
}
featureConverter.setSourceId(getId());
featureConverter.setMetacardType(ftMetacard);
featureConverter.setWfsUrl(wfsUrl);
// Add the Feature Type name as an alias for xstream
featureCollectionReader.registerConverter(featureConverter);
}
} catch (WfsException | IllegalArgumentException wfse) {
LOGGER.debug(WFS_ERROR_MESSAGE, wfse);
} catch (WebApplicationException wae) {
LOGGER.debug(handleWebApplicationException(wae), wae);
}
}
// 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.
unregisterAllMetacardTypes();
this.featureTypeFilters.clear();
if (!mcTypeRegs.isEmpty()) {
Set<Entry<String, MetacardTypeRegistration>> entries = mcTypeRegs.entrySet();
for (Map.Entry<String, MetacardTypeRegistration> entry : mcTypeRegs.entrySet()) {
MetacardTypeRegistration mcTypeReg = entry.getValue();
FeatureMetacardType ftMetacard = mcTypeReg.getFtMetacard();
ServiceRegistration serviceRegistration = context.registerService(MetacardType.class.getName(), ftMetacard, mcTypeReg.getProps());
this.metacardTypeServiceRegistrations.put(entry.getKey(), serviceRegistration);
this.featureTypeFilters.put(ftMetacard.getFeatureType(), new WfsFilterDelegate(ftMetacard, supportedGeo, mcTypeReg.getSrs()));
}
}
if (featureTypeFilters.isEmpty()) {
LOGGER.info("Wfs Source {}: No Feature Type schemas validated. Marking source as unavailable", getId());
}
LOGGER.debug("Wfs Source {}: Number of validated Features = {}", getId(), featureTypeFilters.size());
}
use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType in project ddf by codice.
the class TestGenericFeatureConverter method buildMetacardType.
private MetacardType buildMetacardType() {
XmlSchema schema = new XmlSchema();
schema.getElements().putAll(buildElementMap(schema));
return new FeatureMetacardType(schema, new QName(FEATURE_TYPE), new ArrayList<>(), Wfs10Constants.GML_NAMESPACE);
}
Aggregations