private List<JiraWorkflow> getWorkflowsIncludingDrafts() { // Cache this call as it is expensive. if (workflowsIncludingDrafts == null) { workflowsIncludingDrafts = workflowManager.getWorkflowsIncludingDrafts(); } return workflowsIncludingDrafts; }
private boolean hasAssociatedWorkflows(final Status status) { List<JiraWorkflow> workflows = workflowManager.getWorkflowsIncludingDrafts(); return Iterables.any(workflows, containsStatus(status)); }
private List<JiraWorkflow> getWorkflowsIncludingDrafts() { final List<JiraWorkflow> allWorkflows = workflowManager.getWorkflowsIncludingDrafts(); //only include drafts if their parent is active Iterable<JiraWorkflow> filteredWorkflows = Iterables.filter(allWorkflows,new Predicate<JiraWorkflow>() { @Override public boolean apply(JiraWorkflow jiraWorkflow) { if(null == jiraWorkflow) { return false; } if(jiraWorkflow.isDraftWorkflow() && !parentWorkflowChecker.isParentWorkflowActive(jiraWorkflow)) { return false; } else { return true; } } }); return ImmutableList.copyOf(filteredWorkflows); } }
private List<JiraWorkflow> getDraftWorkflows() { if (draftWorkflows == null) { final ImmutableList.Builder<JiraWorkflow> results = ImmutableList.builder(); final List<JiraWorkflow> allWorkflows = workflowManager.getWorkflowsIncludingDrafts(); for (final JiraWorkflow jiraWorkflow : allWorkflows) { if (jiraWorkflow.isDraftWorkflow()) { results.add(jiraWorkflow); } } draftWorkflows = results.build(); } return draftWorkflows; }
@Override public ServiceOutcome<List<JiraWorkflow>> getAssociatedWorkflows(ApplicationUser user, final Status status){ List<JiraWorkflow> allWorkflows = workflowManager.getWorkflowsIncludingDrafts(); List<JiraWorkflow> workflows = ImmutableList.copyOf(Iterables.filter(allWorkflows, containsStatus(status))); return ServiceOutcomeImpl.ok(workflows); }
@ActionViewData public List<String> getWorkflowsForStatus() { List<JiraWorkflow> allWorkflows = workflowManager.getWorkflowsIncludingDrafts(); final Status status = statusService.getStatusById(getLoggedInUser(), id); Iterable<JiraWorkflow> workflowsForStatus = Iterables.filter(allWorkflows, new Predicate<JiraWorkflow>() { @Override public boolean apply(@Nullable final JiraWorkflow input) { return input.getLinkedStatusIds().contains(status.getId()); } }); List<String> workflowNamesForStatus = Lists.newArrayList(Iterables.transform(workflowsForStatus, GET_WORKFLOW_NAME)); Collections.sort(workflowNamesForStatus); return workflowNamesForStatus; }
@ActionViewData public Collection<SimpleStatus> getStatuses() { List<JiraWorkflow> workflows = workflowManager.getWorkflowsIncludingDrafts(); return copyOf(transform(getConstantsManager().getStatusObjects(), new StatusMappingFunction(workflows))); }
@Override public void removeStatus(final String id) { Status status = getStatusOrThrowIllegalArgumentException(id); final List<JiraWorkflow> existingWorkflows = workflowManager.getWorkflowsIncludingDrafts(); for (JiraWorkflow workflow : existingWorkflows) { Collection<Status> linkStatuses = workflow.getLinkedStatusObjects(); if (linkStatuses.contains(status)) { throw new IllegalStateException("Cannot delete a status which is associated with a workflow. Status is associated with workflow " + workflow.getName()); } } try { removeConstant(getIssueConstantField(), status, null); } catch (GenericEntityException | IndexException e) { throw new DataAccessException("Failed to remove status with id '" + id + "'", e); } }