[MGNLUI-6229] Allow DataProvider to handle hasChildren method Created: 22/Sep/20  Updated: 16/Oct/20  Resolved: 16/Oct/20

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 6.2.3
Fix Version/s: 6.2.4

Type: Task Priority: Neutral
Reporter: Jesus Alonso Assignee: Jesus Alonso
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoR:
Empty

 Description   

Background

In S3 external dam we have an issue displaying the asset tree for the first time. When there are many buckets (parent folders), it takes a very long time to render the tree for the first time. Then the assets are cached and we don’t have this issue anymore. Also opening other folders have no problem.

The main problem is vaadin needs to know whether each parent folder has children or not. To do so, vaadin calls sequentially the hasChildren method in the corresponding HierarchicalDataProvider for the view. In our case info.magnolia.ui.contentapp.FilterableHierarchicalDataProvider implements the hasChildren:

public boolean hasChildren(T item) {
    return fetchChildren(new HierarchicalQuery<>(filter, item)).count() > 0;
}

This is always translated into a remote API call. As we are able to know in advance whether a bucket has children or not, we would like to override this method to avoid all these remote API calls. Unfortunately we can’t, as FilterableHierarchicalDataProvider has a private constructor.

Proposed solution

Remove the hasChildren method from info.magnolia.ui.contentapp.FilterableHierarchicalDataProvider so instead we would use the parent (HierarchicalDataProviderWrapper) implementation:

public boolean hasChildren(T item) {
    return dataProvider().hasChildren(item);
}

This would allow to override the implementation appropriately.



 Comments   
Comment by Jesus Alonso [ 16/Oct/20 ]

Issue fixed

Generated at Mon Feb 12 09:34:24 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.