Interface ExecutableInstance

  • All Superinterfaces:
    Instance, LocalisedString, PluginDataContainer, Serializable, UserAttributeContainer

    public interface ExecutableInstance
    extends Instance
    This interface provides additional methods necessary to execute a process instance, that is, setting the user who performs a node and manipulating node states and iteration counts. Additionally, the name of the instance may be changed while executing the instance. This allows to adapt the name based on process data created in the process. However, the instance needs to be identified via its ID.
    Methods having an ExecutableInstance in their signature may rely on that the calling method has at least an execution lock on this instance. So when explicitly retrieving an executable instance be sure to release the lock under all circumstances and make sure the object reference is never used again after unlocking!
    Author:
    Ulrich Kreher
    • Field Detail

      • serialVersionUID

        static final long serialVersionUID
        Generated ID for serialisation.
        See Also:
        Constant Field Values
    • Method Detail

      • getNodesInState

        int[] getNodesInState​(ProcessConstants.NodeState... states)
        Gets all nodes (node IDs) of this instance which are in the designated states. Throws an IllegalArgumentException if null was passed for parameter.
        Parameters:
        states - The node states of the nodes to retrieve.
        Returns:
        The node IDs of the nodes which are in the designated states.
      • setPerformingAgent

        void setPerformingAgent​(int nodeID,
                                QualifiedAgent performingAgent)
        Sets the name of the agent who executes the designated node. This also applies to selected nodes! If the agent is to be unset, use null.
        Parameters:
        nodeID - The ID of the node which is executed by the designated agent.
        performingAgent - The agent who performs/executes the designated node of this process instance.
      • setInstanceName

        void setInstanceName​(String instanceName,
                             Map<String,​String> localisation)
        Sets the instance name including its localisations to the designated ones. This allows to set the localised name based on process data throughout the process. The name must not be null, the localisations may be null. The localisations have to map from Locale-string to the corresponding localised instance name.
        Parameters:
        instanceName - The name of the instance to be set while executing the instance.
        localisation - A mapping from Locale-string to the corresponding localised instance name. This may be null which does not set localised instance names.
      • increaseNodeIteration

        int increaseNodeIteration​(int nodeID)
        Increases the iteration counter of a node and returns the new value. This method has to be called before a node is set to state NS_COMPLETED, i.e. during activityFinished.
        Parameters:
        nodeID - The ID of the node to increase the iteration counter.
        Returns:
        The new iteration value of the node.
        See Also:
        ProcessConstants.NodeState
      • setNodeState

        void setNodeState​(int nodeID,
                          ProcessConstants.NodeState state)
        Sets the designated node to the designated state. There need not be any checks whether the state transition is valid.
        Parameters:
        nodeID - The ID of the node to set the state.
        state - The new state of the node.
      • setExecutionMode

        void setExecutionMode​(int nodeID,
                              ProcessConstants.ExecutionMode executionMode)
        Sets the designated execution mode for the designated node. The execution mode must not be null.
        Parameters:
        nodeID - The ID of the node of which to set the execution mode.
        executionMode - The execution mode in which the node is started (production, test or substituted test).
      • addNodeLWPInstanceID

        void addNodeLWPInstanceID​(int nodeID,
                                  UUID lwpInstanceID)
        Adds the ID of the lightweight-process (subprocess) instance in the designated node with the current iteration. This allows to reference a subprocess in the corresponding super-process. In a loop, every iteration causes another subprocess to be instantiated.
        In case of variable parallel subprocesses this method can be called several times. The index of the subprocess instance is determined by the order in which they are added.
        Parameters:
        nodeID - The ID of the node containing the subprocess.
        lwpInstanceID - The ID of the subprocess instance to be referenced by the designated node.
      • removeNodeLWPInstanceID

        void removeNodeLWPInstanceID​(int nodeID,
                                     UUID lwpInstanceID)
        Removes the ID of the lightweight-process (subprocess) instance from the designated node with the current iteration. This allows to reset a lightweight-process-instance by just dropping the corresponding subprocess instance and removing all references.
        Just like adding such references, this method can be called several times when resetting several subprocesses in case of variable parallel subprocesses.
        Parameters:
        nodeID - The ID of the node containing the subprocess.
        lwpInstanceID - The ID of the subprocess instance not to be referenced any longer by the designated node.
      • removeNodeLWPInstanceID

        void removeNodeLWPInstanceID​(int nodeId,
                                     int iteration,
                                     UUID lwpInstanceId)
        Removes the ID of the lightweight-process (subprocess) instance from the designated node with the designated iteration. This allows to reset a lightweight-process-instance by just dropping the corresponding subprocess instance and removing all references.
        Just like adding such references, this method can be called several times when resetting several subprocesses in case of variable parallel subprocesses.
        Parameters:
        nodeId - The ID of the node containing the subprocess.
        iteration - The iteration of the node for which to remove the designated LWP instance ID.
        lwpInstanceId - The ID of the subprocess instance not to be referenced any longer by the designated node and iteration.
      • getCurrentEnquiries

        List<Enquiry> getCurrentEnquiries​(int nodeID)
        Gets an unmodifiable list of the enquiries currently active for the designated node. The list will be empty if the designated node does not have any running enquiries. Newer enquiries are added at the end of the list.
        As long as the list is not empty, the corresponding activity may not reach the state NS_COMPLETED. If it is finished with an open enquiry, it will reach the state NS_ENQUIRED. This allows to read the replies by the designated originators.
        Parameters:
        nodeID - The ID of the node of which to retrieve the current enquiries.
        Returns:
        A list of enquiries currently active on the designated node (older enquiries first).
      • getRepliedEnquiry

        Enquiry getRepliedEnquiry​(int nodeID)
        Gets the last replied enquiry which allows to retrieve the corresponding reply. The returned inquiry is not in the list of current enquiries any more.
        If there are no current enquiries but only one replied enquiry and the corresponding activity is in state NS_ENQUIRED, the corresponding agent will be able to set the state to NS_COMPLETED (and therefore remove the item from the worklist) by replying the (already replied) enquiry.
        Parameters:
        nodeID - The ID of the node of which to retrieve the last enquiry.
        Returns:
        The enquiry containing the reply from the enquiry recipient for the enquiry initiator which may be the empty string. Null is returned in case the designated node is not in enquiry mode.
      • addEnquiry

        void addEnquiry​(int nodeID,
                        Enquiry enquiry)
        Adds the designated enquiry to the designated node (current node iteration), that is, the enquiry is stacked until replied.
        Parameters:
        nodeID - The ID of the node for which to add an enquiry.
        enquiry - The enquiry which is to be added to the designated node. This contains the agent wanting feedback, the recipients of the enquiry as well as the question of the originator.
      • replyEnquiry

        void replyEnquiry​(int nodeID,
                          String reply,
                          QualifiedAgent replier)
        Answers the current enquiry with the designated reply by the designated replier for the designated node (current node iteration). The last enquiry of the current enquiries Enquiry will be removed from the list and provided as replied enquiry.
        Parameters:
        nodeID - The ID of the node for which to remove the last (current) enquiry.
        reply - The notice providing the feedback needed by the originator of the removed enquiry. This may be null or the empty string.
        replier - The QualifiedAgent that replied the enquiry. This must not be null.
      • dropEnquiries

        void dropEnquiries​(int nodeID)
        Drops all enquiries (including the reply) currently set on the designated node (current node iteration). This is used for resetting the node to its initial state without assigned agent and without enquiries.
        Parameters:
        nodeID - The ID of the node for which to drop all enquiries.
      • getInstanceStateListener

        URI[] getInstanceStateListener()
        Gets the communication protocol depended URIs of the callback interface that needs to be informed in case of state changes (especially for termination) of this instance. Each URI specifies the server as well as the communication type and is resolved by the registry.
        Returns:
        The communication protocol depended URIs specifying the server (and the corresponding protocol) to inform when the instance has changed its state (finished, suspended, resumed or suspended).
      • setInstanceStateListener

        void setInstanceStateListener​(URI[] callback)
        Sets the communication protocol depended URIs of the callback interface that needs to be informed in case of state changes of this instance. Each URI specifies the server as well as the communication type and is resolved by the registry.
        Parameters:
        callback - The communication protocol depended URIs specifying the server (and the corresponding protocol) to inform when the instance has changed its state (finished, suspended, resumed or suspended).
      • getAssignedRuntimeManager

        URI[] getAssignedRuntimeManager​(int nodeID)
        Gets the communication protocol depended URIs assigned to that RuntimeManager instance that executes the activity of the given Node.

        If null is returned then the activity is not currently assigned to an instance.

        Assigned runtime managers are used for automatically starting nodes. For such a node the runtime manager URIs are assigned when the previous node is started or resumed. This allows to automatically start the node on the right runtime manager. If something goes wrong when automatically starting a node, it will fall back to a normal start and the runtime manager URIs will be unassigned. This means, if the node is auto-start enabled but has not runtime manager assigned, automatically starting will not take place.

        Parameters:
        nodeID - The ID of the node
        Returns:
        The URIs assigned to the RuntimeManager that executes the activity of the given Node.
      • setAssignedRuntimeManager

        void setAssignedRuntimeManager​(int nodeID,
                                       URI[] runtimeManagerURIs)
        Associates the node with the RuntimeManager that executes the activity assigned to the node.

        To dissolve the binding between a node and a RuntimeManager, pass null to the parameter runtimeManagerURIs.

        Parameters:
        nodeID - The ID of the node
        runtimeManagerURIs - The communication protocol depended URIs of that runtimeManager which executes the activity assigned to the given node.