Search in sources :

Example 16 with Task

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());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) FlowElement(org.eclipse.bpmn2.FlowElement) RootElement(org.eclipse.bpmn2.RootElement) Element(org.kie.workbench.common.stunner.core.graph.Element) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 17 with Task

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());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) FlowElement(org.eclipse.bpmn2.FlowElement) RootElement(org.eclipse.bpmn2.RootElement) Element(org.kie.workbench.common.stunner.core.graph.Element) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 18 with Task

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());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) FlowElement(org.eclipse.bpmn2.FlowElement) RootElement(org.eclipse.bpmn2.RootElement) Element(org.kie.workbench.common.stunner.core.graph.Element) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 19 with Task

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();
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) IOException(java.io.IOException)

Example 20 with Task

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());
}
Also used : Task(org.openstack4j.model.image.v2.Task) CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)

Aggregations

FlowElement (org.eclipse.bpmn2.FlowElement)9 RootElement (org.eclipse.bpmn2.RootElement)9 ArrayList (java.util.ArrayList)7 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)7 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)7 DataInput (org.eclipse.bpmn2.DataInput)6 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)6 InputSet (org.eclipse.bpmn2.InputSet)6 List (java.util.List)5 BusinessRuleTask (org.eclipse.bpmn2.BusinessRuleTask)5 DataOutput (org.eclipse.bpmn2.DataOutput)5 FormalExpression (org.eclipse.bpmn2.FormalExpression)5 InputOutputSpecification (org.eclipse.bpmn2.InputOutputSpecification)5 ReceiveTask (org.eclipse.bpmn2.ReceiveTask)5 ScriptTask (org.eclipse.bpmn2.ScriptTask)5 SendTask (org.eclipse.bpmn2.SendTask)5 ServiceTask (org.eclipse.bpmn2.ServiceTask)5 UserTask (org.eclipse.bpmn2.UserTask)5 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)4 GlobalTask (org.eclipse.bpmn2.GlobalTask)4