Package io.jmix.flowui.model.impl
Class CollectionLoaderImpl<E>
java.lang.Object
io.jmix.flowui.model.impl.CollectionLoaderImpl<E>
- All Implemented Interfaces:
BaseCollectionLoader
,CollectionLoader<E>
,DataLoader
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jmix.flowui.model.CollectionLoader
CollectionLoader.PostLoadEvent<T>, CollectionLoader.PreLoadEvent<T>
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected Condition
protected CollectionContainer<E>
protected DataContext
protected DataManager
protected Function<LoadContext<E>,
List<E>> protected EventHub
protected FetchPlan
protected String
protected FetchPlanRepository
protected int
protected Map<String,
Serializable> protected int
protected io.micrometer.core.instrument.MeterRegistry
protected Function<DataLoader,
DataLoaderMonitoringInfo> protected String
protected List<QueryStringProcessor>
protected Sort
protected SorterFactory
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
_load()
addPostLoadListener
(Consumer<CollectionLoader.PostLoadEvent<E>> listener) Adds a listener toCollectionLoader.PostLoadEvent
.addPreLoadListener
(Consumer<CollectionLoader.PreLoadEvent<E>> listener) Adds a listener toCollectionLoader.PreLoadEvent
.protected boolean
canLeadToDuplicateResultsRecursive
(Condition condition) Evaluates recursively if the condition depends on some x-to-many property so the list of loaded entities can contain duplicates.ReturnsLoadContext
which is created by the parameters of this loader.Returns the root condition which is used together with the query when loading entities.Returns the container which accepts loaded entities.Returns data context.Returns the fetch plan used for loading entities.int
The position of the first instance to load, numbered from 0.getHints()
Function<LoadContext<E>,
List<E>> Returns a function which will be used to load data instead of standard implementation.int
The maximum number of instances to load.Returns function that provides monitoring info about this data loader.getParameter
(String name) Returns a query parameter by its name.Returns the map of query parameters.getQuery()
Returns the query which is used for loading entities.getSort()
Returns the sort object which is used when loading.boolean
Returns true if the query for loading data is cacheable.void
load()
Loads data to the connected container.void
removeParameter
(String name) Removes a query parameter.protected FetchPlan
protected void
sendPostLoadEvent
(List<E> entities) protected boolean
sendPreLoadEvent
(LoadContext<E> loadContext) void
setCacheable
(boolean cacheable) Sets the query for loading data cacheable.void
setCondition
(Condition condition) Sets the root condition which will be used together with the query when loading entities.void
setContainer
(CollectionContainer<E> container) Sets the container which accepts loaded entities.void
setDataContext
(DataContext dataContext) Sets the data context for the loader.void
setFetchPlan
(FetchPlan fetchPlan) Sets the fetch plan to use for loading entities.void
setFetchPlan
(String fetchPlanName) Sets the name of the fetch plan to use for loading entities.void
setFirstResult
(int firstResult) Sets the position of the first instance to load, numbered from 0.void
setHint
(String hintName, Serializable value) Sets custom hint that should be used by the query for loading data.void
setLoadDelegate
(Function<LoadContext<E>, List<E>> delegate) Sets a function which will be used to load data instead of standard implementation.void
setMaxResults
(int maxResults) Sets the maximum number of instances to load.void
setMonitoringInfoProvider
(Function<DataLoader, DataLoaderMonitoringInfo> monitoringInfoProvider) Sets function that provides monitoring info about this data loader.void
setParameter
(String name, Object value) Sets a query parameter.void
setParameters
(Map<String, Object> parameters) Sets the map of query parameters.void
Sets a query which will be used for loading entities.void
Sets the sort object which is used when loading.
-
Field Details
-
dataManager
-
fetchPlanRepository
-
sorterFactory
-
queryStringProcessors
-
meterRegistry
@Autowired protected io.micrometer.core.instrument.MeterRegistry meterRegistry -
dataContext
-
container
-
query
-
condition
-
parameters
-
firstResult
protected int firstResult -
maxResults
protected int maxResults -
cacheable
protected boolean cacheable -
fetchPlan
-
fetchPlanName
-
sort
-
hints
-
delegate
-
events
-
monitoringInfoProvider
-
-
Constructor Details
-
CollectionLoaderImpl
public CollectionLoaderImpl()
-
-
Method Details
-
getDataContext
Description copied from interface:DataLoader
Returns data context. If the data context is set, all loaded instance will be merged into it.- Specified by:
getDataContext
in interfaceDataLoader
-
setDataContext
Description copied from interface:DataLoader
Sets the data context for the loader. If the data context is set, all loaded instance will be merged into it.- Specified by:
setDataContext
in interfaceDataLoader
-
setMonitoringInfoProvider
public void setMonitoringInfoProvider(Function<DataLoader, DataLoaderMonitoringInfo> monitoringInfoProvider) Description copied from interface:DataLoader
Sets function that provides monitoring info about this data loader.- Specified by:
setMonitoringInfoProvider
in interfaceDataLoader
-
getMonitoringInfoProvider
Description copied from interface:DataLoader
Returns function that provides monitoring info about this data loader.- Specified by:
getMonitoringInfoProvider
in interfaceDataLoader
-
load
public void load()Description copied from interface:DataLoader
Loads data to the connected container.- Specified by:
load
in interfaceDataLoader
-
_load
protected boolean _load() -
createLoadContext
Description copied from interface:CollectionLoader
ReturnsLoadContext
which is created by the parameters of this loader. TheLoadContext
can be used withDataManager
to load data by the same conditions.- Specified by:
createLoadContext
in interfaceCollectionLoader<E>
-
canLeadToDuplicateResultsRecursive
Evaluates recursively if the condition depends on some x-to-many property so the list of loaded entities can contain duplicates.- Parameters:
condition
- condition to check- Returns:
- true if duplicate results are possible, false otherwise
-
resolveFetchPlan
-
sendPreLoadEvent
-
sendPostLoadEvent
-
getContainer
Description copied from interface:CollectionLoader
Returns the container which accepts loaded entities.- Specified by:
getContainer
in interfaceBaseCollectionLoader
- Specified by:
getContainer
in interfaceCollectionLoader<E>
- Specified by:
getContainer
in interfaceDataLoader
-
setContainer
Description copied from interface:CollectionLoader
Sets the container which accepts loaded entities.- Specified by:
setContainer
in interfaceCollectionLoader<E>
-
getQuery
Description copied from interface:DataLoader
Returns the query which is used for loading entities.- Specified by:
getQuery
in interfaceDataLoader
-
setQuery
Description copied from interface:DataLoader
Sets a query which will be used for loading entities.- Specified by:
setQuery
in interfaceDataLoader
-
getCondition
Description copied from interface:DataLoader
Returns the root condition which is used together with the query when loading entities.- Specified by:
getCondition
in interfaceDataLoader
-
setCondition
Description copied from interface:DataLoader
Sets the root condition which will be used together with the query when loading entities.- Specified by:
setCondition
in interfaceDataLoader
-
getParameters
Description copied from interface:DataLoader
Returns the map of query parameters.- Specified by:
getParameters
in interfaceDataLoader
-
setParameters
Description copied from interface:DataLoader
Sets the map of query parameters.- Specified by:
setParameters
in interfaceDataLoader
-
getParameter
Description copied from interface:DataLoader
Returns a query parameter by its name.- Specified by:
getParameter
in interfaceDataLoader
-
setParameter
Description copied from interface:DataLoader
Sets a query parameter.- Specified by:
setParameter
in interfaceDataLoader
-
removeParameter
Description copied from interface:DataLoader
Removes a query parameter.- Specified by:
removeParameter
in interfaceDataLoader
-
getFirstResult
public int getFirstResult()Description copied from interface:BaseCollectionLoader
The position of the first instance to load, numbered from 0. Returns 0 ifBaseCollectionLoader.setFirstResult(int)
was not called.- Specified by:
getFirstResult
in interfaceBaseCollectionLoader
-
setFirstResult
public void setFirstResult(int firstResult) Description copied from interface:BaseCollectionLoader
Sets the position of the first instance to load, numbered from 0.- Specified by:
setFirstResult
in interfaceBaseCollectionLoader
-
getMaxResults
public int getMaxResults()Description copied from interface:BaseCollectionLoader
The maximum number of instances to load. ReturnsInteger.MAX_VALUE
ifBaseCollectionLoader.setMaxResults(int)
was not called.- Specified by:
getMaxResults
in interfaceBaseCollectionLoader
-
setMaxResults
public void setMaxResults(int maxResults) Description copied from interface:BaseCollectionLoader
Sets the maximum number of instances to load.- Specified by:
setMaxResults
in interfaceBaseCollectionLoader
-
setHint
Description copied from interface:DataLoader
Sets custom hint that should be used by the query for loading data.- Specified by:
setHint
in interfaceDataLoader
-
getHints
- Specified by:
getHints
in interfaceDataLoader
- Returns:
- custom hints which are used by the query for loading data.
-
isCacheable
public boolean isCacheable()Description copied from interface:CollectionLoader
Returns true if the query for loading data is cacheable.- Specified by:
isCacheable
in interfaceCollectionLoader<E>
-
setCacheable
public void setCacheable(boolean cacheable) Description copied from interface:CollectionLoader
Sets the query for loading data cacheable.- Specified by:
setCacheable
in interfaceCollectionLoader<E>
-
getFetchPlan
Description copied from interface:CollectionLoader
Returns the fetch plan used for loading entities.- Specified by:
getFetchPlan
in interfaceCollectionLoader<E>
-
setFetchPlan
Description copied from interface:CollectionLoader
Sets the fetch plan to use for loading entities.- Specified by:
setFetchPlan
in interfaceCollectionLoader<E>
-
setFetchPlan
Description copied from interface:CollectionLoader
Sets the name of the fetch plan to use for loading entities.- Specified by:
setFetchPlan
in interfaceCollectionLoader<E>
-
getSort
Description copied from interface:BaseCollectionLoader
Returns the sort object which is used when loading.- Specified by:
getSort
in interfaceBaseCollectionLoader
-
setSort
Description copied from interface:BaseCollectionLoader
Sets the sort object which is used when loading.- Specified by:
setSort
in interfaceBaseCollectionLoader
-
getLoadDelegate
Description copied from interface:CollectionLoader
Returns a function which will be used to load data instead of standard implementation.- Specified by:
getLoadDelegate
in interfaceCollectionLoader<E>
-
setLoadDelegate
Description copied from interface:CollectionLoader
Sets a function which will be used to load data instead of standard implementation.- Specified by:
setLoadDelegate
in interfaceCollectionLoader<E>
-
addPreLoadListener
Description copied from interface:CollectionLoader
Adds a listener toCollectionLoader.PreLoadEvent
.You can also add an event listener declaratively using a controller method annotated with
Subscribe
:@Subscribe(id = "fooDl", target = Target.DATA_LOADER) private void onFooDlPreLoad(CollectionLoader.PreLoadEvent event) { // handle event here }
- Specified by:
addPreLoadListener
in interfaceCollectionLoader<E>
- Parameters:
listener
- listener- Returns:
- subscription
-
addPostLoadListener
Description copied from interface:CollectionLoader
Adds a listener toCollectionLoader.PostLoadEvent
.You can also add an event listener declaratively using a controller method annotated with
Subscribe
:@Subscribe(id = "fooDl", target = Target.DATA_LOADER) private void onFooDlPostLoad(CollectionLoader.PostLoadEvent event) { // handle event here }
- Specified by:
addPostLoadListener
in interfaceCollectionLoader<E>
- Parameters:
listener
- listener- Returns:
- subscription
-