Search in sources :

Example 26 with FlowElement

use of org.osate.aadl2.FlowElement in project droolsjbpm-integration by kiegroup.

the class BPMN2SimulationDataProvider method getProcessDataForNode.

public Map<String, Object> getProcessDataForNode(Node node) {
    Map<String, Object> nodeProperties = new HashMap<String, Object>();
    FlowElement flowElement = null;
    List<RootElement> rootElements = def.getRootElements();
    for (RootElement root : rootElements) {
        if (root instanceof Process) {
            flowElement = findElementInContainer((FlowElementsContainer) root, (String) node.getMetaData().get("UniqueId"));
            break;
        }
    }
    if (flowElement != null) {
        if (flowElement instanceof ScriptTask) {
            nodeProperties.put("node.type", "ScriptTask");
        } else if (flowElement instanceof BusinessRuleTask) {
            nodeProperties.put("node.type", "BusinessRuleTask");
        } else if (flowElement instanceof UserTask) {
            nodeProperties.put("node.type", "UserTask");
        } else if (flowElement instanceof SendTask) {
            nodeProperties.put("node.type", "SendTask");
        } else if (flowElement instanceof ServiceTask) {
            nodeProperties.put("node.type", "ServiceTask");
        } else if (flowElement instanceof ReceiveTask) {
            nodeProperties.put("node.type", "ReceiveTask");
        } else if (flowElement instanceof ManualTask) {
            nodeProperties.put("node.type", "ManualTask");
        } else if (flowElement instanceof InclusiveGateway) {
            nodeProperties.put("node.type", "InclusiveGateway");
        } else if (flowElement instanceof ExclusiveGateway) {
            nodeProperties.put("node.type", "ExclusiveGateway");
        } else if (flowElement instanceof ParallelGateway) {
            nodeProperties.put("node.type", "ParallelGateway");
        } else if (flowElement instanceof BoundaryEvent) {
            BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
            List<EventDefinition> defs = boundaryEvent.getEventDefinitions();
            String eventDef = "";
            if (defs != null && !defs.isEmpty()) {
                eventDef = getEventDefinitionAsString(defs.get(0));
            }
            nodeProperties.put("node.type", "BoundaryEvent:" + eventDef);
        } else if (flowElement instanceof IntermediateCatchEvent) {
            IntermediateCatchEvent boundaryEvent = (IntermediateCatchEvent) flowElement;
            List<EventDefinition> defs = boundaryEvent.getEventDefinitions();
            String eventDef = "";
            if (defs != null && !defs.isEmpty()) {
                eventDef = getEventDefinitionAsString(defs.get(0));
            }
            nodeProperties.put("node.type", "IntermediateCatchEvent:" + eventDef);
        } else if (flowElement instanceof IntermediateThrowEvent) {
            IntermediateThrowEvent boundaryEvent = (IntermediateThrowEvent) flowElement;
            List<EventDefinition> defs = boundaryEvent.getEventDefinitions();
            String eventDef = "";
            if (defs != null && !defs.isEmpty()) {
                eventDef = getEventDefinitionAsString(defs.get(0));
            }
            nodeProperties.put("node.type", "IntermediateThrowEvent:" + eventDef);
        } else if (flowElement instanceof StartEvent) {
            StartEvent boundaryEvent = (StartEvent) flowElement;
            List<EventDefinition> defs = boundaryEvent.getEventDefinitions();
            String eventDef = "";
            if (defs != null && !defs.isEmpty()) {
                eventDef = getEventDefinitionAsString(defs.get(0));
            }
            nodeProperties.put("node.type", "StartEvent:" + eventDef);
        } else if (flowElement instanceof EndEvent) {
            EndEvent boundaryEvent = (EndEvent) flowElement;
            List<EventDefinition> defs = boundaryEvent.getEventDefinitions();
            String eventDef = "";
            if (defs != null && !defs.isEmpty()) {
                eventDef = getEventDefinitionAsString(defs.get(0));
            }
            nodeProperties.put("node.type", "EndEvent:" + eventDef);
        }
    } else {
        nodeProperties.put("node.type", "unknown");
    }
    return nodeProperties;
}
Also used : ServiceTask(org.eclipse.bpmn2.ServiceTask) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) HashMap(java.util.HashMap) BusinessRuleTask(org.eclipse.bpmn2.BusinessRuleTask) Process(org.eclipse.bpmn2.Process) EventDefinition(org.eclipse.bpmn2.EventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) LinkEventDefinition(org.eclipse.bpmn2.LinkEventDefinition) CancelEventDefinition(org.eclipse.bpmn2.CancelEventDefinition) ManualTask(org.eclipse.bpmn2.ManualTask) InclusiveGateway(org.eclipse.bpmn2.InclusiveGateway) StartEvent(org.eclipse.bpmn2.StartEvent) EndEvent(org.eclipse.bpmn2.EndEvent) List(java.util.List) ReceiveTask(org.eclipse.bpmn2.ReceiveTask) IntermediateCatchEvent(org.eclipse.bpmn2.IntermediateCatchEvent) UserTask(org.eclipse.bpmn2.UserTask) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) IntermediateThrowEvent(org.eclipse.bpmn2.IntermediateThrowEvent) ExclusiveGateway(org.eclipse.bpmn2.ExclusiveGateway) RootElement(org.eclipse.bpmn2.RootElement) ScriptTask(org.eclipse.bpmn2.ScriptTask) FlowElement(org.eclipse.bpmn2.FlowElement) ParallelGateway(org.eclipse.bpmn2.ParallelGateway) SendTask(org.eclipse.bpmn2.SendTask)

Example 27 with FlowElement

use of org.osate.aadl2.FlowElement in project droolsjbpm-integration by kiegroup.

the class ActivityElementHandler method handleAllPaths.

protected void handleAllPaths(List<SequenceFlow> outgoing, PathContextManager manager) {
    PathContext context = manager.getContextFromStack();
    context.setCanBeFinished(false);
    int counter = 0;
    for (SequenceFlow seqFlow : outgoing) {
        counter++;
        FlowElement target = seqFlow.getTargetRef();
        if (counter == outgoing.size()) {
            context.setCanBeFinished(true);
        }
        manager.addToPath(seqFlow, context);
        super.handle(target, manager);
    }
}
Also used : PathContext(org.jbpm.simulation.PathContext) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) FlowElement(org.eclipse.bpmn2.FlowElement)

Example 28 with FlowElement

use of org.osate.aadl2.FlowElement in project droolsjbpm-integration by kiegroup.

the class ActivityElementHandler method handleSeparatePaths.

protected void handleSeparatePaths(List<SequenceFlow> outgoing, PathContextManager manager, BoundaryEvent bEvent) {
    List<PathContext> locked = new ArrayList<PathContext>();
    PathContext context = manager.getContextFromStack();
    for (SequenceFlow seqFlow : outgoing) {
        FlowElement target = seqFlow.getTargetRef();
        PathContext separatePath = manager.cloneGiven(context);
        // replace boundary event with a wrapper if sequence flow does not go out if it
        if (!seqFlow.getSourceRef().equals(bEvent)) {
            separatePath.removePathElement(bEvent);
            separatePath.addPathElement(new WrappedBoundaryEvent(bEvent));
        }
        manager.addToPath(seqFlow, separatePath);
        super.handle(target, manager);
        separatePath.setLocked(true);
        locked.add(separatePath);
    }
    // unlock
    for (PathContext ctx : locked) {
        ctx.setLocked(false);
    }
}
Also used : PathContext(org.jbpm.simulation.PathContext) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) FlowElement(org.eclipse.bpmn2.FlowElement) ArrayList(java.util.ArrayList) WrappedBoundaryEvent(org.jbpm.simulation.util.WrappedBoundaryEvent)

Example 29 with FlowElement

use of org.osate.aadl2.FlowElement in project droolsjbpm-integration by kiegroup.

the class GatewayElementHandler method handleParallelGateway.

protected void handleParallelGateway(List<SequenceFlow> outgoing) {
    PathContext context = manager.getContextFromStack();
    boolean canBeFinished = context.isCanBeFinished();
    context.setCanBeFinished(false);
    manager.addAllToPath(outgoing, context);
    int counter = 0;
    for (SequenceFlow seqFlow : outgoing) {
        counter++;
        FlowElement target = seqFlow.getTargetRef();
        if (counter == outgoing.size()) {
            if (manager.getPaths().size() == 1) {
                context.setCanBeFinished(canBeFinished);
            } else {
                Iterator<PathContext> it = manager.getPaths().iterator();
                while (it.hasNext()) {
                    PathContext pathContext = (PathContext) it.next();
                    if (pathContext.getType() == Type.ACTIVE) {
                        pathContext.setCanBeFinished(canBeFinished);
                    }
                }
            }
        }
        super.handle(target, manager);
    }
    // finalize paths if there are any to cover scenario when there was not converging parallel gateway
    if (canBeFinished) {
        for (SequenceFlow seqFlow : outgoing) {
            manager.addToPath(seqFlow, context);
            manager.addToPath(seqFlow.getTargetRef(), context);
        }
        manager.finalizePathOnLeave();
    }
}
Also used : PathContext(org.jbpm.simulation.PathContext) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) FlowElement(org.eclipse.bpmn2.FlowElement)

Example 30 with FlowElement

use of org.osate.aadl2.FlowElement in project kie-wb-common by kiegroup.

the class IntermediateCompensationEventPostConverterTest method testProcessWhenOutEdgeExists.

@Test
@SuppressWarnings("unchecked")
public void testProcessWhenOutEdgeExists() {
    String uuid = "UUID";
    Edge edge = mock(Edge.class);
    Node targetNode = mock(Node.class);
    when(targetNode.getUUID()).thenReturn(uuid);
    List outEdges = new ArrayList<>();
    outEdges.add(edge);
    when(node.getOutEdges()).thenReturn(outEdges);
    Activity activity = mock(Activity.class);
    when(activity.getId()).thenReturn(uuid);
    when(edge.getTargetNode()).thenReturn(targetNode);
    List<FlowElement> flowElements = Collections.singletonList(activity);
    when(process.getFlowElements()).thenReturn(flowElements);
    converter.process(processWriter, nodeWriter, (Node) node);
    verify(activity).setIsForCompensation(true);
}
Also used : FlowElement(org.eclipse.bpmn2.FlowElement) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) Activity(org.eclipse.bpmn2.Activity) ArrayList(java.util.ArrayList) List(java.util.List) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Aggregations

FlowElement (org.eclipse.bpmn2.FlowElement)57 SubProcess (org.eclipse.bpmn2.SubProcess)27 ArrayList (java.util.ArrayList)26 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)22 Process (org.eclipse.bpmn2.Process)21 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)19 RootElement (org.eclipse.bpmn2.RootElement)19 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)16 Activity (org.eclipse.bpmn2.Activity)12 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)12 Entry (java.util.Map.Entry)11 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)11 List (java.util.List)10 EventDefinition (org.eclipse.bpmn2.EventDefinition)10 BoundaryEvent (org.eclipse.bpmn2.BoundaryEvent)9 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)9 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)9 MessageEventDefinition (org.eclipse.bpmn2.MessageEventDefinition)9 SignalEventDefinition (org.eclipse.bpmn2.SignalEventDefinition)9 CallActivity (org.eclipse.bpmn2.CallActivity)8