Search in sources :

Example 46 with UserTask

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

the class UserTaskJsonConverter method convertJsonToElement.

@Override
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
    UserTask task = new UserTask();
    task.setPriority(getPropertyValueAsString(PROPERTY_USERTASK_PRIORITY, elementNode));
    String formKey = getPropertyValueAsString(PROPERTY_FORMKEY, elementNode);
    if (StringUtils.isNotEmpty(formKey)) {
        task.setFormKey(formKey);
    }
    task.setDueDate(getPropertyValueAsString(PROPERTY_USERTASK_DUEDATE, elementNode));
    task.setCategory(getPropertyValueAsString(PROPERTY_USERTASK_CATEGORY, elementNode));
    JsonNode assignmentNode = getProperty(PROPERTY_USERTASK_ASSIGNMENT, elementNode);
    if (assignmentNode != null) {
        JsonNode assignmentDefNode = assignmentNode.get("assignment");
        if (assignmentDefNode != null) {
            JsonNode assigneeNode = assignmentDefNode.get(PROPERTY_USERTASK_ASSIGNEE);
            if (assigneeNode != null && assigneeNode.isNull() == false) {
                task.setAssignee(assigneeNode.asText());
            }
            JsonNode ownerNode = assignmentDefNode.get(PROPERTY_USERTASK_OWNER);
            if (ownerNode != null && ownerNode.isNull() == false) {
                task.setOwner(ownerNode.asText());
            }
            task.setCandidateUsers(getValueAsList(PROPERTY_USERTASK_CANDIDATE_USERS, assignmentDefNode));
            task.setCandidateGroups(getValueAsList(PROPERTY_USERTASK_CANDIDATE_GROUPS, assignmentDefNode));
        }
    }
    convertJsonToFormProperties(elementNode, task);
    return task;
}
Also used : UserTask(org.activiti.bpmn.model.UserTask) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 47 with UserTask

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

the class FormPropertiesConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    assertEquals("formPropertiesProcess", model.getMainProcess().getId());
    assertEquals("User registration", model.getMainProcess().getName());
    assertEquals(true, model.getMainProcess().isExecutable());
    FlowElement startFlowElement = model.getMainProcess().getFlowElement("startNode");
    assertNotNull(startFlowElement);
    assertTrue(startFlowElement instanceof StartEvent);
    StartEvent startEvent = (StartEvent) startFlowElement;
    List<FormProperty> formProperties = startEvent.getFormProperties();
    assertNotNull(formProperties);
    assertEquals("Invalid form properties list: ", 8, formProperties.size());
    for (FormProperty formProperty : formProperties) {
        if (formProperty.getId().equals("new_property_1")) {
            checkFormProperty(formProperty, "v000", true, false, false);
        } else if (formProperty.getId().equals("new_property_2")) {
            checkFormProperty(formProperty, "v001", true, false, true);
        } else if (formProperty.getId().equals("new_property_3")) {
            checkFormProperty(formProperty, "v010", true, true, false);
        } else if (formProperty.getId().equals("new_property_4")) {
            checkFormProperty(formProperty, "v011", true, true, true);
        } else if (formProperty.getId().equals("new_property_5")) {
            checkFormProperty(formProperty, "v100", true, false, false);
            List<Map<String, Object>> formValues = new ArrayList<Map<String, Object>>();
            for (FormValue formValue : formProperty.getFormValues()) {
                Map<String, Object> formValueMap = new HashMap<String, Object>();
                formValueMap.put("id", formValue.getId());
                formValueMap.put("name", formValue.getName());
                formValues.add(formValueMap);
            }
            checkFormPropertyFormValues(formValues);
        } else if (formProperty.getId().equals("new_property_6")) {
            checkFormProperty(formProperty, "v101", true, false, true);
        } else if (formProperty.getId().equals("new_property_7")) {
            checkFormProperty(formProperty, "v110", true, true, false);
        } else if (formProperty.getId().equals("new_property_8")) {
            checkFormProperty(formProperty, "v111", true, true, true);
        } else {
            fail("unexpected form property id " + formProperty.getId());
        }
    }
    FlowElement userFlowElement = model.getMainProcess().getFlowElement("userTask");
    assertNotNull(userFlowElement);
    assertTrue(userFlowElement instanceof UserTask);
    UserTask userTask = (UserTask) userFlowElement;
    formProperties = userTask.getFormProperties();
    assertNotNull(formProperties);
    assertEquals("Invalid form properties list: ", 8, formProperties.size());
    for (FormProperty formProperty : formProperties) {
        if (formProperty.getId().equals("new_property_1")) {
            checkFormProperty(formProperty, "v000", false, false, false);
        } else if (formProperty.getId().equals("new_property_2")) {
            checkFormProperty(formProperty, "v001", false, false, true);
        } else if (formProperty.getId().equals("new_property_3")) {
            checkFormProperty(formProperty, "v010", false, true, false);
        } else if (formProperty.getId().equals("new_property_4")) {
            checkFormProperty(formProperty, "v011", false, true, true);
        } else if (formProperty.getId().equals("new_property_5")) {
            checkFormProperty(formProperty, "v100", true, false, false);
            List<Map<String, Object>> formValues = new ArrayList<Map<String, Object>>();
            for (FormValue formValue : formProperty.getFormValues()) {
                Map<String, Object> formValueMap = new HashMap<String, Object>();
                formValueMap.put("id", formValue.getId());
                formValueMap.put("name", formValue.getName());
                formValues.add(formValueMap);
            }
            checkFormPropertyFormValues(formValues);
        } else if (formProperty.getId().equals("new_property_6")) {
            checkFormProperty(formProperty, "v101", true, false, true);
        } else if (formProperty.getId().equals("new_property_7")) {
            checkFormProperty(formProperty, "v110", true, true, false);
        } else if (formProperty.getId().equals("new_property_8")) {
            checkFormProperty(formProperty, "v111", true, true, true);
        } else {
            fail("unexpected form property id " + formProperty.getId());
        }
    }
}
Also used : FormValue(org.activiti.bpmn.model.FormValue) FormProperty(org.activiti.bpmn.model.FormProperty) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) UserTask(org.activiti.bpmn.model.UserTask) FlowElement(org.activiti.bpmn.model.FlowElement) StartEvent(org.activiti.bpmn.model.StartEvent) HashMap(java.util.HashMap) Map(java.util.Map)

Example 48 with UserTask

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

the class CompleteConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("userTask1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("userTask1", flowElement.getId());
    flowElement = model.getMainProcess().getFlowElement("catchsignal");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof IntermediateCatchEvent);
    assertEquals("catchsignal", flowElement.getId());
    IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) flowElement;
    assertEquals(1, catchEvent.getEventDefinitions().size());
    assertTrue(catchEvent.getEventDefinitions().get(0) instanceof SignalEventDefinition);
    SignalEventDefinition signalEvent = (SignalEventDefinition) catchEvent.getEventDefinitions().get(0);
    assertEquals("testSignal", signalEvent.getSignalRef());
    flowElement = model.getMainProcess().getFlowElement("subprocess");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("subprocess", flowElement.getId());
    SubProcess subProcess = (SubProcess) flowElement;
    flowElement = subProcess.getFlowElement("receiveTask");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof ReceiveTask);
    assertEquals("receiveTask", flowElement.getId());
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) ReceiveTask(org.activiti.bpmn.model.ReceiveTask) FlowElement(org.activiti.bpmn.model.FlowElement) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) UserTask(org.activiti.bpmn.model.UserTask) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition)

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