Search in sources :

Example 1 with Process

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

the class BpmnAutoLayout method execute.

public void execute() {
    // Reset any previous DI information
    bpmnModel.getLocationMap().clear();
    bpmnModel.getFlowLocationMap().clear();
    // Generate DI for each process
    for (Process process : bpmnModel.getProcesses()) {
        layout(process);
        // Operations that can only be done after all elements have received DI
        translateNestedSubprocesses(process);
    }
}
Also used : Process(org.activiti.bpmn.model.Process) SubProcess(org.activiti.bpmn.model.SubProcess)

Example 2 with Process

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

the class LaneExtensionTest method testLaneExtensionElement.

@Test
@Deployment
public void testLaneExtensionElement() {
    ProcessDefinition processDefinition = activitiRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("swimlane-extension").singleResult();
    BpmnModel bpmnModel = activitiRule.getRepositoryService().getBpmnModel(processDefinition.getId());
    byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);
    System.out.println(new String(xml));
    Process bpmnProcess = bpmnModel.getMainProcess();
    for (Lane l : bpmnProcess.getLanes()) {
        Map<String, List<ExtensionElement>> extensions = l.getExtensionElements();
        Assert.assertTrue(extensions.size() > 0);
    }
}
Also used : Lane(org.activiti.bpmn.model.Lane) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) Process(org.activiti.bpmn.model.Process) List(java.util.List) BpmnModel(org.activiti.bpmn.model.BpmnModel) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter) Test(org.junit.Test) Deployment(org.activiti.engine.test.Deployment)

Example 3 with Process

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

the class DefaultProcessDiagramGenerator method generateProcessDiagram.

protected DefaultProcessDiagramCanvas generateProcessDiagram(BpmnModel bpmnModel, String imageType, List<String> highLightedActivities, List<String> highLightedFlows, String activityFontName, String labelFontName, String annotationFontName, ClassLoader customClassLoader, double scaleFactor) {
    prepareBpmnModel(bpmnModel);
    DefaultProcessDiagramCanvas processDiagramCanvas = initProcessDiagramCanvas(bpmnModel, imageType, activityFontName, labelFontName, annotationFontName, customClassLoader);
    // Draw pool shape, if process is participant in collaboration
    for (Pool pool : bpmnModel.getPools()) {
        GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(pool.getId());
        processDiagramCanvas.drawPoolOrLane(pool.getName(), graphicInfo);
    }
    // Draw lanes
    for (Process process : bpmnModel.getProcesses()) {
        for (Lane lane : process.getLanes()) {
            GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(lane.getId());
            processDiagramCanvas.drawPoolOrLane(lane.getName(), graphicInfo);
        }
    }
    // Draw activities and their sequence-flows
    for (Process process : bpmnModel.getProcesses()) {
        for (FlowNode flowNode : process.findFlowElementsOfType(FlowNode.class)) {
            drawActivity(processDiagramCanvas, bpmnModel, flowNode, highLightedActivities, highLightedFlows, scaleFactor);
        }
    }
    // Draw artifacts
    for (Process process : bpmnModel.getProcesses()) {
        for (Artifact artifact : process.getArtifacts()) {
            drawArtifact(processDiagramCanvas, bpmnModel, artifact);
        }
        List<SubProcess> subProcesses = process.findFlowElementsOfType(SubProcess.class, true);
        if (subProcesses != null) {
            for (SubProcess subProcess : subProcesses) {
                for (Artifact subProcessArtifact : subProcess.getArtifacts()) {
                    drawArtifact(processDiagramCanvas, bpmnModel, subProcessArtifact);
                }
            }
        }
    }
    return processDiagramCanvas;
}
Also used : EventSubProcess(org.activiti.bpmn.model.EventSubProcess) SubProcess(org.activiti.bpmn.model.SubProcess) GraphicInfo(org.activiti.bpmn.model.GraphicInfo) Lane(org.activiti.bpmn.model.Lane) Pool(org.activiti.bpmn.model.Pool) EventSubProcess(org.activiti.bpmn.model.EventSubProcess) Process(org.activiti.bpmn.model.Process) SubProcess(org.activiti.bpmn.model.SubProcess) Artifact(org.activiti.bpmn.model.Artifact) FlowNode(org.activiti.bpmn.model.FlowNode)

Example 4 with Process

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

the class WorkflowDefinitionConversionTest method testTaskListenerForOutgoingProperties.

@Test
public void testTaskListenerForOutgoingProperties() throws Exception {
    WorkflowDefinition definition = new WorkflowDefinition();
    definition.setId("process");
    HumanStepDefinition humanStep = new HumanStepDefinition();
    humanStep.setId("step1");
    FormDefinition form = new FormDefinition();
    humanStep.setForm(form);
    TextPropertyDefinition text = new TextPropertyDefinition();
    text.setName("my text");
    text.getParameters().put(AlfrescoConversionConstants.PARAMETER_ADD_PROPERTY_TO_OUTPUT, true);
    FormPropertyGroup group = new FormPropertyGroup();
    group.setId("group");
    form.getFormGroups().add(group);
    group.getFormPropertyDefinitions().add(text);
    definition.addStep(humanStep);
    WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
    conversion.convert();
    Process process = conversion.getProcess();
    assertNotNull(process);
    boolean listenerFound = false;
    for (FlowElement flowElement : process.getFlowElements()) {
        if (flowElement instanceof UserTask) {
            UserTask task = (UserTask) flowElement;
            assertNotNull(task.getTaskListeners());
            assertEquals(2L, task.getTaskListeners().size());
            assertEquals("create", task.getTaskListeners().get(0).getEvent());
            assertEquals("complete", task.getTaskListeners().get(1).getEvent());
            listenerFound = true;
        }
    }
    assertTrue(listenerFound);
}
Also used : WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) HumanStepDefinition(org.activiti.workflow.simple.definition.HumanStepDefinition) TextPropertyDefinition(org.activiti.workflow.simple.definition.form.TextPropertyDefinition) FlowElement(org.activiti.bpmn.model.FlowElement) UserTask(org.activiti.bpmn.model.UserTask) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) FormPropertyGroup(org.activiti.workflow.simple.definition.form.FormPropertyGroup) Process(org.activiti.bpmn.model.Process) FormDefinition(org.activiti.workflow.simple.definition.form.FormDefinition) Test(org.junit.Test)

Example 5 with Process

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

the class WorkflowDefinitionConversionTest method testTaskListenerForIncomingProperties.

@Test
public void testTaskListenerForIncomingProperties() throws Exception {
    WorkflowDefinition definition = new WorkflowDefinition();
    definition.setId("process");
    HumanStepDefinition humanStep = new HumanStepDefinition();
    humanStep.setId("step1");
    FormDefinition form = new FormDefinition();
    form.setFormKey("myform");
    humanStep.setForm(form);
    definition.addStep(humanStep);
    WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
    conversion.convert();
    Process process = conversion.getProcess();
    assertNotNull(process);
    boolean listenerFound = false;
    for (FlowElement flowElement : process.getFlowElements()) {
        if (flowElement instanceof UserTask) {
            UserTask task = (UserTask) flowElement;
            assertNotNull(task.getTaskListeners());
            assertEquals(1L, task.getTaskListeners().size());
            assertEquals("create", task.getTaskListeners().get(0).getEvent());
            listenerFound = true;
        }
    }
    assertTrue(listenerFound);
}
Also used : WorkflowDefinitionConversion(org.activiti.workflow.simple.converter.WorkflowDefinitionConversion) HumanStepDefinition(org.activiti.workflow.simple.definition.HumanStepDefinition) FlowElement(org.activiti.bpmn.model.FlowElement) UserTask(org.activiti.bpmn.model.UserTask) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) Process(org.activiti.bpmn.model.Process) FormDefinition(org.activiti.workflow.simple.definition.form.FormDefinition) Test(org.junit.Test)

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