Package eu.europa.ec.taxud.dac8.vm.utils
Class ValidationContextUtils
java.lang.Object
eu.europa.ec.taxud.dac8.vm.utils.ValidationContextUtils
ValidationContextUtils handles some tools related to the validation context.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.slf4j.LoggerThe Logger of the classValidationContextUtils. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddError(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode, String docRefId, Element element) Adds an error to the validation context.static booleanaddErrorBasedOnExclRules(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode) Add error based on excl rules boolean.static voidaddErrorWithoutRefId(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode) Add error without ref id.static voidaddErrorWithoutRefId(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode, Element element) * Adds an error to the validation context without specifying a docRefId.static voidaddUniqueError(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode) Add unique error.static booleancontainsErrorCode(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 booleandisableEuRules(eu.europa.ec.taxud.validation.ValidationContext context) Disable eu rules.static BooleangetDoubleParsingProperty(eu.europa.ec.taxud.validation.ValidationContext context) Provides the value of the double parsing property from the context.static StringgetValueBasedOnValidationMode(String testValue, String prodValue, eu.europa.ec.taxud.validation.ValidationContext context) Gets the related value based on the validation mode.static voidhandleValidationMode(eu.europa.ec.taxud.validation.ValidationContext context, String modeParameter) Handles the given validation mode parameter.static booleanisRejected(eu.europa.ec.taxud.validation.ValidationContext context) Is rejected boolean.static booleanisRelatedError(eu.europa.ec.taxud.validation.ValidationError validationError, ErrorCode errorCode) Checks if a validation error is related to the error code.static voidlogMessageSpecs(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 booleantoBooleanSafe(String value) To boolean safe boolean.
-
Field Details
-
LOGGER
public static final org.slf4j.Logger LOGGERThe Logger of the classValidationContextUtils.
-
-
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 contexterrorCode- the error code
-
addUniqueError
public static void addUniqueError(eu.europa.ec.taxud.validation.ValidationContext context, ErrorCode errorCode) Add unique error.- Parameters:
context- the contexterrorCode- 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:
trueif at least one validation error matches to the error code. Otherwise, returnsfalse.
-
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:
trueif the error code matches to the validation error. Otherwise, returnsfalse.
-
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 contexterrorCode- the error code- Returns:
- the boolean
-
toBooleanSafe
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
-