Interface ProcessInstance

  • All Superinterfaces:
    Serializable
    All Known Subinterfaces:
    UpdatableProcessInstance
    All Known Implementing Classes:
    ProcessInstanceImpl

    public interface ProcessInstance
    extends Serializable
    A process instance spawned from a given process model. The process model defines the workflow. Each process instance is made up of states and actions through which the process instance changes of states. The current(s) state(s) at which is a process instance are the active states. A process instance can have several active parallel states.
    • Method Detail

      • getInstanceId

        String getInstanceId()
        Get the workflow instance id
        Returns:
        instance id
      • getModelId

        String getModelId()
        Get the workflow model id
        Returns:
        model id
      • getHistorySteps

        HistoryStep[] getHistorySteps()
        Gets the different steps in the history of this process instance. A history step defines the change of a state by an action performed by a given working user.
        Returns:
        an array of HistoryStep objects.
      • getHistoryStep

        HistoryStep getHistoryStep​(String stepId)
                            throws WorkflowException
        Gets the step with the specified identifier in the history of this process instance.
        Parameters:
        stepId - the unique identifier of a history step.
        Returns:
        the asked history step.
        Throws:
        WorkflowException - if no such history step can be found.
      • getActionRecord

        DataRecord getActionRecord​(String actionName)
                            throws WorkflowException
        Gets the data that were provided to the specified action when it was was performed. The most recent data is returned in the case the action has been done several times.
        Parameters:
        actionName - action name the name of the performed action.
        Returns:
        the data record.
        Throws:
        WorkflowException
      • getNewActionRecord

        DataRecord getNewActionRecord​(String actionName,
                                      String language)
                               throws WorkflowException
        Gets a new data record associated with the given action.
        Parameters:
        actionName - action name
        language - the ISO-631 code of the language in which the data will be.
        Returns:
        the new empty data record.
        Throws:
        WorkflowException
      • updateFolder

        void updateFolder​(DataRecord data)
                   throws WorkflowException
        Updates the folder of this process instance with the specified one.
        Parameters:
        data - the data record with which the folder has to be updated.
        Throws:
        WorkflowException - if the update fails.
      • getAllDataRecord

        DataRecord getAllDataRecord​(String role,
                                    String lang)
                             throws WorkflowException
        Parameters:
        role - a role a user can play in this process instance.
        lang - the ISO-631 code of a language in which data have to be.
        Returns:
        a record with all the data.
        Throws:
        WorkflowException - if an error occurs.
      • getRowDataRecord

        DataRecord getRowDataRecord​(String role,
                                    String lang)
                             throws WorkflowException
        Gets a data record which will be used to render this process instance as a row in a list of process instances. The information set in the record are filtered by what is allowed to be rendered for the given role.
        Parameters:
        role - a role a user can play in this process instance.
        lang - the ISO-631 code of the language in which data have to be.
        Throws:
        WorkflowException - if an error occurs.
      • getFormRecord

        DataRecord getFormRecord​(String formName,
                                 String role,
                                 String lang)
                          throws WorkflowException
        Gets the data record of the specified form for the given role and written in the specified language. The information set in the record are filtered by what is allowed to be accessed for the given role.
        Parameters:
        formName - the name of the form to get.
        role - a role a user can play in this process instance.
        lang - the ISO-631 code of the language in which data have to be.
        Returns:
        DataRecord or null if no such form can be found.
        Throws:
        WorkflowException - if an error occurs.
      • getField

        Field getField​(String fieldName)
                throws WorkflowException
        Gets the specified field.
        Parameters:
        fieldName - the name that identifies a field in this process instance.
        Returns:
        the corresponding field.
        Throws:
        WorkflowException - if the field cannot be found or if an error occurs.
      • getActiveStates

        String[] getActiveStates()
        Gets all the active states of this process instance. An active state is the current state at which the process is and waiting for actions.
        Returns:
        an array with the name of all the active states.
      • getWorkingUsers

        Actor[] getWorkingUsers​(String state)
                         throws WorkflowException
        Gets all the users working on the specified state of this instance state.
        Parameters:
        state - the name of a state in this process instance.
        Returns:
        an array of Actor objects.
        Throws:
        WorkflowException
      • getWorkingUsers

        Actor[] getWorkingUsers​(String state,
                                String role)
                         throws WorkflowException
        Gets all the users working on the specified state of this instance state with the given role.
        Parameters:
        state - the name of a state in this process instance.
        Returns:
        an array of Actor objects.
        Throws:
        WorkflowException
      • getAssignedStates

        String[] getAssignedStates​(User user,
                                   String roleName)
        Gets all the states that are assigned to the specified user with given role.
        Parameters:
        user - a user in the workflow.
        roleName - a role the user has to play in this process instance.
        Returns:
        an array with the name of all the states assigned to the given user with the given role name.
      • getAllAssignedStates

        String[] getAllAssignedStates​(User user)
        Gets all the states that are assigned to the specified user.
        Parameters:
        user - a user in the workflow.
        Returns:
        an array with the name of all the states assigned to the given user
      • getLockingUser

        LockingUser getLockingUser​(String state)
        Gets the user that has locked the specified state.
        Parameters:
        state - the name of a state in this process instance.
        Returns:
        the user as a LockingUser instance.
      • isValid

        boolean isValid()
        Is this process instance valid?
        Returns:
        true is this instance is valid. False otherwise.
      • isLockedByAdmin

        boolean isLockedByAdmin()
        Is this process instance has been locked by the supervisor?
        Returns:
        true is this instance is locked by admin, false otherwise.
      • getErrorStatus

        boolean getErrorStatus()
        Is this process instance in error by an action?
        Returns:
        true if this instance is in error, false otherwise.
      • getTimeoutStatus

        boolean getTimeoutStatus()
        Gets the timeout status of this instance
        Returns:
        true if this instance is in an active state for a long long time. False otherwise.
      • lock

        void lock​(State state,
                  User user)
           throws WorkflowException
        Locks this instance for the given instance and state
        Parameters:
        state - state that have to be locked
        user - the locking user
        Throws:
        WorkflowException
      • unLock

        void unLock​(State state,
                    User user)
             throws WorkflowException
        Un-locks this instance for the given instance and state
        Parameters:
        state - state that have to be un-locked
        user - the unlocking user
        Throws:
        WorkflowException
      • getUsersInRole

        List<User> getUsersInRole​(String role)
                           throws WorkflowException
        Gets concrete users affected to given role at runtime
        Parameters:
        role - the name of the role
        Returns:
        users affected to given role
        Throws:
        WorkflowException - if an error occurs.
      • getUsersInGroup

        List<User> getUsersInGroup​(String groupId)
                            throws WorkflowException
        Gets concrete users affected to given group at runtime
        Parameters:
        groupId - the id of the group
        Returns:
        users in given group
        Throws:
        WorkflowException - if an error occurs
      • getActors

        Actor[] getActors​(QualifiedUsers qualifiedUsers,
                          State state)
                   throws WorkflowException
        Computes tuples role/user (stored in an Actor object) from a QualifiedUsers object
        Parameters:
        qualifiedUsers - Users defined by their role or by a relation with a participant
        state - state for which these user were/may be actors
        Returns:
        tuples role/user as an array of Actor objects
        Throws:
        WorkflowException - if an error occurs
      • isStateInBackStatus

        boolean isStateInBackStatus​(String stateName)
        Test is a active state is in back status
        Parameters:
        stateName - name of active state
        Returns:
        true if resolution of active state involves a cancel of actions
      • getMostRecentStep

        HistoryStep getMostRecentStep​(String actionName)
        Recent the most recent step where the named action has been performed.
      • getBackSteps

        HistoryStep[] getBackSteps​(User user,
                                   String roleName,
                                   String stateName)
                            throws WorkflowException
        Get all the steps where given user (with given role) can go back from the given state
        Parameters:
        user - user that can do the back actions
        roleName - role name of this user
        stateName - name of state where user want to go back from
        Returns:
        an array of HistoryStep objects
        Throws:
        WorkflowException
      • addQuestion

        State addQuestion​(String content,
                          String stepId,
                          State fromState,
                          User fromUser)
                   throws WorkflowException
        Add a question
        Parameters:
        content - question text
        stepId - id of destination step for the question
        fromState - the state where the question was asked
        fromUser - the user who asked the question
        Returns:
        The state to which the question is
        Throws:
        WorkflowException
      • answerQuestion

        State answerQuestion​(String content,
                             String questionId)
                      throws WorkflowException
        Answer a question
        Parameters:
        content - response text
        questionId - id of question corresponding to this response
        Returns:
        The state where the question was asked
        Throws:
        WorkflowException
      • getPendingQuestions

        Question[] getPendingQuestions​(String stateName)
                                throws WorkflowException
        Get all the questions asked in the given state
        Parameters:
        stateName - given state name
        Returns:
        all the questions (not yet answered) asked in the given state
        Throws:
        WorkflowException
      • getSentQuestions

        Question[] getSentQuestions​(String stateName)
        Get all the questions asked from the given state
        Parameters:
        stateName - given state name
        Returns:
        all the questions (not yet answered) asked from the given state
      • getRelevantQuestions

        Question[] getRelevantQuestions​(String stateName)
        Get all the questions asked from the given state and that have been answered
        Parameters:
        stateName - given state name
        Returns:
        all the answered questions asked from the given state
      • getQuestions

        Question[] getQuestions()
        Get all the questions asked in this processInstance
        Returns:
        all the questions