Search in sources :

Example 21 with Process

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

the class PoolsConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    assertEquals(1, model.getPools().size());
    Pool pool = model.getPools().get(0);
    assertEquals("pool1", pool.getId());
    assertEquals("Pool", pool.getName());
    Process process = model.getProcess(pool.getId());
    assertNotNull(process);
    assertEquals(2, process.getLanes().size());
    Lane lane = process.getLanes().get(0);
    assertEquals("lane1", lane.getId());
    assertEquals("Lane 1", lane.getName());
    assertEquals(2, lane.getFlowReferences().size());
    lane = process.getLanes().get(1);
    assertEquals("lane2", lane.getId());
    assertEquals("Lane 2", lane.getName());
    assertEquals(2, lane.getFlowReferences().size());
    FlowElement flowElement = process.getFlowElement("flow1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SequenceFlow);
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) Lane(org.activiti.bpmn.model.Lane) Pool(org.activiti.bpmn.model.Pool) Process(org.activiti.bpmn.model.Process)

Example 22 with Process

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

the class ProcessParser method parse.

public Process parse(XMLStreamReader xtr, BpmnModel model) throws Exception {
    Process process = null;
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) {
        String processId = xtr.getAttributeValue(null, ATTRIBUTE_ID);
        process = new Process();
        process.setId(processId);
        BpmnXMLUtil.addXMLLocation(process, xtr);
        process.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
        if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_PROCESS_EXECUTABLE))) {
            process.setExecutable(Boolean.parseBoolean(xtr.getAttributeValue(null, ATTRIBUTE_PROCESS_EXECUTABLE)));
        }
        String candidateUsersString = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_PROCESS_CANDIDATE_USERS);
        if (StringUtils.isNotEmpty(candidateUsersString)) {
            List<String> candidateUsers = BpmnXMLUtil.parseDelimitedList(candidateUsersString);
            process.setCandidateStarterUsers(candidateUsers);
        }
        String candidateGroupsString = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_PROCESS_CANDIDATE_GROUPS);
        if (StringUtils.isNotEmpty(candidateGroupsString)) {
            List<String> candidateGroups = BpmnXMLUtil.parseDelimitedList(candidateGroupsString);
            process.setCandidateStarterGroups(candidateGroups);
        }
        BpmnXMLUtil.addCustomAttributes(xtr, process, ProcessExport.defaultProcessAttributes);
        model.getProcesses().add(process);
    }
    return process;
}
Also used : Process(org.activiti.bpmn.model.Process)

Example 23 with Process

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

the class IOSpecificationParser method parseChildElement.

public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
    if (parentElement instanceof Activity == false && parentElement instanceof Process == false)
        return;
    IOSpecification ioSpecification = new IOSpecification();
    BpmnXMLUtil.addXMLLocation(ioSpecification, xtr);
    boolean readyWithIOSpecification = false;
    try {
        while (readyWithIOSpecification == false && xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && ELEMENT_DATA_INPUT.equalsIgnoreCase(xtr.getLocalName())) {
                DataSpec dataSpec = new DataSpec();
                BpmnXMLUtil.addXMLLocation(dataSpec, xtr);
                dataSpec.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
                dataSpec.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
                dataSpec.setItemSubjectRef(parseItemSubjectRef(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_SUBJECT_REF), model));
                ioSpecification.getDataInputs().add(dataSpec);
            } else if (xtr.isStartElement() && ELEMENT_DATA_OUTPUT.equalsIgnoreCase(xtr.getLocalName())) {
                DataSpec dataSpec = new DataSpec();
                BpmnXMLUtil.addXMLLocation(dataSpec, xtr);
                dataSpec.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
                dataSpec.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
                dataSpec.setItemSubjectRef(parseItemSubjectRef(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_SUBJECT_REF), model));
                ioSpecification.getDataOutputs().add(dataSpec);
            } else if (xtr.isStartElement() && ELEMENT_DATA_INPUT_REFS.equalsIgnoreCase(xtr.getLocalName())) {
                String dataInputRefs = xtr.getElementText();
                if (StringUtils.isNotEmpty(dataInputRefs)) {
                    ioSpecification.getDataInputRefs().add(dataInputRefs.trim());
                }
            } else if (xtr.isStartElement() && ELEMENT_DATA_OUTPUT_REFS.equalsIgnoreCase(xtr.getLocalName())) {
                String dataOutputRefs = xtr.getElementText();
                if (StringUtils.isNotEmpty(dataOutputRefs)) {
                    ioSpecification.getDataOutputRefs().add(dataOutputRefs.trim());
                }
            } else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) {
                readyWithIOSpecification = true;
            }
        }
    } catch (Exception e) {
        LOGGER.warn("Error parsing ioSpecification child elements", e);
    }
    if (parentElement instanceof Process) {
        ((Process) parentElement).setIoSpecification(ioSpecification);
    } else {
        ((Activity) parentElement).setIoSpecification(ioSpecification);
    }
}
Also used : IOSpecification(org.activiti.bpmn.model.IOSpecification) Activity(org.activiti.bpmn.model.Activity) DataSpec(org.activiti.bpmn.model.DataSpec) Process(org.activiti.bpmn.model.Process)

Example 24 with Process

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

the class BpmnParseTest method testParseDiagramInterchangeElementsForUnknownModelElements.

@Deployment
public void testParseDiagramInterchangeElementsForUnknownModelElements() {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("TestAnnotation").singleResult();
    BpmnModel model = repositoryService.getBpmnModel(processDefinition.getId());
    Process mainProcess = model.getMainProcess();
    assertEquals(0, mainProcess.getExtensionElements().size());
}
Also used : ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) Process(org.activiti.bpmn.model.Process) BpmnModel(org.activiti.bpmn.model.BpmnModel) Deployment(org.activiti.engine.test.Deployment)

Example 25 with Process

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

the class BpmnModelValidator method validate.

@Override
public void validate(BpmnModel bpmnModel, List<ValidationError> errors) {
    // If all process definitions of this bpmnModel are not executable, raise an error
    boolean isAtLeastOneExecutable = validateAtLeastOneExecutable(bpmnModel, errors);
    // If at least one process definition is executable, show a warning for each of the none-executables
    if (isAtLeastOneExecutable) {
        for (Process process : bpmnModel.getProcesses()) {
            if (!process.isExecutable()) {
                addWarning(errors, Problems.PROCESS_DEFINITION_NOT_EXECUTABLE, process, process, "Process definition is not executable. Please verify that this is intentional.");
            }
            handleProcessConstraints(bpmnModel, process, errors);
        }
    }
    handleBPMNModelConstraints(bpmnModel, errors);
}
Also used : Process(org.activiti.bpmn.model.Process)

Aggregations

Process (org.activiti.bpmn.model.Process)32 FlowElement (org.activiti.bpmn.model.FlowElement)13 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)9 SubProcess (org.activiti.bpmn.model.SubProcess)9 BpmnModel (org.activiti.bpmn.model.BpmnModel)8 Lane (org.activiti.bpmn.model.Lane)8 Pool (org.activiti.bpmn.model.Pool)8 UserTask (org.activiti.bpmn.model.UserTask)6 Artifact (org.activiti.bpmn.model.Artifact)5 List (java.util.List)4 EventSubProcess (org.activiti.bpmn.model.EventSubProcess)4 FlowNode (org.activiti.bpmn.model.FlowNode)4 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)4 WorkflowDefinitionConversion (org.activiti.workflow.simple.converter.WorkflowDefinitionConversion)4 WorkflowDefinition (org.activiti.workflow.simple.definition.WorkflowDefinition)4 Test (org.junit.Test)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3 ArrayList (java.util.ArrayList)3 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)3