public StepDescriptor getStep(final int id) { return delegate.getStep(id); }
public StepDescriptor getDestinationStepDescriptor() { int targetStepId = resultDescriptor.getStep(); return getWorkflow().getDescriptor().getStep(targetStepId); }
public StepDescriptor getStepDescriptor(ConditionalResultDescriptor conditionalResultDescriptor) { final int targetStepId = conditionalResultDescriptor.getStep(); return getWorkflow().getDescriptor().getStep(targetStepId); }
private StepDescriptor getInitialStepDescriptor(JiraWorkflow workflow) { List initialActions = workflow.getDescriptor().getInitialActions(); ActionDescriptor initialAction = (ActionDescriptor) initialActions.get(0); int initialStep = initialAction.getUnconditionalResult().getStep(); return workflow.getDescriptor().getStep(initialStep); }
private static StepDescriptor getInitialStepDescriptor(JiraWorkflow workflow) { List initialActions = workflow.getDescriptor().getInitialActions(); ActionDescriptor initialAction = (ActionDescriptor) initialActions.get(0); int initialStep = initialAction.getUnconditionalResult().getStep(); return workflow.getDescriptor().getStep(initialStep); }
private String getToStatus(WorkflowDescriptor workflowDescriptor, Step createdStep) { return option(workflowDescriptor.getStep(createdStep.getStepId())).map(new Function<StepDescriptor, String>() { @Override public String apply(final StepDescriptor input) { return input.getName(); } }).getOrElse(""); } }
throw new IllegalStateException("Issue has no status, and status cannot be derived as the workflow step for this issue is missing."); final StepDescriptor step = workflow.getDescriptor().getStep(stepId); if(step == null) throw new IllegalStateException("Can not resolve a step with id: " + stepId + " from workflow " + workflow.getName());
public boolean isStepOnDraftWithNoTransitionsOnParentWorkflow(final JiraServiceContext jiraServiceContext, final JiraWorkflow workflow, final int stepId) { if (workflow.isDraftWorkflow()) { //need to check the parent's step to see if it has any available actions. final JiraWorkflow parentWorkflow = getWorkflow(jiraServiceContext, workflow.getName()); final StepDescriptor originalStep = parentWorkflow.getDescriptor().getStep(stepId); //if the step exists on the original workflow (may not, it could be a new step added to the draft, //in which case we don't care) if (originalStep != null) { final List<?> availableActions = originalStep.getActions(); if ((availableActions == null) || availableActions.isEmpty()) { return true; } } } return false; }
final ActionDescriptor action = descriptor.getAction(actionId); final String firstStepName = (originalIssue == null) ? "" : originalIssue.getStatusObject().getName(); final String endStepName = descriptor.getStep(action.getUnconditionalResult().getStep()).getName(); final String actionName = action.getName(); final boolean notifyClients = Boolean.parseBoolean((String) args.get(HipChatPostFunctionFactory.NOTIFY_CLIENTS_PARAM));
public void execute(Map transientVars, Map args, PropertySet ps) throws StoreException { MutableIssue issue = (MutableIssue) transientVars.get("issue"); WorkflowEntry entry = (WorkflowEntry) transientVars.get("entry"); SimpleStep step = (SimpleStep) ((WorkflowStore) transientVars.get("store")).findCurrentSteps(entry.getId()).get(0); WorkflowDescriptor descriptor = (WorkflowDescriptor) transientVars.get("descriptor"); StepDescriptor stepDescriptor = descriptor.getStep(step.getStepId()); Status oldStatus = issue.getStatus(); Status newStatus = ComponentAccessor.getConstantsManager().getStatus((String) stepDescriptor.getMetaAttributes().get("jira.status.id")); // Update issue issue.setStatusId(newStatus.getId()); // Generate status change item List changeItems = (List) transientVars.get("changeItems"); if (changeItems == null) { changeItems = new LinkedList(); } String from = null; String fromString = null; if (oldStatus != null) { from = oldStatus.getId(); fromString = oldStatus.getName(); } String to = newStatus.getId(); String toString = newStatus.getName(); changeItems.add(new ChangeItemBean(ChangeItemBean.STATIC_FIELD, IssueFieldConstants.STATUS, from, fromString, to, toString)); transientVars.put("changeItems", changeItems); }
private String findPreviousStatus(Step currentStep, WorkflowEntry entry, WorkflowStore workflowStore, WorkflowDescriptor workflowDescriptor) { if (currentStep.getPreviousStepIds().length == 0) { return ""; } final long previousStepId = currentStep.getPreviousStepIds()[0]; try { final List<Step> historySteps = workflowStore.findHistorySteps(entry.getId()); final Step previousStep = Iterables.find(historySteps, new Predicate<Step>() { @Override public boolean apply(Step step) { return step.getId() == previousStepId; } }, null); if (previousStep == null) { LOG.error("Transition from cannot be found. It seems that workflow data is inconsistent."); return ""; } return workflowDescriptor.getStep(previousStep.getStepId()).getName(); } catch (StoreException e) { return ""; } }
@Nonnull @Override public String getNextStatusIdForAction(@Nonnull final Issue issue, final int actionId) { JiraWorkflow workflow = getWorkflow(issue); if (workflow == null) { throw new IllegalStateException("There is no workflow for the issue with key " + issue.getKey()); } ActionDescriptor action = workflow.getDescriptor().getAction(actionId); if (action == null) { throw new IllegalStateException("There is no action descriptor for an action with id " + actionId); } int stepId = action.getUnconditionalResult().getStep(); if (stepId == JiraWorkflow.ACTION_ORIGIN_STEP_ID) { return issue.getStatusObject().getId(); } StepDescriptor step = workflow.getDescriptor().getStep(stepId); return workflow.getLinkedStatusId(step); }
/** * @param issue issue object to derive the workflow from * @param stepId the step id to get the status id for * @return the the status which stepId maps to in the associated workflow */ private Status getStatusFromStep(Issue issue, int stepId) { final WorkflowDescriptor workflowDescriptor = workflowManager.getWorkflow(issue).getDescriptor(); String statusId; if (AUTOMATIC_LOOP_BACK_STEP_ID == stepId) // Then we just need to return the current status, see JRA-32132 for details. { statusId = issue.getStatusObject().getId(); } else { statusId = (String) workflowDescriptor.getStep(stepId).getMetaAttributes().get(JiraWorkflow.STEP_STATUS_KEY); } return statusManager.getStatus(statusId); }
/** * This method is used to determine if workflowstep belongs to a draft workflow and is present on the original * workflow that was used to create the draft. * This means this step cannot be deleted, and cannot be associated with a different status. * @param stepDescriptor The stepDescriptor in being edited. * @return True if the step is an existing step and the workflow is a draft workflow */ public boolean isOldStepOnDraft(StepDescriptor stepDescriptor) { // First check if it is a draft workflow if (!workflow.isDraftWorkflow()) { return false; } // Does this step exist in the live workflow? JiraWorkflow jiraWorkflow = workflowService.getWorkflow(getJiraServiceContext(), workflow.getName()); return jiraWorkflow.getDescriptor().getStep(stepDescriptor.getId()) != null; }
Status status = workflow.getLinkedStatusObject(workflow.getDescriptor().getStep(newStepId)); if (status == null)
@RequiresXsrfCheck protected String doExecute() throws Exception { StepDescriptor stepDescriptor = getWorkflow().getDescriptor().getStep(step.getId()); stepDescriptor.setName(getStepName()); //For a draft workflow, you can only changed the linked status for new steps. if (!isOldStepOnDraft(step)) { stepDescriptor.getMetaAttributes().put(JiraWorkflow.STEP_STATUS_KEY, getStepStatus()); } workflowService.updateWorkflow(getJiraServiceContext(), getWorkflow()); return getRedirect(getCancelUrl()); }
public Status getDestinationStatus(final WorkflowTransitionKey workflowTransitionKey) { final ActionDescriptor actionDescriptor = getBulkWorkflowTransitionOperation().getActionDescriptor(workflowTransitionKey); final JiraWorkflow workflow = workflowManager.getWorkflow(workflowTransitionKey.getWorkflowName()); final int newStepId = actionDescriptor.getUnconditionalResult().getStep(); if (newStepId == JiraWorkflow.ACTION_ORIGIN_STEP_ID) { return getOriginStatus(workflowTransitionKey); } else { final StepDescriptor step = workflow.getDescriptor().getStep(newStepId); return workflow.getLinkedStatus(step); } }
StepDescriptor stepDescriptor = descriptor.getStep(step.getStepId()); issue.setStatusId((String) stepDescriptor.getMetaAttributes().get("jira.status.id"));
public void validateAddWorkflowTransitionToDraft(final JiraServiceContext jiraServiceContext, final JiraWorkflow newJiraWorkflow, final int stepId) { if (!hasAdminPermission(jiraServiceContext)) { jiraServiceContext.getErrorCollection().addErrorMessage(getI18nBean().getText("admin.workflows.service.error.no.admin.permission")); return; } if (isStepOnDraftWithNoTransitionsOnParentWorkflow(jiraServiceContext, newJiraWorkflow, stepId)) { //original step didn't have any actions. Lets check if the new step DOES have any actions. final StepDescriptor newStep = newJiraWorkflow.getDescriptor().getStep(stepId); final List<?> newActions = newStep.getActions(); if ((newActions != null) && !newActions.isEmpty()) { jiraServiceContext.getErrorCollection().addErrorMessage( getI18nBean().getText("admin.workflowtransitions.error.add.transition.draft.step.without.transition", newStep.getName())); } } }
workflow.getLinkedStatusObject(workflow.getDescriptor().getStep(resultStep)); workflowTransitionKey = new WorkflowTransitionKey(workflowName, actionDescriptorId, resultStatus.getId());