Search in sources :

Example 41 with FlowElement

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

the class GenericServiceTaskTest method marshallServiceTask.

@Test
public void marshallServiceTask() throws Exception {
    Diagram<Graph, Metadata> d = unmarshall(marshaller, BPMN_FILE_PATH);
    DefinitionsConverter definitionsConverter = new DefinitionsConverter(d.getGraph());
    Definitions definitions = definitionsConverter.toDefinitions();
    Process p = (Process) definitions.getRootElements().get(0);
    assertEquals(ServiceTaskImpl.class, p.getFlowElements().stream().filter(e -> e.getId().equals(TASK_ID)).findFirst().get().getClass());
    org.eclipse.bpmn2.ServiceTask flowElement = (org.eclipse.bpmn2.ServiceTask) p.getFlowElements().stream().filter(e -> e.getId().equals(TASK_ID)).findFirst().get();
    assertEquals("Service", flowElement.getName());
    assertEquals("op", flowElement.getOperationRef().getName());
    assertEquals("Java", CustomAttribute.serviceImplementation.of(flowElement).get());
    assertEquals("op", CustomAttribute.serviceOperation.of(flowElement).get());
    assertEquals("hgfhfgh", CustomAttribute.serviceInterface.of(flowElement).get());
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) Process(org.eclipse.bpmn2.Process) ServiceTaskImpl(org.eclipse.bpmn2.impl.ServiceTaskImpl) Test(org.junit.Test) CustomAttribute(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.CustomAttribute) BPMNDiagramMarshallerBaseTest(org.kie.workbench.common.stunner.bpmn.backend.service.diagram.marshalling.BPMNDiagramMarshallerBaseTest) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Definitions(org.eclipse.bpmn2.Definitions) TestCase.assertEquals(junit.framework.TestCase.assertEquals) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Definitions(org.eclipse.bpmn2.Definitions) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Process(org.eclipse.bpmn2.Process) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) Test(org.junit.Test) BPMNDiagramMarshallerBaseTest(org.kie.workbench.common.stunner.bpmn.backend.service.diagram.marshalling.BPMNDiagramMarshallerBaseTest)

Example 42 with FlowElement

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

the class Processes method addChildElement.

static void addChildElement(BasePropertyWriter p, Map<String, BasePropertyWriter> childElements, FlowElementsContainer process, Collection<ElementParameters> simulationParameters, List<ItemDefinition> itemDefinitions, List<RootElement> rootElements) {
    childElements.put(p.getElement().getId(), p);
    if (p.getElement() instanceof FlowElement) {
        // otherwise they will be drawn at an incorrect position on load
        if ((p instanceof BoundaryEventPropertyWriter) || (p instanceof DataObjectPropertyWriter)) {
            process.getFlowElements().add((FlowElement) p.getElement());
        } else {
            process.getFlowElements().add(0, (FlowElement) p.getElement());
        }
    } else if (p.getElement() instanceof Artifact) {
        if (process instanceof Process) {
            ((Process) process).getArtifacts().add((Artifact) p.getElement());
        } else if (process instanceof SubProcess) {
            ((SubProcess) process).getArtifacts().add((Artifact) p.getElement());
        }
    }
    if (p instanceof PropertyWriter) {
        ElementParameters sp = ((PropertyWriter) p).getSimulationParameters();
        if (sp != null) {
            simulationParameters.add(sp);
        }
    }
    itemDefinitions.addAll(p.getItemDefinitions());
    rootElements.addAll(p.getRootElements());
    rootElements.addAll(p.getInterfaces());
    if (p instanceof DataObjectPropertyWriter) {
        maybeAddDataObjects(process, ((DataObjectPropertyWriter) p).getDataObjects());
    }
}
Also used : SubProcess(org.eclipse.bpmn2.SubProcess) ElementParameters(bpsim.ElementParameters) FlowElement(org.eclipse.bpmn2.FlowElement) Process(org.eclipse.bpmn2.Process) SubProcess(org.eclipse.bpmn2.SubProcess) Artifact(org.eclipse.bpmn2.Artifact)

Aggregations

FlowElement (org.eclipse.bpmn2.FlowElement)35 SubProcess (org.eclipse.bpmn2.SubProcess)22 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)19 Process (org.eclipse.bpmn2.Process)19 ArrayList (java.util.ArrayList)16 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)15 RootElement (org.eclipse.bpmn2.RootElement)14 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)13 Entry (java.util.Map.Entry)12 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)12 Activity (org.eclipse.bpmn2.Activity)9 List (java.util.List)8 CallActivity (org.eclipse.bpmn2.CallActivity)8 DataObject (org.eclipse.bpmn2.DataObject)8 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)8 Artifact (org.eclipse.bpmn2.Artifact)7 FlowNode (org.eclipse.bpmn2.FlowNode)7 Bounds (org.eclipse.dd.dc.Bounds)7 Test (org.junit.Test)7 BoundaryEvent (org.eclipse.bpmn2.BoundaryEvent)6