public MultiInstance variable(String id, DataType type) { this.variable = new Variable() .id(id) .type(type); return this; } public List<Binding<Object>> getValues() {
public MultiInstance variable(String id, DataType type) { this.variable = new Variable() .id(id) .type(type); return this; } public List<Binding<Object>> getValues() {
public Scope variable(String id, DataType type) { Variable variable = new Variable(); variable.setId(id); variable.setType(type); variable(variable); return this; } public Scope variable(Variable variable) {
public Scope variable(String id, DataType type) { Variable variable = new Variable(); variable.setId(id); variable.setType(type); variable(variable); return this; } public Scope variable(Variable variable) {
/** * Reads the multi-instance model from extension elements, ignoring the BPMN multiInstanceLoopCharacteristics element. */ @Override public void readBpmn(BpmnReader r) { for (XmlElement element : r.readElementsEffektif("variable")) { r.startElement(element); variable = new Variable(); variable.setId(r.readStringAttributeBpmn("id")); variable.setType(r.readTypeAttributeEffektif()); r.endElement(); } values = r.readBindings("value"); }
/** * Reads the multi-instance model from extension elements, ignoring the BPMN multiInstanceLoopCharacteristics element. */ @Override public void readBpmn(BpmnReader r) { for (XmlElement element : r.readElementsEffektif("variable")) { r.startElement(element); variable = new Variable(); variable.setId(r.readStringAttributeBpmn("id")); variable.setType(r.readTypeAttributeEffektif()); r.endElement(); } values = r.readBindings("value"); }
Variable variable = new Variable(); variable.readBpmn(r); variable(variable);
Variable variable = new Variable(); variable.readBpmn(r); variable(variable);
public void testVariables() { ExecutableWorkflow workflow = new ExecutableWorkflow() .variable(new Variable().type(TextType.INSTANCE).id("v").name("version").description("Release version")) .variable("mailing-list", EmailAddressType.INSTANCE) .variable("release-notes", LinkType.INSTANCE)
workflow.variable(new Variable().id("variable01").type(BooleanType.INSTANCE).defaultValue(Boolean.TRUE)); ChoiceType choiceType = new ChoiceType().option("Red pill").option("Blue pill"); workflow.variable(new Variable().id("variable02").type(choiceType).defaultValue("Blue pill")); workflow.variable(new Variable().id("variable03").type(new DateType()).defaultValue(now)); workflow.variable(new Variable().id("variable04").type(EmailAddressType.INSTANCE).defaultValue("alice@example.org")); workflow.variable(new Variable().id("variable05").type(new JavaBeanType(Integer.class))); workflow.variable(new Variable().id("variable06").type(LinkType.INSTANCE).defaultValue("http://example.org/")); workflow.variable(new Variable().id("variable07").type(new ListType(NumberType.INSTANCE)).defaultValue(Lists.of(40, 41, 42))); Money defaultMoneyValue = new Money().currency("EUR").amount(41.99); workflow.variable(new Variable().id("variable08").type(MoneyType.INSTANCE).defaultValue(defaultMoneyValue)); workflow.variable(new Variable().id("variable09").type(NumberType.INSTANCE).defaultValue(42.5)); workflow.variable(new Variable().id("variable10").type(new TextType().multiLine()).defaultValue("hello")); workflow.variable(new Variable().id("variable11").type(new DateType().date()).defaultValue(now)); workflow.variable(new Variable().id("variable12").type(new DateType().time()).defaultValue(now));
@Test public void testVariableDefaultValue() { Variable var = new Variable() .id("v") .type(new TextType()) .defaultValue("This is a string!"); ExecutableWorkflow workflow = new ExecutableWorkflow().variable(var); deploy(workflow); WorkflowInstance workflowInstance = workflowEngine.start(new TriggerInstance() .workflowId(workflow.getId())); Object value = workflowInstance.getVariableValue("v"); assertEquals("The variable default value was ignored.", "This is a string!", value); }
@Test public void testDefaultValueIsOverwritten() { Variable var = new Variable() .id("v") .type(new TextType()) .defaultValue("This is a string!"); ExecutableWorkflow workflow = new ExecutableWorkflow().variable(var); deploy(workflow); WorkflowInstance workflowInstance = workflowEngine.start(new TriggerInstance() .workflowId(workflow.getId()) .data("v", "No, it's not!")); Object value = workflowInstance.getVariableValue("v"); assertEquals("The trigger data didn't overwrite the default value.", "No, it's not!", value); }