Search in sources :

Example 1 with UserTask

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

the class CdiEventSupportBpmnParseHandler method parse.

public void parse(BpmnParse bpmnParse, BaseElement element) {
    if (element instanceof SequenceFlow) {
        TransitionImpl transition = bpmnParse.getSequenceFlows().get(element.getId());
        transition.addExecutionListener(new CdiExecutionListener(transition.getId()));
    } else {
        ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(element.getId());
        if (element instanceof UserTask) {
            addCreateListener(activity);
            addAssignListener(activity);
            addCompleteListener(activity);
            addDeleteListener(activity);
        }
        if (activity != null) {
            addStartEventListener(activity);
            addEndEventListener(activity);
        }
    }
}
Also used : TransitionImpl(org.activiti.engine.impl.pvm.process.TransitionImpl) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) UserTask(org.activiti.bpmn.model.UserTask)

Example 2 with UserTask

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

the class RepositoryServiceTest method testGetBpmnModel.

@Deployment
public void testGetBpmnModel() {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    // Some basic assertions
    BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
    assertNotNull(bpmnModel);
    assertEquals(1, bpmnModel.getProcesses().size());
    assertTrue(!bpmnModel.getLocationMap().isEmpty());
    assertTrue(!bpmnModel.getFlowLocationMap().isEmpty());
    // Test the flow
    org.activiti.bpmn.model.Process process = bpmnModel.getProcesses().get(0);
    List<StartEvent> startEvents = process.findFlowElementsOfType(StartEvent.class);
    assertEquals(1, startEvents.size());
    StartEvent startEvent = startEvents.get(0);
    assertEquals(1, startEvent.getOutgoingFlows().size());
    assertEquals(0, startEvent.getIncomingFlows().size());
    String nextElementId = startEvent.getOutgoingFlows().get(0).getTargetRef();
    UserTask userTask = (UserTask) process.getFlowElement(nextElementId);
    assertEquals("First Task", userTask.getName());
    assertEquals(1, userTask.getOutgoingFlows().size());
    assertEquals(1, userTask.getIncomingFlows().size());
    nextElementId = userTask.getOutgoingFlows().get(0).getTargetRef();
    ParallelGateway parallelGateway = (ParallelGateway) process.getFlowElement(nextElementId);
    assertEquals(2, parallelGateway.getOutgoingFlows().size());
    nextElementId = parallelGateway.getOutgoingFlows().get(0).getTargetRef();
    assertEquals(1, parallelGateway.getIncomingFlows().size());
    userTask = (UserTask) process.getFlowElement(nextElementId);
    assertEquals(1, userTask.getOutgoingFlows().size());
    nextElementId = userTask.getOutgoingFlows().get(0).getTargetRef();
    parallelGateway = (ParallelGateway) process.getFlowElement(nextElementId);
    assertEquals(1, parallelGateway.getOutgoingFlows().size());
    assertEquals(2, parallelGateway.getIncomingFlows().size());
    nextElementId = parallelGateway.getOutgoingFlows().get(0).getTargetRef();
    EndEvent endEvent = (EndEvent) process.getFlowElement(nextElementId);
    assertEquals(0, endEvent.getOutgoingFlows().size());
    assertEquals(1, endEvent.getIncomingFlows().size());
}
Also used : ParallelGateway(org.activiti.bpmn.model.ParallelGateway) StartEvent(org.activiti.bpmn.model.StartEvent) UserTask(org.activiti.bpmn.model.UserTask) EndEvent(org.activiti.bpmn.model.EndEvent) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) BpmnModel(org.activiti.bpmn.model.BpmnModel) Deployment(org.activiti.engine.test.Deployment)

Example 3 with UserTask

use of org.activiti.bpmn.model.UserTask 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 4 with UserTask

use of org.activiti.bpmn.model.UserTask 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)

Example 5 with UserTask

use of org.activiti.bpmn.model.UserTask 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)

Aggregations

UserTask (org.activiti.bpmn.model.UserTask)48 FlowElement (org.activiti.bpmn.model.FlowElement)25 StartEvent (org.activiti.bpmn.model.StartEvent)18 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)11 SubProcess (org.activiti.bpmn.model.SubProcess)11 FormProperty (org.activiti.bpmn.model.FormProperty)7 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)6 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)6 EndEvent (org.activiti.bpmn.model.EndEvent)6 HashMap (java.util.HashMap)5 BpmnModel (org.activiti.bpmn.model.BpmnModel)5 Process (org.activiti.bpmn.model.Process)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 FormValue (org.activiti.bpmn.model.FormValue)4 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)4 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)4 AlfrescoUserTask (org.activiti.bpmn.model.alfresco.AlfrescoUserTask)4 HumanStepDefinition (org.activiti.workflow.simple.definition.HumanStepDefinition)4 FormDefinition (org.activiti.workflow.simple.definition.form.FormDefinition)4 ArrayList (java.util.ArrayList)3