Search in sources :

Example 11 with FlowElementsContainer

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

the class Bpmn2JsonUnmarshaller method setSendReceiveTasksInfo.

public void setSendReceiveTasksInfo(FlowElementsContainer container, Definitions def, List<Message> toAddMessages, List<ItemDefinition> toAddItemDefinitions) {
    List<FlowElement> flowElements = container.getFlowElements();
    for (FlowElement fe : flowElements) {
        if (fe instanceof ReceiveTask) {
            ReceiveTask rt = (ReceiveTask) fe;
            rt.setMessageRef(extractMessage(rt, toAddMessages, toAddItemDefinitions));
        } else if (fe instanceof SendTask) {
            SendTask st = (SendTask) fe;
            st.setMessageRef(extractMessage(st, toAddMessages, toAddItemDefinitions));
        } else if (fe instanceof FlowElementsContainer) {
            setSendReceiveTasksInfo((FlowElementsContainer) fe, def, toAddMessages, toAddItemDefinitions);
        }
    }
}
Also used : ReceiveTask(org.eclipse.bpmn2.ReceiveTask) FlowElement(org.eclipse.bpmn2.FlowElement) SendTask(org.eclipse.bpmn2.SendTask) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer)

Example 12 with FlowElementsContainer

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

the class Bpmn2JsonUnmarshaller method setGatewayInfo.

private void setGatewayInfo(FlowElementsContainer container) {
    List<FlowElement> flowElements = container.getFlowElements();
    for (FlowElement fe : flowElements) {
        if (fe instanceof Gateway) {
            Gateway gateway = (Gateway) fe;
            int incoming = gateway.getIncoming() == null ? 0 : gateway.getIncoming().size();
            int outgoing = gateway.getOutgoing() == null ? 0 : gateway.getOutgoing().size();
            if (incoming <= 1 && outgoing > 1) {
                gateway.setGatewayDirection(GatewayDirection.DIVERGING);
            } else if (incoming > 1 && outgoing <= 1) {
                gateway.setGatewayDirection(GatewayDirection.CONVERGING);
            } else // temp. removing support for mixed gateway direction (not supported by runtime yet)
            // else if (incoming > 1 && outgoing > 1) {
            // gateway.setGatewayDirection(GatewayDirection.MIXED);
            // }
            // else if (incoming == 1 && outgoing == 1) {
            // // this handles the 1:1 case of the diverging gateways
            // }
            {
                gateway.setGatewayDirection(GatewayDirection.UNSPECIFIED);
            }
        }
        if (fe instanceof InclusiveGateway) {
            InclusiveGateway ig = (InclusiveGateway) fe;
            List<SequenceFlow> sqList = new ArrayList<SequenceFlow>();
            if (ig.getIncoming() != null) {
                sqList.addAll(ig.getIncoming());
            }
            if (ig.getOutgoing() != null) {
                sqList.addAll(ig.getOutgoing());
            }
            setDefaultGateway(fe, sqList);
        }
        if (fe instanceof ExclusiveGateway) {
            ExclusiveGateway eg = (ExclusiveGateway) fe;
            List<SequenceFlow> sqList = new ArrayList<SequenceFlow>();
            if (eg.getIncoming() != null) {
                sqList.addAll(eg.getIncoming());
            }
            if (eg.getOutgoing() != null) {
                sqList.addAll(eg.getOutgoing());
            }
            setDefaultGateway(fe, sqList);
        }
        if (fe instanceof FlowElementsContainer) {
            setGatewayInfo((FlowElementsContainer) fe);
        }
    }
}
Also used : ExclusiveGateway(org.eclipse.bpmn2.ExclusiveGateway) InclusiveGateway(org.eclipse.bpmn2.InclusiveGateway) FlowElement(org.eclipse.bpmn2.FlowElement) ExclusiveGateway(org.eclipse.bpmn2.ExclusiveGateway) Gateway(org.eclipse.bpmn2.Gateway) InclusiveGateway(org.eclipse.bpmn2.InclusiveGateway) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) ArrayList(java.util.ArrayList) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) Point(org.eclipse.dd.dc.Point)

Example 13 with FlowElementsContainer

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

the class Bpmn2JsonUnmarshaller method revisitServiceTasksExecuteForLanes.

private void revisitServiceTasksExecuteForLanes(Lane lane, Definitions def, List<RootElement> rootElements, List<Interface> toAddInterfaces, List<Message> toAddMessages, List<ItemDefinition> toAddDefinitions) {
    List<FlowNode> laneFlowNodes = lane.getFlowNodeRefs();
    for (FlowElement fe : laneFlowNodes) {
        if (fe instanceof ServiceTask) {
            Iterator<FeatureMap.Entry> iter = fe.getAnyAttribute().iterator();
            String serviceImplementation = null;
            String serviceInterface = null;
            String serviceOperation = null;
            EStructuralFeature serviceInterfaceFeature = null;
            EStructuralFeature serviceOperationFeature = null;
            while (iter.hasNext()) {
                FeatureMap.Entry entry = iter.next();
                if (entry.getEStructuralFeature().getName().equals("serviceimplementation")) {
                    serviceImplementation = (String) entry.getValue();
                }
                if (entry.getEStructuralFeature().getName().equals("serviceoperation")) {
                    serviceOperation = (String) entry.getValue();
                    serviceOperationFeature = entry.getEStructuralFeature();
                }
                if (entry.getEStructuralFeature().getName().equals("serviceinterface")) {
                    serviceInterface = (String) entry.getValue();
                    serviceInterfaceFeature = entry.getEStructuralFeature();
                }
            }
            boolean foundInterface = false;
            Interface touseInterface = null;
            if (serviceImplementation != null && serviceImplementation.equals("Java")) {
                for (RootElement iroot : rootElements) {
                    if (iroot instanceof Interface && ((Interface) iroot).getName().equals(serviceInterface)) {
                        foundInterface = true;
                        touseInterface = (Interface) iroot;
                        break;
                    }
                }
                if (!foundInterface) {
                    for (Interface toadd : toAddInterfaces) {
                        if (toadd.getName() != null && toadd.getName().equals(serviceInterface)) {
                            foundInterface = true;
                            touseInterface = toadd;
                            break;
                        }
                    }
                }
            } else if (serviceImplementation != null && serviceImplementation.equals("##WebService")) {
                for (RootElement iroot : rootElements) {
                    if (iroot instanceof Interface && ((Interface) iroot).getImplementationRef().equals(serviceInterface)) {
                        foundInterface = true;
                        touseInterface = (Interface) iroot;
                        break;
                    }
                }
                if (!foundInterface) {
                    for (Interface toadd : toAddInterfaces) {
                        if (toadd.getImplementationRef().equals(serviceInterface)) {
                            foundInterface = true;
                            touseInterface = toadd;
                            break;
                        }
                    }
                }
            }
            if (!foundInterface) {
                touseInterface = Bpmn2Factory.eINSTANCE.createInterface();
                if (serviceInterface == null || serviceInterface.length() == 0) {
                    serviceInterface = fe.getId() + "_ServiceInterface";
                    if (serviceInterfaceFeature != null) {
                        fe.getAnyAttribute().set(serviceInterfaceFeature, serviceInterface);
                    }
                }
                touseInterface.setName(serviceInterface);
                touseInterface.setImplementationRef(serviceInterface);
                touseInterface.setId(fe.getId() + "_ServiceInterface");
                toAddInterfaces.add(touseInterface);
            }
            if (serviceOperation != null) {
                boolean foundOperation = false;
                for (Operation oper : touseInterface.getOperations()) {
                    if (serviceImplementation != null && serviceImplementation.equals("Java")) {
                        if (oper.getName().equals(serviceOperation)) {
                            foundOperation = true;
                            break;
                        }
                    } else if (serviceImplementation != null && serviceImplementation.equals("##WebService")) {
                        if (oper.getImplementationRef().equals(serviceOperation)) {
                            foundOperation = true;
                            break;
                        }
                    }
                }
                if (!foundOperation) {
                    Operation touseOperation = Bpmn2Factory.eINSTANCE.createOperation();
                    if (serviceOperation == null || serviceOperation.length() == 0) {
                        serviceOperation = fe.getId() + "_ServiceOperation";
                        if (serviceOperationFeature != null) {
                            fe.getAnyAttribute().set(serviceOperationFeature, serviceOperation);
                        }
                    }
                    touseOperation.setId(fe.getId() + "_ServiceOperation");
                    touseOperation.setName(serviceOperation);
                    touseOperation.setImplementationRef(serviceOperation);
                    Message message = Bpmn2Factory.eINSTANCE.createMessage();
                    message.setId(fe.getId() + "_InMessage");
                    ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition();
                    itemdef.setId(message.getId() + "Type");
                    message.setItemRef(itemdef);
                    toAddDefinitions.add(itemdef);
                    toAddMessages.add(message);
                    touseOperation.setInMessageRef(message);
                    touseInterface.getOperations().add(touseOperation);
                    ((ServiceTask) fe).setOperationRef(touseOperation);
                }
            }
        } else if (fe instanceof FlowElementsContainer) {
            revisitServiceTasksExecute((FlowElementsContainer) fe, rootElements, toAddInterfaces, toAddMessages, toAddDefinitions);
        }
    }
}
Also used : ServiceTask(org.eclipse.bpmn2.ServiceTask) Message(org.eclipse.bpmn2.Message) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) Operation(org.eclipse.bpmn2.Operation) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Entry(java.util.Map.Entry) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) RootElement(org.eclipse.bpmn2.RootElement) FlowElement(org.eclipse.bpmn2.FlowElement) Interface(org.eclipse.bpmn2.Interface) FlowNode(org.eclipse.bpmn2.FlowNode)

Example 14 with FlowElementsContainer

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

the class Bpmn2JsonUnmarshaller method revisitServiceTasksExecute.

private void revisitServiceTasksExecute(FlowElementsContainer container, List<RootElement> rootElements, List<Interface> toAddInterfaces, List<Message> toAddMessages, List<ItemDefinition> toAddDefinitions) {
    List<FlowElement> flowElements = container.getFlowElements();
    for (FlowElement fe : flowElements) {
        if (fe instanceof ServiceTask) {
            Iterator<FeatureMap.Entry> iter = fe.getAnyAttribute().iterator();
            String serviceImplementation = null;
            String serviceInterface = null;
            String serviceOperation = null;
            EStructuralFeature serviceInterfaceFeature = null;
            EStructuralFeature serviceOperationFeature = null;
            while (iter.hasNext()) {
                FeatureMap.Entry entry = iter.next();
                if (entry.getEStructuralFeature().getName().equals("serviceimplementation")) {
                    serviceImplementation = (String) entry.getValue();
                }
                if (entry.getEStructuralFeature().getName().equals("serviceoperation")) {
                    serviceOperation = (String) entry.getValue();
                    serviceOperationFeature = entry.getEStructuralFeature();
                }
                if (entry.getEStructuralFeature().getName().equals("serviceinterface")) {
                    serviceInterface = (String) entry.getValue();
                    serviceInterfaceFeature = entry.getEStructuralFeature();
                }
            }
            boolean foundInterface = false;
            Interface touseInterface = null;
            if (serviceImplementation != null && serviceImplementation.equals("Java")) {
                for (RootElement iroot : rootElements) {
                    if (iroot instanceof Interface && ((Interface) iroot).getName().equals(serviceInterface)) {
                        foundInterface = true;
                        touseInterface = (Interface) iroot;
                        break;
                    }
                }
                if (!foundInterface) {
                    for (Interface toadd : toAddInterfaces) {
                        if (toadd.getName() != null && toadd.getName().equals(serviceInterface)) {
                            foundInterface = true;
                            touseInterface = toadd;
                            break;
                        }
                    }
                }
            } else if (serviceImplementation != null && serviceImplementation.equals("##WebService")) {
                for (RootElement iroot : rootElements) {
                    if (iroot instanceof Interface && ((Interface) iroot).getImplementationRef().equals(serviceInterface)) {
                        foundInterface = true;
                        touseInterface = (Interface) iroot;
                        break;
                    }
                }
                if (!foundInterface) {
                    for (Interface toadd : toAddInterfaces) {
                        if (toadd.getImplementationRef().equals(serviceInterface)) {
                            foundInterface = true;
                            touseInterface = toadd;
                            break;
                        }
                    }
                }
            }
            if (!foundInterface) {
                touseInterface = Bpmn2Factory.eINSTANCE.createInterface();
                if (serviceInterface == null || serviceInterface.length() == 0) {
                    serviceInterface = fe.getId() + "_ServiceInterface";
                    if (serviceInterfaceFeature != null) {
                        fe.getAnyAttribute().set(serviceInterfaceFeature, serviceInterface);
                    }
                }
                touseInterface.setName(serviceInterface);
                touseInterface.setImplementationRef(serviceInterface);
                touseInterface.setId(fe.getId() + "_ServiceInterface");
                toAddInterfaces.add(touseInterface);
            }
            if (serviceOperation != null) {
                boolean foundOperation = false;
                for (Operation oper : touseInterface.getOperations()) {
                    if (serviceImplementation != null && serviceImplementation.equals("Java")) {
                        if (oper.getName().equals(serviceOperation)) {
                            foundOperation = true;
                            break;
                        }
                    } else if (serviceImplementation != null && serviceImplementation.equals("##WebService")) {
                        if (oper.getImplementationRef().equals(serviceOperation)) {
                            foundOperation = true;
                            break;
                        }
                    }
                }
                if (!foundOperation) {
                    Operation touseOperation = Bpmn2Factory.eINSTANCE.createOperation();
                    if (serviceOperation == null || serviceOperation.length() == 0) {
                        serviceOperation = fe.getId() + "_ServiceOperation";
                        if (serviceOperationFeature != null) {
                            fe.getAnyAttribute().set(serviceOperationFeature, serviceOperation);
                        }
                    }
                    touseOperation.setId(fe.getId() + "_ServiceOperation");
                    touseOperation.setName(serviceOperation);
                    touseOperation.setImplementationRef(serviceOperation);
                    Message message = Bpmn2Factory.eINSTANCE.createMessage();
                    message.setId(fe.getId() + "_InMessage");
                    ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition();
                    itemdef.setId(message.getId() + "Type");
                    message.setItemRef(itemdef);
                    toAddDefinitions.add(itemdef);
                    toAddMessages.add(message);
                    touseOperation.setInMessageRef(message);
                    touseInterface.getOperations().add(touseOperation);
                    ((ServiceTask) fe).setOperationRef(touseOperation);
                }
            }
        } else if (fe instanceof FlowElementsContainer) {
            revisitServiceTasksExecute((FlowElementsContainer) fe, rootElements, toAddInterfaces, toAddMessages, toAddDefinitions);
        }
    }
}
Also used : ServiceTask(org.eclipse.bpmn2.ServiceTask) Message(org.eclipse.bpmn2.Message) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) Operation(org.eclipse.bpmn2.Operation) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Entry(java.util.Map.Entry) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) RootElement(org.eclipse.bpmn2.RootElement) FlowElement(org.eclipse.bpmn2.FlowElement) Interface(org.eclipse.bpmn2.Interface)

Aggregations

FlowElement (org.eclipse.bpmn2.FlowElement)14 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)14 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)9 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)9 Entry (java.util.Map.Entry)8 RootElement (org.eclipse.bpmn2.RootElement)8 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)7 CallActivity (org.eclipse.bpmn2.CallActivity)7 Process (org.eclipse.bpmn2.Process)7 SubProcess (org.eclipse.bpmn2.SubProcess)7 ArrayList (java.util.ArrayList)6 Activity (org.eclipse.bpmn2.Activity)6 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)5 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)5 Iterator (java.util.Iterator)4 List (java.util.List)4 CatchEvent (org.eclipse.bpmn2.CatchEvent)4 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)4 EscalationEventDefinition (org.eclipse.bpmn2.EscalationEventDefinition)4 EventDefinition (org.eclipse.bpmn2.EventDefinition)4