use of org.camunda.bpm.engine.form.FormField in project camunda-bpm-platform by camunda.
the class GetTaskFormVariablesCmd method execute.
public VariableMap execute(CommandContext commandContext) {
final TaskManager taskManager = commandContext.getTaskManager();
TaskEntity task = taskManager.findTaskById(resourceId);
ensureNotNull(BadUserRequestException.class, "Cannot find task with id '" + resourceId + "'.", "task", task);
checkGetTaskFormVariables(task, commandContext);
VariableMapImpl result = new VariableMapImpl();
// first, evaluate form fields
TaskDefinition taskDefinition = task.getTaskDefinition();
if (taskDefinition != null) {
TaskFormData taskFormData = taskDefinition.getTaskFormHandler().createTaskForm(task);
for (FormField formField : taskFormData.getFormFields()) {
if (formVariableNames == null || formVariableNames.contains(formField.getId())) {
result.put(formField.getId(), createVariable(formField, task));
}
}
}
// collect remaining variables from task scope and parent scopes
task.collectVariables(result, formVariableNames, false, deserializeObjectValues);
return result;
}
use of org.camunda.bpm.engine.form.FormField in project camunda-bpm-platform by camunda.
the class MockProvider method createMockTaskFormDataUsingFormFieldsWithoutFormKey.
public static TaskFormData createMockTaskFormDataUsingFormFieldsWithoutFormKey() {
FormField mockFormField = mock(FormField.class);
when(mockFormField.getId()).thenReturn(EXAMPLE_FORM_PROPERTY_ID);
when(mockFormField.getLabel()).thenReturn(EXAMPLE_FORM_PROPERTY_NAME);
when(mockFormField.getDefaultValue()).thenReturn(EXAMPLE_FORM_PROPERTY_VALUE);
FormType mockFormType = mock(FormType.class);
when(mockFormType.getName()).thenReturn(EXAMPLE_FORM_PROPERTY_TYPE_NAME);
when(mockFormField.getType()).thenReturn(mockFormType);
TaskFormData mockFormData = mock(TaskFormData.class);
when(mockFormData.getDeploymentId()).thenReturn(EXAMPLE_DEPLOYMENT_ID);
List<FormField> mockFormFields = new ArrayList<FormField>();
mockFormFields.add(mockFormField);
when(mockFormData.getFormFields()).thenReturn(mockFormFields);
return mockFormData;
}
use of org.camunda.bpm.engine.form.FormField in project camunda-bpm-platform by camunda.
the class FormServiceTest method testBusinessKey.
@Deployment
@Test
public void testBusinessKey() {
// given
String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
// when
StartFormData startFormData = formService.getStartFormData(procDefId);
// then
FormField formField = startFormData.getFormFields().get(0);
assertTrue(formField.isBusinessKey());
}
use of org.camunda.bpm.engine.form.FormField in project camunda-bpm-platform by camunda.
the class FormDataTest method testGetFormFieldValidationConstraints.
@Deployment
public void testGetFormFieldValidationConstraints() {
runtimeService.startProcessInstanceByKey("FormDataTest.testGetFormFieldValidationConstraints");
Task task = taskService.createTaskQuery().singleResult();
TaskFormData taskFormData = formService.getTaskFormData(task.getId());
List<FormField> formFields = taskFormData.getFormFields();
FormField field1 = formFields.get(0);
List<FormFieldValidationConstraint> validationConstraints = field1.getValidationConstraints();
FormFieldValidationConstraint constraint1 = validationConstraints.get(0);
assertEquals("maxlength", constraint1.getName());
assertEquals("10", constraint1.getConfiguration());
FormFieldValidationConstraint constraint2 = validationConstraints.get(1);
assertEquals("minlength", constraint2.getName());
assertEquals("5", constraint2.getConfiguration());
}
use of org.camunda.bpm.engine.form.FormField in project camunda-bpm-platform by camunda.
the class FormDataTest method testGetFormFieldProperties.
@Deployment
public void testGetFormFieldProperties() {
runtimeService.startProcessInstanceByKey("FormDataTest.testGetFormFieldProperties");
Task task = taskService.createTaskQuery().singleResult();
TaskFormData taskFormData = formService.getTaskFormData(task.getId());
List<FormField> formFields = taskFormData.getFormFields();
FormField stringField = formFields.get(0);
Map<String, String> properties = stringField.getProperties();
assertEquals("property1", properties.get("p1"));
assertEquals("property2", properties.get("p2"));
}
Aggregations