Class LoggingConstraintValidationHandler

java.lang.Object
dev.metaschema.core.model.constraint.AbstractConstraintValidationHandler
dev.metaschema.core.model.constraint.LoggingConstraintValidationHandler
All Implemented Interfaces:
IConstraintValidationHandler

public class LoggingConstraintValidationHandler extends AbstractConstraintValidationHandler
Supports logging constraint findings to the configured Log4J2 instance.
  • Constructor Details

    • LoggingConstraintValidationHandler

      public LoggingConstraintValidationHandler()
  • Method Details

    • toPath

      protected String toPath(@NonNull INodeItem nodeItem)
      Description copied from class: AbstractConstraintValidationHandler
      Get the path of the provided item using the configured path formatter.
      Overrides:
      toPath in class AbstractConstraintValidationHandler
      Parameters:
      nodeItem - the node item to generate the path for
      Returns:
      the path
      See Also:
    • handleCardinalityMinimumViolation

      public void handleCardinalityMinimumViolation(@NonNull ICardinalityConstraint constraint, @NonNull INodeItem node, @NonNull ISequence<? extends INodeItem> targets, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Description copied from interface: IConstraintValidationHandler
      Handle a cardinality constraint minimum violation.
      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine the items to test
      targets - the items tested
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleCardinalityMaximumViolation

      public void handleCardinalityMaximumViolation(@NonNull ICardinalityConstraint constraint, @NonNull INodeItem node, @NonNull ISequence<? extends INodeItem> targets, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Description copied from interface: IConstraintValidationHandler
      Handle a cardinality constraint maximum violation.
      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine the items to test
      targets - the items tested
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleIndexDuplicateKeyViolation

      public void handleIndexDuplicateKeyViolation(@NonNull IIndexConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem oldItem, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Description copied from interface: IConstraintValidationHandler
      Handle an index duplicate key violation.

      This happens when two target nodes have the same key.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      oldItem - the node that exists in the index for the related key
      target - the target of evaluation
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleUniqueKeyViolation

      public void handleUniqueKeyViolation(@NonNull IUniqueConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem oldItem, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Description copied from interface: IConstraintValidationHandler
      Handle an unique key violation.

      This happens when two target nodes have the same key.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      oldItem - the other node with the same key
      target - the target of evaluation
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleKeyMatchError

      public void handleKeyMatchError(@NonNull IKeyConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull MetapathException cause, @NonNull DynamicContext dynamicContext)
      Description copied from interface: IConstraintValidationHandler
      Handle an error that occurred while generating a key.
      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      cause - the resulting Metapath exception
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
    • handleMatchPatternViolation

      public void handleMatchPatternViolation(@NonNull IMatchesConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull String value, @NonNull Pattern pattern, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Description copied from interface: IConstraintValidationHandler
      Handle a match pattern violation.

      This happens when the target value does not match the specified pattern.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      value - the value used for pattern matching
      pattern - the pattern used for pattern matching
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleMatchDatatypeViolation

      public void handleMatchDatatypeViolation(@NonNull IMatchesConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull String value, @NonNull IDataTypeAdapter<?> adapter, @NonNull IllegalArgumentException cause, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Description copied from interface: IConstraintValidationHandler
      Handle a match data type violation.

      This happens when the target value does not conform to the specified data type.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      value - the value used for data type matching
      adapter - the data type used for data type matching
      cause - the data type exception related to this violation
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleExpectViolation

      public void handleExpectViolation(@NonNull IExpectConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Description copied from interface: IConstraintValidationHandler
      Handle an expect test violation.

      This happens when the test does not evaluate to true.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleReportViolation

      public void handleReportViolation(@NonNull IReportConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Description copied from interface: IConstraintValidationHandler
      Handle a report test finding.

      This happens when the report test expression evaluates to true. Unlike expect constraints which generate violations when false, report constraints generate findings when true.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleAllowedValuesViolation

      public void handleAllowedValuesViolation(List<IAllowedValuesConstraint> failedConstraints, INodeItem target, @NonNull DynamicContext dynamicContext)
      Description copied from interface: IConstraintValidationHandler
      Handle an allowed values constraint violation.
      Parameters:
      failedConstraints - the allowed values constraints that did not match.
      target - the target of evaluation
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
    • handleIndexDuplicateViolation

      public void handleIndexDuplicateViolation(@NonNull IIndexConstraint constraint, @NonNull INodeItem node, @NonNull DynamicContext dynamicContext)
      Description copied from interface: IConstraintValidationHandler
      Handle a duplicate index violation.
      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
    • handleIndexMiss

      public void handleIndexMiss(@NonNull IIndexHasKeyConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull List<String> key, @NonNull DynamicContext dynamicContext) throws ConstraintValidationException
      Description copied from interface: IConstraintValidationHandler
      Handle an index lookup key miss violation.

      This happens when another node references an expected member of an index that does not actually exist in the index.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      key - the key that was used to lookup the index entry
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
      Throws:
      ConstraintValidationException - if the constraint has a custom message that contains a Metapath expression that is invalid or if the expression failed to evaluate
    • handleMissingIndexViolation

      public void handleMissingIndexViolation(@NonNull IIndexHasKeyConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull String message, @NonNull DynamicContext dynamicContext)
      Description copied from interface: IConstraintValidationHandler
      Handle a missing index violation.

      This happens when an index-has-key constraint references a missing index.

      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      message - the error message
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
    • handlePass

      public void handlePass(@NonNull IConstraint constraint, @NonNull INodeItem node, @NonNull INodeItem target, @NonNull DynamicContext dynamicContext)
      Description copied from interface: IConstraintValidationHandler
      Handle a constraint that has passed validation.
      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      target - the target of evaluation
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation
    • handleError

      public void handleError(@NonNull IConstraint constraint, @NonNull INodeItem node, @NonNull String message, @NonNull Throwable exception, @NonNull DynamicContext dynamicContext)
      Description copied from interface: IConstraintValidationHandler
      Handle a constraint that whose evaluation resulted in an unexpected error during validation.
      Parameters:
      constraint - the constraint that was evaluated
      node - the node used as the evaluation focus to determine constraint targets
      message - the error message
      exception - the causing exception
      dynamicContext - the Metapath dynamic execution context to use for Metapath evaluation