Class ProcessEvaluator
- java.lang.Object
-
- com.aquima.interactions.process.impl.ProcessEvaluator
-
- All Implemented Interfaces:
IProcessEvaluator
public class ProcessEvaluator extends Object implements IProcessEvaluator
This class is responsible for evaluating a process based on the current state, and determining the task that should be scheduled.- Since:
- 7.1
- Author:
- O. Kerpershoek
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ProcessEvaluator(ProcessEngine engine, ProcessCase processCase, IUserData userData)
protected
ProcessEvaluator(ProcessEngine engine, ProcessCase processCase, IUserData userData, boolean caseUnlocked)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
continueFromNode(ITaskModel task, String exitState, boolean caseDataChanged)
This method will assume the task as completed, and continue the process from that point.void
continueWithCaseDataChange()
This method may be invoked to force the process to be evaluated after a change in the case data.void
continueWithEvent(IMessageEvent messageEvent)
This method will check if any task is waiting for an event, and activated those tasks if needed.IValue
evaluate(AttributeReference attributeReference)
This method will the evaluate the value of the given attribute reference.boolean
evaluate(ICondition condition, boolean defaultResult)
This method will evaluate the condition and returns it's boolean result.IValue
evaluate(IExpression expression)
This method will evaluate the expression and return its result.DMNDecisionTree
evaluateDecision(String description, ICondition condition, boolean defaultResult)
This method will evaluate the condition and returns it's boolean result as a DMN decision tree.DMNDecisionTree
evaluateDecision(String description, IExpression expression)
This method will evaluate the expression and return its result as a DMN decision tree.protected void
evaluateTaskPriority(DateTimeValue currentTime, String[] nodeIds)
Evaluates the priorities of tasks.protected void
evaluateTimerTasks(DateTimeValue currentTime)
String
getApplicationId()
CaseEngineScheduler
getCaseEngineScheduler()
protected ProcessCaseRepository
getDao()
long
getProcessCaseId()
String
getProcessName()
protected IEvaluationQueue
getQueue()
IScheduler
getScheduler()
ITraceEngine
getTraceEngine()
TriggeredMessageEvent
getTriggeredMessageEvent(String messageEventName)
This method returns the content of a triggered event.IUserData
getUserData()
boolean
handleCaseUpdates(IProcessCaseUpdates updates)
This methods allow updates to the case modelboolean
handleCaseUpdates(IProcessCaseUpdates updates, ICaseUpdatesContext context)
This methods allow updates to the case modelboolean
isMessageEventTriggered(String messageEventName)
This method returns a boolean indicating if the specified event has been raised/signaled/triggered during the current process evaluation.boolean
isProcessCaseLocked()
Checks whether the process case being evaluated is locked.void
notifyAutomaticTaskFinished()
Notify the evaluator that the execution of an automatic task has finished so that it may queue delayed events created by the automatic task.void
notifyCaseDataChanged()
Notify the evaluator that case data has been changed so that cached data may be clearedprotected void
reopenTask(ITaskModel taskModel)
Re-opens the given task.protected long
replayTimerEvent(ICaseEventModel caseEvent)
void
setChangeListener(IProcessCaseChangeListener changeListener)
void
setEvaluationQueue(EvaluationQueue evaluationQueue)
protected void
startProcess(IProcessEventStartDefinition startDefinition)
-
-
-
Constructor Detail
-
ProcessEvaluator
protected ProcessEvaluator(ProcessEngine engine, ProcessCase processCase, IUserData userData) throws UnknownAttributeException, UnknownEntityException
-
ProcessEvaluator
protected ProcessEvaluator(ProcessEngine engine, ProcessCase processCase, IUserData userData, boolean caseUnlocked) throws UnknownAttributeException, UnknownEntityException
Creates a new instance.- Parameters:
engine
-processCase
-userData
- User under who the ProcessEvaluator does its workcaseUnlocked
- - indicates whether the evaluated case has just been unlocked. If true, this evaluator will also evaluate delayed events.- Throws:
UnknownAttributeException
UnknownEntityException
-
-
Method Detail
-
setEvaluationQueue
public void setEvaluationQueue(EvaluationQueue evaluationQueue)
-
getUserData
public IUserData getUserData()
- Specified by:
getUserData
in interfaceIProcessEvaluator
- Returns:
- The current active user
-
getTraceEngine
public ITraceEngine getTraceEngine()
- Specified by:
getTraceEngine
in interfaceIProcessEvaluator
- Returns:
- The trace engine
-
getApplicationId
public String getApplicationId()
- Specified by:
getApplicationId
in interfaceIProcessEvaluator
- Returns:
- The application id of the current applicaiton
-
getProcessName
public String getProcessName()
- Specified by:
getProcessName
in interfaceIProcessEvaluator
- Returns:
- The name of the process for this evaluator, may be null if the case was not started for a predefined process
-
getProcessCaseId
public long getProcessCaseId()
- Specified by:
getProcessCaseId
in interfaceIProcessEvaluator
- Returns:
- the ID of the process for this evaluator
-
getScheduler
public IScheduler getScheduler()
- Specified by:
getScheduler
in interfaceIProcessEvaluator
- Returns:
- the blueriq scheduler which controlls the jobs
-
getCaseEngineScheduler
public CaseEngineScheduler getCaseEngineScheduler()
- Specified by:
getCaseEngineScheduler
in interfaceIProcessEvaluator
- Returns:
- the case engine scheduler which schedules the jobs
-
getQueue
protected IEvaluationQueue getQueue()
-
getDao
protected ProcessCaseRepository getDao()
-
startProcess
protected void startProcess(IProcessEventStartDefinition startDefinition)
-
continueWithEvent
public void continueWithEvent(IMessageEvent messageEvent) throws AppException
Description copied from interface:IProcessEvaluator
This method will check if any task is waiting for an event, and activated those tasks if needed. An event that has been triggered will stay active during the evaluation, but will be discarded once this evaluator has completed.- Specified by:
continueWithEvent
in interfaceIProcessEvaluator
- Parameters:
messageEvent
- The definition of the event that occurred.- Throws:
AppException
- This exception is thrown when the event could not be processed.
-
evaluateTaskPriority
protected void evaluateTaskPriority(DateTimeValue currentTime, String[] nodeIds)
Evaluates the priorities of tasks.- Parameters:
currentTime
- the reference timenodeIds
- optionally restrict the evaluated tasks to only those with these nodeIds (may be null).
-
evaluateTimerTasks
protected void evaluateTimerTasks(DateTimeValue currentTime)
-
reopenTask
protected final void reopenTask(ITaskModel taskModel)
Re-opens the given task. If the task is automatic, it will also be executed.- Parameters:
taskModel
- the task to be re-opened
-
replayTimerEvent
protected final long replayTimerEvent(ICaseEventModel caseEvent) throws ReplayCaseEventException
- Throws:
ReplayCaseEventException
-
continueWithCaseDataChange
public void continueWithCaseDataChange() throws AppException
Description copied from interface:IProcessEvaluator
This method may be invoked to force the process to be evaluated after a change in the case data. A change in case data is mainly relevant for adhoc tasks and condition nodes.- Specified by:
continueWithCaseDataChange
in interfaceIProcessEvaluator
- Throws:
AppException
- This exception is thrown when the evaluation of the process failed.
-
continueFromNode
public void continueFromNode(ITaskModel task, String exitState, boolean caseDataChanged) throws AppException
Description copied from interface:IProcessEvaluator
This method will assume the task as completed, and continue the process from that point.- Specified by:
continueFromNode
in interfaceIProcessEvaluator
- Parameters:
task
- The task that was completed, and from which the processing should continue.exitState
- The exit state/result of the completed task.caseDataChanged
- true if case data may have been changed, if true then conditional nodes and adhoc nodes will also be reevaluated- Throws:
AppException
- This exception is thrown when the process could not continue.
-
evaluate
public IValue evaluate(IExpression expression) throws RuleEngineException
Description copied from interface:IProcessEvaluator
This method will evaluate the expression and return its result.- Specified by:
evaluate
in interfaceIProcessEvaluator
- Parameters:
expression
- The expression that should be evaluated.- Returns:
- The result of the expression.
- Throws:
RuleEngineException
- This exception is thrown when the expression could not be evaluated.
-
evaluate
public boolean evaluate(ICondition condition, boolean defaultResult) throws RuleEngineException
Description copied from interface:IProcessEvaluator
This method will evaluate the condition and returns it's boolean result. If the condition evaluates to false, or if no condition was available (null), the default result will be returned.- Specified by:
evaluate
in interfaceIProcessEvaluator
- Parameters:
condition
- The condition that should be evaluated (may be null).defaultResult
- The result that should be returned if the condition could not be evaluated.- Returns:
- Boolean containing the result of the condition.
- Throws:
RuleEngineException
- This exception is thrown when the condition could not be evaluated.
-
evaluate
public IValue evaluate(AttributeReference attributeReference)
Description copied from interface:IProcessEvaluator
This method will the evaluate the value of the given attribute reference.- Specified by:
evaluate
in interfaceIProcessEvaluator
- Parameters:
attributeReference
- The attribute reference that should be evaluated, may not be null- Returns:
- IValue representing the value, never null
-
evaluateDecision
public DMNDecisionTree evaluateDecision(String description, IExpression expression)
Description copied from interface:IProcessEvaluator
This method will evaluate the expression and return its result as a DMN decision tree.- Specified by:
evaluateDecision
in interfaceIProcessEvaluator
expression
- The expression that should be evaluated.- Returns:
- The result of the decision.
-
evaluateDecision
public DMNDecisionTree evaluateDecision(String description, ICondition condition, boolean defaultResult)
Description copied from interface:IProcessEvaluator
This method will evaluate the condition and returns it's boolean result as a DMN decision tree. If the condition evaluates to false, or if no condition was available (null), the default result will be returned.- Specified by:
evaluateDecision
in interfaceIProcessEvaluator
condition
- The condition that should be evaluated (may be null).defaultResult
- The result that should be returned if the condition could not be evaluated.- Returns:
- DMNDecisionTree containing the result of the decision.
-
isMessageEventTriggered
public boolean isMessageEventTriggered(String messageEventName)
Description copied from interface:IProcessEvaluator
This method returns a boolean indicating if the specified event has been raised/signaled/triggered during the current process evaluation.- Specified by:
isMessageEventTriggered
in interfaceIProcessEvaluator
- Parameters:
messageEventName
- The event that should be checked.- Returns:
- Boolean indicating if the event was triggered during the current evaluation.
-
isProcessCaseLocked
public boolean isProcessCaseLocked()
Description copied from interface:IProcessEvaluator
Checks whether the process case being evaluated is locked.- Specified by:
isProcessCaseLocked
in interfaceIProcessEvaluator
- Returns:
- true if the case is locked, false otherwise
-
getTriggeredMessageEvent
public TriggeredMessageEvent getTriggeredMessageEvent(String messageEventName)
Description copied from interface:IProcessEvaluator
This method returns the content of a triggered event.- Specified by:
getTriggeredMessageEvent
in interfaceIProcessEvaluator
- Parameters:
messageEventName
- The name of the message event.- Returns:
- The data content of the messageevent, or null.
-
handleCaseUpdates
public boolean handleCaseUpdates(IProcessCaseUpdates updates) throws ProcessException, UnknownAttributeException, UnknownEntityException
Description copied from interface:IProcessEvaluator
This methods allow updates to the case model- Specified by:
handleCaseUpdates
in interfaceIProcessEvaluator
- Parameters:
updates
- Interface handling the updates,- Returns:
- Indicator whether the case data was updated.
- Throws:
ProcessException
UnknownAttributeException
UnknownEntityException
-
handleCaseUpdates
public boolean handleCaseUpdates(IProcessCaseUpdates updates, ICaseUpdatesContext context) throws ProcessException, UnknownAttributeException, UnknownEntityException
Description copied from interface:IProcessEvaluator
This methods allow updates to the case model- Specified by:
handleCaseUpdates
in interfaceIProcessEvaluator
- Parameters:
updates
- Interface handling the updates,context
- interface to provide context about the updates- Returns:
- Indicator whether the case data was updated.
- Throws:
ProcessException
UnknownAttributeException
UnknownEntityException
-
setChangeListener
public void setChangeListener(IProcessCaseChangeListener changeListener)
-
notifyCaseDataChanged
public void notifyCaseDataChanged()
Description copied from interface:IProcessEvaluator
Notify the evaluator that case data has been changed so that cached data may be cleared- Specified by:
notifyCaseDataChanged
in interfaceIProcessEvaluator
-
notifyAutomaticTaskFinished
public void notifyAutomaticTaskFinished()
Description copied from interface:IProcessEvaluator
Notify the evaluator that the execution of an automatic task has finished so that it may queue delayed events created by the automatic task.- Specified by:
notifyAutomaticTaskFinished
in interfaceIProcessEvaluator
-
-