use of org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter in project kie-wb-common by kiegroup.
the class StartEventFilterProvider method provideFilters.
@Override
public Collection<FormElementFilter> provideFilters(String elementUUID, Element<? extends Definition<?>> element, Object definition) {
Predicate predicate = o -> isParentAnEventSubProcess(elementUUID);
FormElementFilter isInterruptingFilter = new FormElementFilter("executionSet.isInterrupting", predicate);
return Arrays.asList(isInterruptingFilter);
}
use of org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter in project kie-wb-common by kiegroup.
the class StartEventFilterProviderFactoryTest method testStartEventFilterProviderHideIsInterruptingField.
private void testStartEventFilterProviderHideIsInterruptingField(Class<?> filterClass) {
when(parentView.getDefinition()).thenReturn(otherNode);
startEventFilterProvider = new StartEventFilterProvider(sessionManager, filterClass);
assertEquals(filterClass, startEventFilterProvider.getDefinitionType());
Collection<FormElementFilter> formElementFilters = startEventFilterProvider.provideFilters(ELEMENT_UUID, element, definition);
FormElementFilter formElementFilter = formElementFilters.iterator().next();
assertEquals(1, formElementFilters.size());
assertEquals(ELEMENT_NAME, formElementFilter.getElementName());
assertFalse(formElementFilter.getPredicate().test(definition));
}
use of org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter in project kie-wb-common by kiegroup.
the class StartEventFilterProviderFactoryTest method testStartEventFilterProviderShowIsInterruptingField.
private void testStartEventFilterProviderShowIsInterruptingField(Class<?> filterClass) {
when(parentView.getDefinition()).thenReturn(eventSubprocess);
startEventFilterProvider = new StartEventFilterProvider(sessionManager, filterClass);
assertEquals(filterClass, startEventFilterProvider.getDefinitionType());
Collection<FormElementFilter> formElementFilters = startEventFilterProvider.provideFilters(ELEMENT_UUID, element, definition);
FormElementFilter formElementFilter = formElementFilters.iterator().next();
assertEquals(1, formElementFilters.size());
assertEquals(ELEMENT_NAME, formElementFilter.getElementName());
assertTrue(formElementFilter.getPredicate().test(definition));
}
use of org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter in project kie-wb-common by kiegroup.
the class DynamicFormModelGenerator method addNestedForm.
private void addNestedForm(String className, StaticModelFormRenderingContext context, Collection<FormElementFilter> nestedFormFilters) {
if (!context.getAvailableForms().containsKey(className)) {
FormDefinition nested = formBuildingService.generateFormForClassName(className, nestedFormFilters.stream().toArray(FormElementFilter[]::new));
context.getAvailableForms().put(className, nested);
initNestedFormSettings(nested, null, context, nestedFormFilters);
}
}
use of org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter in project kie-wb-common by kiegroup.
the class DynamicFormModelGeneratorTest method testGenerateContextForModelWithFilters.
@Test
public void testGenerateContextForModelWithFilters() {
FormElementFilter nameFilter = new FormElementFilter("name", o -> true);
FormElementFilter lastNameFilter = new FormElementFilter("lastName", o -> false);
FormElementFilter addressStreetFilter = new FormElementFilter("address.street", o -> true);
FormElementFilter addressNumFilter = new FormElementFilter("address.number", o -> false);
StaticModelFormRenderingContext context = dynamicFormModelGenerator.getContextForModel(model, nameFilter, lastNameFilter, addressStreetFilter, addressNumFilter);
assertEquals(3, context.getAvailableForms().size());
FormDefinition rootForm = context.getRootForm();
assertNotNull(rootForm);
assertEquals(rootForm.getFields().size(), rootForm.getLayoutTemplate().getRows().size());
assertNotNull(rootForm.getFieldByBinding("name"));
assertNull(rootForm.getFieldByBinding("lastName"));
FormDefinition addressForm = context.getAvailableForms().get(Address.class.getName());
assertNotNull(addressForm);
assertEquals(addressForm.getFields().size(), addressForm.getLayoutTemplate().getRows().size());
assertNotNull(addressForm.getFieldByBinding("street"));
assertNull(addressForm.getFieldByBinding("number"));
}
Aggregations