Search in sources :

Example 21 with SequenceFlow

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

the class AbstractActivitiTestCase method createTwoTasksTestProcess.

public BpmnModel createTwoTasksTestProcess() {
    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 22 with SequenceFlow

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

the class BpmnAutoLayout method translateNestedSubprocessElements.

protected void translateNestedSubprocessElements(SubProcess subProcess) {
    GraphicInfo subProcessGraphicInfo = bpmnModel.getLocationMap().get(subProcess.getId());
    double subProcessX = subProcessGraphicInfo.getX();
    double subProcessY = subProcessGraphicInfo.getY();
    List<SubProcess> nestedSubProcesses = new ArrayList<SubProcess>();
    for (FlowElement flowElement : subProcess.getFlowElements()) {
        if (flowElement instanceof SequenceFlow) {
            List<GraphicInfo> graphicInfos = bpmnModel.getFlowLocationMap().get(flowElement.getId());
            for (GraphicInfo graphicInfo : graphicInfos) {
                graphicInfo.setX(graphicInfo.getX() + subProcessX + subProcessMargin);
                graphicInfo.setY(graphicInfo.getY() + subProcessY + subProcessMargin);
            }
        } else if (flowElement instanceof DataObject == false) {
            // Regular element
            GraphicInfo graphicInfo = bpmnModel.getLocationMap().get(flowElement.getId());
            graphicInfo.setX(graphicInfo.getX() + subProcessX + subProcessMargin);
            graphicInfo.setY(graphicInfo.getY() + subProcessY + subProcessMargin);
        }
        if (flowElement instanceof SubProcess) {
            nestedSubProcesses.add((SubProcess) flowElement);
        }
    }
    // Continue for next level of nested subprocesses
    for (SubProcess nestedSubProcess : nestedSubProcesses) {
        translateNestedSubprocessElements(nestedSubProcess);
    }
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) DataObject(org.activiti.bpmn.model.DataObject) FlowElement(org.activiti.bpmn.model.FlowElement) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) ArrayList(java.util.ArrayList)

Example 23 with SequenceFlow

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

the class BpmnAutoLayout method layout.

protected void layout(FlowElementsContainer flowElementsContainer) {
    graph = new mxGraph();
    cellParent = graph.getDefaultParent();
    graph.getModel().beginUpdate();
    // Subprocesses are handled in a new instance of BpmnAutoLayout, hence they instantiations of new maps here.
    handledFlowElements = new HashMap<String, FlowElement>();
    handledArtifacts = new HashMap<String, Artifact>();
    generatedVertices = new HashMap<String, Object>();
    generatedSequenceFlowEdges = new HashMap<String, Object>();
    generatedAssociationEdges = new HashMap<String, Object>();
    // Associations are gathered and processed afterwards, because we must be sure we already found source and target
    associations = new HashMap<String, Association>();
    // Text Annotations are gathered and processed afterwards, because we must be sure we already found the parent.
    textAnnotations = new HashMap<String, TextAnnotation>();
    // Sequence flow are gathered and processed afterwards,because we mustbe sure we already found source and target
    sequenceFlows = new HashMap<String, SequenceFlow>();
    // Boundary events are gathered and processed afterwards, because we must be sure we have its parent
    boundaryEvents = new ArrayList<BoundaryEvent>();
    // Process all elements
    for (FlowElement flowElement : flowElementsContainer.getFlowElements()) {
        if (flowElement instanceof SequenceFlow) {
            handleSequenceFlow((SequenceFlow) flowElement);
        } else if (flowElement instanceof Event) {
            handleEvent(flowElement);
        } else if (flowElement instanceof Gateway) {
            createGatewayVertex(flowElement);
        } else if (flowElement instanceof Task || flowElement instanceof CallActivity) {
            handleActivity(flowElement);
        } else if (flowElement instanceof SubProcess) {
            handleSubProcess(flowElement);
        }
        handledFlowElements.put(flowElement.getId(), flowElement);
    }
    // process artifacts
    for (Artifact artifact : flowElementsContainer.getArtifacts()) {
        if (artifact instanceof Association) {
            handleAssociation((Association) artifact);
        } else if (artifact instanceof TextAnnotation) {
            handleTextAnnotation((TextAnnotation) artifact);
        }
        handledArtifacts.put(artifact.getId(), artifact);
    }
    // Process gathered elements
    handleBoundaryEvents();
    handleSequenceFlow();
    handleAssociations();
    // All elements are now put in the graph. Let's layout them!
    CustomLayout layout = new CustomLayout(graph, SwingConstants.WEST);
    layout.setIntraCellSpacing(100.0);
    layout.setResizeParent(true);
    layout.setFineTuning(true);
    layout.setParentBorder(20);
    layout.setMoveParent(true);
    layout.setDisableEdgeStyle(false);
    layout.setUseBoundingBox(true);
    layout.execute(graph.getDefaultParent());
    graph.getModel().endUpdate();
    generateDiagramInterchangeElements();
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) Task(org.activiti.bpmn.model.Task) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) com.mxgraph.view.mxGraph(com.mxgraph.view.mxGraph) CallActivity(org.activiti.bpmn.model.CallActivity) Artifact(org.activiti.bpmn.model.Artifact) Association(org.activiti.bpmn.model.Association) FlowElement(org.activiti.bpmn.model.FlowElement) Gateway(org.activiti.bpmn.model.Gateway) Event(org.activiti.bpmn.model.Event) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) DataObject(org.activiti.bpmn.model.DataObject) TextAnnotation(org.activiti.bpmn.model.TextAnnotation)

Example 24 with SequenceFlow

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

the class BpmnJsonConverterUtil method parseListeners.

protected static void parseListeners(JsonNode listenersNode, BaseElement element, boolean isTaskListener) {
    if (listenersNode == null)
        return;
    listenersNode = validateIfNodeIsTextual(listenersNode);
    for (JsonNode listenerNode : listenersNode) {
        listenerNode = validateIfNodeIsTextual(listenerNode);
        JsonNode eventNode = listenerNode.get(PROPERTY_LISTENER_EVENT);
        if (eventNode != null && !eventNode.isNull() && StringUtils.isNotEmpty(eventNode.asText())) {
            ActivitiListener listener = new ActivitiListener();
            listener.setEvent(eventNode.asText());
            if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_LISTENER_CLASS_NAME, listenerNode))) {
                listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
                listener.setImplementation(getValueAsString(PROPERTY_LISTENER_CLASS_NAME, listenerNode));
            } else if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_LISTENER_EXPRESSION, listenerNode))) {
                listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
                listener.setImplementation(getValueAsString(PROPERTY_LISTENER_EXPRESSION, listenerNode));
            } else if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_LISTENER_DELEGATE_EXPRESSION, listenerNode))) {
                listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
                listener.setImplementation(getValueAsString(PROPERTY_LISTENER_DELEGATE_EXPRESSION, listenerNode));
            }
            JsonNode fieldsNode = listenerNode.get(PROPERTY_LISTENER_FIELDS);
            if (fieldsNode != null) {
                for (JsonNode fieldNode : fieldsNode) {
                    JsonNode nameNode = fieldNode.get(PROPERTY_FIELD_NAME);
                    if (nameNode != null && !nameNode.isNull() && StringUtils.isNotEmpty(nameNode.asText())) {
                        FieldExtension fieldExtension = new FieldExtension();
                        fieldExtension.setFieldName(nameNode.asText());
                        fieldExtension.setStringValue(getValueAsString(PROPERTY_FIELD_STRING_VALUE, fieldNode));
                        if (StringUtils.isEmpty(fieldExtension.getStringValue())) {
                            fieldExtension.setStringValue(getValueAsString(PROPERTY_FIELD_STRING, fieldNode));
                        }
                        if (StringUtils.isEmpty(fieldExtension.getStringValue())) {
                            fieldExtension.setExpression(getValueAsString(PROPERTY_FIELD_EXPRESSION, fieldNode));
                        }
                        listener.getFieldExtensions().add(fieldExtension);
                    }
                }
            }
            if (element instanceof Process) {
                ((Process) element).getExecutionListeners().add(listener);
            } else if (element instanceof SequenceFlow) {
                ((SequenceFlow) element).getExecutionListeners().add(listener);
            } else if (element instanceof UserTask) {
                if (isTaskListener) {
                    ((UserTask) element).getTaskListeners().add(listener);
                } else {
                    ((UserTask) element).getExecutionListeners().add(listener);
                }
            } else if (element instanceof FlowElement) {
                ((FlowElement) element).getExecutionListeners().add(listener);
            }
        }
    }
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) FlowElement(org.activiti.bpmn.model.FlowElement) UserTask(org.activiti.bpmn.model.UserTask) JsonNode(com.fasterxml.jackson.databind.JsonNode) Process(org.activiti.bpmn.model.Process) ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

Example 25 with SequenceFlow

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

the class SimpleConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    assertThat(model.getMainProcess().getId()).isEqualTo("simpleProcess");
    assertThat(model.getMainProcess().getName()).isEqualTo("Simple process");
    assertThat(model.getMainProcess().isExecutable()).isEqualTo(true);
    FlowElement flowElement = model.getMainProcess().getFlowElement("flow1", true);
    assertThat(flowElement).isNotNull();
    assertThat(flowElement).isInstanceOf(SequenceFlow.class);
    assertThat(flowElement.getId()).isEqualTo("flow1");
    flowElement = model.getMainProcess().getFlowElement("catchEvent", true);
    assertThat(flowElement).isNotNull();
    assertThat(flowElement).isInstanceOf(IntermediateCatchEvent.class);
    assertThat(flowElement.getId()).isEqualTo("catchEvent");
    IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) flowElement;
    assertThat(catchEvent.getEventDefinitions().size() == 1).isTrue();
    EventDefinition eventDefinition = catchEvent.getEventDefinitions().get(0);
    assertThat(eventDefinition).isInstanceOf(TimerEventDefinition.class);
    TimerEventDefinition timerDefinition = (TimerEventDefinition) eventDefinition;
    assertThat(timerDefinition.getTimeDuration()).isEqualTo("PT5M");
    flowElement = model.getMainProcess().getFlowElement("flow1Condition", true);
    assertThat(flowElement).isNotNull();
    assertThat(flowElement).isInstanceOf(SequenceFlow.class);
    assertThat(flowElement.getId()).isEqualTo("flow1Condition");
    SequenceFlow flow = (SequenceFlow) flowElement;
    assertThat(flow.getConditionExpression()).isEqualTo("${number <= 1}");
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) EventDefinition(org.activiti.bpmn.model.EventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition) 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