Search in sources :

Example 1 with EntityRelationField

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

the class AbstractBPMNFormGeneratorService method processFieldDefinition.

protected void processFieldDefinition(FieldDefinition field, GenerationContext<SOURCE> context) {
    if (field instanceof EntityRelationField) {
        if (field instanceof HasNestedForm) {
            HasNestedForm nestedFormField = (HasNestedForm) field;
            FormDefinition nestedForm = findFormDefinitionForModelType(field.getStandaloneClassName(), context);
            if (nestedForm == null) {
                nestedForm = createModelFormDefinition(field.getStandaloneClassName(), context);
            }
            nestedFormField.setNestedForm(nestedForm.getId());
        } else if (field instanceof IsCRUDDefinition) {
            IsCRUDDefinition crudField = (IsCRUDDefinition) field;
            FormDefinition nestedForm = findFormDefinitionForModelType(field.getStandaloneClassName(), context);
            if (nestedForm == null) {
                nestedForm = createModelFormDefinition(field.getStandaloneClassName(), context);
                crudField.setCreationForm(nestedForm.getId());
                crudField.setEditionForm(nestedForm.getId());
                List<TableColumnMeta> tableColumnMetas = new ArrayList<>();
                nestedForm.getFields().forEach(nestedField -> {
                    tableColumnMetas.add(new TableColumnMeta(nestedField.getLabel(), nestedField.getBinding()));
                });
                crudField.setColumnMetas(tableColumnMetas);
            }
        }
    }
}
Also used : LayoutColumnDefinition(org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutColumnDefinition) TableColumnMeta(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.TableColumnMeta) UIDGenerator(org.kie.workbench.common.forms.services.backend.util.UIDGenerator) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) FormLayoutComponent(org.kie.workbench.common.forms.model.FormLayoutComponent) IsCRUDDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.IsCRUDDefinition) BPMNFormGeneratorService(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.BPMNFormGeneratorService) JavaFormModel(org.kie.workbench.common.forms.model.JavaFormModel) JBPMFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel) LayoutComponent(org.uberfire.ext.layout.editor.api.editor.LayoutComponent) ArrayList(java.util.ArrayList) ColSpan(org.kie.workbench.common.forms.adf.definitions.settings.ColSpan) HasNestedForm(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.HasNestedForm) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) StaticFormLayoutTemplateGenerator(org.kie.workbench.common.forms.commons.shared.layout.impl.StaticFormLayoutTemplateGenerator) List(java.util.List) LayoutGenerator(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.layout.LayoutGenerator) FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) EntityRelationField(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.EntityRelationField) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) FieldManager(org.kie.workbench.common.forms.service.shared.FieldManager) LayoutSettings(org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutSettings) DataObjectFormModel(org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel) EntityRelationField(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.EntityRelationField) TableColumnMeta(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.TableColumnMeta) IsCRUDDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.IsCRUDDefinition) HasNestedForm(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.HasNestedForm) ArrayList(java.util.ArrayList) List(java.util.List) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 2 with EntityRelationField

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

the class AbstractFieldManager method getCompatibleFields.

@Override
public Collection<String> getCompatibleFields(FieldDefinition fieldDefinition) {
    if (fieldDefinition.getStandaloneClassName() != null) {
        if (fieldDefinition instanceof EntityRelationField) {
            if (fieldDefinition.getFieldTypeInfo().isMultiple()) {
                return new TreeSet<>(multipleEntityTypeFieldProvider.keySet());
            }
            return new TreeSet<>(entityTypeFieldProvider.keySet());
        }
        Set result = new TreeSet();
        if (fieldDefinition.getFieldTypeInfo().isMultiple()) {
            for (BasicTypeFieldProvider provider : basicMultipleProviders) {
                if (provider.isCompatible(fieldDefinition)) {
                    result.add(provider.getFieldTypeName());
                }
            }
        } else {
            for (BasicTypeFieldProvider provider : basicProviders) {
                if (provider.isCompatible(fieldDefinition)) {
                    result.add(provider.getFieldTypeName());
                }
            }
        }
        return result;
    } else {
        if (fieldDefinition instanceof EntityRelationField) {
            if (fieldDefinition.getFieldTypeInfo().isMultiple()) {
                return new TreeSet<>(multipleEntityTypeFieldProvider.keySet());
            }
            return new TreeSet<>(entityTypeFieldProvider.keySet());
        }
        BasicTypeFieldProvider provider = (BasicTypeFieldProvider) providersByFieldCode.get(fieldDefinition.getFieldType().getTypeName());
        Set result = new TreeSet();
        for (String className : provider.getSupportedTypes()) {
            result.addAll(getCompatibleTypes(className));
        }
        return result;
    }
}
Also used : EntityRelationField(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.EntityRelationField) TreeSet(java.util.TreeSet) Set(java.util.Set) TreeSet(java.util.TreeSet) BasicTypeFieldProvider(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider)

Example 3 with EntityRelationField

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

the class VFSSelectorFormProvider method getSelectorData.

@Override
public SelectorData getSelectorData(FormRenderingContext context) {
    Map<String, String> values = new TreeMap<>();
    if (context.getModel() instanceof EntityRelationField) {
        FormEditorRenderingContext editorContext = (FormEditorRenderingContext) context;
        FieldDefinition field = (FieldDefinition) context.getModel();
        List<FormDefinition> forms;
        if (field != null) {
            forms = vfsFormFinderService.findFormsForType(field.getStandaloneClassName(), editorContext.getFormPath());
        } else {
            forms = vfsFormFinderService.findAllForms(editorContext.getFormPath());
        }
        for (FormDefinition form : forms) {
            values.put(form.getId(), form.getName());
        }
    }
    return new SelectorData(values, null);
}
Also used : EntityRelationField(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.EntityRelationField) FormEditorRenderingContext(org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TreeMap(java.util.TreeMap) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) SelectorData(org.kie.workbench.common.forms.dynamic.model.config.SelectorData)

Aggregations

EntityRelationField (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.EntityRelationField)3 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)2 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 TreeSet (java.util.TreeSet)1 ColSpan (org.kie.workbench.common.forms.adf.definitions.settings.ColSpan)1 LayoutGenerator (org.kie.workbench.common.forms.adf.engine.shared.formGeneration.layout.LayoutGenerator)1 LayoutColumnDefinition (org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutColumnDefinition)1 LayoutSettings (org.kie.workbench.common.forms.adf.service.definitions.layout.LayoutSettings)1 StaticFormLayoutTemplateGenerator (org.kie.workbench.common.forms.commons.shared.layout.impl.StaticFormLayoutTemplateGenerator)1 DataObjectFormModel (org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel)1 SelectorData (org.kie.workbench.common.forms.dynamic.model.config.SelectorData)1 FormEditorRenderingContext (org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext)1 BasicTypeFieldProvider (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider)1 HasNestedForm (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.HasNestedForm)1 IsCRUDDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.IsCRUDDefinition)1 TableColumnMeta (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.TableColumnMeta)1