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