Package gov.nasa.pds.tools.util
Class ReferentialIntegrityUtil
- java.lang.Object
-
- gov.nasa.pds.tools.util.ReferentialIntegrityUtil
-
public class ReferentialIntegrityUtil extends Object
Util class to provide additional integrity checks on a Product_Bundle or Product_Collection label.
-
-
Constructor Summary
Constructors Constructor Description ReferentialIntegrityUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidadditionalReferentialIntegrityChecks(URL crawlTarget)static voidadditionalReferentialIntegrityChecks(URL crawlTarget, URL bundleURL)Perform additional referential integrity check beside the normal check.static RuleContextgetContext()Get the RuleContext of the target of the check.static booleangetContextReferenceCheckFlag()Get the contextReferenceCheck.static ProblemListenergetListener()Get the ProblemListener of the target of the check.static StringgetReferenceType()Get the referenceType of the target of the check.static URLgetTarget()Get the URL of the target of the check.static voidinitialize(String referenceType, URL target, ProblemListener problemListener, RuleContext ruleContext)Initialize this class to ready for doing referential checks.protected static voidreportError(ProblemDefinition defn, URL targetUrl, int lineNumber, int columnNumber)Reports an error to the validation listener.protected static voidreportError(ProblemDefinition defn, URL target, int lineNumber, int columnNumber, String message)Reports an error to the validation listener with a custom message.static voidreportLidOrLidvidReferenceToNonExistLogicalReferences()Report a WARNING if any LID or LIDVID references does not resolve to at least one element in the list of logical identifiers.static voidreset()Reset this class to its initial state in case running from regression tests.static voidsetContext(RuleContext ruleContext)Get the RuleContext of the target of the check.static voidsetContextReferenceCheckFlag(boolean contextReferenceCheck)Set the contextReferenceCheckstatic voidsetListener(ProblemListener problemListener)Set the ProblemListener of the target of the check.static voidsetReferenceType(String referenceType)Set the referenceType of the target of the check.static voidsetTarget(URL target)Set the URL of the target of the check.
-
-
-
Method Detail
-
initialize
public static void initialize(String referenceType, URL target, ProblemListener problemListener, RuleContext ruleContext)
Initialize this class to ready for doing referential checks.- Parameters:
referenceType- the referenceType of the target of the check: 'bundle' or 'collection'target- the URL of the target of the checkproblemListener- the ProblemListener of the target of the checkruleContext- the RuleContext of the target of the check
-
reset
public static void reset()
Reset this class to its initial state in case running from regression tests.
-
setContextReferenceCheckFlag
public static void setContextReferenceCheckFlag(boolean contextReferenceCheck)
Set the contextReferenceCheck
-
getContextReferenceCheckFlag
public static boolean getContextReferenceCheckFlag()
Get the contextReferenceCheck.- Returns:
- The valule of contextReferenceCheck
-
getTarget
public static URL getTarget()
Get the URL of the target of the check.- Returns:
- the URL of the target of the check
-
setTarget
public static void setTarget(URL target)
Set the URL of the target of the check.
-
getListener
public static ProblemListener getListener()
Get the ProblemListener of the target of the check.- Returns:
- the ProblemListener of the target of the check
-
setListener
public static void setListener(ProblemListener problemListener)
Set the ProblemListener of the target of the check.- Parameters:
problemListener- The ProblemListener of the target of the check
-
getContext
public static RuleContext getContext()
Get the RuleContext of the target of the check.- Returns:
- the RuleContext of the target of the check
-
setContext
public static void setContext(RuleContext ruleContext)
Get the RuleContext of the target of the check.
-
getReferenceType
public static String getReferenceType()
Get the referenceType of the target of the check.- Returns:
- the referenceType of the target of the check
-
setReferenceType
public static void setReferenceType(String referenceType)
Set the referenceType of the target of the check.- Parameters:
referenceType- the referenceType of the target of the check: 'bundle' or 'collection'
-
reportLidOrLidvidReferenceToNonExistLogicalReferences
public static void reportLidOrLidvidReferenceToNonExistLogicalReferences()
Report a WARNING if any LID or LIDVID references does not resolve to at least one element in the list of logical identifiers.- Parameters:
validationRule- The rule of the validation, e.g. pds4.label, pds4.bundle. This value can be null since a rule is not required within validate module.
-
additionalReferentialIntegrityChecks
public static void additionalReferentialIntegrityChecks(URL crawlTarget)
-
additionalReferentialIntegrityChecks
public static void additionalReferentialIntegrityChecks(URL crawlTarget, URL bundleURL)
Perform additional referential integrity check beside the normal check. For all references in all labels, check if they refer to a logical identifier that is valid and is in this bundle/collection.- Parameters:
crawlTarget- The URL of the target to validate for.
-
reportError
protected static void reportError(ProblemDefinition defn, URL targetUrl, int lineNumber, int columnNumber)
Reports an error to the validation listener.- Parameters:
defn- the problem definitiontargetFile- the validation target file containing the problemlineNumber- the line number, or -1 if no line number appliescolumnNumber- the column number, or -1 if no column number applies
-
reportError
protected static void reportError(ProblemDefinition defn, URL target, int lineNumber, int columnNumber, String message)
Reports an error to the validation listener with a custom message.- Parameters:
defn- the problem definitiontarget- the validation target containing the problemlineNumber- the line number, or -1 if no line number appliescolumnNumber- the column number, or -1 if no column number appliesmessage- the error message to report
-
-