cuba-platform / cuba

CUBA Platform is a high level framework for enterprise applications development
https://www.cuba-platform.com
Apache License 2.0
1.34k stars 219 forks source link

Nested filter property can't be used for keyValue containers #3261

Open gorbunkov opened 2 years ago

gorbunkov commented 2 years ago

Platform version: 7.2.18

Suppose, there is a KeyValueCollection in the screen:

        <keyValueCollection id="ordersKvDc">
            <loader id="ordersKvDl">
                <query>
                    select o, c from reptest_Order o join o.customer c
                </query>
            </loader>
            <properties>
                <property name="order" class="com.company.reptest.entity.Order"></property>
                <property name="customer" class="com.company.reptest.entity.Customer"></property>
            </properties>
        </keyValueCollection>

If in the <filter> component we define a nested property (like order.number, not just order):

        <filter id="filter"
                applyTo="ordersTable"
                dataLoader="ordersKvDl">
            <property name="order.number" caption="orderNumber"/>
            <property name="customer.name" caption="customerName"/>
        </filter>

then when we try to add a filter condition, we get the following exception:

com.haulmont.cuba.core.global.DevelopmentException: The number of KeyValueEntity properties required is greater than the number of the selected expressions in the data loader query
    at com.haulmont.cuba.gui.components.filter.addcondition.ConditionDescriptorsTreeBuilder.createConditionDescriptorForKeyValueMetaProperty(ConditionDescriptorsTreeBuilder.java:265)
    at com.haulmont.cuba.gui.components.filter.addcondition.ConditionDescriptorsTreeBuilder.build(ConditionDescriptorsTreeBuilder.java:128)
    at com.haulmont.cuba.gui.components.filter.AddConditionHelper.addCondition(AddConditionHelper.java:94)
    at com.haulmont.cuba.gui.components.filter.FilterDelegateImpl.lambda$createControlsLayoutForGeneric$2(FilterDelegateImpl.java:344)
    at com.haulmont.bali.events.EventHub.publish(EventHub.java:170)
    at com.haulmont.cuba.web.gui.components.WebAbstractComponent.publish(WebAbstractComponent.java:100)
    at com.haulmont.cuba.web.gui.components.WebButton.buttonClicked(WebButton.java:70)
    at com.haulmont.cuba.web.widgets.CubaButton.fireClick(CubaButton.java:76)
    at com.vaadin.ui.Button$1.click(Button.java:57)

See forum topic.

The sample project: reptest.zip

Open the Orders screen and try to add a filter condition