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);
}
}
}
}
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;
}
}
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);
}
Aggregations