use of org.kie.workbench.common.forms.dynamic.model.config.SelectorData 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);
}
use of org.kie.workbench.common.forms.dynamic.model.config.SelectorData 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