@Override protected Map<?, ?> extractArgs(AbstractDescriptor descriptor) { if (!(descriptor instanceof ConditionDescriptor)) { throw new IllegalArgumentException("Descriptor must be a ConditionDescriptor."); } ConditionDescriptor conditionDescriptor = (ConditionDescriptor) descriptor; return conditionDescriptor.getArgs(); }
protected void getVelocityParamsForView(Map velocityParams, AbstractDescriptor descriptor) { if (!(descriptor instanceof ConditionDescriptor)) { throw new IllegalArgumentException("Descriptor must be a ConditionDescriptor."); } ConditionDescriptor conditionDescriptor = (ConditionDescriptor) descriptor; velocityParams.put("group", conditionDescriptor.getArgs().get("group")); }
private boolean hasKeyValuesInArgMap(ConditionDescriptor descriptor, Map<String, String> descriptorArguments) { Map argMap = descriptor.getArgs(); for (String key : descriptorArguments.keySet()) { if(!argMap.containsKey(key) || !argMap.get(key).equals(descriptorArguments.get(key))) { return false; } } return true; }
@Override public void beforeSaveOnEdit(ConditionDescriptor descriptor) { clearLegacyPermissionArgument(descriptor.getArgs()); } }
public Map getVelocityParams(String resourceName, AbstractDescriptor descriptor) { if (descriptor == null) { return new HashMap(); } if (!(descriptor instanceof ConditionDescriptor)) { throw new IllegalArgumentException("Descriptor must be a ConditionDescriptor."); } ConditionDescriptor conditionDescriptor = (ConditionDescriptor) descriptor; String isCodeCommitted = (String) conditionDescriptor.getArgs() .get(CodeCommittedCondition.IS_CODE_COMMITTED_KEY); return EasyMap.build(CodeCommittedCondition.IS_CODE_COMMITTED_KEY, isCodeCommitted); }
private Collection<String> getSelectedStatusIds(AbstractDescriptor descriptor) { Collection<String> selectedStatusIds = new LinkedList<String>(); if (!(descriptor instanceof ConditionDescriptor)) { throw new IllegalArgumentException("Descriptor must be a ConditionDescriptor."); } ConditionDescriptor conditionDescriptor = (ConditionDescriptor) descriptor; String statuses = (String) conditionDescriptor.getArgs().get("statuses"); StringTokenizer st = new StringTokenizer(statuses, ","); while (st.hasMoreTokens()) { selectedStatusIds.add(st.nextToken()); } return selectedStatusIds; } }
protected void getVelocityParamsForView(Map<String,Object> velocityParams, AbstractDescriptor descriptor) { if (!(descriptor instanceof ConditionDescriptor)) { throw new IllegalArgumentException("Descriptor must be a ConditionDescriptor."); } ConditionDescriptor conditionDescriptor = (ConditionDescriptor) descriptor; FieldManager fieldManager = ComponentAccessor.getFieldManager(); String fieldId = (String) conditionDescriptor.getArgs().get("groupcf"); Field field = fieldManager.getField(fieldId); velocityParams.put("groupcf", (field == null ? fieldId : field.getName())); }
@SuppressWarnings("unchecked") private ConditionDescriptor makeConditionDescriptor(Class<? extends Condition> clazz, Map<String, String> params) { ConditionDescriptor conditionDescriptor = DescriptorFactory.getFactory().createConditionDescriptor(); conditionDescriptor.setType("class"); final Map conditionArgs = conditionDescriptor.getArgs(); conditionArgs.put(CLASS_NAME_KEY, clazz.getName()); conditionArgs.putAll(params); return conditionDescriptor; }
protected void getVelocityParamsForView(Map velocityParams, AbstractDescriptor descriptor) { if (!(descriptor instanceof ConditionDescriptor)) { throw new IllegalArgumentException("Descriptor must be a ConditionDescriptor."); } ConditionDescriptor conditionDescriptor = (ConditionDescriptor) descriptor; ProjectRoleManager projectRoleManager = ComponentAccessor.getComponentOfType(ProjectRoleManager.class); String id = (String) conditionDescriptor.getArgs().get(InProjectRoleCondition.KEY_PROJECT_ROLE_ID); ProjectRole projectRole = projectRoleManager.getProjectRole(new Long(id)); //Put the project role id into the velocity context velocityParams.put("projectrole", id); //If the project role exists, put it in the velocity context - if its missing the display logic should handle it if (projectRole != null) { velocityParams.put("projectrolename", projectRole.getName()); } }
private Map<String,Set<String>> removeConditionWithClassnames(ConditionsDescriptor rootConditions, Set<String> classesToRemove, Map<String,Set<String>> result) { final List nestedConditions = rootConditions.getConditions(); for (final Iterator iterator = nestedConditions.iterator(); iterator.hasNext(); ) { final Object o = iterator.next(); if (o instanceof ConditionDescriptor) { Set<Map.Entry<String,String>> args = (Set<Map.Entry<String,String>>) ((ConditionDescriptor) o).getArgs().entrySet(); Set<String> usedClassnames = getClassnamesFromArgs(args); if(!Sets.intersection(classesToRemove,usedClassnames).isEmpty()) { String extensionClass = StringUtils.defaultIfEmpty((String)((ConditionDescriptor) o).getArgs().get("class.name"),((ConditionDescriptor) o).toString());//NON-NLS result.put(extensionClass,classesToRemove); iterator.remove(); } } else if (o instanceof ConditionsDescriptor) { removeConditionWithClassnames((ConditionsDescriptor) o,classesToRemove,result); } } return result; }
private Set<String> getConditionClassnames(ConditionsDescriptor rootConditions) { Set<String> classNames = new HashSet<String>(); if(null == rootConditions) { return classNames; } final List nestedConditions = rootConditions.getConditions(); for (final Iterator iterator = nestedConditions.iterator(); iterator.hasNext(); ) { final Object o = iterator.next(); if (o instanceof ConditionDescriptor) { Set<Map.Entry<String,String>> args = (Set<Map.Entry<String,String>>) ((ConditionDescriptor) o).getArgs().entrySet(); classNames.addAll(getClassnamesFromArgs(args)); } else if (o instanceof ConditionsDescriptor) { classNames.addAll(getConditionClassnames((ConditionsDescriptor) o)); } } return classNames; }
Map<String,String> args = (Map<String,String>) ((ConditionDescriptor) o).getArgs(); Map<String,String> updateMap = new HashMap<String, String>(); String extensionClass = StringUtils.defaultIfEmpty((String)((ConditionDescriptor) o).getArgs().get("class.name"),((ConditionDescriptor) o).toString());//NON-NLS result.put(extensionClass,updateMap);
/** * {@link ConditionsDescriptor#getConditions()} returns a mixed List of {@link ConditionDescriptor} for (top * level conditions) and {@link ConditionsDescriptor} (for nested groups of conditions) - see FISH-348 */ protected boolean upgradeConditions(ConditionsDescriptor conditionsDescriptor, ActionDescriptor action, JiraWorkflow workflow, boolean isSystemWorkflow) { boolean updated = false; for (Object node : conditionsDescriptor.getConditions()) { if (node instanceof ConditionsDescriptor) { updated = upgradeConditions((ConditionsDescriptor) node, action, workflow, isSystemWorkflow) || updated; } else if (node instanceof ConditionDescriptor) { ConditionDescriptor condition = (ConditionDescriptor) node; String descriptorClassName = (String) condition.getArgs().get(ARG_CLASSNAME); updated = upgradeCondition(condition, action, workflow, isSystemWorkflow, descriptorClassName); } else { log.debug("Unexpected child of ConditionsDescriptor: " + (node == null ? "null" : node.getClass())); } } return updated; }
Map args = conditionDescriptor.getArgs(); String foundProjectRoleId = (String) args.get(InProjectRoleCondition.KEY_PROJECT_ROLE_ID); if (foundProjectRoleId != null && foundProjectRoleId.equals(projectRoleId.toString()))
private void replaceConditionInConditionsDescriptor(ConditionsDescriptor descriptor, Map<String,String> matchMap, Map modifyMap) { List conditions = descriptor.getConditions(); for (Object condition : conditions) { if (condition instanceof ConditionsDescriptor) { replaceConditionInConditionsDescriptor((ConditionsDescriptor) condition, matchMap, modifyMap); } else if(condition instanceof ConditionDescriptor) { ConditionDescriptor conditionDescriptor = (ConditionDescriptor) condition; if (hasKeyValuesInArgMap(conditionDescriptor, matchMap)) { conditionDescriptor.getArgs().putAll(modifyMap); } } } }
private boolean upgradeCondition(ConditionDescriptor condition, ActionDescriptor action, JiraWorkflow workflow, boolean isSystemWorkflow, String descriptorClassName) { boolean updated = false; if (descriptorClassName != null) { String updatedClassName = CLASSNAMES.get(descriptorClassName); if (updatedClassName != null) { if (isSystemWorkflow) { logError(String.format("Detected reference to a workflow condition in the filesystem-configured " + "workflow '%s' for transition '%s'. Please manually upgrade the configuration " + "for this workflow by updating the condition <arg name=\"class.name\" /> " + "elements containing '%s' to the new namespace: '%s'.", workflow.getName(), action.getName(), descriptorClassName, updatedClassName)); } else { log.debug(String.format("Upgrading '%s' condition class to '%s' (in workflow '%s' under action '%s')", descriptorClassName, updatedClassName, workflow.getName(), action.getName())); condition.getArgs().put(ARG_CLASSNAME, updatedClassName); updated = true; } } } return updated; }
protected void editWorkflowDescriptor(AbstractDescriptor descriptor, Map params) { ConditionDescriptor conditionDescriptor = (ConditionDescriptor) descriptor; final Map conditionArgs = conditionDescriptor.getArgs(); // Add parameters to the workflow condition descriptor // Make the factory process it WorkflowConditionModuleDescriptor conditionModuleDescriptor = (WorkflowConditionModuleDescriptor) getDescriptor(); WorkflowPluginConditionFactory workflowPluginConditionFactory = conditionModuleDescriptor.getModule(); conditionArgs.putAll(workflowPluginConditionFactory.getDescriptorParams(getDescriptorParams())); if (workflowPluginConditionFactory instanceof WorkflowConditionDescriptorEditPreprocessor) { ((WorkflowConditionDescriptorEditPreprocessor) workflowPluginConditionFactory).beforeSaveOnEdit(conditionDescriptor); } }
args = ((ConditionDescriptor) workflowDescriptor).getArgs();
args = ((ConditionDescriptor) descriptor).getArgs();
protected void addWorkflowDescriptor() throws WorkflowException { ConditionDescriptor condition = DescriptorFactory.getFactory().createConditionDescriptor(); condition.setType("class"); final Map conditionArgs = condition.getArgs(); conditionArgs.put("class.name", getDescriptor().getImplementationClass().getName()); // Add parameters to the workflow condition descriptor // Make the factory process it WorkflowPluginConditionFactory workflowConditionFactory = (WorkflowPluginConditionFactory) getDescriptor().getModule(); conditionArgs.putAll(workflowConditionFactory.getDescriptorParams(getDescriptorParams())); // Now create a nested ConditionsDescriptor with the new condition WorkflowEditorTransitionConditionUtil wetcu = new WorkflowEditorTransitionConditionUtil(); if (isNested()) currentConditionCount = wetcu.addNestedCondition(getTransition(), getCount(), condition); else currentConditionCount = wetcu.addCondition(getTransition(), getCount(), condition); workflowService.updateWorkflow(getJiraServiceContext(), getWorkflow()); }