Package org.keycloak.models.workflow
Interface WorkflowConditionProvider
- All Superinterfaces:
Provider
- All Known Implementing Classes:
GroupMembershipWorkflowConditionProvider,IdentityProviderWorkflowConditionProvider,RoleWorkflowConditionProvider,UserAttributeWorkflowConditionProvider
Defines a provider interface for evaluating conditions within workflow executions.
Implementations of this interface are responsible for determining whether specific
conditions are met based on the context of a workflow execution, as well as providing
JPA Criteria API predicates for querying resources based on these conditions.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanevaluate(WorkflowExecutionContext context) Evaluates the condition against the given workflow execution context.Returns the ResourceType} that this condition is capable of evaluating.jakarta.persistence.criteria.PredicatetoPredicate(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.CriteriaQuery<String> query, jakarta.persistence.criteria.Root<?> resourceRoot) Creates a JPA Criteria APIPredicaterepresenting this condition for use in queries.voidvalidate()Validates the internal configuration/state of this condition provider.
-
Method Details
-
getSupportedResourceType
ResourceType getSupportedResourceType()Returns the ResourceType} that this condition is capable of evaluating.- Returns:
- the supported ResourceType for this condition implementation
-
evaluate
Evaluates the condition against the given workflow execution context. Implementations should inspect the providedcontextand returntruewhen the condition is satisfied andfalseotherwise. Typically, implementations use the resource found in the context to test if the condition holds or not, but sometimes the condition may depend on other aspects, such as the current time or other environmental conditions not directly related to the resource.- Parameters:
context- the execution context for the workflow evaluation- Returns:
trueif the condition is met,falseotherwise
-
toPredicate
jakarta.persistence.criteria.Predicate toPredicate(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.CriteriaQuery<String> query, jakarta.persistence.criteria.Root<?> resourceRoot) Creates a JPA Criteria APIPredicaterepresenting this condition for use in queries. Implementations should construct and return a Predicate that can be applied to a query that targets the underlying resource. The method receives aCriteriaBuilder, theCriteriaQuerybeing built and the queryRootcorresponding to the resource being filtered.- Parameters:
cb- the CriteriaBuilder used to construct predicatesquery- the CriteriaQuery being constructedresourceRoot- the Root representing the resource entity in the query- Returns:
- a Predicate representing this condition for use in a CriteriaQuery
-
validate
Validates the internal configuration/state of this condition provider. Implementations should perform any necessary self-checks and throw aWorkflowInvalidStateExceptionif the provider is not correctly configured or cannot operate safely.- Throws:
WorkflowInvalidStateException- if the provider is in an invalid state
-