Search in sources :

Example 1 with FormEditorRenderingContext

use of org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext in project kie-wb-common by kiegroup.

the class FormEditorHelperTest method testGetRenderingContext.

@Test
public void testGetRenderingContext() {
    FormEditorRenderingContext renderingContext = formEditorHelper.getRenderingContext();
    assertEquals(renderingContext, content.getRenderingContext());
}
Also used : FormEditorRenderingContext(org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext) Test(org.junit.Test)

Example 2 with FormEditorRenderingContext

use of org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext 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 3 with FormEditorRenderingContext

use of org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext in project kie-wb-common by kiegroup.

the class FieldPropertiesRenderer method render.

protected void render() {
    FormRenderingContext context = dynamicFormModelGenerator.getContextForModel(fieldCopy);
    if (context != null) {
        FormEditorRenderingContext renderingContext = new FormEditorRenderingContext(helper.getPath());
        renderingContext.setRootForm(context.getRootForm());
        renderingContext.getAvailableForms().putAll(context.getAvailableForms());
        renderingContext.setModel(fieldCopy);
        doRender(helper, renderingContext);
    }
}
Also used : FormEditorRenderingContext(org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext) FormRenderingContext(org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext)

Example 4 with FormEditorRenderingContext

use of org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext 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 FormEditorRenderingContext

use of org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext in project kie-wb-common by kiegroup.

the class BeanPropertiesProviderTest method init.

@Before
public void init() {
    super.init();
    service = spy(service);
    provider = new BeanPropertiesProvider(service);
    currentEditedMeta = new TableColumnMeta();
    context = new FormEditorRenderingContext(path);
    context.setModel(currentEditedMeta);
}
Also used : FormEditorRenderingContext(org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext) TableColumnMeta(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.TableColumnMeta) Before(org.junit.Before)

Aggregations

FormEditorRenderingContext (org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext)8 SelectorData (org.kie.workbench.common.forms.dynamic.model.config.SelectorData)3 TableColumnMeta (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.TableColumnMeta)3 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)3 FormRenderingContext (org.kie.workbench.common.forms.dynamic.service.shared.FormRenderingContext)2 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)2 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 Collectors (java.util.stream.Collectors)1 Dependent (javax.enterprise.context.Dependent)1 Inject (javax.inject.Inject)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Before (org.junit.Before)1 Test (org.junit.Test)1 DataObjectFinderService (org.kie.workbench.common.forms.data.modeller.service.DataObjectFinderService)1 SystemSelectorDataProvider (org.kie.workbench.common.forms.dynamic.model.config.SystemSelectorDataProvider)1 FormModelSynchronizationResult (org.kie.workbench.common.forms.editor.model.FormModelSynchronizationResult)1