Search in sources :

Example 11 with SequenceFlow

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

the class BpmnParse method processFlowElements.

public void processFlowElements(Collection<FlowElement> flowElements) {
    // Parsing the elements is done in a strict order of types,
    // as otherwise certain information might not be available when parsing
    // a certain type.
    // Using lists as we want to keep the order in which they are defined
    List<SequenceFlow> sequenceFlowToParse = new ArrayList<SequenceFlow>();
    List<BoundaryEvent> boundaryEventsToParse = new ArrayList<BoundaryEvent>();
    // Flow elements that depend on other elements are parse after the first run-through
    List<FlowElement> defferedFlowElementsToParse = new ArrayList<FlowElement>();
    // Activities are parsed first
    for (FlowElement flowElement : flowElements) {
        // Sequence flow are also flow elements, but are only parsed once every activity is found
        if (flowElement instanceof SequenceFlow) {
            sequenceFlowToParse.add((SequenceFlow) flowElement);
        } else if (flowElement instanceof BoundaryEvent) {
            boundaryEventsToParse.add((BoundaryEvent) flowElement);
        } else if (flowElement instanceof Event) {
            defferedFlowElementsToParse.add(flowElement);
        } else {
            bpmnParserHandlers.parseElement(this, flowElement);
        }
    }
    // Deferred elements
    for (FlowElement flowElement : defferedFlowElementsToParse) {
        bpmnParserHandlers.parseElement(this, flowElement);
    }
    // Boundary events are parsed after all the regular activities are parsed
    for (BoundaryEvent boundaryEvent : boundaryEventsToParse) {
        bpmnParserHandlers.parseElement(this, boundaryEvent);
    }
    // sequence flows
    for (SequenceFlow sequenceFlow : sequenceFlowToParse) {
        bpmnParserHandlers.parseElement(this, sequenceFlow);
    }
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) FlowElement(org.activiti.bpmn.model.FlowElement) ArrayList(java.util.ArrayList) Event(org.activiti.bpmn.model.Event) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent)

Example 12 with SequenceFlow

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

the class BpmnParse method createBPMNEdge.

public void createBPMNEdge(String key, List<GraphicInfo> graphicList) {
    FlowElement flowElement = bpmnModel.getFlowElement(key);
    if (flowElement instanceof SequenceFlow) {
        SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
        List<Integer> waypoints = new ArrayList<Integer>();
        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 " + key + " not found");
    }
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) ArrayList(java.util.ArrayList) GraphicInfo(org.activiti.bpmn.model.GraphicInfo)

Example 13 with SequenceFlow

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

the class ProcessDefinitionPersistenceTest method testProcessDefinitionIntrospection.

public void testProcessDefinitionIntrospection() {
    String deploymentId = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/db/processOne.bpmn20.xml").deploy().getId();
    String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
    ProcessDefinition processDefinition = ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(procDefId);
    assertThat(processDefinition.getId()).isEqualTo(procDefId);
    assertThat(processDefinition.getName()).isEqualTo("Process One");
    Process process = repositoryService.getBpmnModel(processDefinition.getId()).getMainProcess();
    StartEvent startElement = (StartEvent) process.getFlowElement("start");
    assertThat(startElement).isNotNull();
    assertThat(startElement.getId()).isEqualTo("start");
    assertThat(startElement.getName()).isEqualTo("S t a r t");
    assertThat(startElement.getDocumentation()).isEqualTo("the start event");
    List<SequenceFlow> outgoingFlows = startElement.getOutgoingFlows();
    assertThat(outgoingFlows).hasSize(1);
    assertThat(outgoingFlows.get(0).getConditionExpression()).isEqualTo("${a == b}");
    EndEvent endElement = (EndEvent) process.getFlowElement("end");
    assertThat(endElement).isNotNull();
    assertThat(endElement.getId()).isEqualTo("end");
    assertThat(outgoingFlows.get(0).getId()).isEqualTo("flow1");
    assertThat(outgoingFlows.get(0).getName()).isEqualTo("Flow One");
    assertThat(outgoingFlows.get(0).getDocumentation()).isEqualTo("The only transitions in the process");
    assertThat(outgoingFlows.get(0).getSourceFlowElement()).isSameAs(startElement);
    assertThat(outgoingFlows.get(0).getTargetFlowElement()).isSameAs(endElement);
    repositoryService.deleteDeployment(deploymentId);
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) StartEvent(org.activiti.bpmn.model.StartEvent) EndEvent(org.activiti.bpmn.model.EndEvent) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) RepositoryServiceImpl(org.activiti.engine.impl.RepositoryServiceImpl) Process(org.activiti.bpmn.model.Process)

Example 14 with SequenceFlow

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

the class TestProcessUtil method createTwoTasksBpmnModel.

public static BpmnModel createTwoTasksBpmnModel() {
    BpmnModel model = new BpmnModel();
    org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process();
    model.addProcess(process);
    process.setId("twoTasksProcess");
    process.setName("The two tasks process");
    StartEvent startEvent = new StartEvent();
    startEvent.setId("start");
    process.addFlowElement(startEvent);
    UserTask userTask = new UserTask();
    userTask.setName("The First Task");
    userTask.setId("task1");
    userTask.setAssignee("kermit");
    process.addFlowElement(userTask);
    UserTask userTask2 = new UserTask();
    userTask2.setName("The Second Task");
    userTask2.setId("task2");
    userTask2.setAssignee("kermit");
    process.addFlowElement(userTask2);
    EndEvent endEvent = new EndEvent();
    endEvent.setId("theEnd");
    process.addFlowElement(endEvent);
    process.addFlowElement(new SequenceFlow("start", "task1"));
    process.addFlowElement(new SequenceFlow("start", "task2"));
    process.addFlowElement(new SequenceFlow("task1", "theEnd"));
    process.addFlowElement(new SequenceFlow("task2", "theEnd"));
    return model;
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) StartEvent(org.activiti.bpmn.model.StartEvent) UserTask(org.activiti.bpmn.model.UserTask) EndEvent(org.activiti.bpmn.model.EndEvent) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 15 with SequenceFlow

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

the class EventJavaTest method testStartEventWithExecutionListener.

public void testStartEventWithExecutionListener() throws Exception {
    BpmnModel bpmnModel = new BpmnModel();
    Process process = new Process();
    process.setId("simpleProcess");
    process.setName("Very simple process");
    bpmnModel.getProcesses().add(process);
    StartEvent startEvent = new StartEvent();
    startEvent.setId("startEvent1");
    TimerEventDefinition timerDef = new TimerEventDefinition();
    timerDef.setTimeDuration("PT5M");
    startEvent.getEventDefinitions().add(timerDef);
    ActivitiListener listener = new ActivitiListener();
    listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
    listener.setImplementation("${test}");
    listener.setEvent("end");
    startEvent.getExecutionListeners().add(listener);
    process.addFlowElement(startEvent);
    UserTask task = new UserTask();
    task.setId("reviewTask");
    task.setAssignee("kermit");
    process.addFlowElement(task);
    SequenceFlow flow1 = new SequenceFlow();
    flow1.setId("flow1");
    flow1.setSourceRef("startEvent1");
    flow1.setTargetRef("reviewTask");
    process.addFlowElement(flow1);
    EndEvent endEvent = new EndEvent();
    endEvent.setId("endEvent1");
    process.addFlowElement(endEvent);
    byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);
    new BpmnXMLConverter().validateModel(new InputStreamSource(new ByteArrayInputStream(xml)));
    Deployment deployment = repositoryService.createDeployment().name("test").addString("test.bpmn20.xml", new String(xml)).deploy();
    repositoryService.deleteDeployment(deployment.getId());
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) UserTask(org.activiti.bpmn.model.UserTask) Deployment(org.activiti.engine.repository.Deployment) Process(org.activiti.bpmn.model.Process) ActivitiListener(org.activiti.bpmn.model.ActivitiListener) BpmnModel(org.activiti.bpmn.model.BpmnModel) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter) InputStreamSource(org.activiti.engine.impl.util.io.InputStreamSource) ByteArrayInputStream(java.io.ByteArrayInputStream) StartEvent(org.activiti.bpmn.model.StartEvent) EndEvent(org.activiti.bpmn.model.EndEvent) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

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