Search in sources :

Example 6 with BPMNDiagram

use of org.eclipse.bpmn2.di.BPMNDiagram in project kie-wb-common by kiegroup.

the class AssociationPropertyReaderTest method testGetAssociationByDirection.

@Test
public void testGetAssociationByDirection() {
    final Association association = Bpmn2Factory.eINSTANCE.createAssociation();
    // null direction
    association.setAssociationDirection(null);
    propertyReader = new AssociationPropertyReader(association, bpmnDiagram, definitionResolver);
    assertEquals(NonDirectionalAssociation.class, propertyReader.getAssociationByDirection());
    // none direction
    association.setAssociationDirection(AssociationDirection.NONE);
    assertEquals(NonDirectionalAssociation.class, propertyReader.getAssociationByDirection());
    // one direction
    association.setAssociationDirection(AssociationDirection.ONE);
    assertEquals(DirectionalAssociation.class, propertyReader.getAssociationByDirection());
}
Also used : Association(org.eclipse.bpmn2.Association) DirectionalAssociation(org.kie.workbench.common.stunner.bpmn.definition.DirectionalAssociation) NonDirectionalAssociation(org.kie.workbench.common.stunner.bpmn.definition.NonDirectionalAssociation) Test(org.junit.Test)

Example 7 with BPMNDiagram

use of org.eclipse.bpmn2.di.BPMNDiagram in project kie-wb-common by kiegroup.

the class ProcessConverterDelegateTest method setUp.

@Before
public void setUp() throws Exception {
    parentNode = new BpmnNode.Simple(new NodeImpl<>("ParentNode"), basePropertyReader);
    when(diagram.getPlane()).thenReturn(plane);
    List<RootElement> rootElements = Collections.singletonList(process);
    List<BPMNDiagram> diagrams = Collections.singletonList(diagram);
    when(definitions.getRootElements()).thenReturn(rootElements);
    when(definitions.getDiagrams()).thenReturn(diagrams);
    when(definitions.getRelationships()).thenReturn(Collections.emptyList());
    when(plane.getPlaneElement()).thenReturn(new ArrayList<>());
    definitionResolver = new DefinitionResolver(definitions, Collections.emptyList());
    StunnerTestingGraphBackendAPI api = StunnerTestingGraphBackendAPI.build(BPMNDefinitionSet.class, new BPMNTestDefinitionFactory());
    TypedFactoryManager typedFactoryManager = new TypedFactoryManager(api.getFactoryManager());
    factory = new ConverterFactory(definitionResolver, typedFactoryManager);
    converterDelegate = new ProcessConverterDelegate(typedFactoryManager, propertyReaderFactory, definitionResolver, factory);
}
Also used : TypedFactoryManager(org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager) DefinitionResolver(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BPMNTestDefinitionFactory(org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory) StunnerTestingGraphBackendAPI(org.kie.workbench.common.stunner.core.backend.StunnerTestingGraphBackendAPI) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.ConverterFactory) BaseConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BaseConverterFactory) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) RootElement(org.eclipse.bpmn2.RootElement) Before(org.junit.Before)

Example 8 with BPMNDiagram

use of org.eclipse.bpmn2.di.BPMNDiagram in project kie-wb-common by kiegroup.

the class EmbeddedSubprocessPropertyReaderTest method setUp.

@Before
public void setUp() {
    Definitions definitions = bpmn2.createDefinitions();
    definitions.getRootElements().add(bpmn2.createProcess());
    BPMNDiagram bpmnDiagram = di.createBPMNDiagram();
    bpmnDiagram.setPlane(di.createBPMNPlane());
    definitions.getDiagrams().add(bpmnDiagram);
    definitionResolverReal = new DefinitionResolver(definitions, Collections.emptyList());
}
Also used : BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) DefinitionResolver(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver) Definitions(org.eclipse.bpmn2.Definitions) Before(org.junit.Before)

Example 9 with BPMNDiagram

use of org.eclipse.bpmn2.di.BPMNDiagram in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method createDiagram.

private void createDiagram(Definitions def) {
    for (RootElement rootElement : def.getRootElements()) {
        if (rootElement instanceof Process) {
            Process process = (Process) rootElement;
            BpmnDiFactory factory = BpmnDiFactory.eINSTANCE;
            BPMNDiagram diagram = factory.createBPMNDiagram();
            BPMNPlane plane = factory.createBPMNPlane();
            plane.setBpmnElement(process);
            diagram.setPlane(plane);
            // first process flowNodes
            for (FlowElement flowElement : process.getFlowElements()) {
                if (flowElement instanceof FlowNode) {
                    createBpmnShapeForElement(factory, plane, flowElement);
                    if (flowElement instanceof BoundaryEvent) {
                        createDockersForBoundaryEvent((BoundaryEvent) flowElement);
                    }
                    // check if its a subprocess
                    if (flowElement instanceof SubProcess) {
                        createSubProcessDiagram(plane, flowElement, factory);
                    }
                } else if (flowElement instanceof DataObject) {
                    createBpmnShapeForElement(factory, plane, flowElement);
                } else if (flowElement instanceof SequenceFlow) {
                    createBpmnEdgeForSequenceFlow(factory, plane, (SequenceFlow) flowElement);
                }
            }
            // then process artifacts
            if (process.getArtifacts() != null) {
                List<Association> incompleteAssociations = new ArrayList<Association>();
                for (Artifact artifact : process.getArtifacts()) {
                    // if (artifact instanceof TextAnnotation || artifact instanceof Group) {
                    if (artifact instanceof Group) {
                        createBpmnShapeForElement(factory, plane, artifact);
                    }
                    if (artifact instanceof Association) {
                        Association association = (Association) artifact;
                        if (association.getSourceRef() != null && association.getTargetRef() != null) {
                            createBpmnEdgeForAssociation(factory, plane, association);
                        } else {
                            incompleteAssociations.add(association);
                        }
                    }
                }
                if (!incompleteAssociations.isEmpty()) {
                    for (Association incompleteAssociation : incompleteAssociations) {
                        process.getArtifacts().remove(incompleteAssociation);
                    }
                }
            }
            // finally process lanes
            if (process.getLaneSets() != null && process.getLaneSets().size() > 0) {
                for (LaneSet ls : process.getLaneSets()) {
                    for (Lane lane : ls.getLanes()) {
                        createBpmnShapeForElement(factory, plane, lane);
                    }
                }
            }
            def.getDiagrams().add(diagram);
        }
    }
}
Also used : AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Group(org.eclipse.bpmn2.Group) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) ArrayList(java.util.ArrayList) Lane(org.eclipse.bpmn2.Lane) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process) LaneSet(org.eclipse.bpmn2.LaneSet) BpmnDiFactory(org.eclipse.bpmn2.di.BpmnDiFactory) Artifact(org.eclipse.bpmn2.Artifact) BPMNDiagram(org.eclipse.bpmn2.di.BPMNDiagram) RootElement(org.eclipse.bpmn2.RootElement) DataObject(org.eclipse.bpmn2.DataObject) Association(org.eclipse.bpmn2.Association) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) FlowElement(org.eclipse.bpmn2.FlowElement) BPMNPlane(org.eclipse.bpmn2.di.BPMNPlane) FlowNode(org.eclipse.bpmn2.FlowNode)

Example 10 with BPMNDiagram

use of org.eclipse.bpmn2.di.BPMNDiagram in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testUnmarshallProcessVariables.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallProcessVariables() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
    assertDiagram(diagram, 8);
    assertEquals("ProcessVariables", diagram.getMetadata().getTitle());
    ProcessVariables variables = 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 BPMNDiagram) {
                BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
                variables = bpmnDiagram.getProcessData().getProcessVariables();
                break;
            }
        }
    }
    assertEquals(variables.getValue(), "employee:java.lang.String,reason:java.lang.String,performance:java.lang.String");
    Node<? extends Definition, ?> diagramNode = diagram.getGraph().getNode("_luRBMdEjEeWXpsZ1tNStKQ");
    assertTrue(diagramNode.getContent().getDefinition() instanceof BPMNDiagram);
    BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) diagramNode.getContent().getDefinition();
    assertTrue(bpmnDiagram.getProcessData() != null);
    assertTrue(bpmnDiagram.getProcessData().getProcessVariables() != null);
    variables = bpmnDiagram.getProcessData().getProcessVariables();
    assertEquals(variables.getValue(), "employee:java.lang.String,reason:java.lang.String,performance:java.lang.String");
}
Also used : ProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables) BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) 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) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Aggregations

BPMNDiagram (org.eclipse.bpmn2.di.BPMNDiagram)16 Before (org.junit.Before)12 DefinitionResolver (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver)11 Definitions (org.eclipse.bpmn2.Definitions)8 RootElement (org.eclipse.bpmn2.RootElement)8 FlowElement (org.eclipse.bpmn2.FlowElement)6 BPMNDiagram (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram)6 Test (org.junit.Test)5 BPMNDiagramImpl (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl)5 ArrayList (java.util.ArrayList)4 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)4 TypedFactoryManager (org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager)4 Element (org.kie.workbench.common.stunner.core.graph.Element)4 View (org.kie.workbench.common.stunner.core.graph.content.view.View)4 Process (org.eclipse.bpmn2.Process)3 BPMNPlane (org.eclipse.bpmn2.di.BPMNPlane)3 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)3 Graph (org.kie.workbench.common.stunner.core.graph.Graph)3 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)2 Artifact (org.eclipse.bpmn2.Artifact)2