Java Code Examples for org.flowable.bpmn.model.Process#getDataObjects()

The following examples show how to use org.flowable.bpmn.model.Process#getDataObjects() . 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: PoolDataObjectTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
private void validateModel(BpmnModel model) {

        String idPool = "pool1";
        String idProcess = "process_pool1";

        assertThat(model.getPools())
                .extracting(Pool::getId, Pool::getProcessRef, Pool::isExecutable)
                .containsExactly(tuple(idPool, idProcess, true));

        Process process = model.getProcess(idPool);
        assertThat(process.getId()).isEqualTo(idProcess);
        assertThat(process.isExecutable()).isTrue();
        List<ValuedDataObject> dataObjects = process.getDataObjects();
        assertThat(dataObjects).hasSize(1);

        List<FlowableListener> executionListeners = process.getExecutionListeners();
        assertThat(executionListeners).hasSize(1);
        assertThat(model.getSignal("shareniu_signal").getId()).isEqualTo("shareniu_signal");
    }
 
Example 2
Source File: DataObjectValidator.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {

    // Gather data objects
    List<ValuedDataObject> allDataObjects = new ArrayList<>(process.getDataObjects());
    List<SubProcess> subProcesses = process.findFlowElementsOfType(SubProcess.class, true);
    for (SubProcess subProcess : subProcesses) {
        allDataObjects.addAll(subProcess.getDataObjects());
    }

    // Validate
    for (ValuedDataObject dataObject : allDataObjects) {
        if (StringUtils.isEmpty(dataObject.getName())) {
            addError(errors, Problems.DATA_OBJECT_MISSING_NAME, process, dataObject, "Name is mandatory for a data object");
        }
    }

}
 
Example 3
Source File: SubProcessMultiDiagramConverterTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
private void validateModel(BpmnModel model) {
    Process process = model.getMainProcess();
    Collection<Artifact> artifacts = process.getArtifacts();
    List<ValuedDataObject> dataObjects = process.getDataObjects();

    // verify main process
    assertThat(process.getFlowElements()).hasSize(13);
    assertThat(artifacts).hasSize(2);
    assertThat(dataObjects).hasSize(6);

    Artifact artifact = artifacts.iterator().next();
    assertThat(artifact)
            .isInstanceOfSatisfying(TextAnnotation.class, art -> {
                assertThat(art.getId()).isEqualTo("textannotation1");
                assertThat(art.getText()).isEqualTo("Test Annotation");
            });

    FlowElement flowElement = process.getFlowElement("start1");
    assertThat(flowElement)
            .isInstanceOfSatisfying(StartEvent.class, startEvent -> {
                assertThat(startEvent.getId()).isEqualTo("start1");
            });

    flowElement = process.getFlowElement("userTask1");
    assertThat(flowElement)
            .isInstanceOfSatisfying(UserTask.class, userTask -> {
                assertThat(userTask.getName()).isEqualTo("User task 1");
                assertThat(userTask.getCandidateUsers()).hasSize(1);
                assertThat(userTask.getCandidateGroups()).hasSize(1);
            });

    flowElement = process.getFlowElement("subprocess1");
    assertThat(flowElement)
            .isInstanceOfSatisfying(SubProcess.class, subProcess -> {
                assertThat(subProcess.getId()).isEqualTo("subprocess1");
                assertThat(subProcess.getFlowElements()).hasSize(11);

                // verify subprocess
                assertThat(subProcess.getArtifacts()).hasSize(2);
                assertThat(subProcess.getDataObjects()).hasSize(6);

                assertThat(subProcess.getArtifacts().iterator().next())
                        .isInstanceOfSatisfying(TextAnnotation.class, art -> {
                            assertThat(art.getId()).isEqualTo("textannotation2");
                            assertThat(art.getText()).isEqualTo("Sub Test Annotation");
                        });

                assertThat(subProcess.getFlowElement("subStartEvent"))
                        .isInstanceOfSatisfying(StartEvent.class, startEvent -> {
                            assertThat(startEvent.getId()).isEqualTo("subStartEvent");
                        });

                assertThat(subProcess.getFlowElement("subUserTask1"))
                        .isInstanceOfSatisfying(UserTask.class, userTask -> {
                            assertThat(userTask.getName()).isEqualTo("User task 2");
                            assertThat(userTask.getCandidateUsers()).isEmpty();
                            assertThat(userTask.getCandidateGroups()).isEmpty();
                        });
            });
}
 
Example 4
Source File: BpmnModelWithDataObjectTest.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Test
public void convertModelToXML() throws Exception {
    BpmnModel bpmnModel = new BpmnModel();
    Process process = new Process();
    process.setId("myProcess");
    bpmnModel.addProcess(process);
    
    List<ValuedDataObject> dataObjects = new ArrayList<>();
    StringDataObject dataObject = new StringDataObject();
    dataObject.setId("dObj1");
    dataObject.setName("stringDataObject");
    dataObject.setValue("test");
    ItemDefinition itemDefinition = new ItemDefinition();
    itemDefinition.setStructureRef("xsd:string");
    dataObject.setItemSubjectRef(itemDefinition);
    dataObjects.add(dataObject);
    process.setDataObjects(dataObjects);
    process.addFlowElement(dataObject);
    
    StartEvent startEvent = new StartEvent();
    startEvent.setId("event1");
    
    EndEvent endEvent = new EndEvent();
    endEvent.setId("event2");
    
    SequenceFlow flow = new SequenceFlow("event1", "event2");
    
    process.addFlowElement(startEvent);
    process.addFlowElement(endEvent);
    process.addFlowElement(flow);
    
    BpmnModel parsedModel = exportAndReadXMLFile(bpmnModel);
    
    Process mainProcess = parsedModel.getMainProcess();

    // verify the main process data objects
    List<ValuedDataObject> processDataObjects = mainProcess.getDataObjects();
    assertThat(processDataObjects).hasSize(1);

    Map<String, ValuedDataObject> objectMap = new HashMap<>();
    for (ValuedDataObject valueObj : dataObjects) {
        objectMap.put(valueObj.getId(), valueObj);
    }

    ValuedDataObject dataObj = objectMap.get("dObj1");
    assertThat(dataObj.getId()).isEqualTo("dObj1");
    assertThat(dataObj.getName()).isEqualTo("stringDataObject");
    assertThat(dataObj.getItemSubjectRef().getStructureRef()).isEqualTo("xsd:string");
    assertThat(dataObj.getValue()).isEqualTo("test");
}