Search in sources :

Example 1 with MultipleSubFormFieldDefinition

use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition in project kie-wb-common by kiegroup.

the class BeanPropertiesProviderTest method testGetModelProperties.

protected void testGetModelProperties(String... columns) {
    field = new MultipleSubFormFieldDefinition();
    for (String column : columns) {
        field.getColumnMetas().add(new TableColumnMeta(column, column));
    }
    List<String> bannedColumns = new ArrayList<>(Arrays.asList(columns));
    if (!StringUtils.isEmpty(currentEditedMeta.getProperty())) {
        bannedColumns.remove(currentEditedMeta.getProperty());
    }
    field.setStandaloneClassName(TYPE_NAME);
    parentContext = new FormEditorRenderingContext(path);
    parentContext.setModel(field);
    context.setParentContext(parentContext);
    expectedFields = DATA_OBJECT_VALID_FIELDS - bannedColumns.size();
    SelectorData data = provider.getSelectorData(context);
    verify(service).getDataObjectProperties(any(), any());
    assertNotNull(data);
    assertNotNull(data.getValues());
    assertNull(data.getSelectedValue());
    assertFalse(data.getValues().isEmpty());
    assertEquals(expectedFields, data.getValues().size());
    for (String column : bannedColumns) {
        assertNull(data.getValues().get(column));
    }
    assertNull(data.getValues().get(DataObjectFormModelHandler.SERIAL_VERSION_UID));
    assertNull(data.getValues().get(PERSISTENCE_ID_PROPERTY));
}
Also used : FormEditorRenderingContext(org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext) TableColumnMeta(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.TableColumnMeta) ArrayList(java.util.ArrayList) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) SelectorData(org.kie.workbench.common.forms.dynamic.model.config.SelectorData)

Example 2 with MultipleSubFormFieldDefinition

use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition in project kie-wb-common by kiegroup.

the class DataObjectFormModelHandlerTest method multipleSubformHasCorrectProperties.

@Test
public void multipleSubformHasCorrectProperties() {
    formModel = handler.createFormModel(dataObject, path);
    MultipleSubFormFieldDefinition multipleSubform = (MultipleSubFormFieldDefinition) checkCommonProperties("address_list");
    assertEquals(null, multipleSubform.getCreationForm());
    assertEquals(null, multipleSubform.getEditionForm());
    assertEquals(Collections.emptyList(), multipleSubform.getColumnMetas());
}
Also used : MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) Test(org.junit.Test)

Example 3 with MultipleSubFormFieldDefinition

use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition 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 4 with MultipleSubFormFieldDefinition

use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition in project kie-wb-common by kiegroup.

the class BeanPropertiesProvider method getSelectorData.

@Override
public SelectorData getSelectorData(FormRenderingContext context) {
    HashMap<String, String> values = new HashMap<>();
    if (context instanceof FormEditorRenderingContext && context.getParentContext() != null) {
        if (context.getParentContext().getModel() instanceof MultipleSubFormFieldDefinition) {
            FormEditorRenderingContext editorContext = (FormEditorRenderingContext) context;
            if (context.getParentContext() != null) {
                MultipleSubFormFieldDefinition subForm = (MultipleSubFormFieldDefinition) context.getParentContext().getModel();
                Path path = editorContext.getFormPath();
                String typeName = subForm.getStandaloneClassName();
                final TableColumnMeta currentMeta = (TableColumnMeta) context.getModel();
                Set<String> unavailableProperties = subForm.getColumnMetas().stream().map(TableColumnMeta::getProperty).collect(Collectors.toSet());
                if (currentMeta != null && !StringUtils.isEmpty(currentMeta.getProperty())) {
                    unavailableProperties.remove(currentMeta.getProperty());
                }
                dataObjectFinderService.getDataObjectProperties(typeName, path).stream().filter(property -> !unavailableProperties.contains(property.getName())).forEachOrdered(property -> values.put(property.getName(), property.getName()));
            }
        }
    }
    return new SelectorData(values, null);
}
Also used : Path(org.uberfire.backend.vfs.Path) SelectorData(org.kie.workbench.common.forms.dynamic.model.config.SelectorData) FormRenderingContext(org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext) TableColumnMeta(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.TableColumnMeta) Set(java.util.Set) HashMap(java.util.HashMap) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) DataObjectFinderService(org.kie.workbench.common.forms.data.modeller.service.DataObjectFinderService) Inject(javax.inject.Inject) Dependent(javax.enterprise.context.Dependent) SystemSelectorDataProvider(org.kie.workbench.common.forms.dynamic.model.config.SystemSelectorDataProvider) FormEditorRenderingContext(org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext) Path(org.uberfire.backend.vfs.Path) FormEditorRenderingContext(org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext) HashMap(java.util.HashMap) TableColumnMeta(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.TableColumnMeta) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) SelectorData(org.kie.workbench.common.forms.dynamic.model.config.SelectorData)

Example 5 with MultipleSubFormFieldDefinition

use of org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition in project kie-wb-common by kiegroup.

the class AbstractBPMNFormGeneratorServiceTest method testExpenseForm.

protected void testExpenseForm(FormDefinition form) {
    assertEquals(4, form.getFields().size());
    IntegerBoxFieldDefinition id = (IntegerBoxFieldDefinition) form.getFieldByBinding("id");
    assertNotNull(id);
    assertEquals(Long.class.getName(), id.getStandaloneClassName());
    DatePickerFieldDefinition date = (DatePickerFieldDefinition) form.getFieldByBinding("date");
    assertNotNull(date);
    assertEquals(Date.class.getName(), date.getStandaloneClassName());
    SubFormFieldDefinition client = (SubFormFieldDefinition) form.getFieldByBinding("client");
    assertNotNull(client);
    assertNotNull(client.getNestedForm());
    assertEquals(Client.class.getName(), client.getStandaloneClassName());
    MultipleSubFormFieldDefinition lines = (MultipleSubFormFieldDefinition) form.getFieldByBinding("lines");
    assertNotNull(lines);
    assertNotNull(lines.getCreationForm());
    assertNotNull(lines.getEditionForm());
    assertEquals(lines.getEditionForm(), lines.getCreationForm());
    assertFalse(lines.getColumnMetas().isEmpty());
    assertEquals(Line.class.getName(), lines.getStandaloneClassName());
}
Also used : Line(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Line) 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) DatePickerFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition) Client(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Client) Date(java.util.Date) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) IntegerBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)

Aggregations

MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)10 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)5 EnumListBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition)3 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)3 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)3 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 SelectorData (org.kie.workbench.common.forms.dynamic.model.config.SelectorData)2 FormEditorRenderingContext (org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext)2 DatePickerFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition)2 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)2 TableColumnMeta (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.TableColumnMeta)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 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Dependent (javax.enterprise.context.Dependent)1