Search in sources :

Example 71 with FormDefinition

use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.

the class FormGeneratorTest method testGenerateFormForClassNameWithFilters.

@Test
public void testGenerateFormForClassNameWithFilters() {
    FormDefinition form = generator.generateFormForClassName(Person.class.getName(), getFilters());
    checkFormGeneratedWithFilters(form);
}
Also used : FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Person(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Person) Test(org.junit.Test) AbstractFormGenerationTest(org.kie.workbench.common.forms.adf.engine.shared.test.AbstractFormGenerationTest)

Example 72 with FormDefinition

use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.

the class FormBuildingServiceImplTest method testGenerateFormForClass.

@Test
public void testGenerateFormForClass() {
    FormDefinition form = formBuildingService.generateFormForClass(Person.class);
    testGeneratedForm(form, Person.class.getName());
}
Also used : FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Person(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Person) Test(org.junit.Test) AbstractFormGenerationTest(org.kie.workbench.common.forms.adf.engine.shared.test.AbstractFormGenerationTest)

Example 73 with FormDefinition

use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.

the class FormBuildingServiceImplTest method testGenerateFormForModel.

@Test
public void testGenerateFormForModel() {
    FormDefinition form = formBuildingService.generateFormForModel(model);
    testGeneratedForm(form, Person.class.getName());
}
Also used : FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Person(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Person) Test(org.junit.Test) AbstractFormGenerationTest(org.kie.workbench.common.forms.adf.engine.shared.test.AbstractFormGenerationTest)

Example 74 with FormDefinition

use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.

the class DynamicFormModelGenerator method addNestedForm.

private void addNestedForm(String className, StaticModelFormRenderingContext context, Collection<FormElementFilter> nestedFormFilters) {
    if (!context.getAvailableForms().containsKey(className)) {
        FormDefinition nested = formBuildingService.generateFormForClassName(className, nestedFormFilters.stream().toArray(FormElementFilter[]::new));
        context.getAvailableForms().put(className, nested);
        initNestedFormSettings(nested, null, context, nestedFormFilters);
    }
}
Also used : FormElementFilter(org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 75 with FormDefinition

use of org.kie.workbench.common.forms.model.FormDefinition in project kie-wb-common by kiegroup.

the class DynamicFormModelGeneratorTest method testGenerateContextForModelWithFilters.

@Test
public void testGenerateContextForModelWithFilters() {
    FormElementFilter nameFilter = new FormElementFilter("name", o -> true);
    FormElementFilter lastNameFilter = new FormElementFilter("lastName", o -> false);
    FormElementFilter addressStreetFilter = new FormElementFilter("address.street", o -> true);
    FormElementFilter addressNumFilter = new FormElementFilter("address.number", o -> false);
    StaticModelFormRenderingContext context = dynamicFormModelGenerator.getContextForModel(model, nameFilter, lastNameFilter, addressStreetFilter, addressNumFilter);
    assertEquals(3, context.getAvailableForms().size());
    FormDefinition rootForm = context.getRootForm();
    assertNotNull(rootForm);
    assertEquals(rootForm.getFields().size(), rootForm.getLayoutTemplate().getRows().size());
    assertNotNull(rootForm.getFieldByBinding("name"));
    assertNull(rootForm.getFieldByBinding("lastName"));
    FormDefinition addressForm = context.getAvailableForms().get(Address.class.getName());
    assertNotNull(addressForm);
    assertEquals(addressForm.getFields().size(), addressForm.getLayoutTemplate().getRows().size());
    assertNotNull(addressForm.getFieldByBinding("street"));
    assertNull(addressForm.getFieldByBinding("number"));
}
Also used : Address(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Address) StaticModelFormRenderingContext(org.kie.workbench.common.forms.dynamic.service.shared.impl.StaticModelFormRenderingContext) FormElementFilter(org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test) AbstractFormGenerationTest(org.kie.workbench.common.forms.adf.engine.shared.test.AbstractFormGenerationTest)

Aggregations

FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)89 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)30 Test (org.junit.Test)29 ArrayList (java.util.ArrayList)16 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)14 FormGenerationResult (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult)14 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)13 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)12 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)12 AbstractFormGenerationTest (org.kie.workbench.common.forms.adf.engine.shared.test.AbstractFormGenerationTest)10 Form (org.kie.workbench.common.forms.migration.legacy.model.Form)10 List (java.util.List)9 LayoutTemplate (org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)9 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)8 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)8 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)8 Person (org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Person)7 FormModel (org.kie.workbench.common.forms.model.FormModel)7 PortableJavaModel (org.kie.workbench.common.forms.model.impl.PortableJavaModel)7 Date (java.util.Date)6