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;
}
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);
}
}
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);
}
}
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();
}
}
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);
}
Aggregations