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;
}
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());
}
}
}
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());
}
Aggregations