@Override public Integer apply(final ActionDescriptor input) { final ResultDescriptor result = input.getUnconditionalResult(); return result != null && result.getPostFunctions() != null ? result.getPostFunctions().size() : 0 ; } });
protected void deleteWorkflowDescriptor() throws WorkflowException { getTransition().getUnconditionalResult().getPostFunctions().remove(count - 1); } }
private Set<String> getFunctionClassnames(ActionDescriptor action) { List<FunctionDescriptor> functions = action.getUnconditionalResult().getPostFunctions(); functions.addAll(action.getPostFunctions()); Set<String> classNames = new HashSet<String>(); for (FunctionDescriptor function : functions) { Set<Map.Entry<String,String>> args = (Set<Map.Entry<String,String>>) function.getArgs().entrySet(); classNames.addAll(getClassnamesFromArgs(args)); } return classNames; }
protected List getDescriptorCollection() { return getTransition().getUnconditionalResult().getPostFunctions(); }
public Collection<FunctionDescriptor> getPostFunctionsForTransition(final ActionDescriptor actionDescriptor) { final Collection<FunctionDescriptor> allPostFunctions = Lists.newArrayList(); if ((actionDescriptor.getUnconditionalResult() != null) && (actionDescriptor.getUnconditionalResult().getPostFunctions() != null)) { allPostFunctions.addAll(actionDescriptor.getUnconditionalResult().getPostFunctions()); } final List conditionalResults = actionDescriptor.getConditionalResults(); if (conditionalResults != null) { for (final Object conditionalResult : conditionalResults) { final ResultDescriptor resultDescriptor = (ResultDescriptor) conditionalResult; allPostFunctions.addAll(resultDescriptor.getPostFunctions()); } } if (actionDescriptor.getPostFunctions() != null) { allPostFunctions.addAll(actionDescriptor.getPostFunctions()); } return allPostFunctions; }
private Map<String, Map<String, String>> updatePostFunctionCustomFieldIds(ActionDescriptor action, Map<String, String> oldToNewIdMapping) { Map<String, Map<String, String>> result = new HashMap<String, Map<String, String>>(); Collection<FunctionDescriptor> postFunctions = action.getUnconditionalResult().getPostFunctions(); postFunctions.addAll(action.getPostFunctions()); for(FunctionDescriptor function : postFunctions) { Map<String,String> args = (Map<String,String>) function.getArgs(); Map<String,String> updateMap = new HashMap<String, String>(); for(Map.Entry<String,String> entry : args.entrySet()) { if(entry.getValue().startsWith(WorkflowCustomFieldsHelper.CUSTOM_FIELD_PREFIX) && oldToNewIdMapping.containsKey(entry.getValue())) { updateMap.put(entry.getKey(),oldToNewIdMapping.get(entry.getValue())); } } if(!updateMap.isEmpty()) { for(Map.Entry<String,String> updateEntry : updateMap.entrySet()) { args.put(updateEntry.getKey(),updateEntry.getValue()); } String extensionClass = StringUtils.defaultIfEmpty((String)function.getArgs().get("class.name"),function.toString());//NON-NLS result.put(extensionClass,updateMap); } } return result; }
private Map<String,Set<String>> removePostFunctionsWithClassnames(ActionDescriptor action, Set<String> classesToRemove) { Map<String,Set<String>> result = new HashMap<String,Set<String>>(); Collection<FunctionDescriptor> postFunctions = action.getUnconditionalResult().getPostFunctions(); postFunctions.addAll(action.getPostFunctions()); Iterator<FunctionDescriptor> it = postFunctions.iterator(); while(it.hasNext()) { FunctionDescriptor postFunction = it.next(); Set<Map.Entry<String,String>> args = (Set<Map.Entry<String,String>>) postFunction.getArgs().entrySet(); Set<String> usedClassnames = getClassnamesFromArgs(args); if(!Sets.intersection(classesToRemove,usedClassnames).isEmpty()) { String extensionClass = StringUtils.defaultIfEmpty((String)postFunction.getArgs().get("class.name"),postFunction.toString());//NON-NLS result.put(extensionClass,classesToRemove); it.remove(); } } return result; }
postFunctions.addAll(result.getPostFunctions()); postFunctions.addAll(action.getUnconditionalResult().getPostFunctions()); postFunctions.addAll(action.getPostFunctions());
for (Iterator postFunctions = actionDescriptor.getUnconditionalResult().getPostFunctions().iterator(); actionDescriptor.getUnconditionalResult().getPostFunctions().add(positionInList, makeDescriptor());
final List postFunctions = unconditionalResult.getPostFunctions();
@RequiresXsrfCheck public String doMoveWorkflowFunctionDown() throws Exception { final List postFunctions = getTransition().getUnconditionalResult().getPostFunctions(); if (down < 0 || down >= (postFunctions.size() - 1)) { addErrorMessage(getText("admin.errors.workflows.invalid.index", "" + down)); } else { Object toMove = postFunctions.get(down); CollectionReorderer.decreasePosition(postFunctions, toMove); workflowService.updateWorkflow(getJiraServiceContext(), getWorkflow()); } return getViewRedirect("¤tCount=workflow-function" + (down + 2)); }
protected boolean isModulePresent(Class implementationClass) { // Check if the module is present in either the unconiditional result post functions or in global post-functions // (as they are always executed). return isModulePresent(getTransition().getUnconditionalResult().getPostFunctions(), implementationClass) || isModulePresent(getTransition().getPostFunctions(), implementationClass); }
@RequiresXsrfCheck public String doMoveWorkflowFunctionUp() throws Exception { final List postFunctions = getTransition().getUnconditionalResult().getPostFunctions(); if (up <= 0 || up >= postFunctions.size()) { addErrorMessage(getText("admin.errors.workflows.invalid.index", "" + up)); } else { Object toMove = postFunctions.get(up); CollectionReorderer.increasePosition(postFunctions, toMove); workflowService.updateWorkflow(getJiraServiceContext(), getWorkflow()); } return getViewRedirect("¤tCount=workflow-function" + (up)); }
final List<FunctionDescriptor> postFunctions = actionDescriptor.getUnconditionalResult().getPostFunctions(); for (FunctionDescriptor descriptor : postFunctions)
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)); }
List postFunctions = unconditionalResult.getPostFunctions(); postFunctions.add(0, function);
protected void setupWorkflowDescriptor() { ResultDescriptor unconditionalResult = getTransition().getUnconditionalResult(); if (unconditionalResult != null) { List postFunctions = unconditionalResult.getPostFunctions(); if (postFunctions != null && !postFunctions.isEmpty()) { if (postFunctions.size() >= getIndexCount()) { FunctionDescriptor functionDescriptor = (FunctionDescriptor) postFunctions.get(getIndexCount() - 1); setWorkflowDescriptor(functionDescriptor); } else { addErrorMessage(getText("admin.errors.workflows.count.outside.range", "'" + getIndexCount() + "'")); } } else { addErrorMessage(getText("admin.errors.workflows.no.post.functions","'" + getTransition().getName() + "'")); } } else { addErrorMessage(getText("admin.errors.workflows.no.unconditional.result","'" + getTransition().getName() + "'")); } }
final List postFunctions = unconditionalResult.getPostFunctions();