{
FeatureType fType = mappingDataStore.getSchema(typeName);
assertNotNull(fType);
fSource = mappingDataStore.getFeatureSource(typeName);
}
FeatureCollection features;
// make a getFeatures request with a nested properties filter.
//
// was 96, but now 3 as mapped features are grouped by id
final int EXPECTED_MAPPED_FEATURE_COUNT = 3;
// 96 data rows from property file
final int EXPECTED_SIMPLE_FEATURE_COUNT = 96;
{
features = fSource.getFeatures();
int resultCount = getCount(features);
String msg = "be sure difference in result count is not due to different dataset.";
assertEquals(msg, EXPECTED_MAPPED_FEATURE_COUNT, resultCount);
}
Feature feature;
int count = 0;
FilterFactory ffac;
{
NamespaceSupport namespaces = new NamespaceSupport();
namespaces.declarePrefix("aw", AWNS);
namespaces.declarePrefix("om", OMNS);
namespaces.declarePrefix("swe", SWENS);
namespaces.declarePrefix("gml", GMLNS);
namespaces.declarePrefix("sa", SANS);
namespaces.declarePrefix("cv", CVNS);
// TODO: use commonfactoryfinder or the mechanism choosed
// to pass namespace context to filter factory
ffac = new FilterFactoryImplNamespaceAware(namespaces);
}
final String phenomNamePath = "aw:relatedObservation/aw:PhenomenonTimeSeries/om:observedProperty/swe:Phenomenon/gml:name";
FeatureIterator it = features.features();
for (; it.hasNext();) {
feature = (Feature) it.next();
count++;
{
PropertyName gmlName = ffac.property("gml:name");
PropertyName phenomName = ffac.property(phenomNamePath);
Object nameVal = gmlName.evaluate(feature, String.class);
assertNotNull("gml:name evaluated to null", nameVal);
Object phenomNameVal = phenomName.evaluate(feature, String.class);
assertNotNull(phenomNamePath + " evaluated to null", phenomNameVal);
}
{
PropertyName sampledFeatureName = ffac.property("sa:sampledFeature");
Attribute sampledFeatureVal = (Attribute) sampledFeatureName.evaluate(feature);
assertNotNull("sa:sampledFeature evaluated to null", sampledFeatureVal);
assertEquals(0, ((Collection) sampledFeatureVal.getValue()).size());
Map attributes = (Map) sampledFeatureVal.getUserData().get(Attributes.class);
assertNotNull(attributes);
Name xlinkTitle = name(XLINK.NAMESPACE, "title");
assertTrue(attributes.containsKey(xlinkTitle));
assertNotNull(attributes.get(xlinkTitle));
Name xlinkHref = name(XLINK.NAMESPACE, "href");
assertTrue(attributes.containsKey(xlinkHref));
assertNotNull(attributes.get(xlinkHref));
}
{
final String elementPath = "aw:relatedObservation/aw:PhenomenonTimeSeries/om:result/cv:CompactDiscreteTimeCoverage";
PropertyName elementName = ffac.property(elementPath);
Object timeCovVal = elementName.evaluate(feature);
assertNotNull(elementPath, timeCovVal);
assertTrue(timeCovVal instanceof Feature);
final List elements = (List) ((Feature) timeCovVal).getValue();
assertEquals(1, elements.size());
}
}
it.close();
count = 0;
FeatureIterator<? extends Feature> simpleIterator = ((AbstractMappingFeatureIterator) features.features()).getSourceFeatureIterator();
for (; simpleIterator.hasNext();) {
feature = (Feature) simpleIterator.next();
count++;
if (count == 22) {