Search in sources :

Example 6 with FormElementFilter

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);
}
Also used : Arrays(java.util.Arrays) StunnerFormElementFilterProvider(org.kie.workbench.common.stunner.forms.client.formFilters.StunnerFormElementFilterProvider) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Edge(org.kie.workbench.common.stunner.core.graph.Edge) FormElementFilter(org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) Supplier(java.util.function.Supplier) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) View(org.kie.workbench.common.stunner.core.graph.content.view.View) GraphUtils(org.kie.workbench.common.stunner.core.graph.util.GraphUtils) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) Element(org.kie.workbench.common.stunner.core.graph.Element) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) Node(org.kie.workbench.common.stunner.core.graph.Node) FormElementFilter(org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter) Predicate(java.util.function.Predicate)

Example 7 with FormElementFilter

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));
}
Also used : FormElementFilter(org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter)

Example 8 with FormElementFilter

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));
}
Also used : FormElementFilter(org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter)

Example 9 with FormElementFilter

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);
    }
}
Also used : FormElementFilter(org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 10 with FormElementFilter

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"));
}
Also used : Address(org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Address) StaticModelFormRenderingContext(org.kie.workbench.common.forms.dynamic.service.shared.impl.StaticModelFormRenderingContext) FormElementFilter(org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test) AbstractFormGenerationTest(org.kie.workbench.common.forms.adf.engine.shared.test.AbstractFormGenerationTest)

Aggregations

FormElementFilter (org.kie.workbench.common.forms.adf.engine.shared.FormElementFilter)10 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)4 StaticModelFormRenderingContext (org.kie.workbench.common.forms.dynamic.service.shared.impl.StaticModelFormRenderingContext)3 Collection (java.util.Collection)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Optional (java.util.Optional)1 Predicate (java.util.function.Predicate)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Dependent (javax.enterprise.context.Dependent)1 Inject (javax.inject.Inject)1 BindableProxy (org.jboss.errai.databinding.client.BindableProxy)1 PortablePreconditions (org.kie.soup.commons.validation.PortablePreconditions)1 FormBuildingService (org.kie.workbench.common.forms.adf.engine.shared.FormBuildingService)1 Address (org.kie.workbench.common.forms.adf.engine.shared.formGeneration.model.Address)1 PropertyValueExtractor (org.kie.workbench.common.forms.adf.engine.shared.formGeneration.util.PropertyValueExtractor)1