FeatureSource fSource = (FeatureSource) dataAccess.getFeatureSource(typeName);
FeatureCollection features = (FeatureCollection) fSource.getFeatures();
assertEquals(5, size(features));
FeatureIterator iterator = features.features();
while (iterator.hasNext()) {
Feature next = iterator.next();
Collection<Property> children = next.getProperties("nestedFeature");
if (next.getIdentifier().toString().equals("cc.1")) {
// _=STRING:String,LINK_ONE:String,LINK_TWO:String
// sc.1=string_one|cc.1|cc.2
// sc.2=string_two|cc.1|cc.2
// sc.3=string_three|NULL|cc.2
assertEquals(2, children.size());
} else {
assertEquals(0, children.size());
}
for (Property nestedFeature : children) {
Object value = nestedFeature.getValue();
assertNotNull(value);
value = ((Collection) value).iterator().next();
assertTrue(value instanceof FeatureImpl);
Feature feature = (Feature) value;
assertNotNull(feature.getProperty("someAttribute").getValue());
}
}
// <AttributeMapping>
// <targetAttribute>FEATURE_LINK[2]</targetAttribute>
// <sourceExpression>
// <OCQL>LINK_TWO</OCQL>
// </sourceExpression>
// </AttributeMapping>
dsParams = new HashMap();
url = getClass().getResource(schemaBase + "SecondParentFeature.xml");
assertNotNull(url);
dsParams.put("dbtype", "app-schema");
dsParams.put("url", url.toExternalForm());
dataAccess = DataAccessFinder.getDataStore(dsParams);
assertNotNull(dataAccess);
typeName = Types.typeName("http://example.com", "SecondParentFeature");
featureType = dataAccess.getSchema(typeName);
assertNotNull(featureType);
fSource = (FeatureSource) dataAccess.getFeatureSource(typeName);
features = (FeatureCollection) fSource.getFeatures();
assertEquals(5, size(features));
iterator = features.features();
while (iterator.hasNext()) {
Feature next = iterator.next();
Collection<Property> children = next.getProperties("nestedFeature");
if (next.getIdentifier().toString().equals("cc.2")) {
// _=STRING:String,LINK_ONE:String,LINK_TWO:String
// sc.1=string_one|cc.1|cc.2
// sc.2=string_two|cc.1|cc.2