use of org.kie.workbench.common.stunner.bpmn.definition.ScriptTask in project kie-wb-common by kiegroup.
the class TaskConverter method scriptTask.
private BpmnNode scriptTask(org.eclipse.bpmn2.ScriptTask task) {
Node<View<ScriptTask>, Edge> node = factoryManager.newNode(task.getId(), ScriptTask.class);
ScriptTask definition = node.getContent().getDefinition();
ScriptTaskPropertyReader p = propertyReaderFactory.of(task);
definition.setGeneral(new TaskGeneralSet(new Name(p.getName()), new Documentation(p.getDocumentation())));
definition.setExecutionSet(new ScriptTaskExecutionSet(new Script(p.getScript()), new IsAsync(p.isAsync())));
node.getContent().setBounds(p.getBounds());
definition.setDimensionsSet(p.getRectangleDimensionsSet());
definition.setBackgroundSet(p.getBackgroundSet());
definition.setFontSet(p.getFontSet());
definition.setSimulationSet(p.getSimulationSet());
return BpmnNode.of(node);
}
use of org.kie.workbench.common.stunner.bpmn.definition.ScriptTask in project kie-wb-common by kiegroup.
the class DefaultRouteFormProviderTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
when(definitionManager.adapters()).thenReturn(adapterManager);
when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
when(session.getSelectionControl()).thenReturn(selectionControl);
Collection<String> selectedItems = new ArrayList<>();
when(selectedNode.getUUID()).thenReturn(SELECTED_UUID);
selectedItems.add(selectedNode.getUUID());
when(selectionControl.getSelectedItems()).thenReturn(selectedItems);
when(graph.getNode(SELECTED_UUID)).thenReturn(selectedNode);
outEdges = new ArrayList<>();
UserTask userTask1 = new UserTask(new TaskGeneralSet(new Name("UserTask1"), null), null, null, null, null, null, null);
when(definitionAdapter.getTitle(eq(userTask1))).thenReturn("User Task");
outEdges.add(mockEdge("Edge1", userTask1));
UserTask userTask2 = new UserTask(new TaskGeneralSet(new Name("UserTask2"), null), null, null, null, null, null, null);
when(definitionAdapter.getTitle(eq(userTask2))).thenReturn("User Task");
outEdges.add(mockEdge("Edge2", userTask2));
ScriptTask scriptTask3 = new ScriptTask(new TaskGeneralSet(new Name("ScriptTask3"), null), null, null, null, null, null, null);
when(definitionAdapter.getTitle(eq(scriptTask3))).thenReturn("Script Task");
outEdges.add(mockEdge("Edge3", scriptTask3));
ExclusiveGateway gateway4 = new ExclusiveGateway(new BPMNGeneralSet("Gateway4"), null, null, null, null);
when(definitionAdapter.getTitle(eq(gateway4))).thenReturn("Exclusive Gateway");
outEdges.add(mockEdge("Edge4", gateway4));
InclusiveGateway gateway5 = new InclusiveGateway(new BPMNGeneralSet(""), null, null, null, null);
when(definitionAdapter.getTitle(eq(gateway5))).thenReturn("Inclusive Gateway");
outEdges.add(mockEdge("Edge5", gateway5));
}
use of org.kie.workbench.common.stunner.bpmn.definition.ScriptTask in project kie-wb-common by kiegroup.
the class TaskConverter method scriptTask.
private PropertyWriter scriptTask(Node<View<ScriptTask>, ?> n) {
org.eclipse.bpmn2.ScriptTask task = bpmn2.createScriptTask();
task.setId(n.getUUID());
ScriptTask definition = n.getContent().getDefinition();
ScriptTaskPropertyWriter p = propertyWriterFactory.of(task);
TaskGeneralSet general = definition.getGeneral();
p.setName(general.getName().getValue());
p.setDocumentation(general.getDocumentation().getValue());
ScriptTaskExecutionSet executionSet = definition.getExecutionSet();
p.setScript(executionSet.getScript().getValue());
p.setAsync(executionSet.getIsAsync().getValue());
p.setSimulationSet(definition.getSimulationSet());
p.setBounds(n.getContent().getBounds());
return p;
}
use of org.kie.workbench.common.stunner.bpmn.definition.ScriptTask in project kie-wb-common by kiegroup.
the class ScriptTaskConverter method convert.
public Node<? extends View<? extends BPMNViewDefinition>, ?> convert(org.eclipse.bpmn2.ScriptTask task) {
Node<View<ScriptTask>, Edge> node = factoryManager.newNode(task.getId(), ScriptTask.class);
ScriptTask definition = node.getContent().getDefinition();
ScriptTaskPropertyReader p = propertyReaderFactory.of(task);
definition.setGeneral(new TaskGeneralSet(new Name(p.getName()), new Documentation(p.getDocumentation())));
definition.setExecutionSet(new ScriptTaskExecutionSet(new Script(p.getScript()), new IsAsync(p.isAsync())));
node.getContent().setBounds(p.getBounds());
definition.setDimensionsSet(p.getRectangleDimensionsSet());
definition.setBackgroundSet(p.getBackgroundSet());
definition.setFontSet(p.getFontSet());
definition.setSimulationSet(p.getSimulationSet());
return node;
}
use of org.kie.workbench.common.stunner.bpmn.definition.ScriptTask in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallScriptTask.
@Test
public void testUnmarshallScriptTask() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SCRIPTTASK);
ScriptTask javascriptScriptTask = null;
ScriptTask javaScriptTask = null;
Iterator<Element> it = nodesIterator(diagram);
while (it.hasNext()) {
Element element = it.next();
if (element.getContent() instanceof View) {
Object oDefinition = ((View) element.getContent()).getDefinition();
if (oDefinition instanceof ScriptTask) {
ScriptTask task = (ScriptTask) oDefinition;
if ("Javascript Script Task".equals(task.getGeneral().getName().getValue())) {
javascriptScriptTask = task;
} else if ("Java Script Task".equals(task.getGeneral().getName().getValue())) {
javaScriptTask = task;
}
}
}
}
assertNotNull(javascriptScriptTask);
assertNotNull(javascriptScriptTask.getExecutionSet());
assertNotNull(javascriptScriptTask.getExecutionSet().getScript());
assertEquals(javascriptScriptTask.getTaskType().getValue(), TaskTypes.SCRIPT);
assertEquals("Javascript Script Task", javascriptScriptTask.getGeneral().getName().getValue());
assertEquals("var str = FirstName + LastName;", javascriptScriptTask.getExecutionSet().getScript().getValue().getScript());
assertEquals("javascript", javascriptScriptTask.getExecutionSet().getScript().getValue().getLanguage());
assertEquals("true", javascriptScriptTask.getExecutionSet().getIsAsync().getValue().toString());
assertEquals("true", javascriptScriptTask.getExecutionSet().getIsAsync().getValue().toString());
assertNotNull(javaScriptTask);
assertNotNull(javaScriptTask.getExecutionSet());
assertNotNull(javaScriptTask.getExecutionSet().getScript());
assertEquals(javaScriptTask.getTaskType().getValue(), TaskTypes.SCRIPT);
assertEquals("Java Script Task", javaScriptTask.getGeneral().getName().getValue());
assertEquals("if (name.toString().equals(\"Jay\")) {\n" + "\n" + " System.out.println(\"Hello\\n\" + name.toString() + \"\\n\");\n" + "\n" + "} else {\n" + "\n" + "\n" + " System.out.println(\"Hi\\n\" + name.toString() + \"\\n\");\n" + "\n" + "\n" + "}\n", javaScriptTask.getExecutionSet().getScript().getValue().getScript());
assertEquals("java", javaScriptTask.getExecutionSet().getScript().getValue().getLanguage());
assertEquals("true", javaScriptTask.getExecutionSet().getIsAsync().getValue().toString());
assertEquals("true", javaScriptTask.getExecutionSet().getIsAsync().getValue().toString());
}
Aggregations