if (EMFUtils.isUnset(queries, "typeName")) {
String msg = "No feature types specified";
throw new WFSException(msg);
}
FeatureCollectionType result = WfsFactory.eINSTANCE.createFeatureCollectionType();
int residual = request.getMaxFeatures() != null ? request.getMaxFeatures().intValue() : Integer.MAX_VALUE;
// for each difference query check the feature type is versioned, and
// gather bounds
try {
for (int i = 0; i < queries.size() && residual > 0; i++) {
DifferenceQueryType query = (DifferenceQueryType) queries.get(i);
FeatureTypeInfo meta = featureTypeInfo((QName) query.getTypeName());
FeatureSource<? extends FeatureType, ? extends Feature> source = meta.getFeatureSource(null,null);
if (!(source instanceof VersioningFeatureSource)) {
throw new WFSException("Feature type" + query.getTypeName()
+ " is not versioned");
}
Filter filter = (Filter) query.getFilter();
// make sure filters are sane
if (filter != null) {
final FeatureType featureType = source.getSchema();
ExpressionVisitor visitor = new AbstractExpressionVisitor() {
public Object visit(PropertyName name, Object data) {
// case of multiple geometries being returned
if (name.evaluate(featureType) == null) {
// we want to throw wfs exception, but cant
throw new WFSException("Illegal property name: "
+ name.getPropertyName(), "InvalidParameterValue");
}
return name;
}
;
};
filter.accept(new AbstractFilterVisitor(visitor), null);
}
// extract collection
VersioningFeatureSource store = (VersioningFeatureSource) source;
FeatureCollection<SimpleFeatureType, SimpleFeature> logs = store.getLog(query
.getFromFeatureVersion(), query.getToFeatureVersion(), filter, null,
residual);
residual -= logs.size();
// TODO: handle logs reprojection in another CRS
result.getFeature().add(logs);
}
} catch (IOException e) {
throw new WFSException("Error occurred getting features", e, request.getHandle());
}
result.setNumberOfFeatures(BigInteger.valueOf(residual));
result.setTimeStamp(Calendar.getInstance());
return result;
}