Interface ValidationService
- All Superinterfaces:
Service
public interface ValidationService extends Service
Use to register validation "contexts" (e.g. "ZBKS.BookUpdate" or "ZBKS.OrderCancellation"),
and to invoke validation rules against those contexts.
-
Method Summary
Modifier and Type Method Description void
applyValidatedStateToModel(ValidatedModelState validatedState, Model model)
Apply the supplied ValidatedModelState (computed fields, default values, etc...) to the supplied model.ValidationCompilationResponse
compile(ValidationCompilationRequest request, PlatformUserContext ctx)
Compiles the rules from the given request and returns any resulting compilation failures.java.util.List<Pair<java.lang.String,java.lang.String>>
createModelBindingKeyLabelKeyPairs(Model m)
Given a Model, get a list of pairs of field key to label key (useful in creating a ValidationSubContext for a Model)java.util.Map<java.lang.String,java.lang.Object>
createModelBindings(Model m)
Given a Model, bind all model fields in a Map for evaluation in a Validation context.java.util.List<ValidationPackage>
createValidationPackages(java.util.List<ValidationRule> rules, PlatformUserContext ctx)
Looks up the associated ValidationRuleIf and ValidationRuleThen records for the given rules to assemble ValidationPackages which can be passed to thecompile(ValidationCompilationRequest, PlatformUserContext)
orvalidate(ValidationRequest, PlatformUserContext)
methods.java.util.Map<java.lang.String,java.util.List<PlatformELFunction>>
getContextPlatformELFunctions()
Get a map of context-names to registered Platform Expression Language functions.java.util.List<PlatformELFunction>
getContextPlatformELFunctions(java.lang.String context)
Get a list of Platform Expression Language functions registered for the passed context.java.util.Map<java.lang.String,ValidationContext>
getContexts()
Returns registered Contexts, keyed by context namejava.util.List<PlatformELFunction>
getGlobalPlatformELFunctions()
Get a list of all global Platform Expression Language functions.void
registerContext(ValidationContext validationContext)
Registers a Context and associated SubContexts.void
registerContext(ValidationContext validationContext, java.util.List<PlatformELFunction> functions)
Registers a Context and associated SubContexts.void
registerContextsForValidationConfig(java.util.List<com.onenetwork.platform.data.sql.impl.IDaoRow> validationConfigRows)
Registers validation contexts for ModelValidationConfigRow entriesvoid
registerPlatformELFunctions(java.util.List<PlatformELFunction> functions)
Add new global functions to the Platform Exrpression Language by registering them with this method.void
registerPlatformELFunctions(java.util.List<PlatformELFunction> functions, java.lang.String context)
Add new Platform Expression Language functions for a specific context by registering them with this method.void
unregisterPlatformELFunctions(java.util.List<PlatformELFunction> functions)
Remove the passed global Platform Expression Language functions from the registry.void
unregisterPlatformELFunctions(java.util.List<PlatformELFunction> functions, java.lang.String context)
Remove the context-specific Platform Expression Language functions from the registry.ValidationResponse
validate(ValidationRequest request, PlatformUserContext ctx)
Evaluates the rules from the given request and returns any resulting validation failures.
-
Method Details
-
registerContext
Registers a Context and associated SubContexts. End users will be allowed to create validation rules against these in the UI.- Parameters:
validationContext
- describes the context and its SubContexts
-
registerContext
void registerContext(ValidationContext validationContext, java.util.List<PlatformELFunction> functions)Registers a Context and associated SubContexts. End users will be allowed to create validation rules against these in the UI.- Parameters:
validationContext
- describes the context and its SubContextsfunctions
- additional functions that should be made available to this ValidationContext
-
getContexts
java.util.Map<java.lang.String,ValidationContext> getContexts()Returns registered Contexts, keyed by context name -
createValidationPackages
java.util.List<ValidationPackage> createValidationPackages(java.util.List<ValidationRule> rules, PlatformUserContext ctx)Looks up the associated ValidationRuleIf and ValidationRuleThen records for the given rules to assemble ValidationPackages which can be passed to thecompile(ValidationCompilationRequest, PlatformUserContext)
orvalidate(ValidationRequest, PlatformUserContext)
methods. Inactive rules will be excluded from the packages returned, as will rules where "TestUser" is set and the caller doesn't match the TestUser.- Parameters:
rules
- ValidationRulesctx
- caller's context- Returns:
- ValidationPackages which couple the rules with their ifs/thens
-
compile
ValidationCompilationResponse compile(ValidationCompilationRequest request, PlatformUserContext ctx)Compiles the rules from the given request and returns any resulting compilation failures. Does not evaluate the rules. -
validate
Evaluates the rules from the given request and returns any resulting validation failures. -
createModelBindings
Given a Model, bind all model fields in a Map for evaluation in a Validation context. -
createModelBindingKeyLabelKeyPairs
java.util.List<Pair<java.lang.String,java.lang.String>> createModelBindingKeyLabelKeyPairs(Model m)Given a Model, get a list of pairs of field key to label key (useful in creating a ValidationSubContext for a Model) -
registerContextsForValidationConfig
void registerContextsForValidationConfig(java.util.List<com.onenetwork.platform.data.sql.impl.IDaoRow> validationConfigRows)Registers validation contexts for ModelValidationConfigRow entries- Parameters:
validationConfigRows
- validation configuration rows for whichValidationContext
need to be registerd
-
applyValidatedStateToModel
Apply the supplied ValidatedModelState (computed fields, default values, etc...) to the supplied model.- Parameters:
validatedState
-model
-
-
registerPlatformELFunctions
Add new global functions to the Platform Exrpression Language by registering them with this method.- Parameters:
function
-
-
registerPlatformELFunctions
void registerPlatformELFunctions(java.util.List<PlatformELFunction> functions, java.lang.String context)Add new Platform Expression Language functions for a specific context by registering them with this method. Functions registered this way will only be available to ValidationRules using the passed context.- Parameters:
function
-context
-
-
getGlobalPlatformELFunctions
java.util.List<PlatformELFunction> getGlobalPlatformELFunctions()Get a list of all global Platform Expression Language functions. The excludes functions registered for specific contexts and subcontexts. -
getContextPlatformELFunctions
java.util.Map<java.lang.String,java.util.List<PlatformELFunction>> getContextPlatformELFunctions()Get a map of context-names to registered Platform Expression Language functions.- Parameters:
context
-
-
getContextPlatformELFunctions
Get a list of Platform Expression Language functions registered for the passed context.- Parameters:
context
-
-
unregisterPlatformELFunctions
Remove the passed global Platform Expression Language functions from the registry.- Parameters:
functions
-
-
unregisterPlatformELFunctions
void unregisterPlatformELFunctions(java.util.List<PlatformELFunction> functions, java.lang.String context)Remove the context-specific Platform Expression Language functions from the registry.- Parameters:
functions
-context
-
-