use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition in project kie-wb-common by kiegroup.
the class NestedFormBackendFormRenderingContextManagerTest method getRootForm.
@Override
protected FormDefinition getRootForm() {
FormDefinition form = new FormDefinition(new PortableJavaModel(Person.class.getName()));
FieldDefinition field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(TypeKind.OBJECT, Person.class.getName(), false));
field.setName("person");
field.setBinding("person");
SubFormFieldDefinition subForm = (SubFormFieldDefinition) field;
subForm.setNestedForm(Person.class.getName());
form.getFields().add(field);
return form;
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition in project kie-wb-common by kiegroup.
the class MapModelBindingHelper method generateModelDefinition.
protected Map<String, PropertyType> generateModelDefinition(FormDefinition form, MapModelRenderingContext context, Map<String, Map<String, PropertyType>> availableModels) {
if (availableModels.containsKey(form.getId())) {
return availableModels.get(form.getId());
}
Map<String, PropertyType> formTypes = new HashMap<>();
availableModels.put(form.getId(), formTypes);
form.getFields().forEach(field -> {
PropertyType propertyType = null;
if (basicProperties.containsKey(field.getStandaloneClassName())) {
propertyType = new PropertyType(basicProperties.get(field.getStandaloneClassName()));
} else if (propertiesGenerator.containsKey(field.getClass())) {
PropertyGenerator generator = propertiesGenerator.get(field.getClass());
propertyType = generator.generatePropertyType(field);
} else if (field instanceof SubFormFieldDefinition) {
propertyType = getModeldefinitionFor((SubFormFieldDefinition) field, context, availableModels);
} else if (field instanceof MultipleSubFormFieldDefinition) {
propertyType = new PropertyType(List.class);
}
if (propertyType != null) {
formTypes.put(field.getBinding(), propertyType);
}
});
return formTypes;
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition in project kie-wb-common by kiegroup.
the class NestedFormsBPMNVFSFormDefinitionGeneratorServiceTest method testCreateNewProcessFormNestedFormsWithModelFormsOnVFS.
@Test
public void testCreateNewProcessFormNestedFormsWithModelFormsOnVFS() {
when(ioService.exists(any())).thenReturn(false);
when(formFinderService.findFormsForType(any(), any())).thenAnswer(this::findVFSForms);
FormGenerationResult result = launchNestedFormsTest();
FormDefinition rootForm = result.getRootForm();
assertNotNull(rootForm);
FieldDefinition expenseField = rootForm.getFieldByBinding(EXPENSE_VARIABLE);
assertNotNull(expenseField);
assertTrue(expenseField instanceof SubFormFieldDefinition);
SubFormFieldDefinition subFormFieldDefinition = (SubFormFieldDefinition) expenseField;
// The nested form should be the form with a field not the empty one
assertEquals(EXPENSE_FORM_ID, subFormFieldDefinition.getNestedForm());
assertEquals(EXPENSE_FORM_ID, subFormFieldDefinition.getStandaloneClassName());
// since the nested forms exist on VFS there shouldn't be any nested forms on the result
assertTrue(result.getNestedForms().isEmpty());
// since the nested forms exist on VFS it shouldn't be any write operation on the VFS
verify(ioService, never()).write(any(), anyString(), any());
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition in project kie-wb-common by kiegroup.
the class BPMNFormGenerationTest method checkBPMForm.
private void checkBPMForm(FormDefinition form, Map<String, FormDefinition> allForms) {
assertNotNull(form);
assertEquals(getModelId() + BPMNVariableUtils.TASK_FORM_SUFFIX, form.getId());
assertEquals(getModelId() + BPMNVariableUtils.TASK_FORM_SUFFIX, form.getName());
assertEquals(1, form.getFields().size());
FieldDefinition field = form.getFieldByBinding("person");
assertFieldStatus(field, "person", Person.class.getName());
assertTrue(field instanceof SubFormFieldDefinition);
SubFormFieldDefinition subForm = (SubFormFieldDefinition) field;
assertNotNull(subForm.getNestedForm());
assertNotNull(allForms.get(subForm.getNestedForm()));
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition in project kie-wb-common by kiegroup.
the class FormGenerationIntegrationTest method testNestedFormsHaveCorrectId.
private void testNestedFormsHaveCorrectId(FormDefinition form, String dataObjectFieldName, String expectedFormId) {
SubFormFieldDefinition dataObjectField = (SubFormFieldDefinition) form.getFieldByName(dataObjectFieldName);
assertThat(dataObjectField.getNestedForm()).isEqualTo(expectedFormId);
}
Aggregations