use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.AssignmentData in project kie-wb-common by kiegroup.
the class ActivityDataIOEditor method handleSaveClick.
@Override
public void handleSaveClick() {
if (callback != null) {
AssignmentData data = new AssignmentData(view.getInputAssignmentData(), view.getOutputAssignmentData(), dataTypes, dataTypeDisplayNames);
data.setVariableCountsString(hasInputVars, isSingleInputVar, hasOutputVars, isSingleOutputVar);
String sData = marshallToJson(data);
callback.getData(sData);
}
view.hideView();
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.AssignmentData in project kie-wb-common by kiegroup.
the class AssignmentsEditorWidgetTest method testAssignments.
@SuppressWarnings("unchecked")
private void testAssignments(String encodedAssignments, List<Variable> expectedInputVariables, List<Variable> expectedOutputVariables, List<Pair<Variable, Variable>> expectedAssignments) {
doCallRealMethod().when(widget).setValue(anyString());
doCallRealMethod().when(widget).setValue(anyString(), anyBoolean());
doCallRealMethod().when(widget).getProcessVariables();
doCallRealMethod().when(widget).getSelectedElement();
doCallRealMethod().when(widget).getSelectedElementUUID(anyObject());
when(canvasSessionManager.getCurrentSession()).thenReturn(session);
when(session.getCanvasHandler()).thenReturn(canvasHandler);
when(canvasHandler.getDiagram()).thenReturn(diagram);
when(diagram.getMetadata()).thenReturn(metadata);
when(metadata.getCanvasRootUUID()).thenReturn("rootId");
when(widget.getParentIds()).thenReturn(new HashSet<>());
when(diagram.getGraph()).thenReturn(graph);
when(session.getSelectionControl()).thenReturn(selectionControl);
List<String> selectedItems = Collections.singletonList("UUID");
when(selectionControl.getSelectedItems()).thenReturn(selectedItems);
BPMNDiagramImpl bpmnDiagram = new BPMNDiagramImpl();
Node parentNode = new NodeImpl("PARENT_UUID");
View parentNodeView = new ViewImpl(bpmnDiagram, Bounds.create());
parentNode.setContent(parentNodeView);
bpmnDiagram.getProcessData().getProcessVariables().setValue("processVar1:Object:,processVar2:Object:,processVar3:Object:,processVar4:Object:");
Node node = new NodeImpl("UUID");
Edge edge = new EdgeImpl("edge");
Child child = mock(Child.class);
edge.setContent(child);
edge.setSourceNode(parentNode);
node.getInEdges().add(edge);
when(graph.getNode("UUID")).thenReturn(node);
List<Element> nodes = Arrays.asList(node, parentNode);
when(graph.nodes()).thenReturn(nodes);
widget.setValue(encodedAssignments);
widget.showDataIOEditor(SIMPLE_DATA_TYPES);
verify(activityDataIOEditor).setAssignmentData(assignmentDataCaptor.capture());
AssignmentData assignmentData = assignmentDataCaptor.getValue();
verifyProcessVariables(assignmentData);
assertVariables(expectedInputVariables, assignmentData.getInputVariables());
assertVariables(expectedOutputVariables, assignmentData.getOutputVariables());
assertAssignments(expectedAssignments, assignmentData.getAssignments());
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.AssignmentData in project kie-wb-common by kiegroup.
the class AssignmentsEditorWidget method showDataIOEditor.
public void showDataIOEditor(final String datatypes) {
String taskName = getTaskName();
String processvars = getProcessVariables();
Map<String, String> assignmentsProperties = AssignmentParser.parseAssignmentsInfo(assignmentsInfo);
String datainput = assignmentsProperties.get(AssignmentParser.DATAINPUT);
String datainputset = assignmentsProperties.get(AssignmentParser.DATAINPUTSET);
String dataoutput = assignmentsProperties.get(AssignmentParser.DATAOUTPUT);
String dataoutputset = assignmentsProperties.get(AssignmentParser.DATAOUTPUTSET);
String assignments = assignmentsProperties.get(AssignmentParser.ASSIGNMENTS);
String disallowedpropertynames = getDisallowedPropertyNames();
String inputvars = null;
if (datainput != null) {
inputvars = datainput;
}
if (datainputset != null) {
inputvars = datainputset;
}
String outputvars = null;
if (dataoutput != null) {
outputvars = dataoutput;
}
if (dataoutputset != null) {
outputvars = dataoutputset;
}
AssignmentData assignmentData = new AssignmentData(inputvars, outputvars, processvars, assignments, datatypes, disallowedpropertynames);
assignmentData.setVariableCountsString(hasInputVars, isSingleInputVar, hasOutputVars, isSingleOutputVar);
ActivityDataIOEditor.GetDataCallback callback = new ActivityDataIOEditor.GetDataCallback() {
@Override
public void getData(String assignmentDataJson) {
AssignmentData assignmentData1 = Marshalling.fromJSON(assignmentDataJson, AssignmentData.class);
String assignmentsInfoString = createAssignmentsInfoString(assignmentData1);
setValue(assignmentsInfoString, true);
}
@Override
public void addDataType(String dataType, String oldType) {
if (dataType != null && !dataType.isEmpty()) {
clientDataTypesService.add(dataType, oldType);
}
}
};
activityDataIOEditor.setCallback(callback);
activityDataIOEditor.setAssignmentData(assignmentData);
activityDataIOEditor.setDisallowedPropertyNames(assignmentData.getDisallowedPropertyNames());
activityDataIOEditor.setInputAssignmentRows(assignmentData.getAssignmentRows(Variable.VariableType.INPUT));
activityDataIOEditor.setOutputAssignmentRows(assignmentData.getAssignmentRows(Variable.VariableType.OUTPUT));
activityDataIOEditor.setDataTypes(assignmentData.getDataTypes(), assignmentData.getDataTypeDisplayNames());
activityDataIOEditor.setProcessVariables(assignmentData.getProcessVariableNames().stream().distinct().collect(Collectors.toList()));
activityDataIOEditor.configureDialog(taskName, hasInputVars, isSingleInputVar, hasOutputVars, isSingleOutputVar);
activityDataIOEditor.show();
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.AssignmentData in project kie-wb-common by kiegroup.
the class AssignmentsEditorWidget method getVariableCountsString.
String getVariableCountsString(final String datainput, final String datainputset, final String dataoutput, final String dataoutputset, final String processvars, final String assignments, final String disallowedpropertynames) {
String inputvars = null;
if (datainput != null) {
inputvars = datainput;
}
if (datainputset != null) {
inputvars = datainputset;
}
String outputvars = null;
if (dataoutput != null) {
outputvars = dataoutput;
}
if (dataoutputset != null) {
outputvars = dataoutputset;
}
AssignmentData assignmentData = new AssignmentData(inputvars, outputvars, processvars, assignments, disallowedpropertynames);
return assignmentData.getVariableCountsString(hasInputVars, isSingleInputVar, hasOutputVars, isSingleOutputVar);
}
use of org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.AssignmentData in project kie-wb-common by kiegroup.
the class ActivityDataIOEditor method handleOkClick.
@Override
public void handleOkClick() {
if (callback != null) {
AssignmentData data = new AssignmentData(view.getInputAssignmentData(), view.getOutputAssignmentData(), dataTypes, dataTypeDisplayNames);
data.setVariableCountsString(hasInputVars, isSingleInputVar, hasOutputVars, isSingleOutputVar);
String sData = marshallToJson(data);
callback.getData(sData);
}
view.hideView();
}
Aggregations