Search in sources :

Example 66 with FlowElement

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

the class DefaultWorkflowDefinitionConversionListener method generateSequenceflowMappings.

protected SequenceFlowMapping generateSequenceflowMappings(Process process) {
    HashMap<String, List<SequenceFlow>> incomingSequenceFlowMapping = new HashMap<String, List<SequenceFlow>>();
    HashMap<String, List<SequenceFlow>> outgoingSequenceFlowMapping = new HashMap<String, List<SequenceFlow>>();
    for (FlowElement flowElement : process.findFlowElementsOfType(SequenceFlow.class)) {
        SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
        String srcId = sequenceFlow.getSourceRef();
        String targetId = sequenceFlow.getTargetRef();
        if (outgoingSequenceFlowMapping.get(srcId) == null) {
            outgoingSequenceFlowMapping.put(srcId, new ArrayList<SequenceFlow>());
        }
        outgoingSequenceFlowMapping.get(srcId).add(sequenceFlow);
        if (incomingSequenceFlowMapping.get(targetId) == null) {
            incomingSequenceFlowMapping.put(targetId, new ArrayList<SequenceFlow>());
        }
        incomingSequenceFlowMapping.get(targetId).add(sequenceFlow);
    }
    SequenceFlowMapping mapping = new SequenceFlowMapping();
    mapping.setIncomingSequenceFlowMapping(incomingSequenceFlowMapping);
    mapping.setOutgoingSequenceFlowMapping(outgoingSequenceFlowMapping);
    return mapping;
}
Also used : HashMap(java.util.HashMap) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) FlowElement(org.activiti.bpmn.model.FlowElement) ArrayList(java.util.ArrayList) List(java.util.List)

Example 67 with FlowElement

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

the class SequenceFlowJsonConverter method convertToJson.

@Override
public void convertToJson(BaseElement baseElement, ActivityProcessor processor, BpmnModel model, FlowElementsContainer container, ArrayNode shapesArrayNode, double subProcessX, double subProcessY) {
    SequenceFlow sequenceFlow = (SequenceFlow) baseElement;
    ObjectNode flowNode = BpmnJsonConverterUtil.createChildShape(sequenceFlow.getId(), STENCIL_SEQUENCE_FLOW, 172, 212, 128, 212);
    ArrayNode dockersArrayNode = objectMapper.createArrayNode();
    ObjectNode dockNode = objectMapper.createObjectNode();
    dockNode.put(EDITOR_BOUNDS_X, model.getGraphicInfo(sequenceFlow.getSourceRef()).getWidth() / 2.0);
    dockNode.put(EDITOR_BOUNDS_Y, model.getGraphicInfo(sequenceFlow.getSourceRef()).getHeight() / 2.0);
    dockersArrayNode.add(dockNode);
    if (model.getFlowLocationGraphicInfo(sequenceFlow.getId()).size() > 2) {
        for (int i = 1; i < model.getFlowLocationGraphicInfo(sequenceFlow.getId()).size() - 1; i++) {
            GraphicInfo graphicInfo = model.getFlowLocationGraphicInfo(sequenceFlow.getId()).get(i);
            dockNode = objectMapper.createObjectNode();
            dockNode.put(EDITOR_BOUNDS_X, graphicInfo.getX());
            dockNode.put(EDITOR_BOUNDS_Y, graphicInfo.getY());
            dockersArrayNode.add(dockNode);
        }
    }
    dockNode = objectMapper.createObjectNode();
    dockNode.put(EDITOR_BOUNDS_X, model.getGraphicInfo(sequenceFlow.getTargetRef()).getWidth() / 2.0);
    dockNode.put(EDITOR_BOUNDS_Y, model.getGraphicInfo(sequenceFlow.getTargetRef()).getHeight() / 2.0);
    dockersArrayNode.add(dockNode);
    flowNode.put("dockers", dockersArrayNode);
    ArrayNode outgoingArrayNode = objectMapper.createArrayNode();
    outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(sequenceFlow.getTargetRef()));
    flowNode.put("outgoing", outgoingArrayNode);
    flowNode.put("target", BpmnJsonConverterUtil.createResourceNode(sequenceFlow.getTargetRef()));
    ObjectNode propertiesNode = objectMapper.createObjectNode();
    propertiesNode.put(PROPERTY_OVERRIDE_ID, sequenceFlow.getId());
    if (StringUtils.isNotEmpty(sequenceFlow.getName())) {
        propertiesNode.put(PROPERTY_NAME, sequenceFlow.getName());
    }
    if (StringUtils.isNotEmpty(sequenceFlow.getDocumentation())) {
        propertiesNode.put(PROPERTY_DOCUMENTATION, sequenceFlow.getDocumentation());
    }
    if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) {
        propertiesNode.put(PROPERTY_SEQUENCEFLOW_CONDITION, sequenceFlow.getConditionExpression());
    }
    if (StringUtils.isNotEmpty(sequenceFlow.getSourceRef())) {
        FlowElement sourceFlowElement = container.getFlowElement(sequenceFlow.getSourceRef());
        if (sourceFlowElement != null) {
            String defaultFlowId = null;
            if (sourceFlowElement instanceof ExclusiveGateway) {
                ExclusiveGateway parentExclusiveGateway = (ExclusiveGateway) sourceFlowElement;
                defaultFlowId = parentExclusiveGateway.getDefaultFlow();
            } else if (sourceFlowElement instanceof Activity) {
                Activity parentActivity = (Activity) sourceFlowElement;
                defaultFlowId = parentActivity.getDefaultFlow();
            }
            if (defaultFlowId != null && defaultFlowId.equals(sequenceFlow.getId())) {
                propertiesNode.put(PROPERTY_SEQUENCEFLOW_DEFAULT, true);
            }
        }
    }
    if (sequenceFlow.getExecutionListeners().size() > 0) {
        BpmnJsonConverterUtil.convertListenersToJson(sequenceFlow.getExecutionListeners(), true, propertiesNode);
    }
    flowNode.put(EDITOR_SHAPE_PROPERTIES, propertiesNode);
    shapesArrayNode.add(flowNode);
}
Also used : ExclusiveGateway(org.activiti.bpmn.model.ExclusiveGateway) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) FlowElement(org.activiti.bpmn.model.FlowElement) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) Activity(org.activiti.bpmn.model.Activity) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 68 with FlowElement

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

the class ScopedConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("outerSubProcess");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("outerSubProcess", flowElement.getId());
    SubProcess outerSubProcess = (SubProcess) flowElement;
    List<BoundaryEvent> eventList = outerSubProcess.getBoundaryEvents();
    assertEquals(1, eventList.size());
    BoundaryEvent boundaryEvent = eventList.get(0);
    assertEquals("outerBoundaryEvent", boundaryEvent.getId());
    FlowElement subElement = outerSubProcess.getFlowElement("innerSubProcess");
    assertNotNull(subElement);
    assertTrue(subElement instanceof SubProcess);
    assertEquals("innerSubProcess", subElement.getId());
    SubProcess innerSubProcess = (SubProcess) subElement;
    eventList = innerSubProcess.getBoundaryEvents();
    assertEquals(1, eventList.size());
    boundaryEvent = eventList.get(0);
    assertEquals("innerBoundaryEvent", boundaryEvent.getId());
    FlowElement taskElement = innerSubProcess.getFlowElement("usertask");
    assertNotNull(taskElement);
    assertTrue(taskElement instanceof UserTask);
    UserTask userTask = (UserTask) taskElement;
    assertEquals("usertask", userTask.getId());
    eventList = userTask.getBoundaryEvents();
    assertEquals(1, eventList.size());
    boundaryEvent = eventList.get(0);
    assertEquals("taskBoundaryEvent", boundaryEvent.getId());
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) FlowElement(org.activiti.bpmn.model.FlowElement) UserTask(org.activiti.bpmn.model.UserTask)

Example 69 with FlowElement

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

the class ServiceTaskConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("servicetask");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof ServiceTask);
    assertEquals("servicetask", flowElement.getId());
    ServiceTask serviceTask = (ServiceTask) flowElement;
    assertEquals("servicetask", serviceTask.getId());
    assertEquals("Service task", serviceTask.getName());
    List<FieldExtension> fields = serviceTask.getFieldExtensions();
    assertEquals(2, fields.size());
    FieldExtension field = (FieldExtension) fields.get(0);
    assertEquals("testField", field.getFieldName());
    assertEquals("test", field.getStringValue());
    field = (FieldExtension) fields.get(1);
    assertEquals("testField2", field.getFieldName());
    assertEquals("${test}", field.getExpression());
    List<ActivitiListener> listeners = serviceTask.getExecutionListeners();
    assertEquals(3, listeners.size());
    ActivitiListener listener = (ActivitiListener) listeners.get(0);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
    assertEquals("org.test.TestClass", listener.getImplementation());
    assertEquals("start", listener.getEvent());
    listener = (ActivitiListener) listeners.get(1);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${testExpression}", listener.getImplementation());
    assertEquals("end", listener.getEvent());
    listener = (ActivitiListener) listeners.get(2);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${delegateExpression}", listener.getImplementation());
    assertEquals("start", listener.getEvent());
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) FlowElement(org.activiti.bpmn.model.FlowElement) FieldExtension(org.activiti.bpmn.model.FieldExtension) ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

Example 70 with FlowElement

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

the class StartEventConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("start");
    assertTrue(flowElement instanceof StartEvent);
    StartEvent startEvent = (StartEvent) flowElement;
    assertEquals("start", startEvent.getId());
    assertEquals("startName", startEvent.getName());
    assertEquals("startFormKey", startEvent.getFormKey());
    assertEquals("startInitiator", startEvent.getInitiator());
    assertEquals("startDoc", startEvent.getDocumentation());
    List<FormProperty> formProperties = startEvent.getFormProperties();
    assertEquals(2, formProperties.size());
    FormProperty formProperty = formProperties.get(0);
    assertEquals("startFormProp1", formProperty.getId());
    assertEquals("startFormProp1", formProperty.getName());
    assertEquals("string", formProperty.getType());
    formProperty = formProperties.get(1);
    assertEquals("startFormProp2", formProperty.getId());
    assertEquals("startFormProp2", formProperty.getName());
    assertEquals("boolean", formProperty.getType());
}
Also used : FormProperty(org.activiti.bpmn.model.FormProperty) FlowElement(org.activiti.bpmn.model.FlowElement) StartEvent(org.activiti.bpmn.model.StartEvent)

Aggregations

FlowElement (org.activiti.bpmn.model.FlowElement)77 SubProcess (org.activiti.bpmn.model.SubProcess)27 UserTask (org.activiti.bpmn.model.UserTask)26 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)24 StartEvent (org.activiti.bpmn.model.StartEvent)14 Process (org.activiti.bpmn.model.Process)13 ArrayList (java.util.ArrayList)11 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)11 HashMap (java.util.HashMap)9 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)9 Activity (org.activiti.bpmn.model.Activity)9 ServiceTask (org.activiti.bpmn.model.ServiceTask)9 Gateway (org.activiti.bpmn.model.Gateway)8 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)7 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)7 Artifact (org.activiti.bpmn.model.Artifact)6 FlowNode (org.activiti.bpmn.model.FlowNode)6 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)6 BpmnModel (org.activiti.bpmn.model.BpmnModel)5 EventDefinition (org.activiti.bpmn.model.EventDefinition)5