Search in sources :

Example 61 with SequenceFlow

use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.

the class DefaultProcessDiagramGenerator method drawActivity.

protected void drawActivity(DefaultProcessDiagramCanvas processDiagramCanvas, BpmnModel bpmnModel, FlowNode flowNode, List<String> highLightedActivities, List<String> highLightedFlows) {
    ActivityDrawInstruction drawInstruction = activityDrawInstructions.get(flowNode.getClass());
    if (drawInstruction != null) {
        drawInstruction.draw(processDiagramCanvas, bpmnModel, flowNode);
        // Gather info on the multi instance marker
        boolean multiInstanceSequential = false;
        boolean multiInstanceParallel = false;
        boolean collapsed = false;
        if (flowNode instanceof Activity) {
            Activity activity = (Activity) flowNode;
            MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics = activity.getLoopCharacteristics();
            if (multiInstanceLoopCharacteristics != null) {
                multiInstanceSequential = multiInstanceLoopCharacteristics.isSequential();
                multiInstanceParallel = !multiInstanceSequential;
            }
        }
        // Gather info on the collapsed marker
        GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(flowNode.getId());
        if (flowNode instanceof SubProcess) {
            collapsed = graphicInfo.getExpanded() != null && !graphicInfo.getExpanded();
        } else if (flowNode instanceof CallActivity) {
            collapsed = true;
        }
        // Actually draw the markers
        processDiagramCanvas.drawActivityMarkers((int) graphicInfo.getX(), (int) graphicInfo.getY(), (int) graphicInfo.getWidth(), (int) graphicInfo.getHeight(), multiInstanceSequential, multiInstanceParallel, collapsed);
        // Draw highlighted activities
        if (highLightedActivities.contains(flowNode.getId())) {
            drawHighLight(processDiagramCanvas, bpmnModel.getGraphicInfo(flowNode.getId()));
        }
    }
    // Outgoing transitions of activity
    for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) {
        boolean highLighted = (highLightedFlows.contains(sequenceFlow.getId()));
        String defaultFlow = null;
        if (flowNode instanceof Activity) {
            defaultFlow = ((Activity) flowNode).getDefaultFlow();
        } else if (flowNode instanceof Gateway) {
            defaultFlow = ((Gateway) flowNode).getDefaultFlow();
        }
        boolean isDefault = false;
        if (defaultFlow != null && defaultFlow.equalsIgnoreCase(sequenceFlow.getId())) {
            isDefault = true;
        }
        boolean drawConditionalIndicator = sequenceFlow.getConditionExpression() != null && !(flowNode instanceof Gateway);
        String sourceRef = sequenceFlow.getSourceRef();
        String targetRef = sequenceFlow.getTargetRef();
        FlowElement sourceElement = bpmnModel.getFlowElement(sourceRef);
        FlowElement targetElement = bpmnModel.getFlowElement(targetRef);
        List<GraphicInfo> graphicInfoList = bpmnModel.getFlowLocationGraphicInfo(sequenceFlow.getId());
        if (graphicInfoList != null && graphicInfoList.size() > 0) {
            graphicInfoList = connectionPerfectionizer(processDiagramCanvas, bpmnModel, sourceElement, targetElement, graphicInfoList);
            int[] xPoints = new int[graphicInfoList.size()];
            int[] yPoints = new int[graphicInfoList.size()];
            for (int i = 1; i < graphicInfoList.size(); i++) {
                GraphicInfo graphicInfo = graphicInfoList.get(i);
                GraphicInfo previousGraphicInfo = graphicInfoList.get(i - 1);
                if (i == 1) {
                    xPoints[0] = (int) previousGraphicInfo.getX();
                    yPoints[0] = (int) previousGraphicInfo.getY();
                }
                xPoints[i] = (int) graphicInfo.getX();
                yPoints[i] = (int) graphicInfo.getY();
            }
            processDiagramCanvas.drawSequenceflow(xPoints, yPoints, drawConditionalIndicator, isDefault, highLighted);
            // Draw sequenceflow label
            GraphicInfo labelGraphicInfo = bpmnModel.getLabelGraphicInfo(sequenceFlow.getId());
            if (labelGraphicInfo != null) {
                processDiagramCanvas.drawLabel(sequenceFlow.getName(), labelGraphicInfo, false);
            }
        }
    }
    // Nested elements
    if (flowNode instanceof FlowElementsContainer) {
        for (FlowElement nestedFlowElement : ((FlowElementsContainer) flowNode).getFlowElements()) {
            if (nestedFlowElement instanceof FlowNode) {
                drawActivity(processDiagramCanvas, bpmnModel, (FlowNode) nestedFlowElement, highLightedActivities, highLightedFlows);
            }
        }
    }
}
Also used : EventSubProcess(org.activiti.bpmn.model.EventSubProcess) SubProcess(org.activiti.bpmn.model.SubProcess) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) CallActivity(org.activiti.bpmn.model.CallActivity) Activity(org.activiti.bpmn.model.Activity) FlowElementsContainer(org.activiti.bpmn.model.FlowElementsContainer) CallActivity(org.activiti.bpmn.model.CallActivity) MultiInstanceLoopCharacteristics(org.activiti.bpmn.model.MultiInstanceLoopCharacteristics) ExclusiveGateway(org.activiti.bpmn.model.ExclusiveGateway) EventGateway(org.activiti.bpmn.model.EventGateway) InclusiveGateway(org.activiti.bpmn.model.InclusiveGateway) ParallelGateway(org.activiti.bpmn.model.ParallelGateway) Gateway(org.activiti.bpmn.model.Gateway) FlowElement(org.activiti.bpmn.model.FlowElement) FlowNode(org.activiti.bpmn.model.FlowNode)

Example 62 with SequenceFlow

use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.

the class DelegateHelper method leaveDelegate.

/**
 * To be used in an {@link ActivityBehavior} or {@link JavaDelegate}: leaves
 * the current activity via one specific sequenceflow.
 */
public static void leaveDelegate(DelegateExecution delegateExecution, String sequenceFlowId) {
    String processDefinitionId = delegateExecution.getProcessDefinitionId();
    Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
    FlowElement flowElement = process.getFlowElement(sequenceFlowId);
    if (flowElement instanceof SequenceFlow) {
        delegateExecution.setCurrentFlowElement(flowElement);
        Context.getAgenda().planTakeOutgoingSequenceFlowsOperation((ExecutionEntity) delegateExecution, false);
    } else {
        throw new ActivitiException(sequenceFlowId + " does not match a sequence flow");
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) FlowElement(org.activiti.bpmn.model.FlowElement) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) Process(org.activiti.bpmn.model.Process)

Example 63 with SequenceFlow

use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.

the class BpmnParseTest method testParseNamespaceInConditionExpressionType.

// @Deployment
// public void testParseDiagramInterchangeElements() {
// 
// // Graphical information is not yet exposed publicly, so we need to do some plumbing
// 
// BpmnModel bpmnModel = repositoryService.getBpmnModel(repositoryService.createProcessDefinitionQuery().singleResult().getId());
// Process process = bpmnModel.getMainProcess();
// 
// // Check if diagram has been created based on Diagram Interchange when  it's not a headless instance
// List<String> resourceNames = repositoryService.getDeploymentResourceNames(repositoryService.createProcessDefinitionQuery().singleResult().getDeploymentId());
// assertThat(resourceNames).hasSize(2);
// 
// assertActivityBounds(bpmnModel, "theStart", 70, 255, 30, 30);
// assertActivityBounds(bpmnModel, "task1", 176, 230, 100, 80);
// assertActivityBounds(bpmnModel, "gateway1", 340, 250, 40, 40);
// assertActivityBounds(bpmnModel, "task2", 445, 138, 100, 80);
// assertActivityBounds(bpmnModel, "gateway2", 620, 250, 40, 40);
// assertActivityBounds(bpmnModel, "task3", 453, 304, 100, 80);
// assertActivityBounds(bpmnModel, "theEnd", 713, 256, 28, 28);
// 
// assertSequenceFlowWayPoints(bpmnModel, "flowStartToTask1", 100, 270, 176, 270);
// assertSequenceFlowWayPoints(bpmnModel, "flowTask1ToGateway1", 276, 270, 340, 270);
// assertSequenceFlowWayPoints(bpmnModel, "flowGateway1ToTask2", 360, 250, 360, 178, 445, 178);
// assertSequenceFlowWayPoints(bpmnModel, "flowGateway1ToTask3", 360, 290, 360, 344, 453, 344);
// assertSequenceFlowWayPoints(bpmnModel, "flowTask2ToGateway2", 545, 178, 640, 178, 640, 250);
// assertSequenceFlowWayPoints(bpmnModel, "flowTask3ToGateway2", 553, 344, 640, 344, 640, 290);
// assertSequenceFlowWayPoints(bpmnModel, "flowGateway2ToEnd", 660, 270, 713, 270);
// 
// }
@Deployment
public void testParseNamespaceInConditionExpressionType() {
    BpmnModel bpmnModel = repositoryService.getBpmnModel(repositoryService.createProcessDefinitionQuery().singleResult().getId());
    Process process = bpmnModel.getProcesses().get(0);
    assertThat(process).isNotNull();
    SequenceFlow sequenceFlow = (SequenceFlow) process.getFlowElement("SequenceFlow_3");
    assertThat(sequenceFlow.getConditionExpression()).isEqualTo("#{approved}");
    sequenceFlow = (SequenceFlow) process.getFlowElement("SequenceFlow_4");
    assertThat(sequenceFlow.getConditionExpression()).isEqualTo("#{!approved}");
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) Process(org.activiti.bpmn.model.Process) BpmnModel(org.activiti.bpmn.model.BpmnModel) Deployment(org.activiti.engine.test.Deployment)

Aggregations

SequenceFlow (org.activiti.bpmn.model.SequenceFlow)63 FlowElement (org.activiti.bpmn.model.FlowElement)34 Process (org.activiti.bpmn.model.Process)23 SubProcess (org.activiti.bpmn.model.SubProcess)19 BpmnModel (org.activiti.bpmn.model.BpmnModel)16 StartEvent (org.activiti.bpmn.model.StartEvent)15 EndEvent (org.activiti.bpmn.model.EndEvent)14 ArrayList (java.util.ArrayList)12 FlowNode (org.activiti.bpmn.model.FlowNode)12 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)11 UserTask (org.activiti.bpmn.model.UserTask)11 Activity (org.activiti.bpmn.model.Activity)10 Gateway (org.activiti.bpmn.model.Gateway)9 HashMap (java.util.HashMap)7 Lane (org.activiti.bpmn.model.Lane)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)6 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)6 ExclusiveGateway (org.activiti.bpmn.model.ExclusiveGateway)6 Pool (org.activiti.bpmn.model.Pool)6