Class ValidationContextUtils

java.lang.Object
eu.europa.ec.taxud.dac8.vm.utils.ValidationContextUtils

public final class ValidationContextUtils extends Object
ValidationContextUtils handles some tools related to the validation context.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.slf4j.Logger
    The Logger of the class ValidationContextUtils.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addError(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode, String docRefId, Element element)
    Adds an error to the validation context.
    static boolean
    addErrorBasedOnExclRules(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode)
    Add error based on excl rules boolean.
    static void
    addErrorWithoutRefId(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode)
    Add error without ref id.
    static void
    addErrorWithoutRefId(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode, Element element)
    * Adds an error to the validation context without specifying a docRefId.
    static void
    addUniqueError(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode)
    Add unique error.
    static boolean
    containsErrorCode(eu.europa.ec.taxud.validation.ValidationContext validationContext, ErrorCode errorCode)
    Checks if the context already contains an error with is related to the error code.
    static boolean
    disableEuRules(eu.europa.ec.taxud.validation.ValidationContext context)
    Disable eu rules.
    static Boolean
    getDoubleParsingProperty(eu.europa.ec.taxud.validation.ValidationContext context)
    Provides the value of the double parsing property from the context.
    static String
    getValueBasedOnValidationMode(String testValue, String prodValue, eu.europa.ec.taxud.validation.ValidationContext context)
    Gets the related value based on the validation mode.
    static void
    handleValidationMode(eu.europa.ec.taxud.validation.ValidationContext context, String modeParameter)
    Handles the given validation mode parameter.
    static boolean
    isRejected(eu.europa.ec.taxud.validation.ValidationContext context)
    Is rejected boolean.
    static boolean
    isRelatedError(eu.europa.ec.taxud.validation.ValidationError validationError, ErrorCode errorCode)
    Checks if a validation error is related to the error code.
    static void
    logMessageSpecs(String messageTypeIndic, String messageRefId, String transmittingCountry, String receivingCountry)
    Helper method called by the drool rules to log information found while validating. it is used to log the messageSpec specific information.
    static boolean
    To boolean safe boolean.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOGGER

      public static final org.slf4j.Logger LOGGER
      The Logger of the class ValidationContextUtils.
  • Method Details

    • addError

      public static void addError(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode, String docRefId, Element element)
      Adds an error to the validation context.
      Parameters:
      context - the validation context holding the errors.
      errorCode - the code of the error.
      docRefId - the docRefId of the group of elements that has the error.
      element - the specific element that has the error.
    • addErrorWithoutRefId

      public static void addErrorWithoutRefId(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode, Element element)
      * Adds an error to the validation context without specifying a docRefId.
      Parameters:
      context - the validation context holding the errors.
      errorCode - the code of the error.
      element - the specific element that has the error.
    • addErrorWithoutRefId

      public static void addErrorWithoutRefId(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode)
      Add error without ref id.
      Parameters:
      context - the context
      errorCode - the error code
    • addUniqueError

      public static void addUniqueError(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode)
      Add unique error.
      Parameters:
      context - the context
      errorCode - the error code
    • logMessageSpecs

      public static void logMessageSpecs(String messageTypeIndic, String messageRefId, String transmittingCountry, String receivingCountry)
      Helper method called by the drool rules to log information found while validating. it is used to log the messageSpec specific information.
      Parameters:
      messageTypeIndic - the messageTypeIndic.
      messageRefId - the messageRefId.
      transmittingCountry - the transmittingCountry.
      receivingCountry - the receivingCountry.
    • containsErrorCode

      public static boolean containsErrorCode(eu.europa.ec.taxud.validation.ValidationContext validationContext, ErrorCode errorCode)
      Checks if the context already contains an error with is related to the error code.
      Parameters:
      validationContext - The validation context.
      errorCode - The error code.
      Returns:
      true if at least one validation error matches to the error code. Otherwise, returns false.
    • isRelatedError

      public static boolean isRelatedError(eu.europa.ec.taxud.validation.ValidationError validationError, ErrorCode errorCode)
      Checks if a validation error is related to the error code.
      Parameters:
      validationError - The validation error.
      errorCode - The error code.
      Returns:
      true if the error code matches to the validation error. Otherwise, returns false.
    • getDoubleParsingProperty

      public static Boolean getDoubleParsingProperty(eu.europa.ec.taxud.validation.ValidationContext context) throws ClassCastException
      Provides the value of the double parsing property from the context.
      Parameters:
      context - The validation context.
      Returns:
      the value of the property if it set. Otherwise, returns null.
      Throws:
      ClassCastException - the class cast exception
    • handleValidationMode

      public static void handleValidationMode(eu.europa.ec.taxud.validation.ValidationContext context, String modeParameter)
      Handles the given validation mode parameter.
      Parameters:
      context - The validation context.
      modeParameter - The mode parameter value.
    • getValueBasedOnValidationMode

      public static String getValueBasedOnValidationMode(String testValue, String prodValue, eu.europa.ec.taxud.validation.ValidationContext context)
      Gets the related value based on the validation mode.
      Parameters:
      testValue - The value in case of test validation mode.
      prodValue - The value in case of production validation mode.
      context - The validation context.
      Returns:
      The test value given if the validation context contains a validation mode to test. Otherwise, returns the production value.
    • addErrorBasedOnExclRules

      public static boolean addErrorBasedOnExclRules(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode)
      Add error based on excl rules boolean.
      Parameters:
      context - the context
      errorCode - the error code
      Returns:
      the boolean
    • toBooleanSafe

      public static boolean toBooleanSafe(String value)
      To boolean safe boolean.
      Parameters:
      value - the value
      Returns:
      the boolean
    • disableEuRules

      public static boolean disableEuRules(eu.europa.ec.taxud.validation.ValidationContext context)
      Disable eu rules.
      Parameters:
      context - the context
      Returns:
      the boolean
    • isRejected

      public static boolean isRejected(eu.europa.ec.taxud.validation.ValidationContext context)
      Is rejected boolean.
      Parameters:
      context - the context
      Returns:
      the boolean