Class Workflow

java.lang.Object
com.atlassian.jira.workflow.edit.Workflow
All Implemented Interfaces:
JiraWorkflow, Comparable<JiraWorkflow>

public class Workflow extends Object implements JiraWorkflow
  • Field Details

    • NO_ADDITIONAL_POSTFUNCTIONS

      public static final Supplier<Map<Integer,com.opensymphony.workflow.loader.FunctionDescriptor>> NO_ADDITIONAL_POSTFUNCTIONS
      Represents the screen id property on workflow action descriptor metadata.
  • Constructor Details

  • Method Details

    • getId

      public int getId()
      Returns a unique workflow id.

      The id remains the same even after the workflow name changes.

      Returns:
      workflow id
    • getActionsByName

      public Collection<com.opensymphony.workflow.loader.ActionDescriptor> getActionsByName(String name)
      Description copied from interface: JiraWorkflow
      Get all actions in this workflow, global, common and from steps, whose name matched name.
      Specified by:
      getActionsByName in interface JiraWorkflow
      Parameters:
      name - of the action to match. This is case-insensitive.
      Returns:
      A collection of ActionDescriptor whose name matched the given name.
    • getLinkedStatusId

      public String getLinkedStatusId(com.opensymphony.workflow.loader.StepDescriptor stepDescriptor)
      Description copied from interface: JiraWorkflow
      Get the id of the Status associated with the given StepDescriptor
      Specified by:
      getLinkedStatusId in interface JiraWorkflow
      Parameters:
      stepDescriptor - the StepDescriptor
      Returns:
      the id of the status associated with the given StepDescriptor.
    • getLinkedStatusIds

      public Set<String> getLinkedStatusIds()
      Description copied from interface: JiraWorkflow
      Returns all status ids for this workflow
      Specified by:
      getLinkedStatusIds in interface JiraWorkflow
      Returns:
      a Set of String status id's
    • addStatus

      public ServiceOutcome<Workflow> addStatus(Status status)
      Add a status to the supplied workflow. This method does not save the workflow.
      Parameters:
      status - The status.
      Returns:
      ServiceOutcome A service outcome of the addition process.
    • removeStatus

      public ServiceOutcome<Workflow> removeStatus(@NotNull @NotNull Status status)
      Remove a status from the provided workflow. This will remove any transitions to or from that step. This method does not save the workflow.
      Parameters:
      status - Status to remove from workflow.
      Returns:
      ServiceOutcome A service outcome of the removal process.
    • removeStatus

      public ServiceOutcome<Workflow> removeStatus(String statusId)
      Remove a status from the provided workflow. This will remove any transitions to or from that step. This method does not save the workflow.
      Parameters:
      statusId - Id of the status.
      Returns:
      ServiceOutcome A service outcome of the removal process.
    • updateStatus

      public ServiceOutcome<Workflow> updateStatus(String statusId, String name)
      Update a status identified by the status id in the workflow. This method does not save the workflow.
      Parameters:
      statusId - The status id.
      name - The status name.
      Returns:
      ServiceOutcome A service outcome of the update process.
    • addGlobalTransition

      public ServiceOutcome<Workflow> addGlobalTransition(Workflow.AddTransitionParameters params)
      Add a global transition to this workflow.
      Returns:
      ServiceOutcome
    • addGlobalTransitionReturningId

      public ServiceOutcome<TransitionData> addGlobalTransitionReturningId(Workflow.AddTransitionParameters params)
      Add a global transition to this workflow.
      Returns:
      ServiceOutcome
    • updateGlobalTransition

      public ServiceOutcome<Workflow> updateGlobalTransition(int transitionId, String name, String description, FieldScreen screen)
      Update the global transition represented by the supplied transition id to have the supplied properties.
      Returns:
      ServiceOutcome The updated workflow, note: not saved.
    • addCommonTransition

      public ServiceOutcome<Workflow> addCommonTransition(String sourceStatusId, int transitionId)
      Add a common transition to the workflow.

      If the transition to be shared isn't common yet, we make it a common transition. This is done by removing it from its parent status, adding it to the workflow, then adding back to the status as a common transition.

      Parameters:
      sourceStatusId - The ID of the transition's source status.
      transitionId - The ID of the transition to use.
      Returns:
      ServiceOutcome
    • addTransition

      Add a new transition to the named workflow created with the supplied parameters.
      Returns:
      ServiceOutcome New transition data.
    • addLoopedTransition

      public ServiceOutcome<TransitionData> addLoopedTransition(String name, String description, FieldScreen screen)
      Adds a looped transition to every status on the workflow. This makes use of the special case of configuring a result step with the value of -1.
      Parameters:
      name - The name of the looped transition.
      description - The description of the looped transition.
      screen - The screen to use for the loop.
      Returns:
      ServiceOutcome New transition data.
    • deleteLoopedTransition

      public ServiceOutcome<Workflow> deleteLoopedTransition(int loopedTransitionId)
      Delete the looped transition from the provided workflow.
      Parameters:
      loopedTransitionId -
      Returns:
      ServiceOutcome A service outcome with the updated workflow.
    • updateLoopedTransition

      public ServiceOutcome<Workflow> updateLoopedTransition(int transitionId, String name, String description, FieldScreen screen)
      Update the looped transition represented by the supplied transition id to have the supplied properties.
      Returns:
      ServiceOutcome The updated workflow, note: not saved.
    • deleteTransition

      public ServiceOutcome<Workflow> deleteTransition(int transitionId, int sourceStepId)
      Delete the transition represented by the supplied transition id, source step id.
      Parameters:
      transitionId -
      sourceStepId -
      Returns:
      ServiceOutcome
    • updateTransition

      public ServiceOutcome<Workflow> updateTransition(int transitionId, String name, String description, FieldScreen screen)
      Update the transition specified by the transitionId with the supplied parameters.
      Returns:
      ServiceOutcome
    • updateTransitionTarget

      public ServiceOutcome<Workflow> updateTransitionTarget(int transitionId, Status targetStatus)
      Update the target of the transition specified by the transitionId.
      Returns:
      ServiceOutcome
    • updateTransitionSource

      public ServiceOutcome<Workflow> updateTransitionSource(int transitionId, Status newSourceStatus, Status originalSourceStatus)
      Update the source of the transition specified by the transitionId.
      Parameters:
      transitionId - The transition id to be modified.
      newSourceStatus - The new source status of the transition.
      originalSourceStatus - The original source status of the transition.
      Returns:
      ServiceOutcome An outcome representing the result of updating the source status.
    • deleteGlobalTransition

      public ServiceOutcome<Workflow> deleteGlobalTransition(String globalTransitionId)
      Delete the global transition from the provided workflow.
      Parameters:
      globalTransitionId -
      Returns:
      ServiceOutcome A service outcome with the updated workflow.
    • isDuplicateGlobalTransitionName

      public boolean isDuplicateGlobalTransitionName(String transitionName)
      Is the supplied name already in use as a global transition name. This will only check global actions.
      Parameters:
      transitionName -
      Returns:
      boolean
    • isDuplicateTransitionName

      public boolean isDuplicateTransitionName(String transitionName, int sourceStepId)
      Is the supplied name already in use as a transition name.
      Parameters:
      transitionName -
      Returns:
      boolean
    • isDuplicateLoopedTransitionName

      public boolean isDuplicateLoopedTransitionName(String transitionName)
      Is the supplied name already in use as a looped transition name.
      Parameters:
      transitionName -
      Returns:
      boolean
    • targetStatusHasExistingTransitionWithName

      public boolean targetStatusHasExistingTransitionWithName(int transitionId, String transitionName)
      Does the target status represented by the transition id have an existing transition with the supplied name?
      Parameters:
      transitionId -
      transitionName -
      Returns:
      boolean
    • isCommonTransition

      public boolean isCommonTransition(int transitionId)
      Is the supplied transition id a common transition.
      Parameters:
      transitionId -
      Returns:
      boolean Indicates whether the transition is common or not.
    • commonTransitionExistsFromSource

      public boolean commonTransitionExistsFromSource(int transitionId, Status source)
      Does a common transition already exist from this source to the destination of the transition represented by the supplied transition id?
      Parameters:
      transitionId -
      source -
      Returns:
      boolean representing whether a common transition already exists.
    • hasTransition

      public boolean hasTransition(int transitionId)
      Has this workflow have a transition with the id?
      Returns:
      boolean
    • statusHasOutgoingTransition

      public ServiceOutcome<Boolean> statusHasOutgoingTransition(Status status, int transitionId)
      Parameters:
      status - A status in the workflow.
      transitionId - The ID of a transition in the workflow.
      Returns:
      Whether the transition described by transitionId is an outgoing transition of status.
    • getTransitionName

      public String getTransitionName(int transitionId)
      Get the transition name for the supplied id.
      Parameters:
      transitionId -
      Returns:
      String
    • statusHasGlobalTransition

      public boolean statusHasGlobalTransition(Status status)
      Does the provided status have a global transition?
      Parameters:
      status -
      Returns:
      boolean
    • statusExistsOnWorkflow

      public boolean statusExistsOnWorkflow(Status status)
      Does the supplied status exist on the workflow.
      Parameters:
      status -
      Returns:
      boolean
    • getStepIds

      public List<Integer> getStepIds()
      Get the step ids for this workflow.
      Returns:
      List
    • isDuplicateTransitionName

      public boolean isDuplicateTransitionName(String transitionName, com.opensymphony.workflow.loader.StepDescriptor sourceStep)
      Is the supplied name already in use as a transition name.
      Parameters:
      transitionName -
      Returns:
      boolean
    • stepExists

      public boolean stepExists(int stepId)
      Does a step exist for the supplied step id.
      Parameters:
      stepId -
      Returns:
      boolean
    • stepExists

      public boolean stepExists(Status status)
      Does a step exist for the supplied status?
      Parameters:
      status -
      Returns:
      boolean
    • workflowContainsStepWithStatusId

      public boolean workflowContainsStepWithStatusId(String statusId)
      Does the workflow contain a step with the status id?
      Parameters:
      statusId -
      Returns:
      boolean
    • getSteps

      public List<com.opensymphony.workflow.loader.StepDescriptor> getSteps()
      Get the steps represented in this workflow.
      Returns:
      List
    • getName

      public String getName()
      Specified by:
      getName in interface JiraWorkflow
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface JiraWorkflow
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface JiraWorkflow
    • getDescriptor

      public com.opensymphony.workflow.loader.WorkflowDescriptor getDescriptor()
      Specified by:
      getDescriptor in interface JiraWorkflow
    • getInitialActions

      public Collection<com.opensymphony.workflow.loader.ActionDescriptor> getInitialActions()
    • getGlobalActions

      public Collection<com.opensymphony.workflow.loader.ActionDescriptor> getGlobalActions()
    • getAllActions

      public Collection<com.opensymphony.workflow.loader.ActionDescriptor> getAllActions()
      Get all the actions in this workflow, global, common and from steps.
      Specified by:
      getAllActions in interface JiraWorkflow
      Returns:
      A collection of ActionDescriptors.
    • getActionsWithResult

      public Collection<com.opensymphony.workflow.loader.ActionDescriptor> getActionsWithResult(com.opensymphony.workflow.loader.StepDescriptor stepDescriptor)
      Get all the actions which have a particular step as their unconditional result.
      Specified by:
      getActionsWithResult in interface JiraWorkflow
      Returns:
      all the actions which have a particular step as their unconditional result.
    • removeStep

      public boolean removeStep(com.opensymphony.workflow.loader.StepDescriptor stepDescriptor)
      Remove a step from the workflow.

      This method will also remove all actions with this step ID as their unconditional result.

      Specified by:
      removeStep in interface JiraWorkflow
      Returns:
      true if the remove was successful
    • getLinkedStep

      public com.opensymphony.workflow.loader.StepDescriptor getLinkedStep(org.ofbiz.core.entity.GenericValue status)
      Deprecated.
      Get the StepDescriptor linked to the given status for this workflow.
      Specified by:
      getLinkedStep in interface JiraWorkflow
      Parameters:
      status - the Status
      Returns:
      The StepDescriptor linked, or null if no steps are linked to this status.
    • getLinkedStep

      public com.opensymphony.workflow.loader.StepDescriptor getLinkedStep(Status status)
      Get the StepDescriptor linked to the given status for this workflow.
      Specified by:
      getLinkedStep in interface JiraWorkflow
      Parameters:
      status - the Status
      Returns:
      The StepDescriptor linked, or null if no steps are linked to this status.
    • getLinkedStatuses

      public List<org.ofbiz.core.entity.GenericValue> getLinkedStatuses()
      Deprecated.
      Use getLinkedStatusObjects() instead. Since v5.0.
      Returns all statuses for this workflow
      Specified by:
      getLinkedStatuses in interface JiraWorkflow
      Returns:
      a List of GenericValue
    • getLinkedStatusObjects

      public List<Status> getLinkedStatusObjects()
      Returns all statuses for this workflow
      Specified by:
      getLinkedStatusObjects in interface JiraWorkflow
      Returns:
      a List of Status objects
    • isActive

      public boolean isActive() throws WorkflowException
      Determine whether this workflow object is currently active.
      Specified by:
      isActive in interface JiraWorkflow
      Returns:
      true if this workflow object is active.
      Throws:
      WorkflowException - Runtime Exception indicating a problem in the WorkflowManager.
    • isSystemWorkflow

      public boolean isSystemWorkflow() throws WorkflowException
      Determines if the workflow is loaded from XML or the database
      Specified by:
      isSystemWorkflow in interface JiraWorkflow
      Returns:
      true if this workflow object is the uneditable system workflow.
      Throws:
      WorkflowException - Runtime Exception indicating a problem in the WorkflowManager.
    • isEditable

      public boolean isEditable() throws WorkflowException
      Determines if the workflow can be modifed within JIRA.

      System workflows are never editable. The "published" version of an active workflow is not editable, but the draft version is. Inactive workflows are editable.

      Specified by:
      isEditable in interface JiraWorkflow
      Returns:
      true if this workflow is editable.
      Throws:
      WorkflowException - Runtime Exception indicating a problem in the WorkflowManager.
    • isDefault

      public boolean isDefault()
      Determines if the workflow is the default JIRA workflow
      Specified by:
      isDefault in interface JiraWorkflow
      Returns:
      true if this is the workflow is the default JIRA workflow.
    • isDraftWorkflow

      public boolean isDraftWorkflow()
      Determines if the workflow is an draft edit of an active workflow.
      Specified by:
      isDraftWorkflow in interface JiraWorkflow
      Returns:
      true if an draft workflow, false otherwise.
      Since:
      v3.13
    • hasDraftWorkflow

      public boolean hasDraftWorkflow()
      Determines if this workflow has a draft edit copy.
      Specified by:
      hasDraftWorkflow in interface JiraWorkflow
      Returns:
      true if this workflow has a draft edit copy.
      Since:
      v3.13
    • getNextActionId

      public int getNextActionId()
      Get the next available action id
      Specified by:
      getNextActionId in interface JiraWorkflow
      Returns:
      The next available action id.
    • getStepsForTransition

      public Collection<com.opensymphony.workflow.loader.StepDescriptor> getStepsForTransition(com.opensymphony.workflow.loader.ActionDescriptor action)
      Returns a collection of all step descriptors that reference the given common action.
      Specified by:
      getStepsForTransition in interface JiraWorkflow
      Returns:
      a collection of all step descriptors that reference the given common action.
    • getPostFunctionsForTransition

      public Collection<com.opensymphony.workflow.loader.FunctionDescriptor> getPostFunctionsForTransition(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor)
      Returns all post-functions of the transition, including the ones on all conditional results, unconditional results and 'global' (non-result) postfunctions.
      Specified by:
      getPostFunctionsForTransition in interface JiraWorkflow
      Returns:
      all post-functions of the transition, including the ones on all conditional results, unconditional results and 'global' (non-result) postfunctions.
    • isInitialAction

      public boolean isInitialAction(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor)
      Specified by:
      isInitialAction in interface JiraWorkflow
    • isCommonAction

      public boolean isCommonAction(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor)
      Specified by:
      isCommonAction in interface JiraWorkflow
    • isGlobalAction

      public boolean isGlobalAction(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor)
      Specified by:
      isGlobalAction in interface JiraWorkflow
    • isOrdinaryAction

      public boolean isOrdinaryAction(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor)
      Specified by:
      isOrdinaryAction in interface JiraWorkflow
    • getLinkedStatus

      public Status getLinkedStatus(com.opensymphony.workflow.loader.StepDescriptor stepDescriptor)
      Description copied from interface: JiraWorkflow
      Get the Status associated with the given StepDescriptor.
      Specified by:
      getLinkedStatus in interface JiraWorkflow
      Parameters:
      stepDescriptor - the StepDescriptor
      Returns:
      the Status associated with the given StepDescriptor.
    • getLinkedStatusObject

      @Deprecated public Status getLinkedStatusObject(com.opensymphony.workflow.loader.StepDescriptor stepDescriptor)
      Deprecated.
      Get the Status associated with the given StepDescriptor.
      Specified by:
      getLinkedStatusObject in interface JiraWorkflow
      Parameters:
      stepDescriptor - the StepDescriptor
      Returns:
      the Status associated with the given StepDescriptor.
    • getActionType

      public String getActionType(com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor)
      Specified by:
      getActionType in interface JiraWorkflow
    • reset

      public void reset()
      Specified by:
      reset in interface JiraWorkflow
    • getActionsForScreen

      public Collection<com.opensymphony.workflow.loader.ActionDescriptor> getActionsForScreen(FieldScreen fieldScreen)
      Specified by:
      getActionsForScreen in interface JiraWorkflow
    • getUpdateAuthorName

      public String getUpdateAuthorName()
      Returns the most recent authors username.
      Specified by:
      getUpdateAuthorName in interface JiraWorkflow
      Returns:
      Returns the authors username
      Since:
      v3.13
    • getUpdateAuthor

      public ApplicationUser getUpdateAuthor()
      Returns the most recent author

      Notice: This method will also return proxy user even when is not existing. Please use UserManager.isUserExisting(com.atlassian.jira.user.ApplicationUser) if you want to check user's existence.
      Specified by:
      getUpdateAuthor in interface JiraWorkflow
      Returns:
      The update author.
      Since:
      v6.0
    • getUpdatedDate

      public Date getUpdatedDate()
      Returns the date of the most recent update to this workflow.
      Specified by:
      getUpdatedDate in interface JiraWorkflow
      Returns:
      date of the most recent update to this workflow
      Since:
      v3.13
    • getMode

      public String getMode()
      Returns either JiraWorkflow.DRAFT or JiraWorkflow.LIVE depending on the workflow implementation.
      Specified by:
      getMode in interface JiraWorkflow
      Returns:
      JiraWorkflow.DRAFT or JiraWorkflow.LIVE
      Since:
      v3.13
    • compareTo

      public int compareTo(JiraWorkflow workflow)
      Specified by:
      compareTo in interface Comparable<JiraWorkflow>
    • getJiraWorkflow

      public JiraWorkflow getJiraWorkflow()
    • getDistinctTransitionNames

      public Set<String> getDistinctTransitionNames()
      Returns:
      the set of all distinct transition names used by this workflow including global transition names