* @throws Exception
*/
public void runIntegrityTest(Object testName, ILayer[] layers, ValidationResults results, IProgressMonitor monitor) throws Exception {
// get the validator from testKey
IntegrityValidation validator = null;
// (navigate through the featureLookup until we find an instance of the test)
for (Iterator i = integrityLookup.keySet().iterator(); i.hasNext();) {
ArrayList testList = (ArrayList) integrityLookup.get(i.next());
// iterate through each item in the list
for (Object thisTest : testList) {
Validation test = (Validation) thisTest;
// this is the matching validation for the given test
if (test.getName().equals(testName)) {
validator = (IntegrityValidation) test;
break;
}
}
}
if (validator != null) // if we found the test
{
results.setValidation(validator);
ReferencedEnvelope envelope = layers[0].getMap().getViewportModel().getBounds();
FeatureSource<SimpleFeatureType, SimpleFeature> source;
String nameSpace;
String typeName;
Map<String,FeatureSource<SimpleFeatureType, SimpleFeature>> stores = new HashMap<String,FeatureSource<SimpleFeatureType, SimpleFeature>>();
for (int i = 0; i < layers.length; i++) {
nameSpace = layers[i].getSchema().getName().getNamespaceURI();
typeName = layers[i].getSchema().getName().getLocalPart();
source = layers[i].getResource(FeatureSource.class, monitor);
String typeRef = nameSpace.toString()+":"+typeName; //$NON-NLS-1$
stores.put(typeRef, source);
}
// run the test
validator.validate(stores, envelope, results);
}
}