@Override public Map<String, String> get() { return descriptor.getMetaAttributes(); }
private Map<String, String> getEntityMetaAttributes() { return step.getMetaAttributes(); }
@Override public String apply(StepDescriptor stepDescriptor) { return (String) stepDescriptor.getMetaAttributes().get(JIRA_STATUS_ID); } });
@Override public String getLinkedStatusId(final StepDescriptor stepDescriptor) { if (stepDescriptor == null) { throw new IllegalArgumentException("Step cannot be null."); } if ((stepDescriptor.getMetaAttributes() != null) && stepDescriptor.getMetaAttributes().containsKey(STEP_STATUS_KEY)) { return (String) stepDescriptor.getMetaAttributes().get(JiraWorkflow.STEP_STATUS_KEY); } throw new IllegalStateException("Step with id '" + stepDescriptor.getId() + "' does not have a valid linked status."); }
private StepDescriptor getLinkedStep(final String statusId) { if (statusId == null) { throw new IllegalArgumentException(); } for (final Object o : descriptor.getSteps()) { final StepDescriptor stepDescriptor = (StepDescriptor) o; if (statusId.equals(stepDescriptor.getMetaAttributes().get(JiraWorkflow.STEP_STATUS_KEY))) { return stepDescriptor; } } // not found return null; }
public List<WorkflowPermission> getWorkflowPermissions(PermissionContext ctx, ProjectPermissionKey permissionId, boolean isParent) { StepDescriptor relevantStepDescriptor = ctx.getRelevantStepDescriptor(); if (relevantStepDescriptor == null) { return Collections.emptyList(); } Map<String, String> metaAttributes = relevantStepDescriptor.getMetaAttributes(); List<WorkflowPermission> perms = new ArrayList<WorkflowPermission>(metaAttributes.size()); for (Map.Entry<String, String> metaEntry : metaAttributes.entrySet()) { WorkflowPermission perm = createWorkflowPermission(permissionId, isParent, metaEntry.getKey(), metaEntry.getValue()); if (perm != null) { perms.add(perm); } } return perms; }
private boolean isStatusLinked(GenericValue status) { for (final Object o : workflow.getDescriptor().getSteps()) { StepDescriptor stepDescriptor = (StepDescriptor) o; if (status.getString("id").equals(stepDescriptor.getMetaAttributes().get(JiraWorkflow.STEP_STATUS_KEY))) { return true; } } return false; }
private void initStatuses() { if (step.getMetaAttributes() != null && step.getMetaAttributes().containsKey(JiraWorkflow.STEP_STATUS_KEY)) { setStepStatus((String) step.getMetaAttributes().get(JiraWorkflow.STEP_STATUS_KEY)); statuses = new ArrayList(); // Add existing status to the list statuses.add(getConstantsManager().getStatus(getStepStatus())); // Add all the other available statuses statuses.addAll(getUnlinkedStatusesGVs()); } else { addErrorMessage(getText("admin.errors.no.associated.status")); } }
private boolean findMoreStatuses() { boolean changed = false; while (!changed && hasMoreWorkflows()) { final JiraWorkflow workflow = workflowManager.getWorkflow(pendingWorkflowNames.removeFirst()); @SuppressWarnings ("unchecked") final List<StepDescriptor> steps = workflow.getDescriptor().getSteps(); for (StepDescriptor step : steps) { final String linkedStatusId = (String)step.getMetaAttributes().get("jira.status.id"); changed |= seenStatusIds.add(linkedStatusId); } } return changed; }
@Override public Map<String,StatusMapping> getStatusHolders(File xmlFile) throws Exception { Collection<Status> jiraStatuses = constantsManager.getStatusObjects(); Map<String,StatusMapping> holders = new HashMap<String, StatusMapping>(); String xml = FileUtils.readFileToString(xmlFile); WorkflowDescriptor descriptor = WorkflowUtil.convertXMLtoWorkflowDescriptor(xml); List<StepDescriptor> steps = descriptor.getSteps(); for(StepDescriptor step : steps) { if ((step.getMetaAttributes() != null) && step.getMetaAttributes().containsKey(JiraWorkflow.STEP_STATUS_KEY)) { String statusId = (String) step.getMetaAttributes().get(JiraWorkflow.STEP_STATUS_KEY); try { Status found = Iterables.find(jiraStatuses,new StatusNamePredicate(step.getName())); holders.put(statusId,new StatusMapping(statusId,step.getName(),found.getId(),getSuggestedName(jiraStatuses,found.getName()))); } catch (NoSuchElementException e) { holders.put(statusId, new StatusMapping(statusId, step.getName(), "-1", step.getName())); } } } return holders; }
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); }
/** * @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); }
if (null != step) step.getMetaAttributes().put(JIRA_STATUS_ID, mapping.getNewId());
public boolean isEditable(Issue issue) { if (issue == null || issue.getProjectObject() == null || issue.getIssueTypeObject() == null || issue.getStatusObject() == null) { return false; } try { final JiraWorkflow workflow = getWorkflow(issue.getProjectId(), issue.getIssueTypeId()); final String statusId = issue.getStatusObject().getId(); if (statusId != null) //this should never really be null - but it saves hassle of setting up hundreds of tests with a statusId { final StepDescriptor currentStep = workflow.getLinkedStep(getConstantsManager().getStatusObject(statusId)); if (currentStep == null || !"false".equals(currentStep.getMetaAttributes().get(JiraWorkflow.JIRA_META_ATTRIBUTE_EDIT_ALLOWED))) { return true; } } return false; } catch (WorkflowException e) { throw new RuntimeException(e + " when trying to access workflow for issue " + issue, e); } }
if (!getStepStatus().equals(step.getMetaAttributes().get(JiraWorkflow.STEP_STATUS_KEY))) if (getStepStatus().equalsIgnoreCase((String) existingStep.getMetaAttributes().get(JiraWorkflow.STEP_STATUS_KEY))) if (getStepStatus() != null && !getStepStatus().equals(step.getMetaAttributes().get(JiraWorkflow.STEP_STATUS_KEY)))
@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()); }
WorkflowDescriptor descriptor = (WorkflowDescriptor) transientVars.get("descriptor"); StepDescriptor stepDescriptor = descriptor.getStep(step.getStepId()); issue.setStatusId((String) stepDescriptor.getMetaAttributes().get("jira.status.id"));
public ConfigurableJiraWorkflow(final String name, final WorkflowManager workflowManager) { super(workflowManager, new WorkflowDescriptor()); this.name = name; // create the initial step - useful to have one of these :) final StepDescriptor step = DescriptorFactory.getFactory().createStepDescriptor(); step.setId(1); step.setName("Open"); step.getMetaAttributes().put(JiraWorkflow.STEP_STATUS_KEY, "1"); step.setParent(descriptor); descriptor.addStep(step); // create the initial action final ActionDescriptor initialAction = DescriptorFactory.getFactory().createActionDescriptor(); initialAction.setId(1); initialAction.setName("Create"); initialAction.setParent(descriptor); descriptor.addInitialAction(initialAction); // add create issue permission validator initialAction.getValidators().add(PermissionValidator.makeDescriptor("Create Issue")); // setup result to always be step 1 final ResultDescriptor resultDescriptor = DescriptorFactory.getFactory().createResultDescriptor(); resultDescriptor.setStep(1); resultDescriptor.setStatus("open"); initialAction.setUnconditionalResult(resultDescriptor); // setup post functions resultDescriptor.getPostFunctions().add(IssueCreateFunction.makeDescriptor()); resultDescriptor.getPostFunctions().add(IssueReindexFunction.makeDescriptor()); resultDescriptor.getPostFunctions().add(FireIssueEventFunction.makeDescriptor(EventType.ISSUE_CREATED_ID)); }
if (getStepStatus().equalsIgnoreCase((String) existingStep.getMetaAttributes().get(JiraWorkflow.STEP_STATUS_KEY))) newStep.setName(getStepName()); newStep.setId(WorkflowUtil.getNextId(getWorkflow().getDescriptor().getSteps())); newStep.getMetaAttributes().put(JiraWorkflow.STEP_STATUS_KEY, getStepStatus());
final Map stepAttributes = stepDescriptor.getMetaAttributes();