Package gov.nasa.pds.tools.util
Class ReferentialIntegrityUtil
java.lang.Object
gov.nasa.pds.tools.util.ReferentialIntegrityUtil
Util class to provide additional integrity checks on a Product_Bundle or Product_Collection
label.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidadditionalReferentialIntegrityChecks(URL crawlTarget) static voidadditionalReferentialIntegrityChecks(URL crawlTarget, URL bundleURL) Perform additional referential integrity check beside the normal check.static RuleContextGet the RuleContext of the target of the check.static booleanGet the contextReferenceCheck.static ProblemListenerGet the ProblemListener of the target of the check.static StringGet the referenceType of the target of the check.static URLGet 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 booleanprotected 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 voidReport 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 voidSet the URL of the target of the check.
-
Constructor Details
-
ReferentialIntegrityUtil
public ReferentialIntegrityUtil()
-
-
Method Details
-
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
Get the URL of the target of the check.- Returns:
- the URL of the target of the check
-
setTarget
Set the URL of the target of the check. -
getListener
Get the ProblemListener of the target of the check.- Returns:
- the ProblemListener of the target of the check
-
setListener
Set the ProblemListener of the target of the check.- Parameters:
problemListener- The ProblemListener of the target of the check
-
getContext
Get the RuleContext of the target of the check.- Returns:
- the RuleContext of the target of the check
-
setContext
Get the RuleContext of the target of the check. -
getReferenceType
Get the referenceType of the target of the check.- Returns:
- the referenceType of the target of the check
-
setReferenceType
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
-
additionalReferentialIntegrityChecks
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
-
isDebugLogLevel
protected static boolean isDebugLogLevel()
-