Search in sources :

Example 56 with FieldDefinition

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

the class FormGenerationWithSynchronizationTest method testModelPropertiesConflict.

@Test
public void testModelPropertiesConflict() {
    List<ModelProperty> modelProperties = new ArrayList<>();
    modelProperties.add(new ModelPropertyImpl(NAME_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
    modelProperties.add(new ModelPropertyImpl(LASTNAME_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
    modelProperties.add(new ModelPropertyImpl(AGE_PROPERTY, new TypeInfoImpl(String.class.getName())));
    modelProperties.add(new ModelPropertyImpl(MARRIED_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
    modelProperties.add(new ModelPropertyImpl(ADDRESS_PROPERTY, new TypeInfoImpl(Boolean.class.getName())));
    newFormModel = new TaskFormModel(PROCESS_ID, TASK_NAME, modelProperties);
    FormGenerationResult generationResult = service.generateForms(newFormModel, source);
    assertNotNull(generationResult);
    assertNotNull(generationResult.getRootForm());
    FormDefinition formDefinition = generationResult.getRootForm();
    assertEquals(newFormModel, formDefinition.getModel());
    assertEquals(ORIGINAL_FORM_FIELDS, Integer.valueOf(formDefinition.getFields().size()));
    FieldDefinition field = formDefinition.getFieldByBinding(NAME_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), Integer.class.getName());
    assertTrue(field instanceof IntegerBoxFieldDefinition);
    field = formDefinition.getFieldByBinding(LASTNAME_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), Integer.class.getName());
    assertTrue(field instanceof IntegerBoxFieldDefinition);
    field = formDefinition.getFieldByBinding(AGE_PROPERTY);
    assertEquals(field.getStandaloneClassName(), String.class.getName());
    assertTrue(field instanceof TextBoxFieldDefinition);
    field = formDefinition.getFieldByBinding(MARRIED_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), Integer.class.getName());
    assertTrue(field instanceof IntegerBoxFieldDefinition);
    field = formDefinition.getFieldByBinding(ADDRESS_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), Boolean.class.getName());
    assertTrue(field instanceof CheckBoxFieldDefinition);
}
Also used : TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) IntegerBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition) ArrayList(java.util.ArrayList) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) ModelProperty(org.kie.workbench.common.forms.model.ModelProperty) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) IntegerBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition) Test(org.junit.Test)

Example 57 with FieldDefinition

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

the class BPMNFormGenerationTest method checkPersonalDataForm.

private void checkPersonalDataForm(FormDefinition form, Map<String, FormDefinition> allForms) {
    assertNotNull(form);
    assertEquals(2, form.getFields().size());
    FieldDefinition field = form.getFieldByBinding("address");
    assertFieldStatus(field, "address", String.class.getName());
    field = form.getFieldByBinding("phone");
    assertFieldStatus(field, "phone", String.class.getName());
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) 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) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) Mockito.anyString(org.mockito.Mockito.anyString)

Example 58 with FieldDefinition

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

the class BPMNFormGenerationTest method checkPersonForm.

private void checkPersonForm(FormDefinition form, Map<String, FormDefinition> allForms) {
    assertNotNull(form);
    assertTrue(form.getModel() instanceof JavaFormModel);
    assertEquals(4, form.getFields().size());
    FieldDefinition field = form.getFieldByBinding("name");
    assertFieldStatus(field, "name", String.class.getName());
    field = form.getFieldByBinding("type");
    assertFieldStatus(field, "type", PersonType.class.getName());
    assertTrue(field instanceof EnumListBoxFieldDefinition);
    field = form.getFieldByBinding("personalData");
    assertFieldStatus(field, "personalData", PersonalData.class.getName());
    assertTrue(field instanceof SubFormFieldDefinition);
    SubFormFieldDefinition subForm = (SubFormFieldDefinition) field;
    assertNotNull(subForm.getNestedForm());
    assertNotNull(allForms.get(subForm.getNestedForm()));
    field = form.getFieldByBinding("log");
    assertFieldStatus(field, "log", LogEntry.class.getName());
    assertTrue(field instanceof MultipleSubFormFieldDefinition);
    MultipleSubFormFieldDefinition multipleSubForm = (MultipleSubFormFieldDefinition) field;
    assertNotNull(multipleSubForm.getCreationForm());
    assertEquals(multipleSubForm.getCreationForm(), multipleSubForm.getEditionForm());
    FormDefinition nestedForm = allForms.get(multipleSubForm.getCreationForm());
    assertNotNull(nestedForm);
    assertNotNull(multipleSubForm.getColumnMetas());
    assertEquals(nestedForm.getFields().size(), multipleSubForm.getColumnMetas().size());
    multipleSubForm.getColumnMetas().forEach(columnMeta -> {
        FieldDefinition nestedField = nestedForm.getFieldByBinding(columnMeta.getProperty());
        assertNotNull(nestedField);
        assertEquals(nestedField.getLabel(), columnMeta.getLabel());
    });
}
Also used : PersonalData(org.kie.workbench.common.forms.jbpm.server.service.impl.model.PersonalData) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) 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) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) PersonType(org.kie.workbench.common.forms.jbpm.server.service.impl.model.PersonType) Mockito.anyString(org.mockito.Mockito.anyString) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) JavaFormModel(org.kie.workbench.common.forms.model.JavaFormModel) EnumListBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition) LogEntry(org.kie.workbench.common.forms.jbpm.server.service.impl.model.LogEntry) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)

Example 59 with FieldDefinition

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

the class BPMNFormGenerationTest method checkLogEntryForm.

private void checkLogEntryForm(FormDefinition form) {
    assertNotNull(form);
    assertEquals(2, form.getFields().size());
    FieldDefinition field = form.getFieldByBinding("date");
    assertFieldStatus(field, "date", Date.class.getName());
    field = form.getFieldByBinding("text");
    assertFieldStatus(field, "text", String.class.getName());
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) 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) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) Mockito.anyString(org.mockito.Mockito.anyString) Date(java.util.Date)

Example 60 with FieldDefinition

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

the class BPMNFormGenerationTest method testSimpleVariables.

@Test
public void testSimpleVariables() {
    List<ModelProperty> variables = new ArrayList<>();
    variables.add(new ModelPropertyImpl("employee", new TypeInfoImpl(String.class.getName())));
    variables.add(new ModelPropertyImpl("manager", new TypeInfoImpl(String.class.getName())));
    variables.add(new ModelPropertyImpl("performance", new TypeInfoImpl(Integer.class.getName())));
    variables.add(new ModelPropertyImpl("approved", new TypeInfoImpl(Boolean.class.getName())));
    model = getModel(getModelId(), variables);
    Collection<FormDefinition> forms = getModelForms(model, classLoader);
    try {
        verify(classLoader, never()).loadClass(anyString());
    } catch (ClassNotFoundException e) {
        fail("We shouldn't be here: " + e.getMessage());
    }
    assertNotNull("There should one form", forms);
    assertEquals("There should one form", 1, forms.size());
    FormDefinition form = forms.iterator().next();
    assertEquals(getModelId() + BPMNVariableUtils.TASK_FORM_SUFFIX, form.getId());
    assertEquals(getModelId() + BPMNVariableUtils.TASK_FORM_SUFFIX, form.getName());
    assertEquals(form.getModel(), model);
    assertEquals("There should be 4 fields", 4, form.getFields().size());
    variables.forEach(variable -> {
        FieldDefinition field = form.getFieldByBinding(variable.getName());
        assertFieldStatus(field, variable);
    });
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) 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) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) ModelProperty(org.kie.workbench.common.forms.model.ModelProperty) ArrayList(java.util.ArrayList) Mockito.anyString(org.mockito.Mockito.anyString) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test)

Aggregations

FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)85 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)42 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)29 Test (org.junit.Test)27 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)24 TextAreaFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition)22 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)21 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)20 CheckBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition)18 DecimalBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition)17 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)14 DatePickerFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition)13 ArrayList (java.util.ArrayList)11 LayoutTemplate (org.uberfire.ext.layout.editor.api.editor.LayoutTemplate)9 LayoutComponent (org.uberfire.ext.layout.editor.api.editor.LayoutComponent)8 Form (org.kie.workbench.common.forms.migration.legacy.model.Form)7 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)7 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)7 LayoutColumn (org.uberfire.ext.layout.editor.api.editor.LayoutColumn)7 LayoutRow (org.uberfire.ext.layout.editor.api.editor.LayoutRow)7