Package gov.nasa.pds.tools.validate.rule
Class RuleContext
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap
-
- org.apache.commons.chain.impl.ContextBase
-
- gov.nasa.pds.tools.validate.rule.RuleContext
-
- All Implemented Interfaces:
Serializable,Cloneable,Map,org.apache.commons.chain.Context
public class RuleContext extends org.apache.commons.chain.impl.ContextBaseImplements a type-safe context for using validation rules in commands and chains.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description static StringADDITIONAL_TARGET_KEYKey used to retrieve additional targets.static StringALLOW_UNLABELED_FILES_KEYKey used to tell the tool to allow unlabeled files in a bundle or collection.static StringBUNDLE_PATTERN_KEYstatic StringCATALOG_FILESThe key used to retrieve the catalog files.static StringCATALOG_RESOLVERThe key used to retrieve the XMLCatalogResolver object.static StringCHECK_DATA_KEYThe key used to indicate whether to disable data content validation.static StringCHECK_INBETWEEN_FIELDSstatic StringCHECKSUM_MANIFEST_KEYThe key used to retrieve a hash map containing the checksum values from a given checksum manifest.static StringCOLLECTION_PATTERN_KEYstatic StringCOMPLETE_DESCRIPTIONSThe key used to indicate enable/disable of every bit account for in file areastatic StringCONTEXT_MISMATCH_AS_WARN_KEYstatic StringCONTEXT_VALIDATION_KEYThe key used to indicate whether to disable context validation.static StringCRAWLER_KEYThe key used to retrieve the crawler.static StringEVERY_N_KEYThe key used to indicate how many lines or records to skip during content validation.static StringFILE_FILTERSThe key used to set file name filters.static StringFORCE_LABEL_SCHEMA_VALIDATIONThe key used to indicate that declared schema and Schematron files in a label should be validated before the label is validate.static StringLABEL_EXTENSION_KEYstatic StringLABEL_PATTERN_KEYstatic StringLAST_DIRECTORY_FLAG_KEYstatic StringLISTENER_KEYThe key used to retrieve the definition listener from the execution context.static StringLOCATION_VALIDATOR_KEYThe key used to retrieve the top-level validator for getting singleton utilities.static StringPARENT_TARGET_KEYThe key used to retrieve the parent target from the context.static StringPDF_ERROR_DIRProperty to specify directory for PDF error directory.static StringRECURSIVE_VALIDATIONThe key used to set whether to validate recursively.static StringREGISTERED_PRODUCTS_KEYKey used to store a map of registered Product LIDVIDs.static StringREGISTRAR_KEYThe key used to retrieve the validation registrar from the execution context.static StringRULE_KEYstatic StringRULE_MANAGER_KEYThe key used to retrieve the rule manager from the context.static StringSKIP_PRODUCT_VALIDATION_KEYKey used to ignore(skip) product level validation.static StringSPOT_CHECK_DATA_KEYThe key used to indicate how many lines or records to skip during content validation.static StringTARGET_KEYThe key used to retrieve the current validation target from the execution context.
-
Constructor Summary
Constructors Constructor Description RuleContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleangetAllowUnlabeledFiles()XMLCatalogResolvergetCatalogResolver()List<String>getCatalogs()booleangetCheckData()booleangetCheckInbetweenFields()Map<URL,String>getChecksumManifest()booleangetCompleteDescriptions()booleangetContextMismatchAsWarn()<T> TgetContextValue(String key, Class<T> clazz)Gets a value from the context in a type-safe manner.CrawlergetCrawler()intgetEveryN()AdditionalTargetgetExtraTarget()WildcardOSFiltergetFileFilters()StringgetLabelExtension()PatterngetLabelPattern()ExceptionTypegetLogLevel()StringgetParentTarget()Gets the parent target location.StringgetPDFErrorDir()ProblemListenergetProblemListener()Map<String,List<ContextProductReference>>getRegisteredProducts()LocationValidatorgetRootValidator()Gets the top-level validator for getting singleton utilities, such as the label validator.ValidationRulegetRule()ValidationRuleManagergetRuleManager()Gets the rule manager used to find other rules to apply.booleangetSkipProductValidation()intgetSpotCheckData()URLgetTarget()TargetRegistrargetTargetRegistrar()booleangetValidateContext()booleanisForceLabelSchemaValidation()Tests whether to force validation of schemas and Schematrons defined in a label file.booleanisLastDirectory()booleanisRecursive()booleanisRootTarget()Tests whether this is the root target for the validation.<T> voidputContextValue(String key, T value)Puts a value into the context in a type-safe manner.voidsetAllowUnlabeledFiles(boolean flag)voidsetCatalogResolver(XMLCatalogResolver catalogResolver)voidsetCatalogs(List<String> catalogs)voidsetCheckData(boolean flag)voidsetCheckInbetweenFields(boolean flag)voidsetChecksumManifest(Map<URL,String> manifest)voidsetCompleteDescriptions(boolean b)voidsetContextMismatchAsWarn(boolean value)voidsetCrawler(Crawler crawler)voidsetEveryN(int value)voidsetExtraTarget(ArrayList<URL> targets)voidsetFileFilters(WildcardOSFilter filter)voidsetFileFilters(List<String> filters)voidsetForceLabelSchemaValidation(boolean force)Sets whether to force schema and Schematron validation defined in a label.voidsetLabelExtension(String labelExtension)Set the label extension and the file name patterns to matchvoidsetLabelPattern(Pattern pattern)voidsetLabelPatternWithExtension(String labelExtension)voidsetLastDirectoryFlag(boolean flag)voidsetLogLevel(ExceptionType logLevel)voidsetParentTarget(String parentLocation)Sets the parent target location.voidsetPDFErrorDir(String dir)voidsetProblemListener(ProblemListener listener)voidsetRecursive(boolean isRecursive)voidsetRegisteredProducts(Map<String,List<ContextProductReference>> products)voidsetRootTarget(boolean flag)Sets whether this is the root target for the validation.voidsetRootValidator(LocationValidator validator)Sets the top-level validator.voidsetRule(ValidationRule rule)voidsetRuleManager(ValidationRuleManager ruleManager)Sets the rule manager to use for finding new rules.voidsetSkipProductValidation(boolean flag)voidsetSpotCheckData(int value)voidsetTarget(URL target)voidsetTargetRegistrar(TargetRegistrar registrar)voidsetValidateContext(boolean flag)-
Methods inherited from class org.apache.commons.chain.impl.ContextBase
clear, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll, size
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll, size
-
-
-
-
Field Detail
-
LOCATION_VALIDATOR_KEY
public static final String LOCATION_VALIDATOR_KEY
The key used to retrieve the top-level validator for getting singleton utilities.- See Also:
- Constant Field Values
-
FORCE_LABEL_SCHEMA_VALIDATION
public static final String FORCE_LABEL_SCHEMA_VALIDATION
The key used to indicate that declared schema and Schematron files in a label should be validated before the label is validate.- See Also:
- Constant Field Values
-
RECURSIVE_VALIDATION
public static final String RECURSIVE_VALIDATION
The key used to set whether to validate recursively.- See Also:
- Constant Field Values
-
FILE_FILTERS
public static final String FILE_FILTERS
The key used to set file name filters.- See Also:
- Constant Field Values
-
TARGET_KEY
public static final String TARGET_KEY
The key used to retrieve the current validation target from the execution context.- See Also:
- Constant Field Values
-
ADDITIONAL_TARGET_KEY
public static final String ADDITIONAL_TARGET_KEY
Key used to retrieve additional targets.- See Also:
- Constant Field Values
-
LISTENER_KEY
public static final String LISTENER_KEY
The key used to retrieve the definition listener from the execution context.- See Also:
- Constant Field Values
-
REGISTRAR_KEY
public static final String REGISTRAR_KEY
The key used to retrieve the validation registrar from the execution context.- See Also:
- Constant Field Values
-
RULE_MANAGER_KEY
public static final String RULE_MANAGER_KEY
The key used to retrieve the rule manager from the context.- See Also:
- Constant Field Values
-
RULE_KEY
public static final String RULE_KEY
- See Also:
- Constant Field Values
-
PARENT_TARGET_KEY
public static final String PARENT_TARGET_KEY
The key used to retrieve the parent target from the context.- See Also:
- Constant Field Values
-
CRAWLER_KEY
public static final String CRAWLER_KEY
The key used to retrieve the crawler.- See Also:
- Constant Field Values
-
CHECKSUM_MANIFEST_KEY
public static final String CHECKSUM_MANIFEST_KEY
The key used to retrieve a hash map containing the checksum values from a given checksum manifest.- See Also:
- Constant Field Values
-
CATALOG_FILES
public static final String CATALOG_FILES
The key used to retrieve the catalog files.- See Also:
- Constant Field Values
-
CATALOG_RESOLVER
public static final String CATALOG_RESOLVER
The key used to retrieve the XMLCatalogResolver object.- See Also:
- Constant Field Values
-
CHECK_DATA_KEY
public static final String CHECK_DATA_KEY
The key used to indicate whether to disable data content validation.- See Also:
- Constant Field Values
-
EVERY_N_KEY
public static final String EVERY_N_KEY
The key used to indicate how many lines or records to skip during content validation.- See Also:
- Constant Field Values
-
CONTEXT_MISMATCH_AS_WARN_KEY
public static final String CONTEXT_MISMATCH_AS_WARN_KEY
- See Also:
- Constant Field Values
-
COMPLETE_DESCRIPTIONS
public static final String COMPLETE_DESCRIPTIONS
The key used to indicate enable/disable of every bit account for in file area- See Also:
- Constant Field Values
-
PDF_ERROR_DIR
public static final String PDF_ERROR_DIR
Property to specify directory for PDF error directory.- See Also:
- Constant Field Values
-
SPOT_CHECK_DATA_KEY
public static final String SPOT_CHECK_DATA_KEY
The key used to indicate how many lines or records to skip during content validation.- See Also:
- Constant Field Values
-
ALLOW_UNLABELED_FILES_KEY
public static final String ALLOW_UNLABELED_FILES_KEY
Key used to tell the tool to allow unlabeled files in a bundle or collection.- See Also:
- Constant Field Values
-
REGISTERED_PRODUCTS_KEY
public static final String REGISTERED_PRODUCTS_KEY
Key used to store a map of registered Product LIDVIDs.- See Also:
- Constant Field Values
-
CONTEXT_VALIDATION_KEY
public static final String CONTEXT_VALIDATION_KEY
The key used to indicate whether to disable context validation.- See Also:
- Constant Field Values
-
SKIP_PRODUCT_VALIDATION_KEY
public static final String SKIP_PRODUCT_VALIDATION_KEY
Key used to ignore(skip) product level validation.- See Also:
- Constant Field Values
-
CHECK_INBETWEEN_FIELDS
public static final String CHECK_INBETWEEN_FIELDS
- See Also:
- Constant Field Values
-
LABEL_EXTENSION_KEY
public static final String LABEL_EXTENSION_KEY
- See Also:
- Constant Field Values
-
LABEL_PATTERN_KEY
public static final String LABEL_PATTERN_KEY
- See Also:
- Constant Field Values
-
BUNDLE_PATTERN_KEY
public static final String BUNDLE_PATTERN_KEY
- See Also:
- Constant Field Values
-
COLLECTION_PATTERN_KEY
public static final String COLLECTION_PATTERN_KEY
- See Also:
- Constant Field Values
-
LAST_DIRECTORY_FLAG_KEY
public static final String LAST_DIRECTORY_FLAG_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getContextValue
public <T> T getContextValue(String key, Class<T> clazz)
Gets a value from the context in a type-safe manner.- Parameters:
key- the keyclazz- the expected class- Returns:
- the value, or null if there is no value with that key
-
putContextValue
public <T> void putContextValue(String key, T value)
Puts a value into the context in a type-safe manner.- Parameters:
key- the keyvalue- the value
-
getLogLevel
public ExceptionType getLogLevel()
-
setLogLevel
public void setLogLevel(ExceptionType logLevel)
-
getTarget
public URL getTarget()
-
setTarget
public void setTarget(URL target) throws MalformedURLException, URISyntaxException
-
getExtraTarget
public AdditionalTarget getExtraTarget()
-
setExtraTarget
public void setExtraTarget(ArrayList<URL> targets) throws MalformedURLException, URISyntaxException
-
getProblemListener
public ProblemListener getProblemListener()
-
setProblemListener
public void setProblemListener(ProblemListener listener)
-
getTargetRegistrar
public TargetRegistrar getTargetRegistrar()
-
setTargetRegistrar
public void setTargetRegistrar(TargetRegistrar registrar)
-
getRuleManager
public ValidationRuleManager getRuleManager()
Gets the rule manager used to find other rules to apply.- Returns:
- the rule manager
-
getRule
public ValidationRule getRule()
-
setRuleManager
public void setRuleManager(ValidationRuleManager ruleManager)
Sets the rule manager to use for finding new rules.- Parameters:
ruleManager- the rule manager
-
setRule
public void setRule(ValidationRule rule)
-
getParentTarget
public String getParentTarget()
Gets the parent target location.- Returns:
- the parent target location, or null if there is no parent target
-
setParentTarget
public void setParentTarget(String parentLocation)
Sets the parent target location.- Parameters:
parent- the parent target location
-
isRootTarget
public boolean isRootTarget()
Tests whether this is the root target for the validation.- Returns:
- true, if this context is for the root target
-
setRootTarget
public void setRootTarget(boolean flag)
Sets whether this is the root target for the validation.- Parameters:
flag- true, if this context is for the root target
-
getRootValidator
public LocationValidator getRootValidator()
Gets the top-level validator for getting singleton utilities, such as the label validator.- Returns:
- the top-level validator
-
setRootValidator
public void setRootValidator(LocationValidator validator)
Sets the top-level validator.- Parameters:
validator- the top-level validator
-
isRecursive
public boolean isRecursive()
-
setRecursive
public void setRecursive(boolean isRecursive)
-
getFileFilters
public WildcardOSFilter getFileFilters()
-
setFileFilters
public void setFileFilters(WildcardOSFilter filter)
-
isForceLabelSchemaValidation
public boolean isForceLabelSchemaValidation()
Tests whether to force validation of schemas and Schematrons defined in a label file.- Returns:
- true, if declared schema and Schematron files should be validated
-
setForceLabelSchemaValidation
public void setForceLabelSchemaValidation(boolean force)
Sets whether to force schema and Schematron validation defined in a label.- Parameters:
force- true, if declared schema and Schematron files should be validated
-
getCrawler
public Crawler getCrawler()
-
setCrawler
public void setCrawler(Crawler crawler)
-
setCatalogResolver
public void setCatalogResolver(XMLCatalogResolver catalogResolver)
-
getCatalogResolver
public XMLCatalogResolver getCatalogResolver()
-
getCheckData
public boolean getCheckData()
-
setCheckData
public void setCheckData(boolean flag)
-
getEveryN
public int getEveryN()
-
getContextMismatchAsWarn
public boolean getContextMismatchAsWarn()
-
setEveryN
public void setEveryN(int value)
-
setContextMismatchAsWarn
public void setContextMismatchAsWarn(boolean value)
-
getCompleteDescriptions
public boolean getCompleteDescriptions()
-
setCompleteDescriptions
public void setCompleteDescriptions(boolean b)
-
getPDFErrorDir
public String getPDFErrorDir()
-
setPDFErrorDir
public void setPDFErrorDir(String dir)
-
getSpotCheckData
public int getSpotCheckData()
-
setSpotCheckData
public void setSpotCheckData(int value)
-
getAllowUnlabeledFiles
public boolean getAllowUnlabeledFiles()
-
setAllowUnlabeledFiles
public void setAllowUnlabeledFiles(boolean flag)
-
getRegisteredProducts
public Map<String,List<ContextProductReference>> getRegisteredProducts()
-
setRegisteredProducts
public void setRegisteredProducts(Map<String,List<ContextProductReference>> products)
-
getValidateContext
public boolean getValidateContext()
-
setValidateContext
public void setValidateContext(boolean flag)
-
getSkipProductValidation
public boolean getSkipProductValidation()
-
setSkipProductValidation
public void setSkipProductValidation(boolean flag)
-
getCheckInbetweenFields
public boolean getCheckInbetweenFields()
-
setCheckInbetweenFields
public void setCheckInbetweenFields(boolean flag)
-
getLabelExtension
public String getLabelExtension()
-
setLabelExtension
public void setLabelExtension(String labelExtension)
Set the label extension and the file name patterns to match- Parameters:
labelExtension-
-
getLabelPattern
public Pattern getLabelPattern()
-
setLabelPattern
public void setLabelPattern(Pattern pattern)
-
setLabelPatternWithExtension
public void setLabelPatternWithExtension(String labelExtension)
-
isLastDirectory
public boolean isLastDirectory()
-
setLastDirectoryFlag
public void setLastDirectoryFlag(boolean flag)
-
-