Class ProcessEngine

java.lang.Object
com.aquima.interactions.process.impl.ProcessEngine
All Implemented Interfaces:
ICaseEvaluator, IProcessData, IProcessEngine, IProcessEngineBehavior, IProcessEngineDefinitions, IProcessExpressionHandler

public class ProcessEngine extends Object implements IProcessEngine, ICaseEvaluator
Main class of the process engine.
Since:
7.1
Author:
O. Kerpershoek
  • Constructor Details

    • ProcessEngine

      public ProcessEngine(IProcessExtensionFactory factory, IProcessEngineDS datasource, IRuleEngine ruleEngine, IMetaModel model, IProject project, IProcessCaseDao dao, ProcessSettings settings, ILicenseProvider licenseProvider, ITraceEngine traceEngine, IScheduler scheduler, ILegacyToggles legacyToggles)
      Constructs a process engine with the specified datasource.
      Parameters:
      factory - Extension for authorization, routing and priority algorithms
      datasource - The data source for loading all flows.
      ruleEngine - Rule engine containing the various business rules and the expression parser.
      model - The model that should be used for the case data.
      project - The project for which the process engine is created.
      dao - The process case dao to store the process engine state.
      settings - The settings for the process engine
      licenseProvider - The license provider to check if using the process engine is allowed.
      traceEngine - The trace engine for tracing.
      scheduler - The scheduler used for controlling jobs.
      legacyToggles - The properties for legacy toggles
      Throws:
      InitializationException - When the flow engine could not be correctly initialized.
  • Method Details

    • getScheduler

      public IScheduler getScheduler()
    • registerDelegate

      public void registerDelegate(IProcessTaskDelegate processTaskDelegate)
      Description copied from interface: IProcessEngine
      This method can be used to register a handler that is able to handle certain tasks (for example handling of automatic tasks).
      Specified by:
      registerDelegate in interface IProcessEngine
      Parameters:
      processTaskDelegate - The delegate that is used for certain tasks (like automatic tasks).
    • registerCaseEvaluator

      public void registerCaseEvaluator(ICaseEvaluator evaluator)
      Description copied from interface: IProcessEngine
      Registers a case evaluator that will be used by this process engine to evaluate cases in the background.
      Specified by:
      registerCaseEvaluator in interface IProcessEngine
      Parameters:
      evaluator - the new evaluator (not null)
    • getCaseEvaluator

      public ICaseEvaluator getCaseEvaluator()
      Description copied from interface: IProcessEngine
      Returns the case evaluator currently used by this process engine.

      NOTE: in future versions, the case evaluator will be replaced with a job scheduler.

      Specified by:
      getCaseEvaluator in interface IProcessEngine
      Returns:
      the currently used case evaluator (not null).
    • getCaseModel

      public IMetaModel getCaseModel()
      Description copied from interface: IProcessEngineDefinitions
      This method returns the model that is used by the process engine to store case data.
      Specified by:
      getCaseModel in interface IProcessEngineDefinitions
      Returns:
      the model that is used by the process engine to store case data.
    • closeCase

      public void closeCase(IUserData userData, long caseId)
      Description copied from interface: IProcessEngineBehavior
      This method may be used to close an existing case and cancel all its tasks.
      Specified by:
      closeCase in interface IProcessEngineBehavior
      Parameters:
      userData - Object containing information about the current user.
      caseId - The ID of the case that should be closed.
    • getAvailableCases

      public IProcessCase[] getAvailableCases(IUserData userData)
      Description copied from interface: IProcessData
      This method will return an array containing the cases that are available for the supplied user.
      Specified by:
      getAvailableCases in interface IProcessData
      Parameters:
      userData - Object containing the information about the current user.
      Returns:
      an array containing the cases that are available for the supplied user.
    • getTask

      public IProcessTask getTask(long taskId)
      Description copied from interface: IProcessData
      This method returns the task for the specified ID.
      Specified by:
      getTask in interface IProcessData
      Parameters:
      taskId - The ID of the requested task.
      Returns:
      The task for the specified ID.
    • getTaskModel

      public ITaskModel getTaskModel(long taskId)
      Description copied from interface: IProcessData
      This method returns the task for the specified ID.
      Specified by:
      getTaskModel in interface IProcessData
      Parameters:
      taskId - The ID of the requested task.
      Returns:
      The task for the specified ID.
    • getCase

      public IProcessCase getCase(long caseId)
      Description copied from interface: IProcessData
      This method returns the case for the specified ID.
      Specified by:
      getCase in interface IProcessData
      Parameters:
      caseId - The ID of the requested case.
      Returns:
      The case for the specified ID.
    • getCaseProcesses

      public IProcessDefinition[] getCaseProcesses()
      Description copied from interface: IProcessEngineDefinitions
      This method returns an array containing the processes that may be executed to create a new case in the process engine. The user data is used to determine the processes which may actually be executed by the provided user.
      Specified by:
      getCaseProcesses in interface IProcessEngineDefinitions
      Returns:
      Array containing the processes that may be executed to create a new case.
    • getProcessByName

      public IProcessDefinition getProcessByName(String name)
      Description copied from interface: IProcessEngineDefinitions
      This method returns the process definition for the specified name.
      Specified by:
      getProcessByName in interface IProcessEngineDefinitions
      Parameters:
      name - The name of the requested process definition.
      Returns:
      The process definition for the specified name.
    • getNodeIds

      public GUID[] getNodeIds()
      Description copied from interface: IProcessEngineDefinitions
      This method returns all node id.
      Specified by:
      getNodeIds in interface IProcessEngineDefinitions
      Returns:
      The node ids, never null.
    • getNodeDefinition

      public IProcessNodeDefinition getNodeDefinition(GUID nodeId)
      Description copied from interface: IProcessEngineDefinitions
      This method returns the process node definition by the specified node id.
      Specified by:
      getNodeDefinition in interface IProcessEngineDefinitions
      Parameters:
      nodeId - The node id, may not be null
      Returns:
      The node definition, never null.
    • getProcessEventByName

      public IProcessEventDefinition getProcessEventByName(String eventName)
      Description copied from interface: IProcessEngineDefinitions
      This method returns the event definition for the specified name.
      Specified by:
      getProcessEventByName in interface IProcessEngineDefinitions
      Parameters:
      eventName - The name of the event whose definition is requested.
      Returns:
      The definition of the event with the specified name.
    • getRoutingAlgorithmByName

      public IRoutingAlgorithmDefinition getRoutingAlgorithmByName(String routingAlgorithmName)
    • getTaskByName

      public IProcessTaskDefinition getTaskByName(String name)
      Description copied from interface: IProcessEngineDefinitions
      This method returns the task definition for the specified name. When a task is loaded from the database (e.g. retrieved from the DAO), use the method IProcessEngineDefinitions.getProcessTaskDefinition(GUID) instead, as that method takes renames of tasks in the current model into account. This method does not. It should therefore only be used for retrieving task definitions on task names that are loaded from the current model, such as task mappings.
      Specified by:
      getTaskByName in interface IProcessEngineDefinitions
      Parameters:
      name - The name of the requested process task.
      Returns:
      The process task definition for the specified name.
    • getProcessTaskDefinition

      public IProcessTaskDefinition getProcessTaskDefinition(GUID nodeId)
      Description copied from interface: IProcessEngineDefinitions
      This method retrieves the task definition for the specified node id. It is required that the node id corresponds to a task node. In Studio, the node id of a task node is knows as the persistency id (note that the node id is a GUID of the persistency id). This method should be used in favor of the IProcessEngineDefinitions.getTaskByName(String) method whenever a task is loaded from the database (e.g. retrieved from the DAO), because it takes into account the use case that a task that is stored in the database is renamed in the current model
      Specified by:
      getProcessTaskDefinition in interface IProcessEngineDefinitions
      Parameters:
      nodeId - the id of the task node, which is a GUID of the persistency id in Studio
      Returns:
      the process task definition for the specified node id
    • getAvailableTasks

      public IProcessTask[] getAvailableTasks(IUserData userData, Long caseId)
      Description copied from interface: IProcessData
      This method returns an array containing the tasks that are available for the supplied user. This method is also known as the "tasks for me" in the documentation.
      Specified by:
      getAvailableTasks in interface IProcessData
      Parameters:
      userData - The data of the user to which the task must be assigned.
      caseId - ID of the case to which the tasks must belong.
      Returns:
      an array containing the tasks for the supplied user.
    • getUnassignedTasks

      public IProcessTask[] getUnassignedTasks()
      Description copied from interface: IProcessData
      This method returns an array containing all the tasks that have not yet been assigned.
      Specified by:
      getUnassignedTasks in interface IProcessData
      Returns:
      an array containing all the tasks that have not yet been assigned.
    • findTasks

      public IProcessTaskView[] findTasks(TaskCriteria taskFilter)
      Description copied from interface: IProcessData
      This method returns an array containing views of all tasks that are valid after applying the filters from the filter context.
      Specified by:
      findTasks in interface IProcessData
      Parameters:
      taskFilter - TaskFilterContext to filter the tasks that are returned.
      Returns:
      an array containing the task views.
    • findCases

      public IProcessCaseView[] findCases(CaseCriteria caseFilter)
      Description copied from interface: IProcessData
      This method returns an array containing views of all cases that are valid after applying the filters from the filter context
      Specified by:
      findCases in interface IProcessData
      Parameters:
      caseFilter - CaseFilterContext to filter the cases that are returned.
      Returns:
      an array containing the case views
    • evaluateTimer

      public void evaluateTimer(DateTimeValue currentTime)
      Description copied from interface: IProcessEngineBehavior
      This method (re)evaluates all open timer tasks.
      Specified by:
      evaluateTimer in interface IProcessEngineBehavior
      Parameters:
      currentTime - The current time.
    • evaluateCase

      public void evaluateCase(RefreshableJobDefinition job)
      Evaluates the case specified by the given job.
      Specified by:
      evaluateCase in interface ICaseEvaluator
      Parameters:
      job - specifies the case and required evaluation types.
    • getRoles

      public IRole[] getRoles()
      Description copied from interface: IProcessEngineDefinitions
      This method returns all available roles.
      Specified by:
      getRoles in interface IProcessEngineDefinitions
      Returns:
      an array containing all the roles, never null.
    • getExpressionParser

      public IExpressionParser getExpressionParser()
      Description copied from interface: IProcessEngineDefinitions
      This method returns the expression parser used by the process engine.
      Specified by:
      getExpressionParser in interface IProcessEngineDefinitions
      Returns:
      The expression parser, never null.
    • findWaitingCases

      public ICaseModel[] findWaitingCases(String messageEventName, Set<Long> specificCaseIds)
      Description copied from interface: IProcessData
      This method returns the cases waiting for a message event.
      Specified by:
      findWaitingCases in interface IProcessData
      Parameters:
      messageEventName - The message event name, may not be null.
      specificCaseIds - A set of case ids, may be null. If not null, only those cases are processed.
      Returns:
      The case models waiting for the message event.
    • notifyEvent

      public void notifyEvent(IMessageEvent messageEvent, IUserData userData, IProcessCaseChangeListener listener)
      Description copied from interface: IProcessEngineBehavior
      This method notifies the process engine about an event.
      Specified by:
      notifyEvent in interface IProcessEngineBehavior
      Parameters:
      messageEvent - The message event, may not be null.
      userData - The user, may not be null.
      listener - A listener to trace the modified cases, may be null.
    • notifyEvent

      public void notifyEvent(IMessageEvent messageEvent, IUserData userData, IProcessCaseChangeListener listener, Set<Long> specificCaseIds)
      Description copied from interface: IProcessEngineBehavior
      This method notifies the process engine about an event.
      Specified by:
      notifyEvent in interface IProcessEngineBehavior
      Parameters:
      messageEvent - The message event, may not be null.
      userData - The user, may not be null.
      listener - A listener to trace the modified cases, may be null.
      specificCaseIds - A set of case ids, may be null. If not null, only those cases are processed.
    • reopenTask

      public void reopenTask(long taskId)
      Description copied from interface: IProcessEngineBehavior
      Reopens a task which is stuck in the started state. The case of the task is also opened if it is locked.
      Specified by:
      reopenTask in interface IProcessEngineBehavior
      Parameters:
      taskId - the id of the task to be re-opened
    • reopenTask

      public void reopenTask(long taskId, IUserData userData)
      Description copied from interface: IProcessEngineBehavior
      Reopens a task which is stuck in the started state. The case of the task is also opened if it is locked.
      Specified by:
      reopenTask in interface IProcessEngineBehavior
      Parameters:
      taskId - the id of the task to be re-opened
      userData - the data of the current user
    • replayMessageEvent

      public long replayMessageEvent(long eventId, Long caseId)
      Description copied from interface: IProcessEngineBehavior
      Replays (re-triggers) a message event.
      Specified by:
      replayMessageEvent in interface IProcessEngineBehavior
      Parameters:
      eventId - the id of the original message event which should be replayed
      caseId - the optional ID of the case in which the message event will be replayed (if null, the message event will be broadcast to all waiting cases)
      Returns:
      the id of the newly created event
    • replayMessageEvent

      public long replayMessageEvent(long eventId, Long caseId, IUserData userData)
      Description copied from interface: IProcessEngineBehavior
      Replays (re-triggers) a message event.
      Specified by:
      replayMessageEvent in interface IProcessEngineBehavior
      Parameters:
      eventId - the id of the original message event which should be replayed
      caseId - the optional ID of the case in which the message event will be replayed (if null, the message event will be broadcast to all waiting cases)
      userData - the data of the current user
      Returns:
      the id of the newly created event
    • replayTimerEvent

      public long replayTimerEvent(long eventId)
      Description copied from interface: IProcessEngineBehavior
      Replays (re-triggers) a timer event.
      Specified by:
      replayTimerEvent in interface IProcessEngineBehavior
      Parameters:
      eventId - the id of the original timer event which should be replayed
      Returns:
      the id of the newly created event
    • replayTimerEvent

      public long replayTimerEvent(long eventId, IUserData userData)
      Description copied from interface: IProcessEngineBehavior
      Replays (re-triggers) a timer event.
      Specified by:
      replayTimerEvent in interface IProcessEngineBehavior
      Parameters:
      eventId - the id of the original timer event which should be replayed
      userData - the data of the current user
      Returns:
      the id of the newly created event
    • getMessageEventByName

      public IMessageEventDefinition getMessageEventByName(String eventName)
      Description copied from interface: IProcessEngineDefinitions
      This method returns the message event definition for the specified name.
      Specified by:
      getMessageEventByName in interface IProcessEngineDefinitions
      Parameters:
      eventName - The name of the event whose definition is requested, may not be null.
      Returns:
      The definition of the message event with the specified name.
    • getAuthorizationAlgorithm

      public IAuthorizationAlgorithmDefinition getAuthorizationAlgorithm(String name)
      Description copied from interface: IProcessEngineDefinitions
      This method returns the definition of an authorization algorithm.
      Specified by:
      getAuthorizationAlgorithm in interface IProcessEngineDefinitions
      Parameters:
      name - The name of the algorithm.
      Returns:
      The definition of the algorithm.
    • getPriorityAlgorithm

      public IPriorityAlgorithmDefinition getPriorityAlgorithm(String name)
      Description copied from interface: IProcessEngineDefinitions
      This method returns the definition of an priority algorithm.
      Specified by:
      getPriorityAlgorithm in interface IProcessEngineDefinitions
      Parameters:
      name - The name of the algorithm.
      Returns:
      The definition of the algorithm.
    • getAuthorizationManager

      public AuthorizationManager getAuthorizationManager()
    • getPriorityManager

      public PriorityManager getPriorityManager()
    • getRoutingManager

      public RoutingManager getRoutingManager()
    • getRuleEngine

      protected IRuleEngine getRuleEngine()
    • getTypeByName

      public ProcessTypeDefinition getTypeByName(String typeName)
      Specified by:
      getTypeByName in interface IProcessEngineDefinitions
    • getInternalCase

      public ProcessCase getInternalCase(long caseId)
    • getProcessEvent

      protected IProcessEventDefinition getProcessEvent(String eventName)
    • getRoutingAlgorithm

      public IRoutingAlgorithmDefinition getRoutingAlgorithm(String name)
      Description copied from interface: IProcessEngineDefinitions
      This method returns the routing algorithm definition for the specified name.
      Specified by:
      getRoutingAlgorithm in interface IProcessEngineDefinitions
      Parameters:
      name - The name of the routing algorithm whose definition is requested.
      Returns:
      The definition of the routing algorithm with the specified name.
    • getApplicationId

      public String getApplicationId()
    • getModuleId

      protected String getModuleId()
    • getRepository

      public ProcessCaseRepository getRepository()
    • getProcessTaskDelegate

      public IProcessTaskDelegate getProcessTaskDelegate()
    • containsNodeDefinition

      protected boolean containsNodeDefinition(GUID nodeId)
    • getMessageEvent

      protected IMessageEventDefinition getMessageEvent(String eventName)
    • getDisplayNameValues

      public Map<String,String> getDisplayNameValues(IMultilingualText displayNameContent, IProfile profile)
      This method is responsible for returning a map with displayName values of a task/case. The key of the map will be the language code. If the displayName contains a TSL expression, the value will be the evaluated TSL expression.
      Parameters:
      displayNameContent - Multilingual text value for the display name of the task/case.
      profile - Profile used to get the active instances.
      Returns:
      A map containing the displayName by language code for a task/case.
    • evaluateIMultilingualText

      public IMultilingualText evaluateIMultilingualText(IMultilingualText displayNameContent, IProfile profile)
      This method checks a IMultilingualText to see if there are any TSL expressions. If there are, it will return back a new IMultilingualText with the TSL expresions evaluated and the rest of the text will remain the same
      Specified by:
      evaluateIMultilingualText in interface IProcessExpressionHandler
      Parameters:
      displayNameContent - the MultilingualText used to
      profile - the profile
      Returns:
      IMultilingualText with the TSL values evaluated
    • getCaseState

      public ICaseStateModel getCaseState(long caseId)
      Description copied from interface: IProcessData
      Gets the case state
      Specified by:
      getCaseState in interface IProcessData
      Parameters:
      caseId - the case ID
      Returns:
      the case state
    • getTraceEngine

      public ITraceEngine getTraceEngine()
    • cancelStartedTasks

      public void cancelStartedTasks()
      Description copied from interface: IProcessEngineBehavior
      This method may be used to cancel started tasks that were abandoned, for example due to an unexpected server shutdown
      Specified by:
      cancelStartedTasks in interface IProcessEngineBehavior
    • getProcessSettings

      public ProcessSettings getProcessSettings()
      Description copied from interface: IProcessEngine
      Returns the settings used by the process engine, case lists and work lists.
      Specified by:
      getProcessSettings in interface IProcessEngine
      Returns:
      the process settings
    • findByCriteria

      public TaskViewResult findByCriteria(TaskViewCriteria criteria)
      Description copied from interface: IProcessData
      Find task views based on the specified criteria.

      This method alters the criteria by enabling or disabling checking for restriced users depending on the ignore mode setting of the criteria and on whether any authorization algorithms use the 2-man rule. If the Application ID is not ignored, and no authorization algorithm in this process engine uses the 2-man rule, then checking for restricted users is disabled.

      For an equivalent method which does not alter the criteria, see IProcessCaseDao.findByCriteria(TaskViewCriteria).

      Specified by:
      findByCriteria in interface IProcessData
      Parameters:
      criteria - the task criteria to search for
      Returns:
      TaskViewResult the tasks matching the criteria
    • findByCriteria

      public CaseViewResult findByCriteria(CaseViewCriteria criteria)
      Description copied from interface: IProcessData
      Find case views based on the specified criteria.
      Specified by:
      findByCriteria in interface IProcessData
      Parameters:
      criteria - the case criteria to search for
      Returns:
      CaseViewResult the cases matching the criteria
    • getLegacyToggles

      public ILegacyToggles getLegacyToggles()