Class WorkflowStateHelper

    • Method Detail

      • createNewState

        public static WorkflowStateModel createNewState​(WorkflowStateListModel stateListModel,
                                                        Locale locale)
        Creates a new state with the defaults and no authenticators. Makes sure to assign a name that does not exist yet.
        Parameters:
        stateListModel - State list model with all available states for generating a new unique name.
        locale - Locale to use for localizing the state name and description.
        Returns:
        The newly created state.
      • createNewState

        public static WorkflowStateModel createNewState​(WorkflowStateListModel stateListModel,
                                                        Locale locale,
                                                        String targetName,
                                                        Consumer<WorkflowState> configurator)
        Creates a new state with the defaults and no authenticators. Makes sure to assign a name that does not exist yet.
        Parameters:
        stateListModel - State list model with all available states for generating a new unique name.
        locale - Locale to use for localizing the state name and description.
        targetName - The desired target name for the new state. When null or empty, a default name is generated.
        configurator - Additional options to set on the new state.
        Returns:
        The newly created state.
      • createStateListModel

        public static WorkflowStateListModel createStateListModel​(IBaseWorkflowEnvironmentData env)
        Reads the available states from the database and creates the initial state model.
        Parameters:
        env - Environment data with the project and workflow version.
        Returns:
        The newly create state list model with the states from the database.
      • getStatesByName

        public static List<WorkflowStateModel> getStatesByName​(WorkflowStateListModel stateListModel,
                                                               String stateName,
                                                               boolean includeDeleted)
        Parameters:
        stateListModel - State list model to search in.
        stateName - Name to search for.
        includeDeleted - true to include states that are scheduled for deletion, false to only return states that still exist.
        Returns:
        All elements in WorkflowStateListModel.getStates() with the given name; or empty list when no such elements exist.
      • insertState

        public static void insertState​(IBaseWorkflowEnvironmentData env,
                                       WorkflowModelBean modelBean,
                                       IWorkflowProvider provider,
                                       WorkflowStateModel newState)
        Parameters:
        env - Workflow designer context data.
        modelBean - Model bean with the current set of workflow states.
        provider - Provider to use for accessing workflow designer context data. trigger.
        newState - New state to insert at the end of the available states.
      • isStateListSavable

        public static boolean isStateListSavable​(WorkflowStateListModel stateListModel,
                                                 IWorkflowProvider provider)
        Check whether the given states are not necessarily valid, but not in such a way that they cannot be saved in the database. That is, checks that the states do not violate any unique constraints etc.
        Parameters:
        stateListModel - State list model to check.
        provider - Current provider for accessing workflow designer context data.
        Returns:
        true if the states can be saved in the database, false otherwise.
      • removeStatesQueuedForDeletion

        public static void removeStatesQueuedForDeletion​(WorkflowStateListModel stateListModel)
        Removes all states that were marked for deletion.
        Parameters:
        stateListModel - State list model with the states to clear.
      • mergeWorkflowStates

        public static List<WorkflowStateModel> mergeWorkflowStates​(IBaseWorkflowEnvironmentData env,
                                                                   ProcessModel process,
                                                                   Map<ElementKey,​com.alibaba.fastjson.JSONObject> paramsMap,
                                                                   List<WorkflowState> oldStates,
                                                                   List<WorkflowStateModel> newStates)
        Used when a backup is loaded. Compares the existing states against the new states from the backup. Attempts to match the existing states to the new states, so references to form records etc. are preserved. Makes sure to preserve existing states that are still referenced by a form record. When a new state is mapped to an existing state, the ID and UUID of the new state is set to the ID and UUID of the old state. In that case, this method also updates the references to that state in workflow nodes and triggers of the given process model.
        Parameters:
        env - Current environment data.
        process - New process model that is to be loaded.
        paramsMap - New custom params map for the model to be loaded.
        oldStates - Existing (persisted) workflow states.
        newStates - New state to be loaded.
        Returns:
        The new list of states that should be used.