public class CollectionLoaderImpl<E extends Entity> extends java.lang.Object implements CollectionLoader<E>, LoaderSupportsApplyToSelected
CollectionLoader.PostLoadEvent<T extends Entity>, CollectionLoader.PreLoadEvent<T extends Entity>
Modifier and Type | Field and Description |
---|---|
protected boolean |
cacheable |
protected Condition |
condition |
protected CollectionContainer<E> |
container |
protected DataContext |
dataContext |
protected java.util.function.Function<LoadContext<E>,java.util.List<E>> |
delegate |
protected EventHub |
events |
protected int |
firstResult |
protected LoadContext.Query |
lastQuery |
protected boolean |
loadDynamicAttributes |
protected int |
maxResults |
protected java.util.Map<java.lang.String,java.lang.Object> |
parameters |
protected java.util.List<LoadContext.Query> |
prevQueries |
protected java.lang.String |
query |
protected java.lang.Integer |
queryKey |
protected boolean |
softDeletion |
protected Sort |
sort |
protected View |
view |
protected java.lang.String |
viewName |
Constructor and Description |
---|
CollectionLoaderImpl(org.springframework.context.ApplicationContext applicationContext) |
Modifier and Type | Method and Description |
---|---|
Subscription |
addPostLoadListener(java.util.function.Consumer<CollectionLoader.PostLoadEvent<E>> listener)
Adds a listener to
CollectionLoader.PostLoadEvent . |
Subscription |
addPreLoadListener(java.util.function.Consumer<CollectionLoader.PreLoadEvent<E>> listener)
Adds a listener to
CollectionLoader.PreLoadEvent . |
LoadContext<E> |
createLoadContext()
Returns
LoadContext which is created by the parameters of this loader. |
Condition |
getCondition()
Returns the root condition which is used together with the query when loading entities.
|
CollectionContainer<E> |
getContainer()
Returns the container which accepts loaded entities.
|
DataContext |
getDataContext()
Returns data context.
|
protected DataManager |
getDataManager() |
int |
getFirstResult()
The position of the first instance to load, numbered from 0.
|
LoadContext.Query |
getLastQuery()
Returns last query executed by loader
|
java.util.function.Function<LoadContext<E>,java.util.List<E>> |
getLoadDelegate()
Returns a function which will be used to load data instead of standard implementation.
|
int |
getMaxResults()
The maximum number of instances to load.
|
java.lang.Object |
getParameter(java.lang.String name)
Returns a query parameter by its name.
|
java.util.Map<java.lang.String,java.lang.Object> |
getParameters()
Returns the map of query parameters.
|
java.util.List<LoadContext.Query> |
getPrevQueries()
Allows to load data on a previous loading result.
|
java.lang.String |
getQuery()
Returns the query which is used for loading entities.
|
java.lang.Integer |
getQueryKey() |
Sort |
getSort()
Returns the sort object which is used when loading.
|
protected SorterFactory |
getSorterFactory() |
View |
getView()
Returns the view which is used when loading.
|
protected ViewRepository |
getViewRepository() |
boolean |
isCacheable()
Returns true if the query for loading data is cacheable.
|
boolean |
isLoadDynamicAttributes()
Returns true if the entity's dynamic attributes are loaded.
|
boolean |
isSoftDeletion()
Returns true if the loader respects soft deletion, i.e.
|
void |
load()
Loads data to the connected container.
|
void |
removeParameter(java.lang.String name)
Removes a query parameter.
|
protected View |
resolveView() |
protected void |
sendPostLoadEvent(java.util.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 |
setFirstResult(int firstResult)
Sets the position of the first instance to load, numbered from 0.
|
void |
setLoadDelegate(java.util.function.Function<LoadContext<E>,java.util.List<E>> delegate)
Sets a function which will be used to load data instead of standard implementation.
|
void |
setLoadDynamicAttributes(boolean loadDynamicAttributes)
Set to true to load the entity's dynamic attributes.
|
void |
setMaxResults(int maxResults)
Sets the maximum number of instances to load.
|
void |
setParameter(java.lang.String name,
java.lang.Object value)
Sets a query parameter.
|
void |
setParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)
Sets the map of query parameters.
|
void |
setPrevQueries(java.util.List<LoadContext.Query> prevQueries)
Set previous queries which allows to load data on a previous loading result.
|
void |
setQuery(java.lang.String query)
Sets a query which will be used for loading entities.
|
void |
setQueryKey(java.lang.Integer queryKey) |
void |
setSoftDeletion(boolean softDeletion)
Set to false if you want to load softly deleted instances too.
|
void |
setSort(Sort sort)
Sets the sort object which is used when loading.
|
void |
setView(java.lang.String viewName)
Sets the name of the view which is used when loading.
|
void |
setView(View view)
Sets the view which is used when loading.
|
protected DataContext dataContext
protected CollectionContainer<E extends Entity> container
protected java.lang.String query
protected Condition condition
protected java.util.Map<java.lang.String,java.lang.Object> parameters
protected int firstResult
protected int maxResults
protected boolean softDeletion
protected boolean loadDynamicAttributes
protected boolean cacheable
protected View view
protected java.lang.String viewName
protected Sort sort
protected java.util.function.Function<LoadContext<E extends Entity>,java.util.List<E extends Entity>> delegate
protected LoadContext.Query lastQuery
protected java.util.List<LoadContext.Query> prevQueries
protected java.lang.Integer queryKey
protected EventHub events
public CollectionLoaderImpl(org.springframework.context.ApplicationContext applicationContext)
protected ViewRepository getViewRepository()
protected DataManager getDataManager()
protected SorterFactory getSorterFactory()
@Nullable public DataContext getDataContext()
DataLoader
getDataContext
in interface DataLoader
public void setDataContext(DataContext dataContext)
DataLoader
setDataContext
in interface DataLoader
public void load()
DataLoader
load
in interface DataLoader
public LoadContext<E> createLoadContext()
CollectionLoader
LoadContext
which is created by the parameters of this loader. The LoadContext
can be used with DataManager
to load data by the same conditions.createLoadContext
in interface CollectionLoader<E extends Entity>
protected View resolveView()
protected boolean sendPreLoadEvent(LoadContext<E> loadContext)
protected void sendPostLoadEvent(java.util.List<E> entities)
public CollectionContainer<E> getContainer()
CollectionLoader
getContainer
in interface BaseCollectionLoader
getContainer
in interface CollectionLoader<E extends Entity>
getContainer
in interface DataLoader
public void setContainer(CollectionContainer<E> container)
CollectionLoader
setContainer
in interface CollectionLoader<E extends Entity>
public java.lang.String getQuery()
DataLoader
getQuery
in interface DataLoader
public void setQuery(java.lang.String query)
DataLoader
setQuery
in interface DataLoader
public Condition getCondition()
DataLoader
getCondition
in interface DataLoader
public void setCondition(Condition condition)
DataLoader
setCondition
in interface DataLoader
public java.util.Map<java.lang.String,java.lang.Object> getParameters()
DataLoader
getParameters
in interface DataLoader
public void setParameters(java.util.Map<java.lang.String,java.lang.Object> parameters)
DataLoader
setParameters
in interface DataLoader
public java.lang.Object getParameter(java.lang.String name)
DataLoader
getParameter
in interface DataLoader
public void setParameter(java.lang.String name, java.lang.Object value)
DataLoader
setParameter
in interface DataLoader
public void removeParameter(java.lang.String name)
DataLoader
removeParameter
in interface DataLoader
public int getFirstResult()
BaseCollectionLoader
BaseCollectionLoader.setFirstResult(int)
was not called.getFirstResult
in interface BaseCollectionLoader
public void setFirstResult(int firstResult)
BaseCollectionLoader
setFirstResult
in interface BaseCollectionLoader
public int getMaxResults()
BaseCollectionLoader
Integer.MAX_VALUE
if BaseCollectionLoader.setMaxResults(int)
was not called.getMaxResults
in interface BaseCollectionLoader
public void setMaxResults(int maxResults)
BaseCollectionLoader
setMaxResults
in interface BaseCollectionLoader
public boolean isSoftDeletion()
DataLoader
isSoftDeletion
in interface DataLoader
public void setSoftDeletion(boolean softDeletion)
DataLoader
setSoftDeletion
in interface DataLoader
public boolean isLoadDynamicAttributes()
CollectionLoader
isLoadDynamicAttributes
in interface CollectionLoader<E extends Entity>
public void setLoadDynamicAttributes(boolean loadDynamicAttributes)
CollectionLoader
setLoadDynamicAttributes
in interface CollectionLoader<E extends Entity>
public boolean isCacheable()
CollectionLoader
isCacheable
in interface CollectionLoader<E extends Entity>
public void setCacheable(boolean cacheable)
CollectionLoader
setCacheable
in interface CollectionLoader<E extends Entity>
public View getView()
CollectionLoader
getView
in interface CollectionLoader<E extends Entity>
public void setView(View view)
CollectionLoader
setView
in interface CollectionLoader<E extends Entity>
public void setView(java.lang.String viewName)
CollectionLoader
setView
in interface CollectionLoader<E extends Entity>
public Sort getSort()
BaseCollectionLoader
getSort
in interface BaseCollectionLoader
public void setSort(Sort sort)
BaseCollectionLoader
setSort
in interface BaseCollectionLoader
public java.util.function.Function<LoadContext<E>,java.util.List<E>> getLoadDelegate()
CollectionLoader
getLoadDelegate
in interface CollectionLoader<E extends Entity>
public void setLoadDelegate(java.util.function.Function<LoadContext<E>,java.util.List<E>> delegate)
CollectionLoader
setLoadDelegate
in interface CollectionLoader<E extends Entity>
public Subscription addPreLoadListener(java.util.function.Consumer<CollectionLoader.PreLoadEvent<E>> listener)
CollectionLoader
CollectionLoader.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 }
addPreLoadListener
in interface CollectionLoader<E extends Entity>
listener
- listenerpublic Subscription addPostLoadListener(java.util.function.Consumer<CollectionLoader.PostLoadEvent<E>> listener)
CollectionLoader
CollectionLoader.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 }
addPostLoadListener
in interface CollectionLoader<E extends Entity>
listener
- listenerpublic LoadContext.Query getLastQuery()
LoaderSupportsApplyToSelected
getLastQuery
in interface LoaderSupportsApplyToSelected
public java.util.List<LoadContext.Query> getPrevQueries()
LoaderSupportsApplyToSelected
getPrevQueries
in interface LoaderSupportsApplyToSelected
public void setPrevQueries(java.util.List<LoadContext.Query> prevQueries)
LoaderSupportsApplyToSelected
setPrevQueries
in interface LoaderSupportsApplyToSelected
public java.lang.Integer getQueryKey()
getQueryKey
in interface LoaderSupportsApplyToSelected
public void setQueryKey(java.lang.Integer queryKey)
setQueryKey
in interface LoaderSupportsApplyToSelected
queryKey
- key of the current stack of sequential queries, which is unique for the current user session