/** * Checks if restrictionDescriptor has no {@link com.opensymphony.workflow.loader.ConditionDescriptor}s or * {@link ConditionsDescriptor}s left. */ public boolean isEmpty(RestrictionDescriptor restrictionDescriptor) { ConditionsDescriptor conditionsDescriptor = restrictionDescriptor.getConditionsDescriptor(); if (conditionsDescriptor == null) return true; Collection<?> conditions = conditionsDescriptor.getConditions(); return (conditions == null) || (conditions.isEmpty()); }
private RestrictionDescriptor getOrCreateRestriction(ActionDescriptor transition) { RestrictionDescriptor restriction = transition.getRestriction(); if (restriction == null) { restriction = new RestrictionDescriptor(); transition.setRestriction(restriction); } return restriction; }
ConditionsDescriptor conditionsDescriptor = restriction.getConditionsDescriptor(); if (conditionsDescriptor == null) restriction.setConditionsDescriptor(conditionsDescriptor);
ConditionsDescriptor conditionsDescriptor = restriction.getConditionsDescriptor(); if (conditionsDescriptor == null) restriction.setConditionsDescriptor(conditionsDescriptor);
private ConditionsDescriptor findConfitionsDescriptor(RestrictionDescriptor restrictionDescriptor, String count, int offset) { ConditionsDescriptor conditionsDescriptor = restrictionDescriptor.getConditionsDescriptor(); String[] counts = StringUtils.split(count, SEPARATOR); if (counts != null && counts.length > offset) { for (int i = 0; i < counts.length - offset; i++) { int c = Integer.parseInt(counts[i]); List<?> conditions = conditionsDescriptor.getConditions(); if (conditions.get(c - 1) instanceof ConditionsDescriptor) { conditionsDescriptor = (ConditionsDescriptor) conditions.get(c - 1); } else { throw new IllegalArgumentException("The descriptor at count " + count + " is not a ConditionsDescriptor."); } } } return conditionsDescriptor; }
protected boolean upgradeWorkflow(JiraWorkflow workflow, boolean isSystemWorkflow) { boolean updated = false; for (Iterator actions = workflow.getAllActions().iterator(); actions.hasNext();) { ActionDescriptor action = (ActionDescriptor) actions.next(); RestrictionDescriptor restrictionDescriptor = action.getRestriction(); if (restrictionDescriptor != null && restrictionDescriptor.getConditionsDescriptor() != null) { updated = upgradeConditions(action.getRestriction().getConditionsDescriptor(), action, workflow, isSystemWorkflow) || updated; } } return updated; }
@Override public void replaceConditionInTransition(ActionDescriptor transition, Map<String, String> matchMap, Map<String, String> newMap) { ConditionsDescriptor conditionsDescriptor = transition.getRestriction().getConditionsDescriptor(); if (conditionsDescriptor == null) { return; } replaceConditionInConditionsDescriptor(conditionsDescriptor, matchMap, newMap); }
private Map<String, Map<String, String>> updateConditionsCustomFieldIds(ActionDescriptor action, Map<String, String> oldToNewIdMapping) { Map<String,Map<String, String>> result = new HashMap<String, Map<String, String>>(); if(null != action.getRestriction()) { ConditionsDescriptor rootConditions = action.getRestriction().getConditionsDescriptor(); if(null != rootConditions) { updateConditionsCustomFieldIds(rootConditions, oldToNewIdMapping, result); } } return result; }
private Map<String,Set<String>> removeConditionsWithClassnames(ActionDescriptor action, Set<String> classesToRemove) { Map<String,Set<String>> result = new HashMap<String, Set<String>>(); if(null != action.getRestriction()) { ConditionsDescriptor rootConditions = action.getRestriction().getConditionsDescriptor(); if(null != rootConditions) { removeConditionWithClassnames(rootConditions,classesToRemove,result); } } return result; }
private Set<String> getExtensionClassnames(JiraWorkflow workflow) { Set<String> uniqueClassnames = new HashSet<String>(); Collection<ActionDescriptor> allActions = workflow.getAllActions(); for (ActionDescriptor action : allActions) { uniqueClassnames.addAll(workflowScreensHelper.getClassnamesForScreenFromAction(action)); uniqueClassnames.addAll(getFunctionClassnames(action)); uniqueClassnames.addAll(getValidatorClassnames(action)); if(null != action.getRestriction()) { uniqueClassnames.addAll(getConditionClassnames(action.getRestriction().getConditionsDescriptor())); } } return uniqueClassnames; }
public int getCount(final Map<String, Object> context) { RestrictionDescriptor restriction = WorkflowTransitionContext.getTransition(context).map(new Function<ActionDescriptor, RestrictionDescriptor>() { @Override public RestrictionDescriptor apply(final ActionDescriptor input) { return input.getRestriction(); } }).getOrNull(); if (restriction != null) { return getNumberConditions(restriction.getConditionsDescriptor()); } else { return 0; } }
@Override public MultiMap getAssociatedWorkflows(ProjectRole projectRole, ErrorCollection errorCollection) { Collection<JiraWorkflow> workflows = workflowManager.getWorkflows(); MultiMap associatedWorkflows = new MultiHashMap(workflows.size()); for (JiraWorkflow jiraWorkflow : workflows) { Collection<ActionDescriptor> actions = jiraWorkflow.getAllActions(); for (ActionDescriptor actionDescriptor : actions) { RestrictionDescriptor restriction = actionDescriptor.getRestriction(); if (restriction != null) { ConditionsDescriptor conditionsDescriptor = restriction.getConditionsDescriptor(); if (conditionsDescriptorContainsProjectRoleCondition(conditionsDescriptor, projectRole.getId())) { associatedWorkflows.put(jiraWorkflow, actionDescriptor); // workflow matches, don't need to check the conditions on any more actions } } } } return associatedWorkflows; }