public ViewWorkflowXml(JiraWorkflow workflow) { this.workflow = workflow; this.name = workflow.getName(); }
private Map<Long, ActionDescriptor> getActionsMap(JiraWorkflow workflow) { return Maps.uniqueIndex(workflow.getAllActions(), new Function<ActionDescriptor, Long>() { @Override public Long apply(final ActionDescriptor actionDescriptor) { return (long) actionDescriptor.getId(); } }); } }
private JiraWorkflow getWorkflowForEdit() { if (workflow.isDraftWorkflow()) { return workflow; } else { return workflowManager.getWorkflowClone(workflow.getName()); } }
public boolean isParentWorkflowActive(JiraWorkflow workflow) { //not an draft workflow? Well you don't have a parent so your parent is active for the purposes // of this method. if(!workflow.isDraftWorkflow()) { return true; } JiraWorkflow parentWorkflow = workflowManager.getWorkflow(workflow.getName()); return parentWorkflow != null && parentWorkflow.isActive(); }
public Map<ActionDescriptor, Collection<FunctionDescriptor>> getPostFunctionsForWorkflow(JiraWorkflow workflow) { Map<ActionDescriptor, Collection<FunctionDescriptor>> transitionPostFunctionMap = new HashMap<ActionDescriptor, Collection<FunctionDescriptor>>(); Collection<ActionDescriptor> actions = workflow.getAllActions(); for (final ActionDescriptor actionDescriptor : actions) { Collection<FunctionDescriptor> postFunctions = workflow.getPostFunctionsForTransition(actionDescriptor); transitionPostFunctionMap.put(actionDescriptor, postFunctions); } return transitionPostFunctionMap; }
public void visit(final JiraWorkflow workflow, final ActionDescriptor actionDescriptor, final Set<JiraWorkflow> workflowsToSave) { transitions.add(new WorkflowTransition(workflow.getName(), workflow.isDraftWorkflow(), actionDescriptor.getId(), actionDescriptor.getName(), workflow.isSystemWorkflow())); } });
for (final JiraWorkflow workflow : (Iterable<JiraWorkflow>) workflowManager.getWorkflows()) for (final ActionDescriptor actionDescriptor : (Iterable<ActionDescriptor>) workflow.getAllActions()) if (workflow.hasDraftWorkflow()) final JiraWorkflow draftWorkflow = workflowManager.getDraftWorkflow(workflow.getName()); for (final ActionDescriptor actionDescriptor : (Iterable<ActionDescriptor>) draftWorkflow.getAllActions()) if (workflow.isDraftWorkflow()) else if (!workflow.isSystemWorkflow())
if (workflow == null || workflow.getDescriptor() == null) if (workflow.isDraftWorkflow()) final JiraWorkflow parentWorkflow = getWorkflow(workflow.getName()); if (parentWorkflow == null) originalWorkflow = getDraftWorkflow(workflow.getName()); draftWorkflowStore.updateDraftWorkflow(user, workflow.getName(), workflow); originalWorkflow = getWorkflow(workflow.getName()); if (workflow.isActive()) if (workflow.isSystemWorkflow())
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; }
private WorkflowBean jiraWorkflowToWorkflowBean(JiraWorkflow jiraWorkflow) { String name = jiraWorkflow.getName(); String description = jiraWorkflow.getDescription(); int steps = jiraWorkflow.getDescriptor().getSteps().size(); boolean isDefault = jiraWorkflow.isDefault(); String updateDate = jiraWorkflow.getUpdatedDate() != null ? dateTimeFormatter.forLoggedInUser().format(jiraWorkflow.getUpdatedDate()) : null; ApplicationUser updateAuthor = jiraWorkflow.getUpdateAuthor(); String updateAuthorName = userManager.isUserExisting(updateAuthor)?updateAuthor.getDisplayName():null; return new WorkflowBean(name, description, updateDate, updateAuthorName, steps, isDefault); } }
public void saveWorkflowWithoutAudit(JiraWorkflow workflow) throws WorkflowException { if (workflow.isDraftWorkflow()) { // Save the passed workflow over the existing draft draftWorkflowStore.updateDraftWorkflowWithoutAudit(workflow.getName(), workflow); } try { getConfiguration().saveWorkflow(workflow.getName(), workflow.getDescriptor(), true); workflow.reset(); } catch (FactoryException e) { throw new WorkflowException(e); } }
List<Status> statuses = workflow.getLinkedStatusObjects(); for (Status status : statuses) log.error(String.format("The '%s' workflow is misconfigured", workflow.getName()), e); if (null != step) Status status = workflow.getLinkedStatusObject(step); if (null != status) log.error(String.format("Failed to determine the initial step for '%s' workflow ", workflow.getName()), e); for (ActionDescriptor actionDescriptor : workflow.getAllActions()) && StringUtils.isNotBlank(fieldValue)) final StepDescriptor stepDescriptor = workflow.getDescriptor().getStep(actionDescriptor.getUnconditionalResult().getStep()); final Status destinationStatus = workflow.getLinkedStatusObject(stepDescriptor); map.put(destinationStatus.getId(), getCompleteCategory()); log.error(String.format("Failed to find completion steps for '%s' workflow", workflow.getName()), e);
private boolean checkWorkflow(final boolean equality, final Set<String> ids, final Project project, final String issueType, final String workflowName) { final JiraWorkflow workflow = workflowManager.getWorkflow(workflowName); if (workflow != null) { final List<Status> statusObjects = workflow.getLinkedStatusObjects(); for (Status statusObject : statusObjects) { // JRA-19026 - when we encounter really messed up data the workflow can return null statuses if (statusObject != null) { if (equality == ids.contains(statusObject.getId())) { return true; } } else { final String issueTypeStr = issueType == null ? "default" : issueType; // Kinda strange, probably means you manually messed with your workflow, lets info log log.debug("Workflow: '" + workflow.getName() + "' associated with project: '" + project.getId() + "' and issue type: '" + issueTypeStr + "' contains a null status, you might want to fix that."); } } } return false; }
public void updateWorkflowNameAndDescription(ApplicationUser user, JiraWorkflow currentWorkflow, String newName, String newDescription) final String currentWorkflowName = currentWorkflow.getName(); if (!currentWorkflow.isDraftWorkflow()) if (newDescription != null && !newDescription.equals(workflow.getDescription())) WorkflowDescriptor descriptor = workflow.getDescriptor(); descriptor.getMetaAttributes().put(JiraWorkflow.WORKFLOW_DESCRIPTION_ATTRIBUTE, newDescription); updateWorkflow(user, workflow); if (!currentWorkflowName.equals(newName) && !currentWorkflow.isDraftWorkflow()) getConfiguration().saveWorkflow(newName, workflow.getDescriptor(), true); JiraDraftWorkflow newWorkflow = new JiraDraftWorkflow(newName, this, draftWorkflow.getDescriptor()); draftWorkflowStore.createDraftWorkflow(user, newWorkflow); draftWorkflowStore.deleteDraftWorkflow(currentWorkflowName);
@Override public List<Project> getProjectsForFieldScreen(final FieldScreen fieldScreen) { final WorkflowActionsBean actionsBean = getActionsBean(); final Set<Project> projects = Sets.newTreeSet(ProjectNameComparator.COMPARATOR); final Set<String> matchingWorkflows = Sets.newHashSet(); final Collection<JiraWorkflow> activeWorkflows = workflowManager.getActiveWorkflows(); for (final JiraWorkflow activeWorkflow : activeWorkflows) { final Collection<ActionDescriptor> allActions = activeWorkflow.getAllActions(); for (final ActionDescriptor actionDescriptor : allActions) { final FieldScreen fieldScreenForView = actionsBean.getFieldScreenForView(actionDescriptor); if (fieldScreenForView != null && fieldScreenForView.equals(fieldScreen)) { matchingWorkflows.add(activeWorkflow.getName()); break; } } } final Set<FieldScreenScheme> fieldScreenSchemes = Sets.newHashSet(fieldScreenSchemeManager.getFieldScreenSchemes(fieldScreen)); projects.addAll(projectWorkflowSchemeHelper.getProjectsForWorkflow(matchingWorkflows).values()); projects.addAll(issueTypeScreenSchemeHelper.getProjectsForFieldScreenSchemes(fieldScreenSchemes).values()); return Lists.newArrayList(projects); }
return; if ((currentWorkflow == null) || (currentWorkflow.getDescriptor() == null)) if (!currentWorkflow.isEditable()) if (currentWorkflow.isDraftWorkflow() && !newWorkflowName.equals(currentWorkflow.getName())) if (!newWorkflowName.equals(currentWorkflow.getName()) && workflowManager.workflowExists(newWorkflowName))
if (workflow.isSystemWorkflow()) .addParameter("workflowMode", "live").addParameter("workflowName", workflow.getName()); return getRedirect(builder.asUrlString()); else if (!workflow.isActive()) if (!workflow.hasDraftWorkflow()) workflow = workflowService.createDraftWorkflow(getJiraServiceContext(), workflow.getName()); workflow = workflowService.getDraftWorkflow(getJiraServiceContext(), workflow.getName());
@Override public RecordRequest onWorkflowDeletedEvent(final WorkflowDeletedEvent event) { return new RecordRequest(AuditingCategory.WORKFLOWS, "jira.auditing.workflow.deleted") .forObject(AssociatedItem.Type.WORKFLOW, event.getWorkflow().getDisplayName(), event.getWorkflow().getName()); }
private boolean shouldUpgradeWorkflow(JiraWorkflow workflow) { //custom system workflows will not be automatically updated, but logged with detailed instructions boolean isSystemWorkflow; try { isSystemWorkflow = workflow.isSystemWorkflow(); } catch (WorkflowException e) { logError("Could not determine whether workflow '" + workflow.getName() + "' is System Workflow, " + "skipping. Error: ", e); return false; } return upgradeWorkflow(workflow, isSystemWorkflow); }
public String doDefault() throws Exception { if (workflow.isEditable()) { newWorkflowName = workflow.getName(); description = workflow.getDescription(); return INPUT; } else { addErrorMessage(getText("admin.errors.workflow.cannot.be.edited.as.it.is.not.editable")); } return ERROR; }