@Override public void write(Variable variable, JsonWriter jsonWriter) { DataType type = variable.getType(); Object value = variable.getDefaultValue(); if (type==null && value!=null) { type = mappings.getTypeByValue(value); variable.setType(type); } super.write(variable, jsonWriter); }
@Override public Variable read(Object jsonValue, JsonReader jsonReader) { Variable variable = super.read(jsonValue, jsonReader); DataType type = variable.getType(); Object jsonVariableValue = variable.getDefaultValue(); if (jsonVariableValue!=null && type!=null) { Object objectVariableValue = jsonReader.readObject(jsonVariableValue, type.getValueType()); variable.setDefaultValue(objectVariableValue); } return variable; } }
public void parse(Variable variable, ScopeImpl parentImpl, WorkflowParser parser) { this.id = variable.getId(); this.variable = variable; if (id==null || "".equals(id)) { parser.addError("Variable has no id"); } else if (id.contains(".")) { parser.addError("Variable '%s' has a dot in the name", id); } else if (parser.variableIds.contains(id)) { parser.addError("Duplicate variable id '%s'", id); } else { parser.variableIds.add(id); } this.parent = parentImpl; DataTypeService dataTypeService = parser.getConfiguration(DataTypeService.class); DataType typeApi = variable.getType(); if (typeApi!=null) { this.type = dataTypeService.createDataType(typeApi); } else { parser.addWarning("Variable '%s' does not have a type", id); this.type = new AnyTypeImpl(); } this.defaultValue = variable.getDefaultValue(); }
@Override public void writeBpmn(BpmnWriter w) { w.startElementEffektif("multiInstance"); w.startElementEffektif("variable"); w.writeStringAttributeEffektif("id", variable.getId()); w.writeTypeAttribute(variable.getType()); w.endElement(); w.writeBindings("value", values); w.endElement(); }
@Override public void writeBpmn(BpmnWriter w) { w.startElementEffektif("multiInstance"); w.startElementEffektif("variable"); w.writeStringAttributeEffektif("id", variable.getId()); w.writeTypeAttribute(variable.getType()); w.endElement(); w.writeBindings("value", values); w.endElement(); }
parser.pushContext("inputBindings[" + subWorkflowVariableId + "]", inputBindingApi, null, null); BindingImpl<?> bindingImpl = parser .parseBinding(inputBindingApi, subWorkflowVariableId, false, subWorkflowVariable.getType()); if (bindingImpl != null) { if (inputBindings == null) {
assertEquals("version", workflow.getVariables().get(0).getName()); assertEquals("Release version", workflow.getVariables().get(0).getDescription()); assertEquals(TextType.class, workflow.getVariables().get(0).getType().getClass()); assertEquals(EmailAddressType.class, workflow.getVariables().get(1).getType().getClass()); assertEquals(LinkType.class, workflow.getVariables().get(2).getType().getClass()); assertEquals(MoneyType.class, workflow.getVariables().get(3).getType().getClass()); assertEquals(NumberType.class, workflow.getVariables().get(4).getType().getClass()); assertEquals(ChoiceType.class, workflow.getVariables().get(5).getType().getClass()); ChoiceType choiceType = (ChoiceType) workflow.getVariables().get(5).getType(); assertEquals(2, choiceType.getOptions().size()); assertEquals("Internal", choiceType.getOptions().get(0).getId()); assertEquals("External", choiceType.getOptions().get(1).getId()); assertEquals(ListType.class, workflow.getVariables().get(6).getType().getClass()); ListType listType = (ListType) workflow.getVariables().get(6).getType(); assertEquals(EmailAddressType.class, listType.getElementType().getClass());
assertEquals(BooleanType.class, workflow.getVariables().get(0).getType().getClass()); assertEquals(Boolean.TRUE, workflow.getVariables().get(0).getDefaultValue()); assertEquals(ChoiceType.class, workflow.getVariables().get(1).getType().getClass()); assertEquals("Red pill", ((ChoiceType) workflow.getVariables().get(1).getType()).getOptions().get(0).getId()); assertEquals("Blue pill", workflow.getVariables().get(1).getDefaultValue()); assertEquals(DateType.class, workflow.getVariables().get(2).getType().getClass()); assertEquals("datetime", ((DateType) workflow.getVariables().get(2).getType()).getKind()); assertEquals(now, workflow.getVariables().get(2).getDefaultValue()); assertEquals(EmailAddressType.class, workflow.getVariables().get(3).getType().getClass()); assertEquals("alice@example.org", workflow.getVariables().get(3).getDefaultValue()); assertEquals(JavaBeanType.class, workflow.getVariables().get(4).getType().getClass()); assertEquals(Integer.class, ((JavaBeanType) workflow.getVariables().get(4).getType()).getJavaClass()); assertEquals(LinkType.class, workflow.getVariables().get(5).getType().getClass()); assertEquals(ListType.class, workflow.getVariables().get(6).getType().getClass()); assertEquals(Lists.of(40, 41, 42), workflow.getVariables().get(6).getDefaultValue()); assertEquals(NumberType.class, ((ListType) workflow.getVariables().get(6).getType()).getElementType().getClass()); assertEquals(MoneyType.class, workflow.getVariables().get(7).getType().getClass()); assertEquals(defaultMoneyValue, workflow.getVariables().get(7).getDefaultValue()); assertEquals(NumberType.class, workflow.getVariables().get(8).getType().getClass()); assertEquals(Double.class, workflow.getVariables().get(8).getDefaultValue().getClass());