T
- type of entityK
- type of entity IDpublic class CollectionDatasourceImpl<T extends Entity<K>,K> extends AbstractCollectionDatasource<T,K> implements CollectionDatasource.Indexed<T,K>, CollectionDatasource.Sortable<T,K>, CollectionDatasource.Aggregatable<T,K>, CollectionDatasource.Suspendable<T,K>, CollectionDatasource.SupportsPaging<T,K>, CollectionDatasource.SupportsApplyToSelected<T,K>
CollectionDatasource
implementation.
Contains collection of standalone (not property) entities, and can request data from database and commit changes.
loadData(java.util.Map)
method.AbstractCollectionDatasource.ComponentValueListener
AbstractDatasource.ItemListener
CollectionDatasource.Sortable.Order, CollectionDatasource.Sortable.SortInfo<P>
CollectionDatasource.Aggregatable<T extends Entity<K>,K>, CollectionDatasource.CollectionChangeEvent<T extends Entity<K>,K>, CollectionDatasource.CollectionChangeListener<T extends Entity<K>,K>, CollectionDatasource.Indexed<T extends Entity<K>,K>, CollectionDatasource.Lazy<T extends Entity<K>,K>, CollectionDatasource.Operation, CollectionDatasource.Ordered<T extends Entity<K>,K>, CollectionDatasource.RefreshMode, CollectionDatasource.Sortable<T extends Entity<K>,K>, CollectionDatasource.SupportsApplyToSelected<T extends Entity<K>,K>, CollectionDatasource.SupportsPaging<T extends Entity<K>,K>, CollectionDatasource.SupportsRefreshMode<T extends Entity<K>,K>, CollectionDatasource.Suspendable<T extends Entity<K>,K>, CollectionDatasource.UnmuteEventsMode
Datasource.CommitMode, Datasource.ItemChangeEvent<T extends Entity>, Datasource.ItemChangeListener<T extends Entity>, Datasource.ItemPropertyChangeEvent<T extends Entity>, Datasource.ItemPropertyChangeListener<T extends Entity>, Datasource.State, Datasource.StateChangeEvent<T extends Entity>, Datasource.StateChangeListener<T extends Entity>
Modifier and Type | Field and Description |
---|---|
protected AggregatableDelegate<K> |
aggregatableDelegate |
protected org.apache.commons.collections4.map.LinkedMap |
data |
protected int |
firstResult |
protected boolean |
inRefresh |
protected LoadContext.Query |
lastQuery |
protected java.util.LinkedList<LoadContext.Query> |
prevQueries |
protected java.lang.Integer |
queryKey |
protected boolean |
refreshOnResumeRequired |
protected boolean |
sortOnDb |
protected boolean |
suspended |
cacheable, componentValueListener, dataLoadError, filter, listenersSuspended, maxResults, query, queryParameters, refreshMode, refreshOnComponentValueChange, savedParameters, softDeletion, sortInfos, suspendedEvents, userSession
dataSupplier, dsContext, item, metaClass, state, view
allowCommit, backgroundWorker, commitMode, id, itemsToCreate, itemsToDelete, itemsToUpdate, listener, listenersEnabled, loadDynamicAttributes, metadata, modified, parentDs
Constructor and Description |
---|
CollectionDatasourceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addItem(T item)
Add an item to the collection.
|
void |
addItemFirst(T item)
Add an item to the collection to the first position.
|
protected void |
afterLoadData(java.util.Map<java.lang.String,java.lang.Object> params,
LoadContext context,
java.util.Collection<T> entities)
This method is invoked by
loadData(Map) method immediately after loading entities from DataSupplier . |
protected void |
afterRefresh(java.util.Map<java.lang.String,java.lang.Object> parameters,
java.util.Collection prevIds) |
java.util.Map<AggregationInfo,java.lang.String> |
aggregate(AggregationInfo[] aggregationInfos,
java.util.Collection itemIds)
Perform aggregation and return map with formatted string values.
|
java.util.Map<AggregationInfo,java.lang.Object> |
aggregateValues(AggregationInfo[] aggregationInfos,
java.util.Collection<K> itemIds)
Perform aggregation and return map with aggregation info and aggregation column type, i.e.
|
protected LoadContext |
beforeLoadData(java.util.Map<java.lang.String,java.lang.Object> params)
This method is invoked by
loadData(Map) method immediately before loading entities from DataSupplier . |
protected java.util.Collection |
beforeRefresh(java.util.Map<java.lang.String,java.lang.Object> parameters) |
protected void |
checkState() |
protected void |
checkStateBeforeAdd() |
void |
clear()
Clear the underlying collection.
|
void |
committed(java.util.Set<Entity> entities)
Invoked after commit.
|
protected boolean |
containsAllDataFromDb() |
boolean |
containsItem(K itemId) |
protected void |
detachListener(java.util.Collection instances) |
protected void |
doSort() |
void |
excludeItem(T item)
Exclude an item from the collection.
|
K |
firstItemId() |
LoadContext |
getCompiledLoadContext() |
int |
getFirstResult() |
K |
getIdByIndex(int index) |
T |
getItem(K id) |
java.util.Collection<K> |
getItemIds() |
java.util.List<K> |
getItemIds(int startIndex,
int numberOfItems) |
java.util.Collection<T> |
getItems()
In standard implementations this is a wrapper method around
CollectionDatasource.getItemIds() and CollectionDatasource.getItem(Object) . |
protected java.lang.Object |
getItemValue(com.haulmont.chile.core.model.MetaPropertyPath property,
K itemId) |
void |
includeItem(T item)
Include an item into the collection.
|
void |
includeItemFirst(T item)
Include an item into the collection to the first position.
|
protected void |
incrementQueryKey() |
int |
indexOfId(K itemId) |
protected void |
internalAddItem(T item,
java.lang.Runnable addToData) |
protected void |
internalIncludeItem(T item,
java.lang.Runnable addToData) |
boolean |
isFirstId(K itemId) |
boolean |
isLastId(K itemId) |
boolean |
isSuspended() |
K |
lastItemId() |
protected void |
loadData(java.util.Map<java.lang.String,java.lang.Object> params)
Load data from middleware into
data field. |
void |
modifyItem(T item)
Update an item in the collection if it is already there.
|
protected boolean |
needLoading() |
K |
nextItemId(K itemId) |
void |
pinQuery() |
protected void |
prepareLoadContext(LoadContext<?> context) |
K |
prevItemId(K itemId) |
void |
refresh()
Refreshes the datasource moving it to the
Datasource.State.VALID state |
void |
refresh(java.util.Map<java.lang.String,java.lang.Object> parameters)
Refresh datasource passing specified parameters to the query.
|
void |
refreshIfNotSuspended() |
void |
refreshIfNotSuspended(java.util.Map<java.lang.String,java.lang.Object> parameters) |
void |
removeItem(T item)
Remove an item from the collection.
|
void |
resetSortOrder()
Remove sort infos
|
void |
revert()
Revert the datasource to its initial state before data modification.
|
void |
setFirstResult(int startPosition) |
void |
setSuspended(boolean suspended) |
int |
size() |
void |
sort(CollectionDatasource.Sortable.SortInfo[] sortInfos)
Perform sorting
|
void |
unpinAllQuery() |
void |
unpinLastQuery() |
void |
updateItem(T item)
Update an item in the collection if it is already there.
|
addCollectionChangeListener, checkDataLoadError, commit, createDataQuery, createEntityComparator, fireCollectionChanged, getCount, getItemNN, getJPQLQuery, getLastRefreshParameters, getLoggingTag, getMaxResults, getQuery, getQueryFilter, getQueryParameters, getRefreshMode, getRefreshOnComponentValueChange, getSortPropertiesForPersistentAttribute, getTemplateParams, isCacheable, isSoftDeletion, makeCaseInsensitive, mute, removeCollectionChangeListener, resumeListeners, setCacheable, setItem, setMaxResults, setQuery, setQuery, setQueryFilter, setRefreshMode, setRefreshOnComponentValueChange, setSoftDeletion, setSortDirection, suspendListeners, unmute
__setItem, getDataSupplier, getDsContext, getItem, getItemIfValid, getMetaClass, getState, getView, initialized, invalidate, setDataSupplier, setDsContext, setMetaClass, setup, setView, setView, valid
addItemChangeListener, addItemPropertyChangeListener, addParentsToNested, addStateChangeListener, attachListener, clearCommitLists, deleted, detachListener, enableListeners, fireItemChanged, fireStateChanged, getCommitMode, getEventRouter, getId, getItemsToCreate, getItemsToDelete, getItemsToUpdate, getLoadDynamicAttributes, getParent, isAllowCommit, isModified, modified, removeItemChangeListener, removeItemPropertyChangeListener, removeStateChangeListener, setAllowCommit, setCommitMode, setLoadDynamicAttributes, setModified, setParent, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addCollectionChangeListener, getItemNN, getLastRefreshParameters, getMaxResults, getQuery, getQueryFilter, getRefreshOnComponentValueChange, isCacheable, isSoftDeletion, mute, removeCollectionChangeListener, resumeListeners, setCacheable, setMaxResults, setQuery, setQuery, setQueryFilter, setRefreshOnComponentValueChange, setSoftDeletion, suspendListeners, unmute
addItemChangeListener, addItemPropertyChangeListener, addStateChangeListener, commit, getCommitMode, getDataSupplier, getDsContext, getId, getItem, getItemIfValid, getLoadDynamicAttributes, getMetaClass, getState, getView, invalidate, isAllowCommit, isModified, removeItemChangeListener, removeItemPropertyChangeListener, removeStateChangeListener, setAllowCommit, setItem, setLoadDynamicAttributes, setup
getCount
clearCommitLists, deleted, enableListeners, getItemsToCreate, getItemsToDelete, getItemsToUpdate, getParent, modified, setCommitMode, setModified, setParent
protected org.apache.commons.collections4.map.LinkedMap data
protected boolean inRefresh
protected AggregatableDelegate<K> aggregatableDelegate
protected boolean suspended
protected boolean refreshOnResumeRequired
protected int firstResult
protected boolean sortOnDb
protected LoadContext.Query lastQuery
protected java.util.LinkedList<LoadContext.Query> prevQueries
protected java.lang.Integer queryKey
public void refreshIfNotSuspended()
refreshIfNotSuspended
in interface CollectionDatasource.Suspendable<T extends Entity<K>,K>
public void refreshIfNotSuspended(java.util.Map<java.lang.String,java.lang.Object> parameters)
refreshIfNotSuspended
in interface CollectionDatasource.Suspendable<T extends Entity<K>,K>
public void refresh()
Datasource
Datasource.State.VALID
staterefresh
in interface Datasource<T extends Entity<K>>
refresh
in class DatasourceImpl<T extends Entity<K>>
public void refresh(java.util.Map<java.lang.String,java.lang.Object> parameters)
CollectionDatasource
These parameters may be referenced in the query text by "custom$" prefix.
protected java.util.Collection beforeRefresh(java.util.Map<java.lang.String,java.lang.Object> parameters)
protected void afterRefresh(java.util.Map<java.lang.String,java.lang.Object> parameters, java.util.Collection prevIds)
public java.util.Collection<K> getItemIds()
getItemIds
in interface CollectionDatasource<T extends Entity<K>,K>
public java.util.Collection<T> getItems()
CollectionDatasource
CollectionDatasource.getItemIds()
and CollectionDatasource.getItem(Object)
.
Use it only if you really need the collection of items. Otherwise use CollectionDatasource.getItemIds()
or CollectionDatasource.size()
directly.public int size()
public void sort(CollectionDatasource.Sortable.SortInfo[] sortInfos)
CollectionDatasource.Sortable
public void resetSortOrder()
CollectionDatasource.Sortable
resetSortOrder
in interface CollectionDatasource.Sortable<T extends Entity<K>,K>
protected boolean containsAllDataFromDb()
protected void doSort()
public int indexOfId(K itemId)
public K getIdByIndex(int index)
getIdByIndex
in interface CollectionDatasource.Indexed<T extends Entity<K>,K>
public java.util.List<K> getItemIds(int startIndex, int numberOfItems)
getItemIds
in interface CollectionDatasource.Indexed<T extends Entity<K>,K>
public K firstItemId()
firstItemId
in interface CollectionDatasource.Ordered<T extends Entity<K>,K>
public K lastItemId()
lastItemId
in interface CollectionDatasource.Ordered<T extends Entity<K>,K>
public K nextItemId(K itemId)
nextItemId
in interface CollectionDatasource.Ordered<T extends Entity<K>,K>
public K prevItemId(K itemId)
prevItemId
in interface CollectionDatasource.Ordered<T extends Entity<K>,K>
public boolean isFirstId(K itemId)
public boolean isLastId(K itemId)
protected void checkState()
protected void checkStateBeforeAdd()
public void addItem(T item)
CollectionDatasource
public void addItemFirst(T item)
CollectionDatasource.Ordered
addItemFirst
in interface CollectionDatasource.Ordered<T extends Entity<K>,K>
protected void internalAddItem(T item, java.lang.Runnable addToData)
public void removeItem(T item)
CollectionDatasource
removeItem
in interface CollectionDatasource<T extends Entity<K>,K>
public void includeItem(T item)
CollectionDatasource
includeItem
in interface CollectionDatasource<T extends Entity<K>,K>
public void includeItemFirst(T item)
CollectionDatasource.Ordered
includeItemFirst
in interface CollectionDatasource.Ordered<T extends Entity<K>,K>
protected void internalIncludeItem(T item, java.lang.Runnable addToData)
public void excludeItem(T item)
CollectionDatasource
excludeItem
in interface CollectionDatasource<T extends Entity<K>,K>
public void clear()
CollectionDatasource
public void revert()
CollectionDatasource
public void modifyItem(T item)
CollectionDatasource
modifyItem
in interface CollectionDatasource<T extends Entity<K>,K>
public void updateItem(T item)
CollectionDatasource
updateItem
in interface CollectionDatasource<T extends Entity<K>,K>
public boolean containsItem(K itemId)
containsItem
in interface CollectionDatasource<T extends Entity<K>,K>
public void committed(java.util.Set<Entity> entities)
DatasourceImplementation
committed
in interface DatasourceImplementation<T extends Entity<K>>
committed
in class DatasourceImpl<T extends Entity<K>>
entities
- committed entities returned from middlewareprotected boolean needLoading()
public LoadContext getCompiledLoadContext()
getCompiledLoadContext
in interface CollectionDatasource<T extends Entity<K>,K>
getCompiledLoadContext
in class AbstractCollectionDatasource<T extends Entity<K>,K>
protected void loadData(java.util.Map<java.lang.String,java.lang.Object> params)
data
field.
In case of error sets AbstractCollectionDatasource.dataLoadError
field to the exception object.
params
- datasource parameters, as described in CollectionDatasource.refresh(java.util.Map)
protected LoadContext beforeLoadData(java.util.Map<java.lang.String,java.lang.Object> params)
loadData(Map)
method immediately before loading entities from DataSupplier
.
super()
.params
- datasource parameters, as described in CollectionDatasource.refresh(java.util.Map)
protected void afterLoadData(java.util.Map<java.lang.String,java.lang.Object> params, LoadContext context, java.util.Collection<T> entities)
loadData(Map)
method immediately after loading entities from DataSupplier
.
If you override this method, be sure to call super()
. If you process the loaded entities somehow,
call super()
after processing.
params
- datasource parameters, as described in CollectionDatasource.refresh(java.util.Map)
context
- LoadContext
which was used for loading dataentities
- loaded entitiesprotected void prepareLoadContext(LoadContext<?> context)
prepareLoadContext
in class AbstractCollectionDatasource<T extends Entity<K>,K>
protected void detachListener(java.util.Collection instances)
public java.util.Map<AggregationInfo,java.lang.String> aggregate(AggregationInfo[] aggregationInfos, java.util.Collection itemIds)
CollectionDatasource.Aggregatable
public java.util.Map<AggregationInfo,java.lang.Object> aggregateValues(AggregationInfo[] aggregationInfos, java.util.Collection<K> itemIds)
CollectionDatasource.Aggregatable
aggregateValues
in interface CollectionDatasource.Aggregatable<T extends Entity<K>,K>
aggregationInfos
- aggregation infositemIds
- collection of item idsprotected java.lang.Object getItemValue(com.haulmont.chile.core.model.MetaPropertyPath property, K itemId)
public boolean isSuspended()
isSuspended
in interface CollectionDatasource.Suspendable<T extends Entity<K>,K>
public void setSuspended(boolean suspended)
setSuspended
in interface CollectionDatasource.Suspendable<T extends Entity<K>,K>
public int getFirstResult()
getFirstResult
in interface CollectionDatasource.SupportsPaging<T extends Entity<K>,K>
public void setFirstResult(int startPosition)
setFirstResult
in interface CollectionDatasource.SupportsPaging<T extends Entity<K>,K>
protected void incrementQueryKey()
public void pinQuery()
public void unpinLastQuery()
unpinLastQuery
in interface CollectionDatasource.SupportsApplyToSelected<T extends Entity<K>,K>
public void unpinAllQuery()
unpinAllQuery
in interface CollectionDatasource.SupportsApplyToSelected<T extends Entity<K>,K>