use of org.eclipse.bpmn2.Task 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());
}
use of org.eclipse.bpmn2.Task in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallBusinessRuleTask.
@Test
public void testUnmarshallBusinessRuleTask() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_BUSINESSRULETASKRULEFLOWGROUP);
BusinessRuleTask businessRuleTask = 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 BusinessRuleTask) {
businessRuleTask = (BusinessRuleTask) oDefinition;
break;
}
}
}
assertNotNull(businessRuleTask);
assertNotNull(businessRuleTask.getExecutionSet());
assertNotNull(businessRuleTask.getExecutionSet().getRuleFlowGroup());
assertNotNull(businessRuleTask.getGeneral());
assertNotNull(businessRuleTask.getGeneral().getName());
assertEquals(businessRuleTask.getTaskType().getValue(), TaskTypes.BUSINESS_RULE);
assertEquals("my business rule task", businessRuleTask.getGeneral().getName().getValue());
assertEquals("my-ruleflow-group", businessRuleTask.getExecutionSet().getRuleFlowGroup().getValue());
assertEquals("true", businessRuleTask.getExecutionSet().getIsAsync().getValue().toString());
assertEquals("true", businessRuleTask.getExecutionSet().getIsAsync().getValue().toString());
assertEquals("System.out.println(\"Hello\");", businessRuleTask.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getScript());
assertEquals("java", businessRuleTask.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getLanguage());
assertEquals("System.out.println(\"Bye\");", businessRuleTask.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getScript());
assertEquals("java", businessRuleTask.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getLanguage());
}
use of org.eclipse.bpmn2.Task in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest 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());
}
use of org.eclipse.bpmn2.Task in project kie-wb-common by kiegroup.
the class FormDefinitionGeneratorImpl method generateSelectedFormsForTasks.
private void generateSelectedFormsForTasks(Diagram diagram, String... taskIds) {
try {
final String idsRaw = Arrays.stream(taskIds).collect(Collectors.joining(","));
LOGGER.finest("Generating form for tasks " + idsRaw);
final Path path = diagram.getMetadata().getPath();
org.uberfire.java.nio.file.Path nioPath = Paths.convert(path);
ioService.startBatch(ioService.getFileSystem(nioPath.toUri()));
final Definitions definitions = toDefinitions(diagram);
for (String taskId : taskIds) {
final TaskFormModel formModel = bpmnFormModelGenerator.generateTaskFormModel(definitions, taskId, path);
createFormForModel(formModel, nioPath);
}
} catch (Exception ex) {
LOGGER.severe("Error generating task forms");
throw new RuntimeException(ex);
} finally {
ioService.endBatch();
}
}
use of org.eclipse.bpmn2.Task in project cloudbreak by hortonworks.
the class OpenStackImageImporter method importImage.
public void importImage(OSClient osClient, String name) {
String importLocation = openStackImageImportTaskParameters.getImportLocation(name);
LOGGER.info("Import OpenStack image from: {}", importLocation);
if (!urlAccessValidationService.isAccessible(importLocation)) {
throw new CloudConnectorException(String.format("OpenStack image '%s' is not accessible, therefore it cannot be imported automatically", importLocation));
}
Map<String, Object> input = openStackImageImportTaskParameters.buildInput(name);
LOGGER.info("Executing of the following import Task: {}", input);
Task task = osClient.imagesV2().tasks().create(Builders.taskBuilder().type("import").input(input).build());
evaluateTaskStatus(task, name);
LOGGER.info("Task of importing {} image, returned with {}", name, task.getStatus());
}
Aggregations