Class ModelManager

java.lang.Object
org.imixs.workflow.ModelManager

public class ModelManager extends Object
This ModelManager provides methods to get model entities from a model instance. The ModelManager is used by the WorkflowKernel to manage the processing life cycle of a workitem. The implementation is based on the OpenBPMN Meta model.

By analyzing the workitem model version the WorkflowKernel determines the corresponding model and get the Tasks and Events from the ModelManager to process the workitem and assign the workitem to the next Task defined by the BPMN Model.

  • Field Details

  • Constructor Details

    • ModelManager

      public ModelManager()
      Private constructor to prevent instantiation
  • Method Details

    • getModelStore

      public Map<String,org.openbpmn.bpmn.BPMNModel> getModelStore()
      Returns the internal ModelStore holding all BPMNModels by version.
      Returns:
    • addModel

      public void addModel(org.openbpmn.bpmn.BPMNModel model) throws ModelException
      Adds a new model into the local model store
      Throws:
      ModelException
    • removeModel

      public void removeModel(String version)
      Removes a BPMNModel form the local model store
    • getModel

      public org.openbpmn.bpmn.BPMNModel getModel(String version) throws ModelException
      Returns a BPMNModel by its version from the local model store
      Parameters:
      version - - a bpmn model version ($modelVersion)
      Returns:
      a BPMNModel instance.
      Throws:
      ModelException
    • getAllModels

      public List<org.openbpmn.bpmn.BPMNModel> getAllModels()
      Returns a List with all BPMNModel instances
      Returns:
    • getModelByWorkitem

      public org.openbpmn.bpmn.BPMNModel getModelByWorkitem(ItemCollection workitem) throws ModelException
      Throws:
      ModelException
    • loadDefinition

      public ItemCollection loadDefinition(org.openbpmn.bpmn.BPMNModel model) throws ModelException
      Returns the BPMN Definition entity associated with a given workitem, based on its attribute "$modelVersion". The definition holds the bpmn meta data.

      The method throws a ModelException if no Process can be resolved based on the given model information.

      The method is called by the WorkflowKernel during the processing life cycle to update the process group information.

      Parameters:
      workitem -
      Returns:
      BPMN Event entity - ItemCollection
      Throws:
      ModelException - if no event was found
    • loadProcess

      public ItemCollection loadProcess(ItemCollection workitem) throws ModelException
      Returns the BPMN Process entity associated with a given workitem, based on its attributes "$modelVersion", "$taskID". The process holds the name for the attribute $worklfowGroup

      The taskID has to be unique in a process. The method throws a ModelException if no Process can be resolved based on the given model information.

      The method is called by the WorkflowKernel during the processing life cycle to update the process group information.

      Parameters:
      workitem -
      Returns:
      BPMN Event entity - ItemCollection
      Throws:
      ModelException - if no event was found
    • loadTask

      public ItemCollection loadTask(ItemCollection workitem) throws ModelException
      Returns the BPMN Task entity associated with a given workitem, based on its attributes "$modelVersion" and "$taskID".

      The method throws a ModelException if no Task can be resolved based on the given model information.

      The method is called by the WorkflowKernel during the the processing life cycle.

      Parameters:
      workitem -
      Returns:
      BPMN Event entity - ItemCollection
      Throws:
      ModelException - if no event was found
    • loadEvent

      public ItemCollection loadEvent(ItemCollection workitem) throws ModelException
      Returns the BPMN Event entity associated with a given workitem, based on its attributes "$modelVersion", "$taskID" and "$eventID".

      The method throws a ModelException if no Event can be resolved based on the given model information.

      The method is called by the WorkflowKernel to start the processing life cycle.

      A Event is typically connected with a Task by outgoing SequenceFlows. A special case is a Start event followed by one or more Events connected with a Task (Start-Task) element.

      Parameters:
      workitem -
      Returns:
      BPMN Event entity - ItemCollection
      Throws:
      ModelException - if no event was found
    • nextModelElement

      public ItemCollection nextModelElement(ItemCollection event, ItemCollection workitem) throws ModelException
      Finds the next BPMN Element associated with a given event element. The returned BPMN Element must either be an Activity (Task) element, an Intermediate Catch Event (follow-up-event) or a End Event. The method must not return any other BPMN elements (e.g. Gateways, Intermediate Throw Events).

      The method throws a ModelException if no Element can be resolved based on the given model information.

      Parameters:
      event - - current event
      workitem - - current Workitem
      Returns:
      a BPMN Element entity - ItemCollection
      Throws:
      ModelException - - if no valid element was found
      org.openbpmn.bpmn.exceptions.BPMNValidationException
    • getVersions

      public List<String> getVersions()
      returns a sorted String list of all stored model versions
      Returns:
    • findModelByWorkitem

      public org.openbpmn.bpmn.BPMNModel findModelByWorkitem(ItemCollection workitem) throws ModelException
      Returns a Model matching the $modelversion of a given workitem. The $modelversion can optional be provided as a regular expression.

      In case no matching model version exits, the method tries to find the highest Model Version matching the corresponding workflow group.

      The method throws a ModelException in case the model version did not exits.

      Throws:
      ModelException
    • findAllGroupsByModel

      public Set<String> findAllGroupsByModel(org.openbpmn.bpmn.BPMNModel _model) throws ModelException
      This method returns a sorted list of all workflow groups contained in a BPMN model.

      In case the model is a collaboration diagram, the method returns only group names from private process instances (Pools)!

      Parameters:
      _model - - BPMN model instance
      Returns:
      list of workflow groups
      Throws:
      ModelException - if model is undefined
    • findAllGroups

      public Set<String> findAllGroups() throws ModelException
      This method returns a sorted list of all unique workflow groups contained in the model store.

      In case the model is a collaboration diagram, the method returns only group names from private process instances (Pools)!

      Parameters:
      group -
      Returns:
      Throws:
      ModelException
    • findAllVersionsByGroup

      public Set<String> findAllVersionsByGroup(String group) throws ModelException
      Returns a sorted list of all model versions containing the requested workflow group. The result is sorted in reverse order, so the highest version number is the first in the result list.
      Parameters:
      group - - name of the workflow group
      Returns:
      list of matching model versions
      Throws:
      ModelException
    • findVersionByGroup

      public String findVersionByGroup(String group) throws ModelException
      Returns the first matching model version by a given workflow group.

      If multiple models are containing the same group the latest version will be returned.

      In case the model is a collaboration diagram, the method compares the given group name only with private process instances (Pools)!

      Parameters:
      group -
      Returns:
      Throws:
      ModelException
    • findVersionsByRegEx

      public Set<String> findVersionsByRegEx(String modelRegex)
      This method returns a sorted list of model versions matching a given regex for a model version. The result is sorted in reverse order, so the highest version number is the first in the result list.
      Parameters:
      group -
      Returns:
    • findTaskByID

      public ItemCollection findTaskByID(org.openbpmn.bpmn.BPMNModel model, int taskID)
      This method finds a Imixs task element by its ID (imixs:activityid). The method returns a cloned Instance of the model entity to avoid manipulation by the client.

      The method implements an effectively generic, thread-safe way of a compute-once, cache-for-later pattern.

      Parameters:
      model -
      taskID -
      Returns:
    • findEventByID

      public ItemCollection findEventByID(org.openbpmn.bpmn.BPMNModel model, int taskID, int eventID)
      This method finds a Imixs Event element by its ID (imixs:activityid) associated with a given Task. The method returns a cloned Instance of the model entity to avoid manipulation by the client.

      The method implements an effectively generic, thread-safe way of a compute-once, cache-for-later pattern.

    • findTasks

      public List<ItemCollection> findTasks(org.openbpmn.bpmn.BPMNModel model, String processGroup) throws ModelException
      Returns a list of all Tasks of a given Process Group

      In case of a collaboration diagram only Pool names are compared. The default process (Public Process) will be ignored.

      Parameters:
      model - - the BPMN model
      processGroup - - the name of the process group to match
      Returns:
      list of all Task entities or null if not process with the given name was found.
      Throws:
      org.openbpmn.bpmn.exceptions.BPMNModelException
      ModelException
    • findStartTasks

      public List<ItemCollection> findStartTasks(org.openbpmn.bpmn.BPMNModel model, String processGroup) throws ModelException
      Returns a list of start Tasks of a given Process Group

      In case of a collaboration diagram only Pool names are compared. The default process (Public Process) will be ignored.

      Parameters:
      model - - the BPMN model
      processGroup - - the name of the process group to match
      Returns:
      list of all Start Task entities or null if not process with the given name was found.
      Throws:
      org.openbpmn.bpmn.exceptions.BPMNModelException
      ModelException
    • findEndTasks

      public List<ItemCollection> findEndTasks(org.openbpmn.bpmn.BPMNModel model, String processGroup) throws ModelException
      Returns a list of End Tasks of a given Process Group

      In case of a collaboration diagram only Pool names are compared. The default process (Public Process) will be ignored.

      Parameters:
      model - - the BPMN model
      processGroup - - the name of the process group to match
      Returns:
      list of all End Task entities or null if not process with the given name was found.
      Throws:
      org.openbpmn.bpmn.exceptions.BPMNModelException
      ModelException
    • findEventsByTask

      public List<ItemCollection> findEventsByTask(org.openbpmn.bpmn.BPMNModel model, int taskID)
      Returns a list of all Events assigned to a Task. The event can be either connected by an outgoing sequence flow or by an ingoing sequence flow (init-event-node).
      Parameters:
      model -
      taskID -
      Returns:
      list of all events assigned to the task as an processing event.
    • findDataObject

      public String findDataObject(ItemCollection bpmnElement, String name)
      Returns the content of a BPMN DataObject, part of a Task or Event element.

      DataObjects can be associated in a BPMN Diagram with a Task or an Event element.

      Parameters:
      bpmnElement - - bpmn element, either a Task or a Event
      name - - name of the dataobject
      Returns:
    • evaluateCondition

      public boolean evaluateCondition(String expression, ItemCollection workitem)
      Evaluates a condition
      Parameters:
      expression -
      workitem -
      Returns:
    • isMainParallelGatewayFlow

      public boolean isMainParallelGatewayFlow(org.openbpmn.bpmn.elements.core.BPMNElementNode gatewayNode, org.openbpmn.bpmn.elements.core.BPMNElementNode targetNode, ItemCollection workitem)
      This method evaluates the outgoing sequenceFlows of a ParallelGateway.

      The method returns true if the given targetNode is connected with a TASK_ELEMENT or with a EVENT_ELEMENT by a conditional flow that evaluates to true. These are the only two cases that indicate the Main Version flow!

      Parameters:
      gatewayNode - - ParallelGateway Node
      targetNode - - Target Node (either a Task or a Event)
      workitem - - current workitem
      Returns:
      true if targetNode defines the main flow