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 TypeMethodDescriptionvoidaddElementValidationMessage(ElementKey key, IWorkflowValidationMessage message) Adds a validation message for the given workflow element.voidaddGlobalValidationMessage(ElementKey key, IWorkflowValidationMessage message) Adds a validations message for the workflow element with the given key.voidAdds a validation message for the given process.voidaddTaskValidationMessage(UUID key, IWorkflowValidationMessage message) Adds a validation message for the given workflow task.voidaddUnhandledException(Throwable exception) Adds an unhandled exception to this workflow validation context.voidvoidvoid<T> TassociateValue(Object key, Function<IWorkflowLocalValidationContext, T> supplier) Associates the given value for the duration of the workflow validation process.Called after validation is done.voidclose()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.booleanhasGroup(EWorkflowValidationGroup group) voidMarks the given element as having been validated, regardless of whether it is valid or invalid.voidMarks the given element as being invalid.voidMarks the given workflow element as invalid, when validation failed.voidMarks the given process as having been validated.voidMarks the process as being invalid.voidmarkTaskValidated(UUID key) Marks the given task as having been validated, regardless of whether it is valid or invalid.voidMarks the given task as being invalid.voidsetCurrentElementKey(ElementKey currentElementKey) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.xima.fc.interfaces.workflow.validation.IWorkflowGlobalHandlerValidationContext
getNodeByUuid, getTriggerByUuidMethods 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:IWorkflowGlobalHandlerValidationContextAdds a validations message for the workflow element with the given key.- Specified by:
addGlobalValidationMessagein 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:IWorkflowLocalValidationContextAssociates the given value for the duration of the workflow validation process. Once validation is done, the values are discarded.- Specified by:
associateValuein 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:
closein interfaceAutoCloseable
-
getAvailabilityCheck
- Returns:
- Checker for checking whether a workflow element is available to the current user and client.
-
getBeanValidator
- Specified by:
getBeanValidatorin 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
IBeanValidatingElementwhich automatically delegates to the bean validator.
-
getClient
- Specified by:
getClientin interfaceIBaseEnvironmentData- Returns:
- The
Mandantof the current context.
-
getCurrentElementKey
- Specified by:
getCurrentElementKeyin interfaceIWorkflowLocalBeanValidationContext- Returns:
- The
ElementKeyof the current workflow node or trigger that is currently being checked in the current workflow process.nullwhen no such element key exists.
-
getCurrentResourceBundle
Description copied from interface:IWorkflowHandlerValidationContextResolves 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:
getCurrentResourceBundlein 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:
getEntityContextin interfaceIBaseEnvironmentData- Returns:
- The current entity context that may be used for database interactions.
-
getFlowAnalysis
- Specified by:
getFlowAnalysisin 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:
getLocalein interfaceIBaseEnvironmentData- Returns:
- The locale to use for locale-sensitive actions.
-
getNodeByUuid
public IWorkflowElementWithDeserializedModel<?,WorkflowNode> getNodeByUuid(NodeKey key, String nodeType) - Specified by:
getNodeByUuidin 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.
nullwhen no such node exists.
-
getNodesByType
public Collection<IWorkflowElementWithDeserializedModel<?,WorkflowNode>> getNodesByType(String nodeType) - Specified by:
getNodesByTypein 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:
getProjectin interfaceIBaseWorkflowEnvironmentData- Returns:
- The current project to which the workflow belongs.
-
getProvider
- Specified by:
getProviderin 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:
getTriggerByUuidin 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.
nullwhen no such node exists.
-
getTriggersByType
public Collection<IWorkflowElementWithDeserializedModel<?,WorkflowTrigger>> getTriggersByType(String triggerType) - Specified by:
getTriggersByTypein 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:
getUserModelin 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:
getWorkflowVersionin 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:IWorkflowGlobalHandlerValidationContextMarks the given workflow element as invalid, when validation failed.- Specified by:
markGlobalValidationFailedin 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:
resultBuilderin 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- TheNodeKeyof the current workflow node or trigger that is currently being checked.
-
getUser
Deprecated.UsegetUserModel()instead.- Specified by:
getUserin interfaceIBaseEnvironmentData- Returns:
- The user of the active context that should be used for protocol entries etc.
-
getUserModel()instead.