Search in sources :

Example 41 with ItemDefinition

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

the class Bpmn2JsonUnmarshaller method revisitSendReceiveTasks.

public void revisitSendReceiveTasks(Definitions def) {
    List<Message> toAddMessages = new ArrayList<Message>();
    List<ItemDefinition> toAddItemDefinitions = new ArrayList<ItemDefinition>();
    List<RootElement> rootElements = def.getRootElements();
    for (RootElement root : rootElements) {
        if (root instanceof Process) {
            setSendReceiveTasksInfo((Process) root, def, toAddMessages, toAddItemDefinitions);
        }
    }
    for (ItemDefinition idef : toAddItemDefinitions) {
        def.getRootElements().add(idef);
    }
    for (Message msg : toAddMessages) {
        def.getRootElements().add(msg);
    }
}
Also used : RootElement(org.eclipse.bpmn2.RootElement) Message(org.eclipse.bpmn2.Message) ArrayList(java.util.ArrayList) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) SubProcess(org.eclipse.bpmn2.SubProcess) Process(org.eclipse.bpmn2.Process)

Example 42 with ItemDefinition

use of org.eclipse.bpmn2.ItemDefinition 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 43 with ItemDefinition

use of org.eclipse.bpmn2.ItemDefinition 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)

Example 44 with ItemDefinition

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

the class BPMNDiagramMarshallerTest method validateDataInputOrOutput.

private void validateDataInputOrOutput(ItemAwareElement itemAwareElement, String idSuffix, String dataType, String itemSubjectRefSuffix) {
    assertNotNull(itemAwareElement);
    assertTrue(itemAwareElement.getId().endsWith(idSuffix));
    ItemDefinition itemDefinition = itemAwareElement.getItemSubjectRef();
    assertNotNull(itemDefinition);
    assertTrue(itemDefinition.getStructureRef().equals(dataType));
    assertTrue(itemDefinition.getId().endsWith(itemSubjectRefSuffix));
}
Also used : ItemDefinition(org.eclipse.bpmn2.ItemDefinition)

Example 45 with ItemDefinition

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

the class CustomInput method typedefInput.

private ItemDefinition typedefInput(String name, String type) {
    ItemDefinition typeDef = bpmn2.createItemDefinition();
    typeDef.setId(Ids.dataInputItem(element.getId(), name));
    typeDef.setStructureRef(type);
    return typeDef;
}
Also used : ItemDefinition(org.eclipse.bpmn2.ItemDefinition)

Aggregations

ItemDefinition (org.kie.dmn.model.v1_1.ItemDefinition)22 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)21 ArrayList (java.util.ArrayList)17 RootElement (org.eclipse.bpmn2.RootElement)17 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)13 Process (org.eclipse.bpmn2.Process)13 SubProcess (org.eclipse.bpmn2.SubProcess)13 Entry (java.util.Map.Entry)11 FlowElement (org.eclipse.bpmn2.FlowElement)11 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)11 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)11 Message (org.eclipse.bpmn2.Message)10 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)9 Test (org.junit.Test)9 List (java.util.List)8 CallActivity (org.eclipse.bpmn2.CallActivity)7 DataInput (org.eclipse.bpmn2.DataInput)7 QName (javax.xml.namespace.QName)6 Activity (org.eclipse.bpmn2.Activity)6 DataOutput (org.eclipse.bpmn2.DataOutput)6