Search in sources :

Example 31 with Process

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

the class WorkflowDefinitionConversion method convert.

/**
   * Call this method to actually execute the conversion of the {@link WorkflowDefinition}
   * which was provided in the constructor.
   */
public void convert() {
    if (workflowDefinition == null) {
        throw new SimpleWorkflowException("Cannot start conversion: need to set a WorkflowDefinition first!");
    }
    this.incrementalIdMapping = new HashMap<String, Integer>();
    this.additionalArtifacts = new HashMap<String, Object>();
    // Create new process
    bpmnModel = new BpmnModel();
    process = new Process();
    bpmnModel.addProcess(process);
    // Let conversion listeners know initialization is finished
    if (conversionFactory.getAllWorkflowDefinitionConversionListeners() != null) {
        for (WorkflowDefinitionConversionListener conversionListener : conversionFactory.getAllWorkflowDefinitionConversionListeners()) {
            conversionListener.beforeStepsConversion(this);
        }
    }
    // Convert each step
    convertSteps(workflowDefinition.getSteps());
    // Let conversion listeners know step conversion is done
    if (conversionFactory.getAllWorkflowDefinitionConversionListeners() != null) {
        for (WorkflowDefinitionConversionListener conversionListener : conversionFactory.getAllWorkflowDefinitionConversionListeners()) {
            conversionListener.afterStepsConversion(this);
        }
    }
    // Add DI information to bpmn model
    BpmnAutoLayout bpmnAutoLayout = new BpmnAutoLayout(bpmnModel);
    bpmnAutoLayout.execute();
}
Also used : WorkflowDefinitionConversionListener(org.activiti.workflow.simple.converter.listener.WorkflowDefinitionConversionListener) BpmnAutoLayout(org.activiti.bpmn.BpmnAutoLayout) Process(org.activiti.bpmn.model.Process) SimpleWorkflowException(org.activiti.workflow.simple.exception.SimpleWorkflowException) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 32 with Process

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

the class PoolConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    String idPool = "idPool";
    String idProcess = "poolProcess";
    assertEquals(1, model.getPools().size());
    Pool pool = model.getPool(idPool);
    assertEquals(idPool, pool.getId());
    assertEquals(idProcess, pool.getProcessRef());
    assertTrue(pool.isExecutable());
    Process process = model.getProcess(idPool);
    assertEquals(idProcess, process.getId());
    assertTrue(process.isExecutable());
    assertEquals(3, process.getLanes().size());
    Lane lane = process.getLanes().get(0);
    assertEquals("idLane1", lane.getId());
    assertEquals("Lane 1", lane.getName());
    assertEquals(7, lane.getFlowReferences().size());
    assertTrue(lane.getFlowReferences().contains("startevent"));
    assertTrue(lane.getFlowReferences().contains("usertask1"));
    assertTrue(lane.getFlowReferences().contains("usertask6"));
    assertTrue(lane.getFlowReferences().contains("endevent"));
    lane = process.getLanes().get(1);
    assertEquals("idLane2", lane.getId());
    assertEquals("Lane 2", lane.getName());
    assertEquals(4, lane.getFlowReferences().size());
    assertTrue(lane.getFlowReferences().contains("usertask2"));
    assertTrue(lane.getFlowReferences().contains("usertask5"));
    lane = process.getLanes().get(2);
    assertEquals("idLane3", lane.getId());
    assertEquals("Lane 3", lane.getName());
    assertEquals(4, lane.getFlowReferences().size());
    assertTrue(lane.getFlowReferences().contains("usertask3"));
    assertTrue(lane.getFlowReferences().contains("usertask4"));
    assertNotNull(process.getFlowElement("startevent"));
    assertNotNull(process.getFlowElement("usertask1"));
    assertNotNull(process.getFlowElement("usertask2"));
    assertNotNull(process.getFlowElement("usertask3"));
    assertNotNull(process.getFlowElement("usertask4"));
    assertNotNull(process.getFlowElement("usertask5"));
    assertNotNull(process.getFlowElement("usertask6"));
    assertNotNull(process.getFlowElement("endevent"));
    assertNotNull(process.getFlowElement("flow1"));
    assertNotNull(process.getFlowElement("flow2"));
    assertNotNull(process.getFlowElement("flow3"));
    assertNotNull(process.getFlowElement("flow4"));
    assertNotNull(process.getFlowElement("flow5"));
    assertNotNull(process.getFlowElement("flow6"));
    assertNotNull(process.getFlowElement("flow7"));
}
Also used : Lane(org.activiti.bpmn.model.Lane) Pool(org.activiti.bpmn.model.Pool) 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