Class DefaultWorkflowValidationContext
java.lang.Object
de.xima.fc.workflow.processor.logic.validation.DefaultWorkflowValidationContext
- All Implemented Interfaces:
IBaseEnvironmentData
,IWorkflowValidationEnvironmentData
,IBaseWorkflowEnvironmentData
,IWorkflowGlobalHandlerValidationContext
,IWorkflowHandlerValidationContext
,IWorkflowLocalBeanValidationContext
,IWorkflowLocalHandlerValidationContext
,IWorkflowLocalValidationContext
,IWorkflowValidationContext
,AutoCloseable
public class DefaultWorkflowValidationContext
extends Object
implements IWorkflowLocalHandlerValidationContext, IWorkflowLocalBeanValidationContext, IWorkflowGlobalHandlerValidationContext, AutoCloseable
Default (mainly POJO) implementation of the
IWorkflowLocalHandlerValidationContext
and
IWorkflowGlobalHandlerValidationContext
. Can also be used as a IWorkflowLocalBeanValidationContext
.
Contains additional methods meant only for the WorkflowValidator
implementation.- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new internal workflow validation context with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addElementValidationMessage
(ElementKey key, IWorkflowValidationMessage message) Adds a validation message for the given workflow element.void
addGlobalValidationMessage
(ElementKey key, IWorkflowValidationMessage message) Adds a validations message for the workflow element with the given key.void
Adds a validation message for the given process.void
addTaskValidationMessage
(UUID key, IWorkflowValidationMessage message) Adds a validation message for the given workflow task.void
addUnhandledException
(Throwable exception) Adds an unhandled exception to this workflow validation context.void
void
void
<T> T
associateValue
(Object key, Function<IWorkflowLocalValidationContext, T> supplier) Associates the given value for the duration of the workflow validation process.Called after validation is done.void
close()
Resolves the resource bundle to be used for the workflow element that is currently being validated.getNodeByUuid
(NodeKey key, String nodeType) getNodesByType
(String nodeType) getTriggerByUuid
(TriggerKey key, String triggerType) getTriggersByType
(String triggerType) getUser()
Deprecated.boolean
hasGroup
(EWorkflowValidationGroup group) void
Marks the given element as having been validated, regardless of whether it is valid or invalid.void
Marks the given element as being invalid.void
Marks the given workflow element as invalid, when validation failed.void
Marks the given process as having been validated.void
Marks the process as being invalid.void
markTaskValidated
(UUID key) Marks the given task as having been validated, regardless of whether it is valid or invalid.void
Marks the given task as being invalid.void
setCurrentElementKey
(ElementKey currentElementKey) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface de.xima.fc.interfaces.workflow.validation.IWorkflowGlobalHandlerValidationContext
getNodeByUuid, getTriggerByUuid
Methods inherited from interface de.xima.fc.interfaces.workflow.validation.IWorkflowHandlerValidationContext
getLocalizedMessage
-
Constructor Details
-
DefaultWorkflowValidationContext
Creates a new internal workflow validation context with the given parameters.- Parameters:
params
- Configuration for the validation process.
-
-
Method Details
-
addElementValidationMessage
Adds a validation message for the given workflow element.- Parameters:
key
- Key of the workflow element for which to add the message.message
- Message to add.
-
addGlobalValidationMessage
Description copied from interface:IWorkflowGlobalHandlerValidationContext
Adds a validations message for the workflow element with the given key.- Specified by:
addGlobalValidationMessage
in interfaceIWorkflowGlobalHandlerValidationContext
- Parameters:
key
- Key of the element to which the validation result applies.message
- Validation message to add.
-
addProcessValidationMessage
Adds a validation message for the given process.- Parameters:
message
- Message to add.
-
addTaskValidationMessage
Adds a validation message for the given workflow task.- Parameters:
key
- Key of the workflow element for which to add the message.message
- Message to add.
-
addUnhandledException
Adds an unhandled exception to this workflow validation context. Usually called when an exception occurred during the validation of a certain node or trigger. This should not prevent other nodes and triggers from being validated.- Parameters:
exception
- The unhandled exception that occurred.
-
appendElementValidationResult
- Parameters:
key
- Key of the workflow element for which to set the validation result.result
- The validation result to register for the given element.
-
appendProcessValidationResult
- Parameters:
result
- The validation result to register for the process.
-
appendTaskValidationResult
- Parameters:
key
- Key of the workflow element for which to set the validation result.result
- The validation result to register for the given element.
-
associateValue
Description copied from interface:IWorkflowLocalValidationContext
Associates the given value for the duration of the workflow validation process. Once validation is done, the values are discarded.- Specified by:
associateValue
in interfaceIWorkflowLocalValidationContext
- Type Parameters:
T
- Type of the associate value.- Parameters:
key
- Key for the association.supplier
- Supplier that produces the value when not yet present.- Returns:
- The associated value.
-
buildResult
Called after validation is done. Collects all validation messages added during the validation process and returns them.- Returns:
- The validation result representing the current state of this context.
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
getAvailabilityCheck
- Returns:
- Checker for checking whether a workflow element is available to the current user and client.
-
getBeanValidator
- Specified by:
getBeanValidator
in interfaceIWorkflowLocalHandlerValidationContext
- Returns:
- An instance of the bean validator that may be used to validate the properties model of a workflow
element. Bean validation is not required, but recommended, as it can be used in the UI as well. Consider
adding the mixin
IBeanValidatingElement
which automatically delegates to the bean validator.
-
getClient
- Specified by:
getClient
in interfaceIBaseEnvironmentData
- Returns:
- The
Mandant
of the current context.
-
getCurrentElementKey
- Specified by:
getCurrentElementKey
in interfaceIWorkflowLocalBeanValidationContext
- Returns:
- The
ElementKey
of the current workflow node or trigger that is currently being checked in the current workflow process.null
when no such element key exists.
-
getCurrentResourceBundle
Description copied from interface:IWorkflowHandlerValidationContext
Resolves the resource bundle to be used for the workflow element that is currently being validated. This resource bundle takes into account the default resource bundle offered by formcycle, as well as the custom resource bundle indicated byIElementHandler.getResourceBundle(Locale)
.Please note as this depends upon the workflow element currently being validated, you should not store references to the returned bundle, always call this method directly.
- Specified by:
getCurrentResourceBundle
in interfaceIWorkflowHandlerValidationContext
- Returns:
- The current resource bundle containing all messages of the custom formcycle resources and the custom resources of the node or trigger handler.
-
getElementIndex
- Returns:
- The element index for quickly accessing workflow element by their key.
-
getEntityContext
- Specified by:
getEntityContext
in interfaceIBaseEnvironmentData
- Returns:
- The current entity context that may be used for database interactions.
-
getFlowAnalysis
- Specified by:
getFlowAnalysis
in interfaceIWorkflowGlobalHandlerValidationContext
- Returns:
- A handler for querying data about the execution of the workflow task being validated, such as whether a certain node is reachable from another node.
-
getGroups
- Returns:
- Groups to validate.
-
getLocale
- Specified by:
getLocale
in interfaceIBaseEnvironmentData
- Returns:
- The locale to use for locale-sensitive actions.
-
getNodeByUuid
public IWorkflowElementWithDeserializedModel<?,WorkflowNode> getNodeByUuid(NodeKey key, String nodeType) - Specified by:
getNodeByUuid
in interfaceIWorkflowGlobalHandlerValidationContext
- Parameters:
key
- Key of a node to find.nodeType
- Expected type of the node. Pass null or the empty string to return the node irrespective of its type.- Returns:
- The node with the given key and the given type in the current workflow process.
null
when no such node exists.
-
getNodesByType
public Collection<IWorkflowElementWithDeserializedModel<?,WorkflowNode>> getNodesByType(String nodeType) - Specified by:
getNodesByType
in interfaceIWorkflowGlobalHandlerValidationContext
- Parameters:
nodeType
- Expected type of the node. Pass null or the empty string to return the all nodes.- Returns:
- All nodes of the given type, or all nodes when no type is given.
-
getProject
- Specified by:
getProject
in interfaceIBaseWorkflowEnvironmentData
- Returns:
- The current project to which the workflow belongs.
-
getProvider
- Specified by:
getProvider
in interfaceIWorkflowValidationContext
- Returns:
- The provider for accessing various contextual data, such as a list of all users or user groups.
-
getTriggerByUuid
public IWorkflowElementWithDeserializedModel<?,WorkflowTrigger> getTriggerByUuid(TriggerKey key, String triggerType) - Specified by:
getTriggerByUuid
in interfaceIWorkflowGlobalHandlerValidationContext
- Parameters:
key
- Key of a trigger to find.triggerType
- Expected type of the trigger. Pass null or the empty string to return the trigger irrespective of its type.- Returns:
- The trigger with the given key and the given type in the current workflow process.
null
when no such node exists.
-
getTriggersByType
public Collection<IWorkflowElementWithDeserializedModel<?,WorkflowTrigger>> getTriggersByType(String triggerType) - Specified by:
getTriggersByType
in interfaceIWorkflowGlobalHandlerValidationContext
- Parameters:
triggerType
- Expected type of the trigger. Pass null or the empty string to return the all triggers.- Returns:
- All triggers of the given type, or all triggers when no type is given.
-
getUserModel
- Specified by:
getUserModel
in interfaceIBaseEnvironmentData
- Returns:
- The user of the active context that should be used for protocol entries etc.
-
getWorkflowBeanValidator
- Returns:
- The bean validator to be used for the workflow validation process.
-
getWorkflowResouceBundleLocator
public WorkflowResourceBundleLocator.MutableWorkflowResourceBundleLocator getWorkflowResouceBundleLocator()- Returns:
- The resource bundle locator to be used for the workflow validation process.
-
getWorkflowVersion
- Specified by:
getWorkflowVersion
in interfaceIBaseWorkflowEnvironmentData
- Returns:
- The current workflow version that is being validated.
-
hasGroup
- Parameters:
group
- Group to check- Returns:
- Whether the group should be validated.
-
markElementValidated
Marks the given element as having been validated, regardless of whether it is valid or invalid. This exists to keep track of the elements that were validated and the elements for which validation was skipped.- Parameters:
key
- Key of the validated element.
-
markElementValidationFailed
Marks the given element as being invalid.- Parameters:
key
- Key of the invalid element.
-
markGlobalValidationFailed
Description copied from interface:IWorkflowGlobalHandlerValidationContext
Marks the given workflow element as invalid, when validation failed.- Specified by:
markGlobalValidationFailed
in interfaceIWorkflowGlobalHandlerValidationContext
- Parameters:
key
- Key of the element to mark as invalid.
-
markProcessValidated
public void markProcessValidated()Marks the given process as having been validated. -
markProcessValidationFailed
public void markProcessValidationFailed()Marks the process as being invalid. -
markTaskValidated
Marks the given task as having been validated, regardless of whether it is valid or invalid. This exists to keep track of the tasks that were validated and the tasks for which validation was skipped.- Parameters:
key
- Key of the validated task.
-
markTaskValidationFailed
Marks the given task as being invalid.- Parameters:
key
- Key of the invalid task.
-
resultBuilder
- Specified by:
resultBuilder
in interfaceIWorkflowLocalValidationContext
- Returns:
- Builder for creating the result that needs to be returned by
IElementHandler#validateLocal
. This is provided for convenience, you can also create your own implementation ofIWorkflowElementValidationResult
.
-
setCurrentElementKey
- Parameters:
currentElementKey
- TheNodeKey
of the current workflow node or trigger that is currently being checked.
-
getUser
Deprecated.UsegetUserModel()
instead.- Specified by:
getUser
in interfaceIBaseEnvironmentData
- Returns:
- The user of the active context that should be used for protocol entries etc.
-
getUserModel()
instead.