public class InstanceLoaderImpl<E> extends java.lang.Object implements InstanceLoader<E>
InstanceLoader.PostLoadEvent<T>, InstanceLoader.PreLoadEvent<T>
Modifier and Type | Field and Description |
---|---|
protected io.jmix.core.querycondition.Condition |
condition |
protected InstanceContainer<E> |
container |
protected DataContext |
dataContext |
protected io.jmix.core.DataManager |
dataManager |
protected java.util.function.Function<io.jmix.core.LoadContext<E>,E> |
delegate |
protected java.lang.Object |
entityId |
protected io.jmix.core.common.event.EventHub |
events |
protected io.jmix.core.FetchPlan |
fetchPlan |
protected java.lang.String |
fetchPlanName |
protected io.jmix.core.FetchPlanRepository |
fetchPlanRepository |
protected java.util.Map<java.lang.String,java.io.Serializable> |
hints |
protected io.jmix.core.Metadata |
metadata |
protected java.util.Map<java.lang.String,java.lang.Object> |
parameters |
protected java.lang.String |
query |
protected java.util.List<io.jmix.core.QueryStringProcessor> |
queryStringProcessors |
Constructor and Description |
---|
InstanceLoaderImpl() |
Modifier and Type | Method and Description |
---|---|
io.jmix.core.common.event.Subscription |
addPostLoadListener(java.util.function.Consumer<InstanceLoader.PostLoadEvent<E>> listener)
Adds a listener to
InstanceLoader.PostLoadEvent . |
io.jmix.core.common.event.Subscription |
addPreLoadListener(java.util.function.Consumer<InstanceLoader.PreLoadEvent<E>> listener)
Adds a listener to
InstanceLoader.PreLoadEvent . |
io.jmix.core.LoadContext<E> |
createLoadContext() |
io.jmix.core.querycondition.Condition |
getCondition()
Returns the root condition which is used together with the query when loading entities.
|
InstanceContainer<E> |
getContainer()
Returns the container which accepts the loaded entity.
|
DataContext |
getDataContext()
Returns data context.
|
java.lang.Object |
getEntityId()
Returns id of the entity to load.
|
io.jmix.core.FetchPlan |
getFetchPlan()
Returns the fetch plan used for loading the entity.
|
java.util.Map<java.lang.String,java.io.Serializable> |
getHints() |
java.util.function.Function<io.jmix.core.LoadContext<E>,E> |
getLoadDelegate()
Returns a function which will be used to load data instead of standard implementation.
|
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.lang.String |
getQuery()
Returns the query which is used for loading entities.
|
void |
load()
Loads data to the connected container.
|
protected boolean |
needLoad() |
void |
removeParameter(java.lang.String name)
Removes a query parameter.
|
protected io.jmix.core.FetchPlan |
resolveFetchPlan() |
protected void |
sendPostLoadEvent(E entity) |
protected boolean |
sendPreLoadEvent(io.jmix.core.LoadContext<E> loadContext) |
void |
setCondition(io.jmix.core.querycondition.Condition condition)
Sets the root condition which will be used together with the query when loading entities.
|
void |
setContainer(InstanceContainer<E> container)
Sets the container which accepts the loaded entity.
|
void |
setDataContext(DataContext dataContext)
Sets the data context for the loader.
|
void |
setEntityId(java.lang.Object entityId)
Sets the id of the entity to load.
|
void |
setFetchPlan(io.jmix.core.FetchPlan fetchPlan)
Sets the fetch plan to use for loading the entity.
|
void |
setFetchPlan(java.lang.String fetchPlanName)
Sets the name of the fetch plan to use for loading the entity.
|
void |
setHint(java.lang.String hintName,
java.io.Serializable value)
Sets custom hint that should be used by the query for loading data.
|
void |
setLoadDelegate(java.util.function.Function<io.jmix.core.LoadContext<E>,E> delegate)
Sets a function which will be used to load data instead of standard implementation.
|
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 |
setQuery(java.lang.String query)
Sets a query which will be used for loading entities.
|
@Autowired protected io.jmix.core.DataManager dataManager
@Autowired protected io.jmix.core.FetchPlanRepository fetchPlanRepository
@Autowired protected java.util.List<io.jmix.core.QueryStringProcessor> queryStringProcessors
@Autowired protected io.jmix.core.Metadata metadata
protected DataContext dataContext
protected InstanceContainer<E> container
protected java.lang.String query
protected io.jmix.core.querycondition.Condition condition
protected java.util.Map<java.lang.String,java.lang.Object> parameters
protected java.lang.Object entityId
protected io.jmix.core.FetchPlan fetchPlan
protected java.lang.String fetchPlanName
protected java.util.Map<java.lang.String,java.io.Serializable> hints
protected io.jmix.core.common.event.EventHub events
@Nullable public DataContext getDataContext()
DataLoader
getDataContext
in interface DataLoader
public void setDataContext(@Nullable DataContext dataContext)
DataLoader
setDataContext
in interface DataLoader
public void load()
DataLoader
load
in interface DataLoader
protected boolean needLoad()
public io.jmix.core.LoadContext<E> createLoadContext()
protected io.jmix.core.FetchPlan resolveFetchPlan()
protected boolean sendPreLoadEvent(io.jmix.core.LoadContext<E> loadContext)
protected void sendPostLoadEvent(E entity)
public InstanceContainer<E> getContainer()
InstanceLoader
getContainer
in interface DataLoader
getContainer
in interface InstanceLoader<E>
public void setContainer(InstanceContainer<E> container)
InstanceLoader
setContainer
in interface InstanceLoader<E>
public java.lang.String getQuery()
DataLoader
getQuery
in interface DataLoader
public void setQuery(java.lang.String query)
DataLoader
setQuery
in interface DataLoader
@Nullable public io.jmix.core.querycondition.Condition getCondition()
DataLoader
getCondition
in interface DataLoader
public void setCondition(io.jmix.core.querycondition.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, @Nullable java.lang.Object value)
DataLoader
setParameter
in interface DataLoader
public void removeParameter(java.lang.String name)
DataLoader
removeParameter
in interface DataLoader
public java.lang.Object getEntityId()
InstanceLoader
getEntityId
in interface InstanceLoader<E>
public void setEntityId(java.lang.Object entityId)
InstanceLoader
setEntityId
in interface InstanceLoader<E>
public void setHint(java.lang.String hintName, java.io.Serializable value)
DataLoader
setHint
in interface DataLoader
public java.util.Map<java.lang.String,java.io.Serializable> getHints()
getHints
in interface DataLoader
public java.util.function.Function<io.jmix.core.LoadContext<E>,E> getLoadDelegate()
InstanceLoader
getLoadDelegate
in interface InstanceLoader<E>
public void setLoadDelegate(java.util.function.Function<io.jmix.core.LoadContext<E>,E> delegate)
InstanceLoader
setLoadDelegate
in interface InstanceLoader<E>
public io.jmix.core.common.event.Subscription addPreLoadListener(java.util.function.Consumer<InstanceLoader.PreLoadEvent<E>> listener)
InstanceLoader
InstanceLoader.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(InstanceLoader.PreLoadEvent<Foo> event) { // handle event here }
addPreLoadListener
in interface InstanceLoader<E>
listener
- listenerpublic io.jmix.core.common.event.Subscription addPostLoadListener(java.util.function.Consumer<InstanceLoader.PostLoadEvent<E>> listener)
InstanceLoader
InstanceLoader.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(InstanceLoader.PostLoadEvent<Foo> event) { // handle event here }
addPostLoadListener
in interface InstanceLoader<E>
listener
- listenerpublic io.jmix.core.FetchPlan getFetchPlan()
InstanceLoader
getFetchPlan
in interface InstanceLoader<E>
public void setFetchPlan(io.jmix.core.FetchPlan fetchPlan)
InstanceLoader
setFetchPlan
in interface InstanceLoader<E>
public void setFetchPlan(java.lang.String fetchPlanName)
InstanceLoader
setFetchPlan
in interface InstanceLoader<E>