Search in sources :

Example 66 with FormDefinition

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

the class FormLayoutTemplateGeneratorTest method init.

@Before
public void init() {
    templateGenerator = getTemplateGenerator();
    form = new FormDefinition();
    form.setName("Test");
    form.setId("Test-ID");
    TextBoxFieldDefinition name = new TextBoxFieldDefinition();
    name.setId("name");
    name.setName("employee_name");
    name.setLabel("Name");
    name.setPlaceHolder("Name");
    name.setBinding("name");
    name.setStandaloneClassName(String.class.getName());
    TextBoxFieldDefinition lastName = new TextBoxFieldDefinition();
    lastName.setId("lastName");
    lastName.setName("employee_lastName");
    lastName.setLabel("Last Name");
    lastName.setPlaceHolder("Last Name");
    lastName.setBinding("lastName");
    lastName.setStandaloneClassName(String.class.getName());
    DatePickerFieldDefinition birthday = new DatePickerFieldDefinition();
    birthday.setId("birthday");
    birthday.setName("employee_birthday");
    birthday.setLabel("Birthday");
    birthday.setBinding("birthday");
    birthday.setStandaloneClassName(Date.class.getName());
    CheckBoxFieldDefinition married = new CheckBoxFieldDefinition();
    married.setId("married");
    married.setName("employee_married");
    married.setLabel("Married");
    married.setBinding("married");
    married.setStandaloneClassName(Boolean.class.getName());
    form.getFields().add(name);
    form.getFields().add(lastName);
    form.getFields().add(birthday);
    form.getFields().add(married);
}
Also used : TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) DatePickerFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Date(java.util.Date) Before(org.junit.Before)

Example 67 with FormDefinition

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

the class FormDefinitionSerializerImplTest method initTest.

@Before
public void initTest() {
    fieldManager = new TestFieldManager();
    definitionSerializer = new FormDefinitionSerializerImpl(new FieldSerializer(), new FormModelSerializer(), new TestMetaDataEntryManager());
    JavaFormModel model = new PortableJavaModel("org.test.MyParentModel");
    formDefinition = new FormDefinition(model);
    formDefinition.setId("testForm");
    formDefinition.setName("testForm");
    formDefinition.setLayoutTemplate(new LayoutTemplate());
    for (BasicTypeFieldProvider provider : fieldManager.getAllBasicTypeProviders()) {
        for (String type : provider.getSupportedTypes()) {
            FieldDefinition field = provider.getFieldByType(new TypeInfoImpl(type));
            assertNotNull(field);
            String fieldDescription = provider.getFieldTypeName() + "_" + type;
            field.setName(fieldDescription);
            field.setLabel(fieldDescription);
            field.setStandaloneClassName(type);
            field.setBinding(fieldDescription);
            model.getProperties().add(new ModelPropertyImpl(fieldDescription, new TypeInfoImpl(type)));
            formDefinition.getFields().add(field);
        }
    }
    SubFormFieldDefinition subForm = new SubFormFieldDefinition();
    subForm.setLabel("SubForm");
    subForm.setNestedForm("");
    subForm.setBinding("model");
    subForm.setStandaloneClassName("org.test.MyTestModel");
    subForm.setBinding("SubForm");
    formDefinition.getFields().add(subForm);
    model.getProperties().add(new ModelPropertyImpl(subForm.getBinding(), new TypeInfoImpl(TypeKind.OBJECT, subForm.getStandaloneClassName(), false)));
    MultipleSubFormFieldDefinition multipleSubForm = new MultipleSubFormFieldDefinition();
    multipleSubForm.setLabel("MultipleSubForm");
    multipleSubForm.setCreationForm("");
    multipleSubForm.setEditionForm("");
    multipleSubForm.setStandaloneClassName("org.test.MyTestModel");
    multipleSubForm.setBinding("MultipleSubForm");
    formDefinition.getFields().add(multipleSubForm);
    model.getProperties().add(new ModelPropertyImpl(multipleSubForm.getBinding(), new TypeInfoImpl(TypeKind.OBJECT, multipleSubForm.getStandaloneClassName(), true)));
    EnumListBoxFieldDefinition enumListBox = new EnumListBoxFieldDefinition();
    enumListBox.setLabel("EnumListBox");
    enumListBox.setBinding("EnumListBox");
    enumListBox.setStandaloneClassName("org.test.MyTestModel");
    formDefinition.getFields().add(enumListBox);
    model.getProperties().add(new ModelPropertyImpl(enumListBox.getBinding(), new TypeInfoImpl(TypeKind.ENUM, enumListBox.getStandaloneClassName(), false)));
}
Also used : LayoutTemplate(org.uberfire.ext.layout.editor.api.editor.LayoutTemplate) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) EnumListBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TestMetaDataEntryManager(org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) EnumListBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) PortableJavaModel(org.kie.workbench.common.forms.model.impl.PortableJavaModel) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) JavaFormModel(org.kie.workbench.common.forms.model.JavaFormModel) BasicTypeFieldProvider(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider) Before(org.junit.Before)

Example 68 with FormDefinition

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

the class FormDefinitionSerializerImplTest method testFormDeSerialization.

@Test
public void testFormDeSerialization() {
    String serializedForm = doSerializationTest();
    FormDefinition deSerializedForm = definitionSerializer.deserialize(serializedForm);
    assertNotNull(deSerializedForm);
    assertEquals(formDefinition.getFields().size(), deSerializedForm.getFields().size());
    for (FieldDefinition originalField : formDefinition.getFields()) {
        FieldDefinition resultField = deSerializedForm.getFieldById(originalField.getId());
        assertNotNull(resultField);
        assertEquals(originalField.getClass(), resultField.getClass());
        assertEquals(originalField.getName(), resultField.getName());
        assertEquals(originalField.getLabel(), resultField.getLabel());
        assertEquals(originalField.getStandaloneClassName(), resultField.getStandaloneClassName());
    }
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) EnumListBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test)

Example 69 with FormDefinition

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

the class FormGeneratorTest method testGenerateFormForClassWithFilters.

@Test
public void testGenerateFormForClassWithFilters() {
    FormDefinition form = generator.generateFormForClass(Person.class, 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 70 with FormDefinition

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

the class FormGeneratorTest method testGenerateFormForClassName.

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

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