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 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 check
      problemListener - the ProblemListener of the target of the check
      ruleContext - 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 definition
      targetFile - the validation target file containing the problem
      lineNumber - the line number, or -1 if no line number applies
      columnNumber - 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 definition
      target - the validation target containing the problem
      lineNumber - the line number, or -1 if no line number applies
      columnNumber - the column number, or -1 if no column number applies
      message - the error message to report
    • isDebugLogLevel

      protected static boolean isDebugLogLevel()