private Set<FlowElementAttribute> parseAttributes(Element element) { Element definitionAttributesElement = DomUtils.getChildElementByTagName(element, "flow-definition-attributes"); if (definitionAttributesElement != null) { List<Element> attributeElements = DomUtils.getChildElementsByTagName(definitionAttributesElement, "attribute"); Set<FlowElementAttribute> attributes = new HashSet<>(attributeElements.size()); for (Element attributeElement : attributeElements) { String name = attributeElement.getAttribute("name"); String value = attributeElement.getAttribute("value"); String type = attributeElement.getAttribute("type"); attributes.add(new FlowElementAttribute(name, value, type)); } return attributes; } else { return null; } }
private AttributeMap<Object> getFlowAttributes(Set<FlowElementAttribute> attributes) { MutableAttributeMap<Object> flowAttributes = null; if (flowBuilderServices.getDevelopment()) { flowAttributes = new LocalAttributeMap<>(1 + attributes.size(), 1); flowAttributes.put("development", true); } if (!attributes.isEmpty()) { if (flowAttributes == null) { flowAttributes = new LocalAttributeMap<>(attributes.size(), 1); } for (FlowElementAttribute attribute : attributes) { flowAttributes.put(attribute.getName(), getConvertedValue(attribute)); } } return flowAttributes; }
private Object getConvertedValue(FlowElementAttribute attribute) { if (attribute.needsTypeConversion()) { Class<?> targetType = fromStringToClass(attribute.getType()); ConversionExecutor converter = conversionService.getConversionExecutor(String.class, targetType); return converter.execute(attribute.getValue()); } else { return attribute.getValue(); } }
private Object getConvertedValue(FlowElementAttribute attribute) { if (attribute.needsTypeConversion()) { Class<?> targetType = fromStringToClass(attribute.getType()); ConversionExecutor converter = flowBuilderServices.getConversionService().getConversionExecutor( String.class, targetType); return converter.execute(attribute.getValue()); } else { return attribute.getValue(); } }
private Set<Object> parseFlowExecutionAttributes(Element element) { Element executionAttributesElement = DomUtils.getChildElementByTagName(element, "flow-execution-attributes"); if (executionAttributesElement != null) { HashSet<Object> attributes = new HashSet<>(); Element redirectElement = DomUtils.getChildElementByTagName(executionAttributesElement, "always-redirect-on-pause"); if (redirectElement != null) { String value = redirectElement.getAttribute("value"); attributes.add(new FlowElementAttribute("alwaysRedirectOnPause", value, "boolean")); } Element redirectInSameStateElement = DomUtils.getChildElementByTagName(executionAttributesElement, "redirect-in-same-state"); if (redirectInSameStateElement != null) { String value = redirectInSameStateElement.getAttribute("value"); attributes.add(new FlowElementAttribute("redirectInSameState", value, "boolean")); } List<Element> attributeElements = DomUtils.getChildElementsByTagName(executionAttributesElement, "attribute"); for (Element attributeElement : attributeElements) { String name = attributeElement.getAttribute("name"); String value = attributeElement.getAttribute("value"); String type = attributeElement.getAttribute("type"); attributes.add(new FlowElementAttribute(name, value, type)); } return attributes; } else { return null; } }
private MutableAttributeMap<Object> createFlowExecutionAttributes() { LocalAttributeMap<Object> executionAttributes = new LocalAttributeMap<>(); if (flowExecutionAttributes != null) { for (FlowElementAttribute attribute : flowExecutionAttributes) { executionAttributes.put(attribute.getName(), getConvertedValue(attribute)); } } putDefaultFlowExecutionAttributes(executionAttributes); return executionAttributes; }
private Object getConvertedValue(FlowElementAttribute attribute) { if (attribute.needsTypeConversion()) { Class<?> targetType = fromStringToClass(attribute.getType()); ConversionExecutor converter = conversionService.getConversionExecutor(String.class, targetType); return converter.execute(attribute.getValue()); } else { return attribute.getValue(); } }
private Set parseAttributes(Element element) { Element definitionAttributesElement = DomUtils.getChildElementByTagName(element, "flow-definition-attributes"); if (definitionAttributesElement != null) { List attributeElements = DomUtils.getChildElementsByTagName(definitionAttributesElement, "attribute"); HashSet attributes = new HashSet(attributeElements.size()); for (Iterator it = attributeElements.iterator(); it.hasNext();) { Element attributeElement = (Element) it.next(); String name = attributeElement.getAttribute("name"); String value = attributeElement.getAttribute("value"); String type = attributeElement.getAttribute("type"); attributes.add(new FlowElementAttribute(name, value, type)); } return attributes; } else { return null; } }
private MutableAttributeMap createFlowExecutionAttributes() { LocalAttributeMap executionAttributes = new LocalAttributeMap(); if (flowExecutionAttributes != null) { for (Iterator it = flowExecutionAttributes.iterator(); it.hasNext();) { FlowElementAttribute attribute = (FlowElementAttribute) it.next(); executionAttributes.put(attribute.getName(), getConvertedValue(attribute)); } } putDefaultFlowExecutionAttributes(executionAttributes); return executionAttributes; }
private Object getConvertedValue(FlowElementAttribute attribute) { if (attribute.needsTypeConversion()) { Class targetType = fromStringToClass(attribute.getType()); ConversionExecutor converter = conversionService.getConversionExecutor(String.class, targetType); return converter.execute(attribute.getValue()); } else { return attribute.getValue(); } }
private Set<FlowElementAttribute> parseAttributes(Element element) { Element definitionAttributesElement = DomUtils.getChildElementByTagName(element, "flow-definition-attributes"); if (definitionAttributesElement != null) { List<Element> attributeElements = DomUtils.getChildElementsByTagName(definitionAttributesElement, "attribute"); Set<FlowElementAttribute> attributes = new HashSet<>(attributeElements.size()); for (Element attributeElement : attributeElements) { String name = attributeElement.getAttribute("name"); String value = attributeElement.getAttribute("value"); String type = attributeElement.getAttribute("type"); attributes.add(new FlowElementAttribute(name, value, type)); } return attributes; } else { return null; } }
private AttributeMap getFlowAttributes(Set attributes) { MutableAttributeMap flowAttributes = null; if (flowBuilderServices.getDevelopment()) { flowAttributes = new LocalAttributeMap(1 + attributes.size(), 1); flowAttributes.put("development", Boolean.TRUE); } if (!attributes.isEmpty()) { if (flowAttributes == null) { flowAttributes = new LocalAttributeMap(attributes.size(), 1); } for (Iterator it = attributes.iterator(); it.hasNext();) { FlowElementAttribute attribute = (FlowElementAttribute) it.next(); flowAttributes.put(attribute.getName(), getConvertedValue(attribute)); } } return flowAttributes; }
private Object getConvertedValue(FlowElementAttribute attribute) { if (attribute.needsTypeConversion()) { Class targetType = fromStringToClass(attribute.getType()); ConversionExecutor converter = flowBuilderServices.getConversionService().getConversionExecutor( String.class, targetType); return converter.execute(attribute.getValue()); } else { return attribute.getValue(); } }
private Set parseFlowExecutionAttributes(Element element) { Element executionAttributesElement = DomUtils.getChildElementByTagName(element, "flow-execution-attributes"); if (executionAttributesElement != null) { HashSet attributes = new HashSet(); Element redirectElement = DomUtils.getChildElementByTagName(executionAttributesElement, "always-redirect-on-pause"); if (redirectElement != null) { String value = redirectElement.getAttribute("value"); attributes.add(new FlowElementAttribute("alwaysRedirectOnPause", value, "boolean")); } List attributeElements = DomUtils.getChildElementsByTagName(executionAttributesElement, "attribute"); for (Iterator it = attributeElements.iterator(); it.hasNext();) { Element attributeElement = (Element) it.next(); String name = attributeElement.getAttribute("name"); String value = attributeElement.getAttribute("value"); String type = attributeElement.getAttribute("type"); attributes.add(new FlowElementAttribute(name, value, type)); } return attributes; } else { return null; } }
private AttributeMap<Object> getFlowAttributes(Set<FlowElementAttribute> attributes) { MutableAttributeMap<Object> flowAttributes = null; if (flowBuilderServices.getDevelopment()) { flowAttributes = new LocalAttributeMap<>(1 + attributes.size(), 1); flowAttributes.put("development", true); } if (!attributes.isEmpty()) { if (flowAttributes == null) { flowAttributes = new LocalAttributeMap<>(attributes.size(), 1); } for (FlowElementAttribute attribute : attributes) { flowAttributes.put(attribute.getName(), getConvertedValue(attribute)); } } return flowAttributes; }
private Object getConvertedValue(FlowElementAttribute attribute) { if (attribute.needsTypeConversion()) { Class<?> targetType = fromStringToClass(attribute.getType()); ConversionExecutor converter = flowBuilderServices.getConversionService().getConversionExecutor( String.class, targetType); return converter.execute(attribute.getValue()); } else { return attribute.getValue(); } }
private Set<Object> parseFlowExecutionAttributes(Element element) { Element executionAttributesElement = DomUtils.getChildElementByTagName(element, "flow-execution-attributes"); if (executionAttributesElement != null) { HashSet<Object> attributes = new HashSet<>(); Element redirectElement = DomUtils.getChildElementByTagName(executionAttributesElement, "always-redirect-on-pause"); if (redirectElement != null) { String value = redirectElement.getAttribute("value"); attributes.add(new FlowElementAttribute("alwaysRedirectOnPause", value, "boolean")); } Element redirectInSameStateElement = DomUtils.getChildElementByTagName(executionAttributesElement, "redirect-in-same-state"); if (redirectInSameStateElement != null) { String value = redirectInSameStateElement.getAttribute("value"); attributes.add(new FlowElementAttribute("redirectInSameState", value, "boolean")); } List<Element> attributeElements = DomUtils.getChildElementsByTagName(executionAttributesElement, "attribute"); for (Element attributeElement : attributeElements) { String name = attributeElement.getAttribute("name"); String value = attributeElement.getAttribute("value"); String type = attributeElement.getAttribute("type"); attributes.add(new FlowElementAttribute(name, value, type)); } return attributes; } else { return null; } }
private MutableAttributeMap<Object> createFlowExecutionAttributes() { LocalAttributeMap<Object> executionAttributes = new LocalAttributeMap<>(); if (flowExecutionAttributes != null) { for (FlowElementAttribute attribute : flowExecutionAttributes) { executionAttributes.put(attribute.getName(), getConvertedValue(attribute)); } } putDefaultFlowExecutionAttributes(executionAttributes); return executionAttributes; }
public void testGetFlowRegistry() throws Exception { HashSet<FlowElementAttribute> attributes = new HashSet<>(); attributes.add(new FlowElementAttribute("foo", "bar", null)); attributes.add(new FlowElementAttribute("bar", "2", "integer")); FlowLocation location1 = new FlowLocation("flow1", "org/springframework/webflow/config/flow.xml", attributes); FlowLocation location2 = new FlowLocation("flow2", "org/springframework/webflow/config/flow.xml", attributes); FlowLocation[] flowLocations = new FlowLocation[] { location1, location2 }; factoryBean.setFlowBuilderServices(TestFlowBuilderServicesFactory.getServices()); factoryBean.setFlowLocations(flowLocations); factoryBean.afterPropertiesSet(); FlowDefinitionRegistry registry = factoryBean.getObject(); FlowDefinition def = registry.getFlowDefinition("flow1"); assertNotNull(def); assertEquals("flow1", def.getId()); assertEquals("bar", def.getAttributes().get("foo")); assertEquals(new Integer(2), def.getAttributes().getInteger("bar")); def = registry.getFlowDefinition("flow2"); assertNotNull(def); assertEquals("flow2", def.getId()); }
public void testGetFlowExecutorOptionsSpecified() throws Exception { factoryBean.setFlowDefinitionLocator(id -> { Flow flow = new Flow(id); ViewState view = new ViewState(flow, "view", new StubViewFactory()); view.getTransitionSet().add(new Transition(new DefaultTargetStateResolver("end"))); new EndState(flow, "end"); return flow; }); Set<FlowElementAttribute> attributes = new HashSet<>(); attributes.add(new FlowElementAttribute("foo", "bar", null)); factoryBean.setFlowExecutionAttributes(attributes); FlowExecutionListener listener = new FlowExecutionListener() {}; factoryBean.setFlowExecutionListenerLoader(new StaticFlowExecutionListenerLoader(listener)); factoryBean.setMaxFlowExecutionSnapshots(2); factoryBean.setMaxFlowExecutions(1); factoryBean.afterPropertiesSet(); factoryBean.getObject(); } }