Search in sources :

Example 11 with UserTask

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

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

the class ResourceParser method parse.

public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception {
    String resourceId = xtr.getAttributeValue(null, ATTRIBUTE_ID);
    String resourceName = xtr.getAttributeValue(null, ATTRIBUTE_NAME);
    Resource resource;
    if (model.containsResourceId(resourceId)) {
        resource = model.getResource(resourceId);
        resource.setName(resourceName);
        for (org.activiti.bpmn.model.Process process : model.getProcesses()) {
            for (FlowElement fe : process.getFlowElements()) {
                if (fe instanceof UserTask && ((UserTask) fe).getCandidateGroups().contains(resourceId)) {
                    ((UserTask) fe).getCandidateGroups().remove(resourceId);
                    ((UserTask) fe).getCandidateGroups().add(resourceName);
                }
            }
        }
    } else {
        resource = new Resource(resourceId, resourceName);
        model.addResource(resource);
    }
    BpmnXMLUtil.addXMLLocation(resource, xtr);
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) Resource(org.activiti.bpmn.model.Resource) UserTask(org.activiti.bpmn.model.UserTask)

Example 13 with UserTask

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

the class SimpleConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    assertEquals(2, model.getDefinitionsAttributes().size());
    assertEquals("2.2A", model.getDefinitionsAttributeValue("http://activiti.com/modeler", "version"));
    assertEquals("20140312T10:45:23", model.getDefinitionsAttributeValue("http://activiti.com/modeler", "exportDate"));
    assertEquals("simpleProcess", model.getMainProcess().getId());
    assertEquals("Simple process", model.getMainProcess().getName());
    assertEquals("simple doc", model.getMainProcess().getDocumentation());
    assertEquals(true, model.getMainProcess().isExecutable());
    FlowElement flowElement = model.getMainProcess().getFlowElement("flow1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SequenceFlow);
    assertEquals("flow1", flowElement.getId());
    flowElement = model.getMainProcess().getFlowElement("catchEvent");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof IntermediateCatchEvent);
    assertEquals("catchEvent", flowElement.getId());
    IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) flowElement;
    assertTrue(catchEvent.getEventDefinitions().size() == 1);
    EventDefinition eventDefinition = catchEvent.getEventDefinitions().get(0);
    assertTrue(eventDefinition instanceof TimerEventDefinition);
    TimerEventDefinition timerDefinition = (TimerEventDefinition) eventDefinition;
    assertEquals("PT5M", timerDefinition.getTimeDuration());
    flowElement = model.getMainProcess().getFlowElement("userTask1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    UserTask task = (UserTask) flowElement;
    assertEquals("task doc", task.getDocumentation());
    flowElement = model.getMainProcess().getFlowElement("flow1Condition");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SequenceFlow);
    assertEquals("flow1Condition", flowElement.getId());
    SequenceFlow flow = (SequenceFlow) flowElement;
    assertEquals("${number <= 1}", flow.getConditionExpression());
    flowElement = model.getMainProcess().getFlowElement("gateway1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof ExclusiveGateway);
}
Also used : ExclusiveGateway(org.activiti.bpmn.model.ExclusiveGateway) FlowElement(org.activiti.bpmn.model.FlowElement) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) UserTask(org.activiti.bpmn.model.UserTask) EventDefinition(org.activiti.bpmn.model.EventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Example 14 with UserTask

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

the class SubProcessConverterAutoLayoutTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof StartEvent);
    assertEquals("start1", flowElement.getId());
    flowElement = model.getMainProcess().getFlowElement("userTask1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("userTask1", flowElement.getId());
    UserTask userTask = (UserTask) flowElement;
    assertTrue(userTask.getCandidateUsers().size() == 1);
    assertTrue(userTask.getCandidateGroups().size() == 1);
    flowElement = model.getMainProcess().getFlowElement("subprocess1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("subprocess1", flowElement.getId());
    SubProcess subProcess = (SubProcess) flowElement;
    assertTrue(subProcess.getFlowElements().size() == 6);
    List<ValuedDataObject> dataObjects = ((SubProcess) flowElement).getDataObjects();
    assertTrue(dataObjects.size() == 1);
    ValuedDataObject dataObj = dataObjects.get(0);
    assertEquals("SubTest", dataObj.getName());
    assertEquals("xsd:string", dataObj.getItemSubjectRef().getStructureRef());
    assertTrue(dataObj.getValue() instanceof String);
    assertEquals("Testing", dataObj.getValue());
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) ValuedDataObject(org.activiti.bpmn.model.ValuedDataObject) FlowElement(org.activiti.bpmn.model.FlowElement) StartEvent(org.activiti.bpmn.model.StartEvent) UserTask(org.activiti.bpmn.model.UserTask)

Example 15 with UserTask

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

the class UserTaskConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("usertask");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("usertask", flowElement.getId());
    UserTask userTask = (UserTask) flowElement;
    assertEquals("usertask", userTask.getId());
    assertEquals("User task", userTask.getName());
    assertEquals("Test Category", userTask.getCategory());
    assertEquals("testKey", userTask.getFormKey());
    assertEquals("40", userTask.getPriority());
    assertEquals("2012-11-01", userTask.getDueDate());
    assertEquals("customCalendarName", userTask.getBusinessCalendarName());
    assertEquals("kermit", userTask.getAssignee());
    assertEquals(2, userTask.getCandidateUsers().size());
    assertTrue(userTask.getCandidateUsers().contains("kermit"));
    assertTrue(userTask.getCandidateUsers().contains("fozzie"));
    assertEquals(2, userTask.getCandidateGroups().size());
    assertTrue(userTask.getCandidateGroups().contains("management"));
    assertTrue(userTask.getCandidateGroups().contains("sales"));
    assertEquals(1, userTask.getCustomUserIdentityLinks().size());
    assertEquals(2, userTask.getCustomGroupIdentityLinks().size());
    assertTrue(userTask.getCustomUserIdentityLinks().get("businessAdministrator").contains("kermit"));
    assertTrue(userTask.getCustomGroupIdentityLinks().get("manager").contains("management"));
    assertTrue(userTask.getCustomGroupIdentityLinks().get("businessAdministrator").contains("management"));
    List<FormProperty> formProperties = userTask.getFormProperties();
    assertEquals(3, formProperties.size());
    FormProperty formProperty = formProperties.get(0);
    assertEquals("formId", formProperty.getId());
    assertEquals("formName", formProperty.getName());
    assertEquals("string", formProperty.getType());
    assertEquals("variable", formProperty.getVariable());
    assertEquals("${expression}", formProperty.getExpression());
    formProperty = formProperties.get(1);
    assertEquals("formId2", formProperty.getId());
    assertEquals("anotherName", formProperty.getName());
    assertEquals("long", formProperty.getType());
    assertTrue(StringUtils.isEmpty(formProperty.getVariable()));
    assertTrue(StringUtils.isEmpty(formProperty.getExpression()));
    formProperty = formProperties.get(2);
    assertEquals("formId3", formProperty.getId());
    assertEquals("enumName", formProperty.getName());
    assertEquals("enum", formProperty.getType());
    assertTrue(StringUtils.isEmpty(formProperty.getVariable()));
    assertTrue(StringUtils.isEmpty(formProperty.getExpression()));
    assertEquals(2, formProperty.getFormValues().size());
    List<ActivitiListener> listeners = userTask.getTaskListeners();
    assertEquals(3, listeners.size());
    ActivitiListener listener = listeners.get(0);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
    assertEquals("org.test.TestClass", listener.getImplementation());
    assertEquals("create", listener.getEvent());
    listener = listeners.get(1);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${someExpression}", listener.getImplementation());
    assertEquals("assignment", listener.getEvent());
    listener = listeners.get(2);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${someDelegateExpression}", listener.getImplementation());
    assertEquals("complete", listener.getEvent());
    List<ActivitiListener> executionListeners = userTask.getExecutionListeners();
    assertEquals(1, executionListeners.size());
    ActivitiListener executionListener = executionListeners.get(0);
    assertEquals("end", executionListener.getEvent());
}
Also used : FormProperty(org.activiti.bpmn.model.FormProperty) FlowElement(org.activiti.bpmn.model.FlowElement) UserTask(org.activiti.bpmn.model.UserTask) ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

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