org.geotools.validation
Class ValidationProcessor

java.lang.Object
  extended byorg.geotools.validation.ValidationProcessor

public class ValidationProcessor
extends java.lang.Object

ValidationProcessor Runs validation tests against Features and reports the outcome of the tests.

The validation processor contains two main data structures. Each one is a HashMap of ArrayLists that hold Validations. The first one, featureLookup, holds per-feature validation tests (tests that operate on one feature at a time with no knowledge of any other features. The second one, integrityLookup, holds integrity validations (validations that span multiple features and/or multiple feature types).

Each HashMap of validations is hashed with a key whose value is a FeatureTypeName. This key provides access to an ArrayList of validations that are to be performed on this FeatureTypeInfo.

Validations are added via the two addValidation() methods.

The validations are run when runFeatureTests() and runIntegrityTests() are called. It is recommended that the user call runFeatureTests() before runIntegrityTests() as it is usually the case that integrity tests are much more time consuming. If a Feature is incorrect, it can probably be detected early on, and quickly, in the feature validation tests.

For validations that are performed on every FeatureTypeInfo, a value called ANYTYPENAME has been created and can be stored in the validationLookup tables if a validation specifies that it is run against all FeatureTypes. The value that causes a validation to be run against all FeatureTypes is null. Or Validation.ALL

Results of the validation tests are handled using a Visitor pattern. This visitor is a ValidationResults object that is passed into the runFeatureTests() and runIntegrityTests() methods. Each individual validation will record error messages in the ValidationResults visitor.

Example Use:


 ValidationProcessor processor = new ValidationProcessor();
processor.addValidation(FeatureValidation1);
processor.addValidation(FeatureValidation2);
processor.addValidation(IntegrityValidation1);
processor.addValidation(FeatureValidation3);

processor.runFeatureTests(FeatureTypeInfo, Feature, ValidationResults);
processor.runIntegrityTests(layers, Envelope, ValidationResults);

Version:
$Id: ValidationProcessor.java 17704 2006-01-23 00:26:16Z desruisseaux $
Author:
bowens, Refractions Research, Inc., $Author: jive $ (last modification)

Field Summary
protected  java.util.Map featureLookup
          Stores Lists of FeatureTests by featureType.
protected  java.util.Map integrityLookup
          Stores Lists of IntegrityValidation by featureType.
protected  java.util.ArrayList modifiedFeatureTypes
          List of feature types that have been modified.
 
Constructor Summary
ValidationProcessor()
          ValidationProcessor constructor.
 
Method Summary
 void addValidation(FeatureValidation validation)
          addValidation Add a FeatureValidation to the list of Feature tests
 void addValidation(IntegrityValidation validation)
          addValidation Add an IntegrityValidation to the list of Integrity tests
 java.util.Set getDependencies(java.lang.String typeName)
          getDependencies purpose.
 void load(java.io.File plugins, java.io.File testsuites)
          Load testsuites from provided directories.
 void load(java.util.Map plugInDTOs, java.util.Map testSuiteDTOs)
          Populates this validation processor against the provided DTO objects.
protected static java.util.Set queryPlugInNames(java.util.Map testSuiteDTOs)
           
 void runFeatureTests(java.lang.String dsID, FeatureType type, FeatureReader reader, ValidationResults results)
          runFeatureTests Change: Uses a FeatureReader now instead of a FeatureCollection.
 void runIntegrityTests(java.util.Set typeRefs, java.util.Map stores, com.vividsolutions.jts.geom.Envelope envelope, ValidationResults results)
          runIntegrityTests Performs a lookup on the FeatureTypeInfo name to determine what IntegrityTests need to be performed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

featureLookup

protected java.util.Map featureLookup
Stores Lists of FeatureTests by featureType.

Map of ArrayLists by featureType (the lists contain FeatureValidation instances)


integrityLookup

protected java.util.Map integrityLookup
Stores Lists of IntegrityValidation by featureType.

A Map with featureTypes as keys that map to array lists of integrity validation tests.

How are tests that map against all FeatureTypes stored?


modifiedFeatureTypes

protected java.util.ArrayList modifiedFeatureTypes
List of feature types that have been modified.

Constructor Detail

ValidationProcessor

public ValidationProcessor()
ValidationProcessor constructor.

Initializes the data structure to hold the validations.

Method Detail

addValidation

public void addValidation(FeatureValidation validation)
addValidation

Add a FeatureValidation to the list of Feature tests

Parameters:
validation -

addValidation

public void addValidation(IntegrityValidation validation)
addValidation

Add an IntegrityValidation to the list of Integrity tests

Parameters:
validation -

getDependencies

public java.util.Set getDependencies(java.lang.String typeName)
getDependencies purpose.

Gets all the FeatureTypes that this FeatureTypeInfo uses.

Parameters:
typeName - the FeatureTypeName
Returns:
all the FeatureTypes that this FeatureTypeInfo uses.

runFeatureTests

public void runFeatureTests(java.lang.String dsID,
                            FeatureType type,
                            FeatureReader reader,
                            ValidationResults results)
                     throws java.lang.Exception
runFeatureTests Change: Uses a FeatureReader now instead of a FeatureCollection.

Performs a lookup on the FeatureTypeInfo name to determine what FeatureTests need to be performed. Once these tests are gathered, they are run on each feature in the FeatureCollection. The first validation test lookup checks to see if there are any validations that are to be performed on every FeatureTypeInfo. An example of this could be an isValid() test on all geometries in all FeatureTypes. Once those tests have been gathered, a lookup is performed on the TypeName of the FeatureTypeInfo to check for specific FeatureTypeInfo validation tests. A list of validation tests is returned from each lookup, if any exist. When all the validation tests have been gathered, each test is iterated through then run on each Feature, with the ValidationResults coming along for the ride, collecting error information. Parameter "FeatureCollection collection" should be changed later to take in a FeatureSource so not everything is loaded into memory.

Parameters:
dsID - data Store id.
type - The FeatureTypeInfo of the features being tested.
reader - The collection of features, of a particulare FeatureTypeInfo "type", that are to be validated.
results - Storage for the results of the validation tests.
Throws:
java.lang.Exception - FeatureValidations throw Exceptions

runIntegrityTests

public void runIntegrityTests(java.util.Set typeRefs,
                              java.util.Map stores,
                              com.vividsolutions.jts.geom.Envelope envelope,
                              ValidationResults results)
                       throws java.lang.Exception
runIntegrityTests

Performs a lookup on the FeatureTypeInfo name to determine what IntegrityTests need to be performed. Once these tests are gathered, they are run on the collection features in the Envelope, defined by a FeatureSource (not a FeatureCollection!). The first validation test lookup checks to see if there are any validations that are to be performed on every FeatureTypeInfo. An example of this could be a uniqueID() test on a unique column value in all FeatureTypes. Once those tests have been gathered, a lookup is performed on the TypeName of the FeatureTypeInfo to check for specific Integrity validation tests. A list of validation tests is returned from each lookup, if any exist. When all the validation tests have been gathered, each test is iterated through then run on each Feature, with the ValidationResults coming along for the ride, collecting error information.

Parameters:
typeRefs - List of modified features, or null to use stores.keySet()
stores - the Map of effected features (Map of key=typeRef, value="featureSource"
envelope - The bounding box that contains all modified Features
results - Storage for the results of the validation tests.
Throws:
java.lang.Exception - Throws an exception if the HashMap contains a value that is not a FeatureSource

queryPlugInNames

protected static final java.util.Set queryPlugInNames(java.util.Map testSuiteDTOs)

load

public void load(java.io.File plugins,
                 java.io.File testsuites)
          throws java.lang.Exception
Load testsuites from provided directories.

This is mostly useful for testing, you may want to write your own load method with enhanced error reporting.

Parameters:
plugins - DOCUMENT ME!
testsuites - DOCUMENT ME!
Throws:
java.lang.Exception - DOCUMENT ME!

load

public void load(java.util.Map plugInDTOs,
                 java.util.Map testSuiteDTOs)
          throws java.lang.Exception
Populates this validation processor against the provided DTO objects.

This method is useful for testing, it is not forgiving and will error out if things go bad.

Parameters:
plugInDTOs -
testSuiteDTOs -
Throws:
java.lang.Exception
java.lang.ClassNotFoundException - DOCUMENT ME!


Copyright © GeoTools. All Rights Reserved.