Search in sources :

Example 1 with SubFormFieldDefinition

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;
}
Also used : SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) PortableJavaModel(org.kie.workbench.common.forms.model.impl.PortableJavaModel) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) Person(org.kie.workbench.common.forms.dynamic.backend.server.context.generation.dynamic.impl.model.Person)

Example 2 with SubFormFieldDefinition

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;
}
Also used : 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) HashMap(java.util.HashMap) MapPropertyType(org.jboss.errai.databinding.client.MapPropertyType) PropertyType(org.jboss.errai.databinding.client.PropertyType) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)

Example 3 with SubFormFieldDefinition

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());
}
Also used : SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) DatePickerFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test)

Example 4 with SubFormFieldDefinition

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()));
}
Also used : 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) Person(org.kie.workbench.common.forms.jbpm.server.service.impl.model.Person)

Example 5 with SubFormFieldDefinition

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);
}
Also used : SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)

Aggregations

SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)12 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)7 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)5 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)5 DatePickerFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition)4 EnumListBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition)4 Test (org.junit.Test)3 Date (java.util.Date)2 CheckBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition)2 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)2 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)2 JavaFormModel (org.kie.workbench.common.forms.model.JavaFormModel)2 PortableJavaModel (org.kie.workbench.common.forms.model.impl.PortableJavaModel)2 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)2 HashMap (java.util.HashMap)1 MapPropertyType (org.jboss.errai.databinding.client.MapPropertyType)1 PropertyType (org.jboss.errai.databinding.client.PropertyType)1 Before (org.junit.Before)1 Person (org.kie.workbench.common.forms.dynamic.backend.server.context.generation.dynamic.impl.model.Person)1 Address (org.kie.workbench.common.forms.dynamic.test.model.Address)1