use of org.camunda.bpm.engine.form.FormField in project camunda-bpm-platform by camunda.
the class MockProvider method createMockStartFormDataUsingFormFieldsWithoutFormKey.
public static StartFormData createMockStartFormDataUsingFormFieldsWithoutFormKey(ProcessDefinition definition) {
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);
StartFormData mockFormData = mock(StartFormData.class);
when(mockFormData.getDeploymentId()).thenReturn(EXAMPLE_DEPLOYMENT_ID);
when(mockFormData.getProcessDefinition()).thenReturn(definition);
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 HtmlFormEngine method renderFormData.
protected String renderFormData(FormData formData) {
if (formData == null || (formData.getFormFields() == null || formData.getFormFields().isEmpty()) && (formData.getFormProperties() == null || formData.getFormProperties().isEmpty())) {
return null;
} else {
HtmlElementWriter formElement = new HtmlElementWriter(FORM_ELEMENT).attribute(NAME_ATTRIBUTE, GENERATED_FORM_NAME).attribute(ROLE_ATTRIBUTE, FORM_ROLE);
HtmlDocumentBuilder documentBuilder = new HtmlDocumentBuilder(formElement);
// render fields
for (FormField formField : formData.getFormFields()) {
renderFormField(formField, documentBuilder);
}
// render deprecated form properties
for (FormProperty formProperty : formData.getFormProperties()) {
renderFormField(new FormPropertyAdapter(formProperty), documentBuilder);
}
// end document element
documentBuilder.endElement();
return documentBuilder.getHtmlString();
}
}
use of org.camunda.bpm.engine.form.FormField in project camunda-bpm-platform by camunda.
the class GetStartFormVariablesCmd method execute.
public VariableMap execute(final CommandContext commandContext) {
StartFormData startFormData = commandContext.runWithoutAuthorization(new Callable<StartFormData>() {
public StartFormData call() throws Exception {
return new GetStartFormCmd(resourceId).execute(commandContext);
}
});
ProcessDefinition definition = startFormData.getProcessDefinition();
checkGetStartFormVariables((ProcessDefinitionEntity) definition, commandContext);
VariableMap result = new VariableMapImpl();
for (FormField formField : startFormData.getFormFields()) {
if (formVariableNames == null || formVariableNames.contains(formField.getId())) {
result.put(formField.getId(), createVariable(formField, null));
}
}
return result;
}
use of org.camunda.bpm.engine.form.FormField in project camunda-bpm-platform by camunda.
the class AbstractRenderFormDelegate method renderFormData.
protected String renderFormData(FormData formData) {
if (formData == null || (formData.getFormFields() == null || formData.getFormFields().isEmpty()) && (formData.getFormProperties() == null || formData.getFormProperties().isEmpty())) {
return null;
} else {
HtmlElementWriter formElement = new HtmlElementWriter(FORM_ELEMENT).attribute(NAME_ATTRIBUTE, GENERATED_FORM_NAME).attribute(ROLE_ATTRIBUTE, FORM_ROLE);
HtmlDocumentBuilder documentBuilder = new HtmlDocumentBuilder(formElement);
// render fields
for (FormField formField : formData.getFormFields()) {
renderFormField(formField, documentBuilder);
}
// render deprecated form properties
for (FormProperty formProperty : formData.getFormProperties()) {
renderFormField(new FormPropertyAdapter(formProperty), documentBuilder);
}
// end document element
documentBuilder.endElement();
return documentBuilder.getHtmlString();
}
}
use of org.camunda.bpm.engine.form.FormField in project camunda-bpm-platform by camunda.
the class FormServiceTest method testGetTaskFormWithoutLabels.
@Deployment
@Test
public void testGetTaskFormWithoutLabels() {
runtimeService.startProcessInstanceByKey("testProcess");
Task task = taskService.createTaskQuery().singleResult();
// form data can be retrieved
TaskFormData formData = formService.getTaskFormData(task.getId());
List<FormField> formFields = formData.getFormFields();
assertEquals(3, formFields.size());
List<String> formFieldIds = new ArrayList<String>();
for (FormField field : formFields) {
assertNull(field.getLabel());
formFieldIds.add(field.getId());
}
assertTrue(formFieldIds.containsAll(Arrays.asList("stringField", "customField", "longField")));
// the form can be rendered
Object startForm = formService.getRenderedTaskForm(task.getId());
assertNotNull(startForm);
}
Aggregations