Module dev.metaschema.core
Class LoggingConstraintValidationHandler
java.lang.Object
dev.metaschema.core.model.constraint.AbstractConstraintValidationHandler
dev.metaschema.core.model.constraint.LoggingConstraintValidationHandler
- All Implemented Interfaces:
IConstraintValidationHandler
Supports logging constraint findings to the configured Log4J2 instance.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidhandleAllowedValuesViolation(List<IAllowedValuesConstraint> failedConstraints, INodeItem target, DynamicContext dynamicContext) Handle an allowed values constraint violation.voidhandleCardinalityMaximumViolation(ICardinalityConstraint constraint, INodeItem node, ISequence<? extends INodeItem> targets, DynamicContext dynamicContext) Handle a cardinality constraint maximum violation.voidhandleCardinalityMinimumViolation(ICardinalityConstraint constraint, INodeItem node, ISequence<? extends INodeItem> targets, DynamicContext dynamicContext) Handle a cardinality constraint minimum violation.voidhandleError(IConstraint constraint, INodeItem node, String message, Throwable exception, DynamicContext dynamicContext) Handle a constraint that whose evaluation resulted in an unexpected error during validation.voidhandleExpectViolation(IExpectConstraint constraint, INodeItem node, INodeItem target, DynamicContext dynamicContext) Handle an expect test violation.voidhandleIndexDuplicateKeyViolation(IIndexConstraint constraint, INodeItem node, INodeItem oldItem, INodeItem target, DynamicContext dynamicContext) Handle an index duplicate key violation.voidhandleIndexDuplicateViolation(IIndexConstraint constraint, INodeItem node, DynamicContext dynamicContext) Handle a duplicate index violation.voidhandleIndexMiss(IIndexHasKeyConstraint constraint, INodeItem node, INodeItem target, List<String> key, DynamicContext dynamicContext) Handle an index lookup key miss violation.voidhandleKeyMatchError(IKeyConstraint constraint, INodeItem node, INodeItem target, MetapathException cause, DynamicContext dynamicContext) Handle an error that occurred while generating a key.voidhandleMatchDatatypeViolation(IMatchesConstraint constraint, INodeItem node, INodeItem target, String value, IDataTypeAdapter<?> adapter, IllegalArgumentException cause, DynamicContext dynamicContext) Handle a match data type violation.voidhandleMatchPatternViolation(IMatchesConstraint constraint, INodeItem node, INodeItem target, String value, Pattern pattern, DynamicContext dynamicContext) Handle a match pattern violation.voidhandleMissingIndexViolation(IIndexHasKeyConstraint constraint, INodeItem node, INodeItem target, String message, DynamicContext dynamicContext) Handle a missing index violation.voidhandlePass(IConstraint constraint, INodeItem node, INodeItem target, DynamicContext dynamicContext) Handle a constraint that has passed validation.voidhandleReportViolation(IReportConstraint constraint, INodeItem node, INodeItem target, DynamicContext dynamicContext) Handle a report test finding.voidhandleUniqueKeyViolation(IUniqueConstraint constraint, INodeItem node, INodeItem oldItem, INodeItem target, DynamicContext dynamicContext) Handle an unique key violation.protected StringGet the path of the provided item using the configured path formatter.Methods inherited from class dev.metaschema.core.model.constraint.AbstractConstraintValidationHandler
getPathFormatter, newAllowedValuesViolationMessage, newCardinalityMaximumViolationMessage, newCardinalityMinimumViolationMessage, newExpectViolationMessage, newIndexDuplicateKeyViolationMessage, newIndexDuplicateViolationMessage, newIndexMissMessage, newMatchDatatypeViolationMessage, newMatchPatternViolationMessage, newMissingIndexViolationMessage, newReportViolationMessage, newUniqueKeyViolationMessage, setPathFormatter
-
Constructor Details
-
LoggingConstraintValidationHandler
public LoggingConstraintValidationHandler()
-
-
Method Details
-
toPath
Description copied from class:AbstractConstraintValidationHandlerGet the path of the provided item using the configured path formatter.- Overrides:
toPathin classAbstractConstraintValidationHandler- 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:IConstraintValidationHandlerHandle a cardinality constraint minimum violation.- Parameters:
constraint- the constraint that was evaluatednode- the node used as the evaluation focus to determine the items to testtargets- the items testeddynamicContext- 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:IConstraintValidationHandlerHandle a cardinality constraint maximum violation.- Parameters:
constraint- the constraint that was evaluatednode- the node used as the evaluation focus to determine the items to testtargets- the items testeddynamicContext- 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:IConstraintValidationHandlerHandle an index duplicate key violation.This happens when two target nodes have the same key.
- Parameters:
constraint- the constraint that was evaluatednode- the node used as the evaluation focus to determine constraint targetsoldItem- the node that exists in the index for the related keytarget- the target of evaluationdynamicContext- 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:IConstraintValidationHandlerHandle an unique key violation.This happens when two target nodes have the same key.
- Parameters:
constraint- the constraint that was evaluatednode- the node used as the evaluation focus to determine constraint targetsoldItem- the other node with the same keytarget- the target of evaluationdynamicContext- 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:IConstraintValidationHandlerHandle an error that occurred while generating a key.- Parameters:
constraint- the constraint that was evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationcause- the resulting Metapath exceptiondynamicContext- 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:IConstraintValidationHandlerHandle a match pattern violation.This happens when the target value does not match the specified pattern.
- Parameters:
constraint- the constraint that was evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationvalue- the value used for pattern matchingpattern- the pattern used for pattern matchingdynamicContext- 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:IConstraintValidationHandlerHandle 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 evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationvalue- the value used for data type matchingadapter- the data type used for data type matchingcause- the data type exception related to this violationdynamicContext- 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:IConstraintValidationHandlerHandle an expect test violation.This happens when the test does not evaluate to true.
- Parameters:
constraint- the constraint that was evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationdynamicContext- 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:IConstraintValidationHandlerHandle 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 evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationdynamicContext- 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:IConstraintValidationHandlerHandle an allowed values constraint violation.- Parameters:
failedConstraints- the allowed values constraints that did not match.target- the target of evaluationdynamicContext- 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:IConstraintValidationHandlerHandle a duplicate index violation.- Parameters:
constraint- the constraint that was evaluatednode- the node used as the evaluation focus to determine constraint targetsdynamicContext- 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:IConstraintValidationHandlerHandle 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 evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationkey- the key that was used to lookup the index entrydynamicContext- 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:IConstraintValidationHandlerHandle a missing index violation.This happens when an index-has-key constraint references a missing index.
- Parameters:
constraint- the constraint that was evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationmessage- the error messagedynamicContext- 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:IConstraintValidationHandlerHandle a constraint that has passed validation.- Parameters:
constraint- the constraint that was evaluatednode- the node used as the evaluation focus to determine constraint targetstarget- the target of evaluationdynamicContext- 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:IConstraintValidationHandlerHandle a constraint that whose evaluation resulted in an unexpected error during validation.- Parameters:
constraint- the constraint that was evaluatednode- the node used as the evaluation focus to determine constraint targetsmessage- the error messageexception- the causing exceptiondynamicContext- the Metapath dynamic execution context to use for Metapath evaluation
-