Search in sources :

Example 6 with CallActivity

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

the class TerminateEndEventActivityBehavior method defaultTerminateEndEventBehaviour.

protected void defaultTerminateEndEventBehaviour(DelegateExecution execution, CommandContext commandContext, ExecutionEntityManager executionEntityManager) {
    ExecutionEntity scopeExecutionEntity = executionEntityManager.findFirstScope((ExecutionEntity) execution);
    sendProcessInstanceCancelledEvent(scopeExecutionEntity, execution.getCurrentFlowElement());
    // If the scope is the process instance, we can just terminate it all
    // Special treatment is needed when the terminated activity is a subprocess (embedded/callactivity/..)
    // The subprocess is destroyed, but the execution calling it, continues further on.
    // In case of a multi-instance subprocess, only one instance is terminated, the other instances continue to exist.
    String deleteReason = createDeleteReason(execution.getCurrentActivityId());
    if (scopeExecutionEntity.isProcessInstanceType() && scopeExecutionEntity.getSuperExecutionId() == null) {
        endAllHistoricActivities(scopeExecutionEntity.getId(), deleteReason);
        deleteExecutionEntities(executionEntityManager, scopeExecutionEntity, deleteReason);
        commandContext.getHistoryManager().recordProcessInstanceEnd(scopeExecutionEntity.getId(), deleteReason, execution.getCurrentActivityId());
    } else if (scopeExecutionEntity.getCurrentFlowElement() != null && scopeExecutionEntity.getCurrentFlowElement() instanceof SubProcess) {
        // SubProcess
        SubProcess subProcess = (SubProcess) scopeExecutionEntity.getCurrentFlowElement();
        scopeExecutionEntity.setDeleteReason(deleteReason);
        if (subProcess.hasMultiInstanceLoopCharacteristics()) {
            Context.getAgenda().planDestroyScopeOperation(scopeExecutionEntity);
            MultiInstanceActivityBehavior multiInstanceBehavior = (MultiInstanceActivityBehavior) subProcess.getBehavior();
            multiInstanceBehavior.leave(scopeExecutionEntity);
        } else {
            Context.getAgenda().planDestroyScopeOperation(scopeExecutionEntity);
            ExecutionEntity outgoingFlowExecution = executionEntityManager.createChildExecution(scopeExecutionEntity.getParent());
            outgoingFlowExecution.setCurrentFlowElement(scopeExecutionEntity.getCurrentFlowElement());
            Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(outgoingFlowExecution, true);
        }
    } else if (scopeExecutionEntity.getParentId() == null && scopeExecutionEntity.getSuperExecutionId() != null) {
        // CallActivity
        ExecutionEntity callActivityExecution = scopeExecutionEntity.getSuperExecution();
        CallActivity callActivity = (CallActivity) callActivityExecution.getCurrentFlowElement();
        if (callActivity.hasMultiInstanceLoopCharacteristics()) {
            MultiInstanceActivityBehavior multiInstanceBehavior = (MultiInstanceActivityBehavior) callActivity.getBehavior();
            multiInstanceBehavior.leave(callActivityExecution);
            executionEntityManager.deleteProcessInstanceExecutionEntity(scopeExecutionEntity.getId(), execution.getCurrentFlowElement().getId(), "terminate end event", false, false);
        } else {
            executionEntityManager.deleteProcessInstanceExecutionEntity(scopeExecutionEntity.getId(), execution.getCurrentFlowElement().getId(), "terminate end event", false, false);
            ExecutionEntity superExecutionEntity = executionEntityManager.findById(scopeExecutionEntity.getSuperExecutionId());
            Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(superExecutionEntity, true);
        }
    }
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) CallActivity(org.activiti.bpmn.model.CallActivity)

Example 7 with CallActivity

use of org.activiti.bpmn.model.CallActivity 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, double scaleFactor) {
    ActivityDrawInstruction drawInstruction = activityDrawInstructions.get(flowNode.getClass());
    if (drawInstruction != null) {
        drawInstruction.draw(processDiagramCanvas, bpmnModel, flowNode);
        // Gather info on the multi instance marker
        boolean multiInstanceSequential = false, multiInstanceParallel = false, 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;
        }
        if (scaleFactor == 1.0) {
            // 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, scaleFactor);
            // 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, scaleFactor);
            }
        }
    }
}
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 8 with CallActivity

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

the class CallActivityXMLConverter method writeExtensionChildElements.

@Override
protected boolean writeExtensionChildElements(BaseElement element, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception {
    CallActivity callActivity = (CallActivity) element;
    didWriteExtensionStartElement = writeIOParameters(ELEMENT_CALL_ACTIVITY_IN_PARAMETERS, callActivity.getInParameters(), didWriteExtensionStartElement, xtw);
    didWriteExtensionStartElement = writeIOParameters(ELEMENT_CALL_ACTIVITY_OUT_PARAMETERS, callActivity.getOutParameters(), didWriteExtensionStartElement, xtw);
    return didWriteExtensionStartElement;
}
Also used : CallActivity(org.activiti.bpmn.model.CallActivity)

Example 9 with CallActivity

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

the class CallActivityConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("callactivity");
    assertThat(flowElement).isNotNull();
    assertThat(flowElement).isInstanceOf(CallActivity.class);
    CallActivity callActivity = (CallActivity) flowElement;
    assertThat(callActivity.getId()).isEqualTo("callactivity");
    assertThat(callActivity.getName()).isEqualTo("Call activity");
    assertThat(callActivity.getCalledElement()).isEqualTo("processId");
    List<IOParameter> parameters = callActivity.getInParameters();
    assertThat(parameters).hasSize(2);
    IOParameter parameter = parameters.get(0);
    assertThat(parameter.getSource()).isEqualTo("test");
    assertThat(parameter.getTarget()).isEqualTo("test");
    parameter = parameters.get(1);
    assertThat(parameter.getSourceExpression()).isEqualTo("${test}");
    assertThat(parameter.getTarget()).isEqualTo("test");
    parameters = callActivity.getOutParameters();
    assertThat(parameters).hasSize(1);
    parameter = parameters.get(0);
    assertThat(parameter.getSource()).isEqualTo("test");
    assertThat(parameter.getTarget()).isEqualTo("test");
}
Also used : IOParameter(org.activiti.bpmn.model.IOParameter) FlowElement(org.activiti.bpmn.model.FlowElement) CallActivity(org.activiti.bpmn.model.CallActivity)

Example 10 with CallActivity

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

the class CallActivityConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("callactivity", true);
    assertThat(flowElement).isNotNull();
    assertThat(flowElement).isInstanceOf(CallActivity.class);
    CallActivity callActivity = (CallActivity) flowElement;
    assertThat(callActivity.getId()).isEqualTo("callactivity");
    assertThat(callActivity.getName()).isEqualTo("Call activity");
    assertThat(callActivity.getCalledElement()).isEqualTo("processId");
    List<IOParameter> parameters = callActivity.getInParameters();
    assertThat(parameters).hasSize(2);
    IOParameter parameter = parameters.get(0);
    assertThat(parameter.getSource()).isEqualTo("test");
    assertThat(parameter.getTarget()).isEqualTo("test");
    parameter = parameters.get(1);
    assertThat(parameter.getSourceExpression()).isEqualTo("${test}");
    assertThat(parameter.getTarget()).isEqualTo("test");
    parameters = callActivity.getOutParameters();
    assertThat(parameters).hasSize(1);
    parameter = parameters.get(0);
    assertThat(parameter.getSource()).isEqualTo("test");
    assertThat(parameter.getTarget()).isEqualTo("test");
}
Also used : IOParameter(org.activiti.bpmn.model.IOParameter) FlowElement(org.activiti.bpmn.model.FlowElement) CallActivity(org.activiti.bpmn.model.CallActivity)

Aggregations

CallActivity (org.activiti.bpmn.model.CallActivity)14 FlowElement (org.activiti.bpmn.model.FlowElement)7 SubProcess (org.activiti.bpmn.model.SubProcess)5 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)4 Activity (org.activiti.bpmn.model.Activity)3 Gateway (org.activiti.bpmn.model.Gateway)3 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)3 ExecutionEntityManager (org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)3 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)2 EventGateway (org.activiti.bpmn.model.EventGateway)2 EventSubProcess (org.activiti.bpmn.model.EventSubProcess)2 ExclusiveGateway (org.activiti.bpmn.model.ExclusiveGateway)2 FlowElementsContainer (org.activiti.bpmn.model.FlowElementsContainer)2 FlowNode (org.activiti.bpmn.model.FlowNode)2 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)2 IOParameter (org.activiti.bpmn.model.IOParameter)2 InclusiveGateway (org.activiti.bpmn.model.InclusiveGateway)2 MultiInstanceLoopCharacteristics (org.activiti.bpmn.model.MultiInstanceLoopCharacteristics)2 ParallelGateway (org.activiti.bpmn.model.ParallelGateway)2 com.mxgraph.view.mxGraph (com.mxgraph.view.mxGraph)1