Search in sources :

Example 1 with BaseAdHocSubprocess

use of org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess in project kie-wb-common by kiegroup.

the class SubProcessConverterTest method testConvertAdHocSubprocessNode_autostart.

@Test
public void testConvertAdHocSubprocessNode_autostart() {
    final AdHocSubprocess definition = new AdHocSubprocess();
    definition.getExecutionSet().setAdHocAutostart(new AdHocAutostart(true));
    final View<BaseAdHocSubprocess> view = new ViewImpl<>(definition, Bounds.create());
    final Node<View<BaseAdHocSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString());
    node.setContent(view);
    SubProcessPropertyWriter writer = tested.convertAdHocSubprocessNode(node);
    assertTrue(AdHocSubProcessPropertyWriter.class.isInstance(writer));
    assertTrue(CustomElement.autoStart.of(writer.getFlowElement()).get());
}
Also used : AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) AdHocAutostart(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocAutostart) View(org.kie.workbench.common.stunner.core.graph.content.view.View) SubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter) AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) Test(org.junit.Test)

Example 2 with BaseAdHocSubprocess

use of org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess in project kie-wb-common by kiegroup.

the class SubProcessConverterTest method testConvertAdHocSubprocessNode_notautostart.

@Test
public void testConvertAdHocSubprocessNode_notautostart() {
    final AdHocSubprocess definition = new AdHocSubprocess();
    definition.getExecutionSet().setAdHocAutostart(new AdHocAutostart(false));
    final View<BaseAdHocSubprocess> view = new ViewImpl<>(definition, Bounds.create());
    final Node<View<BaseAdHocSubprocess>, ?> node = new NodeImpl<>(UUID.randomUUID().toString());
    node.setContent(view);
    SubProcessPropertyWriter writer = tested.convertAdHocSubprocessNode(node);
    assertTrue(AdHocSubProcessPropertyWriter.class.isInstance(writer));
    assertFalse(CustomElement.autoStart.of(writer.getFlowElement()).get());
}
Also used : AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) AdHocAutostart(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocAutostart) View(org.kie.workbench.common.stunner.core.graph.content.view.View) SubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter) AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) Test(org.junit.Test)

Example 3 with BaseAdHocSubprocess

use of org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess in project kie-wb-common by kiegroup.

the class SubProcessConverterTest method testConvertAdhocSubprocess.

@Test
public void testConvertAdhocSubprocess() {
    AdHocSubprocess definition = new AdHocSubprocess();
    String adHocOrdering = "Parallel";
    boolean adHocAutostart = true;
    String processVariables = "processVar1:Object,processVar2:Integer";
    definition.getGeneral().getName().setValue(NAME);
    definition.getGeneral().getDocumentation().setValue(DOCUMENTATION);
    definition.getProcessData().getProcessVariables().setValue(processVariables);
    definition.getExecutionSet().getAdHocOrdering().setValue(adHocOrdering);
    definition.getExecutionSet().getAdHocAutostart().setValue(adHocAutostart);
    definition.getExecutionSet().getAdHocActivationCondition().setValue(ACTIVATION_CONDITION);
    definition.getExecutionSet().getAdHocCompletionCondition().setValue(COMPLETION_CONDITION);
    definition.getExecutionSet().getOnEntryAction().getValue().addValue(ON_ENTRY_ACTION);
    definition.getExecutionSet().getOnExitAction().getValue().addValue(ON_EXIT_ACTION);
    setBaseSubprocessExecutionSetValues(definition.getExecutionSet());
    double nodeX1 = 10;
    double nodeY1 = 20;
    double nodeX2 = 40;
    double nodeY2 = 60;
    View<BaseAdHocSubprocess> view = new ViewImpl<>(definition, Bounds.create(nodeX1, nodeY1, nodeX2, nodeY2));
    Node<View<? extends BPMNViewDefinition>, Edge> node = new NodeImpl<>(ELEMENT_ID);
    node.setContent(view);
    double parentX1 = 30;
    double parentY1 = 40;
    double parentX2 = 60;
    double parentY2 = 100;
    Node<View<? extends BPMNViewDefinition>, ?> parent = new NodeImpl<>("parentId");
    View<? extends BPMNViewDefinition> parentView = new ViewImpl<>(null, Bounds.create(parentX1, parentY1, parentX2, parentY2));
    parent.setContent(parentView);
    Edge<Child, Node> edge = new EdgeImpl("edgeId");
    edge.setContent(mock(Child.class));
    node.getInEdges().add(edge);
    edge.setSourceNode(parent);
    edge.setTargetNode(node);
    Result<SubProcessPropertyWriter> result = tested.convertSubProcess(node);
    assertTrue(result.isSuccess());
    AdHocSubProcess adHocSubProcess = (AdHocSubProcess) result.value().getElement();
    assertEquals(ELEMENT_ID, adHocSubProcess.getId());
    assertEquals(NAME, adHocSubProcess.getName());
    assertEquals(asCData(NAME), CustomElement.name.of(adHocSubProcess).get());
    assertEquals(asCData(DOCUMENTATION), adHocSubProcess.getDocumentation().get(0).getText());
    assertEquals(adHocOrdering, adHocSubProcess.getOrdering().getName());
    assertEquals(adHocAutostart, CustomElement.autoStart.of(adHocSubProcess).get());
    assertEquals(asCData(ACTIVATION_CONDITION), CustomElement.customActivationCondition.of(adHocSubProcess).get());
    assertEquals(Scripts.LANGUAGE.valueOf(COMPLETION_CONDITION.getLanguage().toUpperCase()).format(), ((FormalExpression) adHocSubProcess.getCompletionCondition()).getLanguage());
    assertEquals(asCData(COMPLETION_CONDITION.getScript()), ((FormalExpression) adHocSubProcess.getCompletionCondition()).getBody());
    assertEquals(ON_ENTRY_ACTION.getLanguage(), Scripts.onEntry(adHocSubProcess.getExtensionValues()).getValues().get(0).getLanguage());
    assertEquals(asCData(ON_ENTRY_ACTION.getScript()), Scripts.onEntry(adHocSubProcess.getExtensionValues()).getValues().get(0).getScript());
    assertEquals(ON_EXIT_ACTION.getLanguage(), Scripts.onExit(adHocSubProcess.getExtensionValues()).getValues().get(0).getLanguage());
    assertEquals(asCData(ON_EXIT_ACTION.getScript()), Scripts.onExit(adHocSubProcess.getExtensionValues()).getValues().get(0).getScript());
    assertVariables(Arrays.asList(new Pair<>("processVar1", "Object"), new Pair<>("processVar2", "Integer")), adHocSubProcess.getProperties());
    BPMNShape shape = result.value().getShape();
    assertEquals(parentX1 + nodeX1, shape.getBounds().getX(), 0);
    assertEquals(parentY1 + nodeY1, shape.getBounds().getY(), 0);
    assertEquals(nodeX2 - nodeX1, shape.getBounds().getWidth(), 0);
    assertEquals(nodeY2 - nodeY1, shape.getBounds().getHeight(), 0);
    assertBaseSubprocessExecutionSet(result.value());
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) Node(org.kie.workbench.common.stunner.core.graph.Node) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) BPMNViewDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition) BPMNShape(org.eclipse.bpmn2.di.BPMNShape) View(org.kie.workbench.common.stunner.core.graph.content.view.View) SubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter) AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) Pair(org.uberfire.commons.data.Pair) Test(org.junit.Test)

Example 4 with BaseAdHocSubprocess

use of org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess in project kie-wb-common by kiegroup.

the class VariableUtils method encodeProcessVariables.

public static String encodeProcessVariables(Diagram diagram, Node selectedElement) {
    Element parent = null;
    if (selectedElement != null) {
        parent = GraphUtils.getParent(selectedElement);
    }
    Iterator<Element> it = diagram.getGraph().nodes().iterator();
    StringBuffer variables = new StringBuffer();
    while (it.hasNext()) {
        Element element = it.next();
        if (element.getContent() instanceof View) {
            Object oDefinition = ((View) element.getContent()).getDefinition();
            if ((oDefinition instanceof BPMNDiagram)) {
                BPMNDiagram bpmnDiagram = (BPMNDiagram) oDefinition;
                BaseProcessVariables processVariables = bpmnDiagram.getProcessData().getProcessVariables();
                if (processVariables != null) {
                    if (variables.length() > 0) {
                        variables.append(",");
                    }
                    variables.append(processVariables.getValue());
                }
                CaseManagementSet caseManagementSet = bpmnDiagram.getCaseManagementSet();
                if (caseManagementSet != null) {
                    CaseFileVariables caseFileVariables = caseManagementSet.getCaseFileVariables();
                    if (caseFileVariables != null) {
                        if (variables.length() > 0) {
                            variables.append(",");
                        }
                        variables.append(caseFileVariables.getRawValue());
                    }
                }
            }
            if ((Objects.nonNull(parent) && Objects.equals(parent, element)) || Objects.isNull(selectedElement)) {
                BaseProcessVariables subprocessVariables = null;
                if (oDefinition instanceof EventSubprocess) {
                    EventSubprocess subprocess = (EventSubprocess) oDefinition;
                    subprocessVariables = subprocess.getProcessData().getProcessVariables();
                } else if (oDefinition instanceof BaseAdHocSubprocess) {
                    BaseAdHocSubprocess subprocess = (BaseAdHocSubprocess) oDefinition;
                    subprocessVariables = subprocess.getProcessData().getProcessVariables();
                } else if (oDefinition instanceof MultipleInstanceSubprocess) {
                    MultipleInstanceSubprocess subprocess = (MultipleInstanceSubprocess) oDefinition;
                    subprocessVariables = subprocess.getProcessData().getProcessVariables();
                } else if (oDefinition instanceof EmbeddedSubprocess) {
                    EmbeddedSubprocess subprocess = (EmbeddedSubprocess) oDefinition;
                    subprocessVariables = subprocess.getProcessData().getProcessVariables();
                }
                if (subprocessVariables != null) {
                    if (variables.length() > 0) {
                        variables.append(",");
                    }
                    variables.append(subprocessVariables.getValue());
                }
            }
        }
    }
    return variables.toString();
}
Also used : Element(org.kie.workbench.common.stunner.core.graph.Element) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) View(org.kie.workbench.common.stunner.core.graph.content.view.View) MultipleInstanceSubprocess(org.kie.workbench.common.stunner.bpmn.definition.MultipleInstanceSubprocess) CaseManagementSet(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseManagementSet) BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) CaseFileVariables(org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseFileVariables) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) BaseProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.BaseProcessVariables) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess)

Example 5 with BaseAdHocSubprocess

use of org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess in project kie-wb-common by kiegroup.

the class SubProcessConverter method convertAdHocSubprocessNode.

protected SubProcessPropertyWriter convertAdHocSubprocessNode(Node<View<BaseAdHocSubprocess>, ?> n) {
    org.eclipse.bpmn2.AdHocSubProcess process = bpmn2.createAdHocSubProcess();
    process.setId(n.getUUID());
    AdHocSubProcessPropertyWriter p = propertyWriterFactory.of(process);
    BaseAdHocSubprocess definition = n.getContent().getDefinition();
    BPMNGeneralSet general = definition.getGeneral();
    p.setName(general.getName().getValue());
    p.setDocumentation(general.getDocumentation().getValue());
    BaseProcessData processData = definition.getProcessData();
    p.setProcessVariables(processData.getProcessVariables());
    BaseAdHocSubprocessTaskExecutionSet executionSet = definition.getExecutionSet();
    p.setAdHocActivationCondition(executionSet.getAdHocActivationCondition());
    p.setAdHocCompletionCondition(executionSet.getAdHocCompletionCondition());
    p.setAdHocOrdering(executionSet.getAdHocOrdering());
    p.setOnEntryAction(executionSet.getOnEntryAction());
    p.setOnExitAction(executionSet.getOnExitAction());
    p.setAsync(executionSet.getIsAsync().getValue());
    p.setSlaDueDate(executionSet.getSlaDueDate());
    p.setSimulationSet(definition.getSimulationSet());
    p.setMetaData(definition.getAdvancedData().getMetaDataAttributes());
    p.setAbsoluteBounds(n);
    p.setAdHocAutostart(executionSet.getAdHocAutostart().getValue());
    return p;
}
Also used : AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) BaseProcessData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.BaseProcessData) Factories.bpmn2(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) BaseAdHocSubprocessTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.BaseAdHocSubprocessTaskExecutionSet)

Aggregations

BaseAdHocSubprocess (org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess)6 AdHocSubProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter)4 View (org.kie.workbench.common.stunner.core.graph.content.view.View)4 Test (org.junit.Test)3 SubProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter)3 AdHocSubprocess (org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess)3 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)3 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)3 EmbeddedSubprocess (org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess)2 EventSubprocess (org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess)2 AdHocAutostart (org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocAutostart)2 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)1 DataObject (org.eclipse.bpmn2.DataObject)1 BPMNShape (org.eclipse.bpmn2.di.BPMNShape)1 Factories.bpmn2 (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2)1 BPMNDiagram (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram)1 BPMNViewDefinition (org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition)1 MultipleInstanceSubprocess (org.kie.workbench.common.stunner.bpmn.definition.MultipleInstanceSubprocess)1 CaseFileVariables (org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseFileVariables)1 CaseManagementSet (org.kie.workbench.common.stunner.bpmn.definition.property.cm.CaseManagementSet)1