use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class FormGenerationIntegrationTest method sameIOTaskFormIsCorrectlyGenerated.
@Test
public void sameIOTaskFormIsCorrectlyGenerated() {
when(module.getRootPath()).thenReturn(rootPathWithNestedForms);
final FormGenerationResult formGenerationResult = generateForm("FormGenerationTest_TaskWithTheSameInputsAndOutputs-taskform.frm", taskFormModels.get(3));
final List<String> expectedProcessFormFields = Arrays.asList("_boolean_", CHECKBOX_FIELDTYPE, "_dataObject_", SUBFORM_FIELDTYPE, "_document_", DOCUMENT_FIELDTYPE, "_float_", DECIMALBOX_FIELDTYPE, "_integer_", INTEGERBOX_FIELDTYPE, "_object_", TEXTAREA_FIELDTYPE, "_string_", TEXTBOX_FIELDTYPE);
final FormDefinition rootForm = formGenerationResult.getRootForm();
testFormDefinition(rootForm, expectedProcessFormFields);
testNestedFormsHaveCorrectId(rootForm, "_dataObject_", DATAOBJECT_FORM_ID);
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class FormGenerationIntegrationTest method differentIOTaskFormIsCorrectlyGenerated.
@Test
public void differentIOTaskFormIsCorrectlyGenerated() {
when(module.getRootPath()).thenReturn(rootPathWithNestedForms);
final FormGenerationResult formGenerationResult = generateForm("FormGenerationTest_TaskWithDifferentInputsAndOutputs-taskform.frm", taskFormModels.get(0));
final List<String> expectedProcessFormFields = Arrays.asList(// inputs
"_boolean", CHECKBOX_FIELDTYPE, "_dataObject", SUBFORM_FIELDTYPE, "_document", DOCUMENT_FIELDTYPE, "_float", DECIMALBOX_FIELDTYPE, "_integer", INTEGERBOX_FIELDTYPE, "_object", TEXTAREA_FIELDTYPE, "_string", TEXTBOX_FIELDTYPE, // outputs
"boolean_", CHECKBOX_FIELDTYPE, "dataObject_", SUBFORM_FIELDTYPE, "document_", DOCUMENT_FIELDTYPE, "float_", DECIMALBOX_FIELDTYPE, "integer_", INTEGERBOX_FIELDTYPE, "object_", TEXTAREA_FIELDTYPE, "string_", TEXTBOX_FIELDTYPE);
final FormDefinition rootForm = formGenerationResult.getRootForm();
testFormDefinition(rootForm, expectedProcessFormFields);
testNestedFormsHaveCorrectId(rootForm, "_dataObject", DATAOBJECT_FORM_ID);
testNestedFormsHaveCorrectId(rootForm, "dataObject_", DATAOBJECT_FORM_ID);
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class FormGenerationIntegrationTest method emptyTaskFormIsCorrectlyGenerated.
@Test
public void emptyTaskFormIsCorrectlyGenerated() {
final FormGenerationResult formGenerationResult = generateForm("FormGenerationTest_EmptyTask-taskform.frm", taskFormModels.get(1));
final FormDefinition rootForm = formGenerationResult.getRootForm();
testFormDefinition(rootForm, Collections.emptyList());
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class AbstractBPMNFormGeneratorService method processFieldDefinition.
protected void processFieldDefinition(FieldDefinition field, GenerationContext<SOURCE> context) {
if (field instanceof EntityRelationField) {
if (field instanceof HasNestedForm) {
HasNestedForm nestedFormField = (HasNestedForm) field;
FormDefinition nestedForm = findFormDefinitionForModelType(field.getStandaloneClassName(), context);
if (nestedForm == null) {
nestedForm = createModelFormDefinition(field.getStandaloneClassName(), context);
}
nestedFormField.setNestedForm(nestedForm.getId());
} else if (field instanceof IsCRUDDefinition) {
IsCRUDDefinition crudField = (IsCRUDDefinition) field;
FormDefinition nestedForm = findFormDefinitionForModelType(field.getStandaloneClassName(), context);
if (nestedForm == null) {
nestedForm = createModelFormDefinition(field.getStandaloneClassName(), context);
crudField.setCreationForm(nestedForm.getId());
crudField.setEditionForm(nestedForm.getId());
List<TableColumnMeta> tableColumnMetas = new ArrayList<>();
nestedForm.getFields().forEach(nestedField -> {
tableColumnMetas.add(new TableColumnMeta(nestedField.getLabel(), nestedField.getBinding()));
});
crudField.setColumnMetas(tableColumnMetas);
}
}
}
}
use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.
the class AbstractBPMNFormGeneratorService method createModelFormDefinition.
protected FormDefinition createModelFormDefinition(String modelType, GenerationContext<SOURCE> context) {
FormDefinition form = context.getContextForms().get(modelType);
if (form == null) {
String modelName = modelType.substring(modelType.lastIndexOf(".") + 1);
String formModelName = modelName;
formModelName = formModelName.substring(0, 1).toLowerCase() + formModelName.substring(1);
DataObjectFormModel formModel = new DataObjectFormModel(formModelName, modelType);
form = new FormDefinition(formModel);
context.getContextForms().put(modelType, form);
form.setId(UIDGenerator.generateUID());
form.setName(modelName);
// TODO: extract model properties & generate fields
List<FieldDefinition> fields = extractModelFields(formModel, context);
form.getFields().addAll(fields);
createFormLayout(form);
processFormDefinition(form, context);
}
return form;
}
Aggregations