@Test public void testDeserializeVariables() { List<String> dataTypes = new ArrayList<String>(Arrays.asList("Boolean", "Float", "Integer", "Object", "org.veg.Potato", "String")); List<String> dataTypeDisplayNames = new ArrayList<String>(Arrays.asList("Boolean", "Float", "Integer", "Potato [org.veg]", "Object", "String")); variablesEditor.setDataTypes(dataTypes, dataTypeDisplayNames); List<VariableRow> variableRows = variablesEditor.deserializeVariables("var1:String:[internal;input],var2:Integer:[output],var3:org.stuff.Potato:,var4:com.myCustomDataType:[]"); assertEquals(4, variableRows.size()); VariableRow var = variableRows.get(0); assertEquals("var1", var.getName()); assertEquals("String", var.getDataTypeDisplayName()); assertEquals(Variable.VariableType.PROCESS, var.getVariableType()); assertEquals(2, var.getTags().size()); assertEquals("internal", var.getTags().get(0)); assertEquals("input", var.getTags().get(1)); var = variableRows.get(1); assertEquals("var2", var.getName()); assertEquals("Integer", var.getDataTypeDisplayName()); assertEquals(Variable.VariableType.PROCESS, var.getVariableType()); assertEquals(1, var.getTags().size()); assertEquals("output", var.getTags().get(0)); var = variableRows.get(2); assertEquals("var3", var.getName()); assertEquals("org.stuff.Potato", var.getCustomDataType()); assertEquals(Variable.VariableType.PROCESS, var.getVariableType()); assertEquals(0, var.getTags().size()); var = variableRows.get(3); assertEquals("var4", var.getName()); assertEquals("com.myCustomDataType", var.getCustomDataType()); assertEquals(Variable.VariableType.PROCESS, var.getVariableType()); assertEquals(0, var.getTags().size()); }
@Override public List<VariableRow> deserializeVariables(final String s) { List<VariableRow> variableRows = new ArrayList<>(); if (s != null && !s.isEmpty()) { String[] vs = s.split(","); for (String v : vs) { if (!v.isEmpty()) { Variable var = Variable.deserialize(v, Variable.VariableType.PROCESS, dataTypes); if (var != null && var.getName() != null && !var.getName().isEmpty()) { variableRows.add(new VariableRow(var, mapDataTypeNamesToDisplayNames)); } } } } return variableRows; }
VariablesEditorFieldRenderer extends FieldRenderer<VariablesEditorFieldDefinition, DefaultFormGroup> implements VariablesEditorWidgetView.Presenter { @Override public List<VariableRow> deserializeVariables(final String s) { List<VariableRow> variableRows = new ArrayList<>(); if (s != null && !s.isEmpty()) { String[] vs = s.split(","); for (String v : vs) { if (!v.isEmpty()) { Variable var = Variable.deserialize(v, Variable.VariableType.PROCESS, dataTypes); if (var != null && var.getName() != null && !var.getName().isEmpty()) { variableRows.add(new VariableRow(var, mapDataTypeNamesToDisplayNames)); } } } } return variableRows; } }
VariablesEditorFieldRenderer extends FieldRenderer<VariablesEditorFieldDefinition, DefaultFormGroup> implements VariablesEditorWidgetView.Presenter { @Override public List<VariableRow> deserializeVariables(final String s) { List<VariableRow> variableRows = new ArrayList<>(); if (s != null && !s.isEmpty()) { String[] vs = s.split(","); for (String v : vs) { if (!v.isEmpty()) { Variable var = Variable.deserialize(v, Variable.VariableType.PROCESS, dataTypes); if (var != null && var.getName() != null && !var.getName().isEmpty()) { variableRows.add(new VariableRow(var, mapDataTypeNamesToDisplayNames)); } } } } return variableRows; } @Inject  VariablesEditorFieldRenderer(final VariablesEditorWidgetView variablesEditor,
                                        final SessionManager sessionManager,
                                        final ErrorPopupPresenter errorPopupPresenter); }
VariablesEditorFieldRenderer extends FieldRenderer<VariablesEditorFieldDefinition, DefaultFormGroup> implements VariablesEditorWidgetView.Presenter { @Override public List<VariableRow> deserializeVariables(final String s) { List<VariableRow> variableRows = new ArrayList<>(); if (s != null && !s.isEmpty()) { String[] vs = s.split(","); for (String v : vs) { if (!v.isEmpty()) { Variable var = Variable.deserialize(v, Variable.VariableType.PROCESS, dataTypes); if (var != null && var.getName() != null && !var.getName().isEmpty()) { variableRows.add(new VariableRow(var, mapDataTypeNamesToDisplayNames)); } } } } return variableRows; } @Inject  VariablesEditorFieldRenderer(final VariablesEditorWidgetView variablesEditor,
                                        final SessionManager sessionManager,
                                        final ErrorPopupPresenter errorPopupPresenter); @Override String getName(); @Override void doSave(); @Override void addVariable(); @Override void setDataTypes(final List<String> dataTypes,
                             final List<String> dataTypeDisplayNames); @Override void notifyModelChanged(); @Override List<VariableRow> deserializeVariables(final String s); @Override String serializeVariables(final List<VariableRow> variableRows); @Override boolean isDuplicateName(final String name); @Override boolean isBoundToNodes(String name); @Override void removeVariable(final VariableRow variableRow); @Override ListBoxValues.ValueTester dataTypesTester(); @Override Path getDiagramPath(); void setLastOverlayOpened(final Button overlayCloseButton); Button getLastOverlayOpened(); void closeLastOverlay(); static Set<String> getDefaultTagsSet(); }
VariablesEditorFieldRenderer extends FieldRenderer<VariablesEditorFieldDefinition, DefaultFormGroup> implements VariablesEditorWidgetView.Presenter { @Override public List<VariableRow> deserializeVariables(final String s) { List<VariableRow> variableRows = new ArrayList<>(); if (s != null && !s.isEmpty()) { String[] vs = s.split(","); for (String v : vs) { if (!v.isEmpty()) { Variable var = Variable.deserialize(v, Variable.VariableType.PROCESS, dataTypes); if (var != null && var.getName() != null && !var.getName().isEmpty()) { variableRows.add(new VariableRow(var, mapDataTypeNamesToDisplayNames)); } } } } return variableRows; } @Inject  VariablesEditorFieldRenderer(final VariablesEditorWidgetView variablesEditor,
                                        final SessionManager sessionManager,
                                        final ErrorPopupPresenter errorPopupPresenter); @Override String getName(); @Override void doSave(); @Override void addVariable(); @Override void setDataTypes(final List<String> dataTypes,
                             final List<String> dataTypeDisplayNames); @Override void notifyModelChanged(); @Override List<VariableRow> deserializeVariables(final String s); @Override String serializeVariables(final List<VariableRow> variableRows); @Override boolean isDuplicateName(final String name); @Override boolean isBoundToNodes(String name); @Override void removeVariable(final VariableRow variableRow); @Override ListBoxValues.ValueTester dataTypesTester(); @Override Path getDiagramPath(); void setLastOverlayOpened(final Button overlayCloseButton); Button getLastOverlayOpened(); void closeLastOverlay(); static Set<String> getDefaultTagsSet();  }