org.flowable.bpmn.model.FlowElement Java Examples

The following examples show how to use org.flowable.bpmn.model.FlowElement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TerminateEndEventActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void deleteExecutionEntities(ExecutionEntityManager executionEntityManager, ExecutionEntity rootExecutionEntity,
                ExecutionEntity executionAtTerminateEndEvent, String deleteReason) {

    FlowElement terminateEndEvent = executionAtTerminateEndEvent.getCurrentFlowElement();
    
    List<ExecutionEntity> childExecutions = executionEntityManager.collectChildren(rootExecutionEntity);
    for (ExecutionEntity childExecution : childExecutions) {
        if (childExecution.isProcessInstanceType()) {
            sendProcessInstanceCompletedEvent(childExecution, terminateEndEvent);
        }
    }
    
    CommandContextUtil.getExecutionEntityManager().deleteChildExecutions(rootExecutionEntity, null, null, deleteReason, true, terminateEndEvent);
    sendProcessInstanceCompletedEvent(rootExecutionEntity, terminateEndEvent);
    executionEntityManager.deleteExecutionAndRelatedData(rootExecutionEntity, deleteReason, false);
}
 
Example #2
Source File: InjectParallelEmbeddedSubProcessCmd.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateExecutions(CommandContext commandContext, ProcessDefinitionEntity processDefinitionEntity,
                                ExecutionEntity processInstance, List<ExecutionEntity> childExecutions) {

    ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext);

    TaskEntity taskEntity = CommandContextUtil.getTaskService().getTask(taskId);
    ExecutionEntity executionAtTask = executionEntityManager.findById(taskEntity.getExecutionId());
    
    BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionEntity.getId());
    FlowElement taskElement = bpmnModel.getFlowElement(executionAtTask.getCurrentActivityId());
    FlowElement subProcessElement = bpmnModel.getFlowElement(((SubProcess) taskElement.getParentContainer()).getId());
    ExecutionEntity subProcessExecution = executionEntityManager.createChildExecution(executionAtTask.getParent());
    subProcessExecution.setScope(true);
    subProcessExecution.setCurrentFlowElement(subProcessElement);
    CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordActivityStart(subProcessExecution);
    
    executionAtTask.setParent(subProcessExecution);
   
    ExecutionEntity execution = executionEntityManager.createChildExecution(subProcessExecution);
    FlowElement newSubProcess = bpmnModel.getMainProcess().getFlowElement(dynamicEmbeddedSubProcessBuilder.getDynamicSubProcessId(), true);
    execution.setCurrentFlowElement(newSubProcess);

    CommandContextUtil.getAgenda().planContinueProcessOperation(execution);
}
 
Example #3
Source File: MultiInstanceActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void executeCompensationBoundaryEvents(FlowElement flowElement, DelegateExecution execution) {

        // Execute compensation boundary events
        Collection<BoundaryEvent> boundaryEvents = findBoundaryEventsForFlowNode(execution.getProcessDefinitionId(), flowElement);
        if (CollectionUtil.isNotEmpty(boundaryEvents)) {

            // The parent execution becomes a scope, and a child execution is created for each of the boundary events
            for (BoundaryEvent boundaryEvent : boundaryEvents) {

                if (CollectionUtil.isEmpty(boundaryEvent.getEventDefinitions())) {
                    continue;
                }

                if (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition) {
                    ExecutionEntity childExecutionEntity = CommandContextUtil.getExecutionEntityManager()
                            .createChildExecution((ExecutionEntity) execution);
                    childExecutionEntity.setParentId(execution.getId());
                    childExecutionEntity.setCurrentFlowElement(boundaryEvent);
                    childExecutionEntity.setScope(false);

                    ActivityBehavior boundaryEventBehavior = ((ActivityBehavior) boundaryEvent.getBehavior());
                    boundaryEventBehavior.execute(childExecutionEntity);
                }
            }
        }
    }
 
Example #4
Source File: ModelImageService.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void calculateWidthForFlowElements(Collection<FlowElement> elementList, BpmnModel bpmnModel, GraphicInfo diagramInfo) {
    for (FlowElement flowElement : elementList) {
        List<GraphicInfo> graphicInfoList = new ArrayList<>();
        if (flowElement instanceof SequenceFlow) {
            List<GraphicInfo> flowGraphics = bpmnModel.getFlowLocationGraphicInfo(flowElement.getId());
            if (flowGraphics != null && flowGraphics.size() > 0) {
                graphicInfoList.addAll(flowGraphics);
            }
        } else {
            GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(flowElement.getId());
            if (graphicInfo != null) {
                graphicInfoList.add(graphicInfo);
            }
        }

        processGraphicInfoList(graphicInfoList, diagramInfo);
    }
}
 
Example #5
Source File: IntermediateCatchEventActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected EventGateway getPrecedingEventBasedGateway(DelegateExecution execution) {
    FlowElement currentFlowElement = execution.getCurrentFlowElement();
    if (currentFlowElement instanceof IntermediateCatchEvent) {
        IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) currentFlowElement;
        List<SequenceFlow> incomingSequenceFlow = intermediateCatchEvent.getIncomingFlows();

        // If behind an event based gateway, there is only one incoming sequence flow that originates from said gateway
        if (incomingSequenceFlow != null && incomingSequenceFlow.size() == 1) {
            SequenceFlow sequenceFlow = incomingSequenceFlow.get(0);
            FlowElement sourceFlowElement = sequenceFlow.getSourceFlowElement();
            if (sourceFlowElement instanceof EventGateway) {
                return (EventGateway) sourceFlowElement;
            }
        }

    }
    return null;
}
 
Example #6
Source File: ShellTaskConverterTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("servicetask", true);
    assertThat(flowElement).isNotNull();
    assertThat(flowElement).isInstanceOf(ServiceTask.class);
    assertThat(flowElement.getId()).isEqualTo("servicetask");
    ServiceTask serviceTask = (ServiceTask) flowElement;
    assertThat(serviceTask.getId()).isEqualTo("servicetask");
    assertThat(serviceTask.getName()).isEqualTo("Shell");

    List<FieldExtension> fields = serviceTask.getFieldExtensions();
    Collection<String> expectedField = new HashSet<>(EXPECTED_FIELDS);
    for (FieldExtension field : fields) {
        assertThat(expectedField.contains(field.getFieldName())).isTrue();
        assertThat(expectedField.contains(field.getStringValue())).isTrue();
        assertThat(field.getStringValue()).isEqualTo(field.getFieldName());
        expectedField.remove(field.getFieldName());
    }
    assertThat(expectedField).isEmpty();
}
 
Example #7
Source File: MultiInstanceActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void cleanupMiRoot(DelegateExecution execution) {
    // Delete multi instance root and all child executions.
    // Create a fresh execution to continue
    
    ExecutionEntity multiInstanceRootExecution = (ExecutionEntity) getMultiInstanceRootExecution(execution);
    FlowElement flowElement = multiInstanceRootExecution.getCurrentFlowElement();
    ExecutionEntity parentExecution = multiInstanceRootExecution.getParent();
    
    ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager();
    Collection<String> executionIdsNotToSendCancelledEventsFor = execution.isMultiInstanceRoot() ? null : Collections.singletonList(execution.getId());
    executionEntityManager.deleteChildExecutions(multiInstanceRootExecution, null, executionIdsNotToSendCancelledEventsFor, DELETE_REASON_END, true, flowElement);
    executionEntityManager.deleteRelatedDataForExecution(multiInstanceRootExecution, DELETE_REASON_END);
    executionEntityManager.delete(multiInstanceRootExecution);

    ExecutionEntity newExecution = executionEntityManager.createChildExecution(parentExecution);
    newExecution.setCurrentFlowElement(flowElement);
    super.leave(newExecution);
}
 
Example #8
Source File: BpmnLoggingSessionUtil.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public static void addLoggingData(String type, String message, DelegateExecution execution) {
    FlowElement flowElement = execution.getCurrentFlowElement();
    String activityId = null;
    String activityName = null;
    String activityType = null;
    String activitySubType = null;
    if (flowElement != null) {
        activityId = flowElement.getId();
        activityName = flowElement.getName();
        activityType = flowElement.getClass().getSimpleName();
        activitySubType = getActivitySubType(flowElement);
    }
    
    ObjectNode loggingNode = LoggingSessionUtil.fillLoggingData(message, execution.getProcessInstanceId(), execution.getId(), 
                    ScopeTypes.BPMN, execution.getProcessDefinitionId(), activityId, activityName, activityType, activitySubType);
    fillScopeDefinitionInfo(execution.getProcessDefinitionId(), loggingNode);
    LoggingSessionUtil.addLoggingData(type, loggingNode);
}
 
Example #9
Source File: EventSubProcessConverterTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("task1");
    assertThat(flowElement).isNotNull();
    assertThat(flowElement).isInstanceOf(UserTask.class);
    assertThat(flowElement.getId()).isEqualTo("task1");

    FlowElement eventSubProcessElement = model.getMainProcess().getFlowElement("eventSubProcess");
    assertThat(eventSubProcessElement).isNotNull();
    assertThat(eventSubProcessElement).isInstanceOf(EventSubProcess.class);
    EventSubProcess eventSubProcess = (EventSubProcess) eventSubProcessElement;
    assertThat(eventSubProcess.getId()).isEqualTo("eventSubProcess");

    FlowElement signalStartEvent = eventSubProcess.getFlowElement("eventSignalStart");
    assertThat(signalStartEvent).isNotNull();
    assertThat(signalStartEvent).isInstanceOf(StartEvent.class);
    StartEvent startEvent = (StartEvent) signalStartEvent;
    assertThat(startEvent.getId()).isEqualTo("eventSignalStart");
    assertThat(startEvent.isInterrupting()).isTrue();
    assertThat(startEvent.getSubProcess().getId()).isEqualTo(eventSubProcess.getId());
}
 
Example #10
Source File: BPMNDIExport.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected static void createBpmnShape(BpmnModel model, String elementId, XMLStreamWriter xtw) throws Exception {
    xtw.writeStartElement(BPMNDI_PREFIX, ELEMENT_DI_SHAPE, BPMNDI_NAMESPACE);
    xtw.writeAttribute(ATTRIBUTE_DI_BPMNELEMENT, elementId);
    xtw.writeAttribute(ATTRIBUTE_ID, "BPMNShape_" + elementId);

    GraphicInfo graphicInfo = model.getGraphicInfo(elementId);
    FlowElement flowElement = model.getFlowElement(elementId);
    if (flowElement instanceof SubProcess && graphicInfo.getExpanded() != null) {
        xtw.writeAttribute(ATTRIBUTE_DI_IS_EXPANDED, String.valueOf(graphicInfo.getExpanded()));
    }

    xtw.writeStartElement(OMGDC_PREFIX, ELEMENT_DI_BOUNDS, OMGDC_NAMESPACE);
    xtw.writeAttribute(ATTRIBUTE_DI_HEIGHT, String.valueOf(graphicInfo.getHeight()));
    xtw.writeAttribute(ATTRIBUTE_DI_WIDTH, String.valueOf(graphicInfo.getWidth()));
    xtw.writeAttribute(ATTRIBUTE_DI_X, String.valueOf(graphicInfo.getX()));
    xtw.writeAttribute(ATTRIBUTE_DI_Y, String.valueOf(graphicInfo.getY()));
    xtw.writeEndElement();

    xtw.writeEndElement();
}
 
Example #11
Source File: BpmnParse.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public void createBPMNEdge(String key, List<GraphicInfo> graphicList) {
    FlowElement flowElement = bpmnModel.getFlowElement(key);
    if (flowElement != null && sequenceFlows.containsKey(key)) {
        TransitionImpl sequenceFlow = sequenceFlows.get(key);
        List<Integer> waypoints = new ArrayList<>();
        for (GraphicInfo waypointInfo : graphicList) {
            waypoints.add((int) waypointInfo.getX());
            waypoints.add((int) waypointInfo.getY());
        }
        sequenceFlow.setWaypoints(waypoints);
    } else if (bpmnModel.getArtifact(key) != null) {
        // it's an association, so nothing to do
    } else {
        LOGGER.warn("Invalid reference in 'bpmnElement' attribute, sequenceFlow {} not found", key);
    }
}
 
Example #12
Source File: TakeOutgoingSequenceFlowsOperation.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    FlowElement currentFlowElement = getCurrentFlowElement(execution);

    // Compensation check
    if ((currentFlowElement instanceof Activity) && ((Activity) currentFlowElement).isForCompensation()) {

        /*
         * If the current flow element is part of a compensation, we don't always want to follow the regular rules of leaving an activity. More specifically, if there are no outgoing sequenceflow,
         * we simply must stop the execution there and don't go up in the scopes as we usually do to find the outgoing sequenceflow
         */

        cleanupCompensation();
        return;
    }

    // When leaving the current activity, we need to delete any related execution (eg active boundary events)
    cleanupExecutions(currentFlowElement);

    if (currentFlowElement instanceof FlowNode) {
        handleFlowNode((FlowNode) currentFlowElement);
    } else if (currentFlowElement instanceof SequenceFlow) {
        handleSequenceFlow();
    }
}
 
Example #13
Source File: SubProcessConverterAutoLayoutTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
    assertThat(flowElement)
            .isInstanceOfSatisfying(StartEvent.class, startEvent -> {
                assertThat(startEvent.getId()).isEqualTo("start1");
            });

    flowElement = model.getMainProcess().getFlowElement("userTask1");
    assertThat(flowElement)
            .isInstanceOfSatisfying(UserTask.class, userTask -> {
                assertThat(userTask.getId()).isEqualTo("userTask1");
                assertThat(userTask.getCandidateUsers()).hasSize(1);
                assertThat(userTask.getCandidateGroups()).hasSize(1);
            });

    flowElement = model.getMainProcess().getFlowElement("subprocess1");
    assertThat(flowElement)
            .isInstanceOfSatisfying(SubProcess.class, subProcess -> {
                assertThat(subProcess.getId()).isEqualTo("subprocess1");
                assertThat(subProcess.getFlowElements()).hasSize(6);
                assertThat(subProcess.getDataObjects())
                        .extracting(ValuedDataObject::getName, ValuedDataObject::getValue)
                        .containsExactly(tuple("SubTest", "Testing"));
                assertThat(subProcess.getDataObjects().get(0).getItemSubjectRef().getStructureRef()).isEqualTo("xsd:string");
            });
}
 
Example #14
Source File: ScopedConverterTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("outerSubProcess");
    assertThat(flowElement)
            .isInstanceOfSatisfying(SubProcess.class, outerProcess -> {
                assertThat(outerProcess.getId()).isEqualTo("outerSubProcess");
                assertThat(outerProcess.getBoundaryEvents())
                        .extracting(BoundaryEvent::getId)
                        .containsExactly("outerBoundaryEvent");
                assertThat(outerProcess.getFlowElement("innerSubProcess"))
                        .isInstanceOfSatisfying(SubProcess.class, innerProcess -> {
                            assertThat(innerProcess.getId()).isEqualTo("innerSubProcess");
                            assertThat(innerProcess.getBoundaryEvents())
                                    .extracting(BoundaryEvent::getId)
                                    .containsExactly("innerBoundaryEvent");
                            assertThat(innerProcess.getFlowElement("usertask"))
                                    .isInstanceOfSatisfying(UserTask.class, userTask -> {
                                        assertThat(userTask.getBoundaryEvents())
                                                .extracting(BoundaryEvent::getId)
                                                .containsExactly("taskBoundaryEvent");
                                    });
                        });
            });
}
 
Example #15
Source File: HttpServiceTaskConverterTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("servicetask");
    assertThat(flowElement)
            .isInstanceOfSatisfying(HttpServiceTask.class, httpServiceTask -> {
                assertThat(httpServiceTask.getId()).isEqualTo("servicetask");
                assertThat(httpServiceTask.getName()).isEqualTo("Service task");
                assertThat(httpServiceTask.getFieldExtensions())
                        .extracting(FieldExtension::getFieldName, FieldExtension::getStringValue, FieldExtension::getExpression)
                        .containsExactly(
                                tuple("url", "test", null),
                                tuple("method", null, "GET")
                        );
                assertThat(httpServiceTask.getHttpRequestHandler())
                        .extracting(FlowableHttpRequestHandler::getImplementationType, FlowableHttpRequestHandler::getImplementation)
                        .containsExactly(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION, "${delegateExpression}");
                assertThat(httpServiceTask.getHttpResponseHandler())
                        .extracting(FlowableHttpResponseHandler::getImplementationType, FlowableHttpResponseHandler::getImplementation)
                        .containsExactly(ImplementationType.IMPLEMENTATION_TYPE_CLASS, "org.flowable.Test");
            });
}
 
Example #16
Source File: FormHandlerHelper.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public StartFormHandler getStartFormHandler(CommandContext commandContext, ProcessDefinition processDefinition) {
    StartFormHandler startFormHandler = new DefaultStartFormHandler();
    org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinition.getId());

    FlowElement initialFlowElement = process.getInitialFlowElement();
    if (initialFlowElement instanceof StartEvent) {

        StartEvent startEvent = (StartEvent) initialFlowElement;

        List<FormProperty> formProperties = startEvent.getFormProperties();
        String formKey = startEvent.getFormKey();
        DeploymentEntity deploymentEntity = CommandContextUtil.getDeploymentEntityManager(commandContext).findById(processDefinition.getDeploymentId());

        startFormHandler.parseConfiguration(formProperties, formKey, deploymentEntity, processDefinition);
        return startFormHandler;
    }

    return null;

}
 
Example #17
Source File: CatchEventJsonConverter.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap,
    BpmnJsonConverterContext converterContext) {
    IntermediateCatchEvent catchEvent = new IntermediateCatchEvent();
    String stencilId = BpmnJsonConverterUtil.getStencilId(elementNode);
    if (STENCIL_EVENT_CATCH_TIMER.equals(stencilId)) {
        convertJsonToTimerDefinition(elementNode, catchEvent);
    } else if (STENCIL_EVENT_CATCH_MESSAGE.equals(stencilId)) {
        convertJsonToMessageDefinition(elementNode, catchEvent);
    } else if (STENCIL_EVENT_CATCH_SIGNAL.equals(stencilId)) {
        convertJsonToSignalDefinition(elementNode, catchEvent);
    } else if (STENCIL_EVENT_CATCH_CONDITIONAL.equals(stencilId)) {
        convertJsonToConditionalDefinition(elementNode, catchEvent);
    }  else if (STENCIL_EVENT_CATCH_EVENT_REGISTRY.equals(stencilId)) {
        addReceiveEventExtensionElements(elementNode, catchEvent);

    }
    return catchEvent;
}
 
Example #18
Source File: BpmnParseHandlers.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public void parseElement(BpmnParse bpmnParse, BaseElement element) {

        if (element instanceof DataObject) {
            // ignore DataObject elements because they are processed on Process
            // and Sub process level
            return;
        }

        if (element instanceof FlowElement) {
            bpmnParse.setCurrentFlowElement((FlowElement) element);
        }

        // Execute parse handlers
        List<BpmnParseHandler> handlers = parseHandlers.get(element.getClass());

        if (handlers == null) {
            LOGGER.warn("Could not find matching parse handler for + {} this is likely a bug.", element.getId());
        } else {
            for (BpmnParseHandler handler : handlers) {
                handler.parse(bpmnParse, element);
            }
        }
    }
 
Example #19
Source File: FlowableEventBuilder.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public static FlowableMultiInstanceActivityEvent createMultiInstanceActivityEvent(FlowableEngineEventType type, String activityId, String activityName,
        String executionId, String processInstanceId, String processDefinitionId, FlowElement flowElement) {

    FlowableMultiInstanceActivityEventImpl newEvent = new FlowableMultiInstanceActivityEventImpl(type);
    newEvent.setActivityId(activityId);
    newEvent.setActivityName(activityName);
    newEvent.setExecutionId(executionId);
    newEvent.setProcessDefinitionId(processDefinitionId);
    newEvent.setProcessInstanceId(processInstanceId);

    if (flowElement instanceof FlowNode) {
        FlowNode flowNode = (FlowNode) flowElement;
        newEvent.setActivityType(parseActivityType(flowNode));
        Object behaviour = flowNode.getBehavior();
        if (behaviour != null) {
            newEvent.setBehaviorClass(behaviour.getClass().getCanonicalName());
        }

        newEvent.setSequential(((Activity) flowNode).getLoopCharacteristics().isSequential());
    }

    return newEvent;
}
 
Example #20
Source File: PoolsConverterTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
private void validateModel(BpmnModel model) {
    assertThat(model.getPools())
            .extracting(Pool::getId, Pool::getName)
            .containsExactly(tuple("pool1", "Pool"));
    Pool pool = model.getPools().get(0);
    Process process = model.getProcess(pool.getId());
    assertThat(process.getLanes())
            .extracting(Lane::getId, Lane::getName)
            .containsExactly(
                    tuple("lane1", "Lane 1"),
                    tuple("lane2", "Lane 2")
            );
    assertThat(process.getLanes().get(0).getFlowReferences()).hasSize(2);
    assertThat(process.getLanes().get(1).getFlowReferences()).hasSize(2);

    FlowElement flowElement = process.getFlowElement("flow1");
    assertThat(flowElement).isInstanceOf(SequenceFlow.class);
}
 
Example #21
Source File: DataStoreConverterTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
private void validateModel(BpmnModel model) {
    assertThat(model.getDataStores())
            .containsOnlyKeys("DataStore_1");
    DataStore dataStore = model.getDataStore("DataStore_1");
    assertThat(dataStore).isNotNull();
    assertThat(dataStore.getId()).isEqualTo("DataStore_1");
    assertThat(dataStore.getDataState()).isEqualTo("test");
    assertThat(dataStore.getName()).isEqualTo("Test Database");
    assertThat(dataStore.getItemSubjectRef()).isEqualTo("test");

    FlowElement refElement = model.getFlowElement("DataStoreReference_1");
    assertThat(refElement).isInstanceOf(DataStoreReference.class);

    assertThat(model.getPools())
            .extracting(Pool::getId)
            .containsExactly("pool1");
}
 
Example #22
Source File: CallActivityWithNoFallbackConverterTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
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");

    assertThat(callActivity.getFallbackToDefaultTenant()).isNull();

    List<IOParameter> parameters = callActivity.getInParameters();
    assertThat(parameters)
            .extracting(IOParameter::getSource, IOParameter::getTarget, IOParameter::getSourceExpression)
            .containsExactly(
                    tuple("test", "test", null),
                    tuple(null, "test", "${test}")
            );

    parameters = callActivity.getOutParameters();
    assertThat(parameters)
            .extracting(IOParameter::getSource, IOParameter::getTarget)
            .containsExactly(
                    tuple("test", "test")
            );
}
 
Example #23
Source File: ContinueMultiInstanceOperation.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    FlowElement currentFlowElement = getCurrentFlowElement(execution);
    if (currentFlowElement instanceof FlowNode) {
        continueThroughMultiInstanceFlowNode((FlowNode) currentFlowElement);
    } else {
        throw new RuntimeException("Programmatic error: no valid multi instance flow node, type: " + currentFlowElement + ". Halting.");
    }
}
 
Example #24
Source File: AbstractBpmnParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected String getPrecedingEventBasedGateway(BpmnParse bpmnParse, IntermediateCatchEvent event) {
    String eventBasedGatewayId = null;
    for (SequenceFlow sequenceFlow : event.getIncomingFlows()) {
        FlowElement sourceElement = bpmnParse.getBpmnModel().getFlowElement(sequenceFlow.getSourceRef());
        if (sourceElement instanceof EventGateway) {
            eventBasedGatewayId = sourceElement.getId();
            break;
        }
    }
    return eventBasedGatewayId;
}
 
Example #25
Source File: AdhocSubProcessJsonConverter.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap,
    BpmnJsonConverterContext converterContext) {
    AdhocSubProcess subProcess = new AdhocSubProcess();
    subProcess.setCompletionCondition(getPropertyValueAsString("completioncondition", elementNode));
    subProcess.setOrdering(getPropertyValueAsString("ordering", elementNode));
    subProcess.setCancelRemainingInstances(getPropertyValueAsBoolean("cancelremaininginstances", elementNode));
    JsonNode childShapesArray = elementNode.get(EDITOR_CHILD_SHAPES);
    processor.processJsonElements(childShapesArray, modelNode, subProcess, shapeMap, converterContext, model);
    return subProcess;
}
 
Example #26
Source File: ReceiveTaskJsonConverter.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap,
    BpmnJsonConverterContext converterContext) {
    ReceiveTask task = new ReceiveTask();

    String stencilId = BpmnJsonConverterUtil.getStencilId(elementNode);
    if (STENCIL_TASK_RECEIVE_EVENT.equals(stencilId)) {
        addReceiveEventExtensionElements(elementNode, task);
    }

    return task;
}
 
Example #27
Source File: CallActivityConverterTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
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");
    assertThat(callActivity.getCalledElementType()).isEqualTo("id");
    assertThat(callActivity.getFallbackToDefaultTenant()).isTrue();
    assertThat(callActivity.isInheritVariables()).isTrue();
    assertThat(callActivity.isSameDeployment()).isTrue();
    assertThat(callActivity.isInheritBusinessKey()).isTrue();
    assertThat(callActivity.isUseLocalScopeForOutParameters()).isTrue();

    List<IOParameter> parameters = callActivity.getInParameters();
    assertThat(parameters)
            .extracting(IOParameter::getSource, IOParameter::getTarget, IOParameter::getSourceExpression)
            .containsExactly(
                    tuple("test", "test", null),
                    tuple(null, "test", "${test}")
            );

    parameters = callActivity.getOutParameters();
    assertThat(parameters)
            .extracting(IOParameter::getSource, IOParameter::getTarget)
            .containsExactly(tuple("test", "test"));
}
 
Example #28
Source File: GetEnabledActivitiesForAdhocSubProcessCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public List<FlowNode> execute(CommandContext commandContext) {
    ExecutionEntity execution = CommandContextUtil.getExecutionEntityManager(commandContext).findById(executionId);
    if (execution == null) {
        throw new FlowableObjectNotFoundException("No execution found for id '" + executionId + "'", ExecutionEntity.class);
    }

    if (!(execution.getCurrentFlowElement() instanceof AdhocSubProcess)) {
        throw new FlowableException("The current flow element of the requested execution is not an ad-hoc sub process");
    }

    List<FlowNode> enabledFlowNodes = new ArrayList<>();

    AdhocSubProcess adhocSubProcess = (AdhocSubProcess) execution.getCurrentFlowElement();

    // if sequential ordering, only one child execution can be active, so no enabled activities
    if (adhocSubProcess.hasSequentialOrdering()) {
        if (execution.getExecutions().size() > 0) {
            return enabledFlowNodes;
        }
    }

    for (FlowElement flowElement : adhocSubProcess.getFlowElements()) {
        if (flowElement instanceof FlowNode) {
            FlowNode flowNode = (FlowNode) flowElement;
            if (flowNode.getIncomingFlows().size() == 0) {
                enabledFlowNodes.add(flowNode);
            }
        }
    }

    return enabledFlowNodes;
}
 
Example #29
Source File: CorrelationUtil.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public static String getCorrelationKey(String elementName, CommandContext commandContext, FlowElement flowElement, ExecutionEntity executionEntity) {
    String correlationKey = null;
    if (flowElement != null) {
        List<ExtensionElement> eventCorrelations = flowElement.getExtensionElements().get(elementName);
        if (eventCorrelations != null && !eventCorrelations.isEmpty()) {
            ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
            ExpressionManager expressionManager = processEngineConfiguration.getExpressionManager();

            Map<String, Object> correlationParameters = new HashMap<>();
            for (ExtensionElement eventCorrelation : eventCorrelations) {
                String name = eventCorrelation.getAttributeValue(null, "name");
                String valueExpression = eventCorrelation.getAttributeValue(null, "value");
                if (StringUtils.isNotEmpty(valueExpression)) {
                    if (executionEntity != null) {
                        Object value = expressionManager.createExpression(valueExpression).getValue(executionEntity);
                        correlationParameters.put(name, value);
                    } else {
                        correlationParameters.put(name, valueExpression);
                    }
                    
                } else {
                    correlationParameters.put(name, null);
                }
            }

            correlationKey = CommandContextUtil.getEventRegistry().generateKey(correlationParameters);
        }
    }
    
    return correlationKey;
}
 
Example #30
Source File: CompleteConverterTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("userTask1");
    assertThat(flowElement).isNotNull();
    assertThat(flowElement).isInstanceOf(UserTask.class);
    assertThat(flowElement.getId()).isEqualTo("userTask1");

    flowElement = model.getMainProcess().getFlowElement("catchsignal");
    assertThat(flowElement).isNotNull();
    assertThat(flowElement).isInstanceOf(IntermediateCatchEvent.class);
    assertThat(flowElement.getId()).isEqualTo("catchsignal");
    IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) flowElement;
    assertThat(catchEvent.getEventDefinitions()).hasSize(1);
    assertThat(catchEvent.getEventDefinitions().get(0)).isInstanceOf(SignalEventDefinition.class);
    SignalEventDefinition signalEvent = (SignalEventDefinition) catchEvent.getEventDefinitions().get(0);
    assertThat(signalEvent.getSignalRef()).isEqualTo("testSignal");

    flowElement = model.getMainProcess().getFlowElement("subprocess");
    assertThat(flowElement).isNotNull();
    assertThat(flowElement).isInstanceOf(SubProcess.class);
    assertThat(flowElement.getId()).isEqualTo("subprocess");
    SubProcess subProcess = (SubProcess) flowElement;

    flowElement = subProcess.getFlowElement("receiveTask");
    assertThat(flowElement).isNotNull();
    assertThat(flowElement).isInstanceOf(ReceiveTask.class);
    assertThat(flowElement.getId()).isEqualTo("receiveTask");
}