Search in sources :

Example 21 with FormDefinition

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

the class FormGeneratorTest method testGenerateFormForModel.

@Test
public void testGenerateFormForModel() {
    FormDefinition form = generator.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 22 with FormDefinition

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

the class FormGeneratorTest method testGenerateFormForModelWithFilters.

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

Example 23 with FormDefinition

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

the class FormBuildingServiceImplTest method testGenerateFormForClassName.

@Test
public void testGenerateFormForClassName() {
    FormDefinition form = formBuildingService.generateFormForClassName(Person.class.getName());
    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 24 with FormDefinition

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

the class DynamicFormModelGenerator method getContextForModel.

public StaticModelFormRenderingContext getContextForModel(Object model, FormElementFilter... filters) {
    PortablePreconditions.checkNotNull("model", model);
    Optional<FormElementFilter[]> optional = Optional.ofNullable(filters);
    Stream<FormElementFilter> streamFilter = optional.map(value -> Stream.of(value)).orElseGet(Stream::empty);
    List<FormElementFilter> rootFormElemenFilters = new ArrayList<>();
    List<FormElementFilter> nestedFormFilters = new ArrayList<>();
    streamFilter.forEach(filter -> {
        if (!filter.getElementName().contains(".")) {
            rootFormElemenFilters.add(filter);
        } else {
            nestedFormFilters.add(filter);
        }
    });
    FormDefinition formDefinition = formBuildingService.generateFormForModel(model, rootFormElemenFilters.stream().toArray(FormElementFilter[]::new));
    if (formDefinition == null) {
        return null;
    }
    StaticModelFormRenderingContext context = new StaticModelFormRenderingContext();
    context.setModel(model);
    context.setRootForm(formDefinition);
    if (context.getModel() != null) {
        initNestedFormSettings(formDefinition, context.getModel(), context, nestedFormFilters);
    } else {
        initNestedFormSettings(formDefinition, null, context, nestedFormFilters);
    }
    return context;
}
Also used : TableColumnMeta(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.TableColumnMeta) Collection(java.util.Collection) FormElementFilter(org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter) IsCRUDDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.IsCRUDDefinition) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) HasNestedForm(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.HasNestedForm) Inject(javax.inject.Inject) PropertyValueExtractor(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.util.PropertyValueExtractor) List(java.util.List) Stream(java.util.stream.Stream) StaticModelFormRenderingContext(org.kie.workbench.common.forms.dynamic.service.shared.impl.StaticModelFormRenderingContext) Dependent(javax.enterprise.context.Dependent) FormBuildingService(org.kie.workbench.common.forms.adf.engine.shared.FormBuildingService) Optional(java.util.Optional) EntityRelationField(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.EntityRelationField) PortablePreconditions(org.kie.soup.commons.validation.PortablePreconditions) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) ArrayList(java.util.ArrayList) StaticModelFormRenderingContext(org.kie.workbench.common.forms.dynamic.service.shared.impl.StaticModelFormRenderingContext) FormElementFilter(org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter) Stream(java.util.stream.Stream) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 25 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(Object model, StaticModelFormRenderingContext context, Collection<FormElementFilter> nestedFormFilters) {
    if (!context.getAvailableForms().containsKey(model.getClass().getName())) {
        FormDefinition nested = formBuildingService.generateFormForModel(model, nestedFormFilters.stream().toArray(FormElementFilter[]::new));
        context.getAvailableForms().put(model.getClass().getName(), nested);
        initNestedFormSettings(nested, model, context, nestedFormFilters);
    }
}
Also used : FormElementFilter(org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

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