Generic Filter over REST Datastore

Hi,

we are evaluating the split of our full stack JMIX application to have a separated frontend and a backend so we integrate them through REST Datastore. When evaluating this apporach we found the generic filter does not work or we don’t know how to make it work properly with Data Store entities.

So is Rest Datastore compatible with that great feature that is the generic filter?
If not is there any sample or experience we can check for implementing something similar in terms of configuration and parameterization like saving filters, select fields etc…?

Thanks in advance!

Hi Vicente,

The GenericFilter component is fully compatible with REST DataStore. It doesn’t work in Jmix 2.4.1 because of this bug:

It will be fixed in the next patch (2.4.2) which will be available in December.

Meanwhile, you can fix the problem in your project as follows:

  1. Create a bean overriding the one from the framework:

    package com.company.frontend;
    
    import io.jmix.core.AccessManager;
    import io.jmix.core.Metadata;
    import io.jmix.core.MetadataTools;
    import io.jmix.core.metamodel.model.MetaProperty;
    import io.jmix.core.metamodel.model.MetaPropertyPath;
    import io.jmix.flowui.UiComponentProperties;
    import io.jmix.flowui.component.genericfilter.FilterMetadataTools;
    import org.springframework.context.annotation.Primary;
    import org.springframework.stereotype.Component;
    
    @Primary
    @Component
    public class MyFilterMetadataTools extends FilterMetadataTools {
    
        public MyFilterMetadataTools(MetadataTools metadataTools, UiComponentProperties uiComponentProperties, AccessManager accessManager, Metadata metadata) {
            super(metadataTools, uiComponentProperties, accessManager, metadata);
        }
    
        @Override
        protected boolean belongToCrossDataStoreReference(MetaPropertyPath propertyPath, String query) {
            for (int i = 0; i < propertyPath.getMetaProperties().length - 1; i++) {
                MetaProperty parentMetaProperty = propertyPath.getMetaProperties()[i];
                if (isCrossDataStoreReference(parentMetaProperty)) {
                    return true;
                }
            }
            return false;
        }
    }
    
  2. Add the application property:

    jmix.core.exclude-beans = flowui_UiDataFilterMetadataTools
    

Regards,
Konstantin