public class CollectionPropertyDatasourceImpl<T extends Entity<K>,K> extends PropertyDatasourceImpl<T> implements CollectionDatasource<T,K>, CollectionDatasource.Indexed<T,K>, CollectionDatasource.Sortable<T,K>, CollectionDatasource.Aggregatable<T,K>
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 boolean |
cascadeProperty |
protected java.util.List<CollectionDatasource.CollectionChangeListener<? super T,K>> |
collectionChangeListeners |
protected boolean |
doNotModify |
protected T |
item |
protected boolean |
listenersSuspended |
protected CollectionDatasource.Sortable.SortInfo<com.haulmont.chile.core.model.MetaPropertyPath>[] |
sortInfos |
protected java.util.LinkedList<CollectionDatasource.CollectionChangeEvent<T,K>> |
suspendedEvents |
masterDs, metaClass, metaProperty, view
allowCommit, backgroundWorker, commitMode, id, itemsToCreate, itemsToDelete, itemsToUpdate, listener, listenersEnabled, loadDynamicAttributes, metadata, modified, parentDs
Constructor and Description |
---|
CollectionPropertyDatasourceImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addCollectionChangeListener(CollectionDatasource.CollectionChangeListener<? super T,K> listener) |
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 |
addToCollectionFirst(T item) |
java.util.Map<AggregationInfo,java.lang.String> |
aggregate(AggregationInfo[] aggregationInfos,
java.util.Collection<K> 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 void |
checkPermission() |
protected void |
checkState() |
void |
clear()
Clear the underlying collection.
|
void |
committed(java.util.Set<Entity> entities)
Invoked after commit.
|
boolean |
containsItem(K itemId) |
protected boolean |
containsObjectInstance(T instance)
Search the collection using object identity.
|
protected EntityComparator<T> |
createEntityComparator() |
protected void |
doSort() |
void |
excludeItem(T item)
Exclude an item from the collection.
|
protected void |
fireCollectionChanged(CollectionDatasource.Operation operation,
java.util.List<T> items) |
K |
firstItemId() |
protected java.util.Collection<T> |
getCollection() |
LoadContext |
getCompiledLoadContext() |
K |
getIdByIndex(int index) |
T |
getItem() |
T |
getItem(K id) |
java.util.Collection<K> |
getItemIds() |
java.util.List<K> |
getItemIds(int startIndex,
int numberOfItems) |
T |
getItemNN(K id) |
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) |
java.util.Map<java.lang.String,java.lang.Object> |
getLastRefreshParameters()
Returns the parameters last used in
CollectionDatasource.refresh(Map) method or empty map if there was no refresh with parameters |
int |
getMaxResults() |
java.lang.String |
getQuery() |
QueryFilter |
getQueryFilter() |
boolean |
getRefreshOnComponentValueChange()
Whether to refresh datasource on changing value of a component which it depends on
(through
component$ parameter) |
void |
includeItem(T item)
Include an item into the collection.
|
void |
includeItemFirst(T item)
Include an item into the collection to the first position.
|
int |
indexOfId(K itemId) |
protected void |
initCollection() |
protected void |
initParentDsListeners() |
protected void |
internalAddItem(T item,
java.lang.Runnable addToCollection) |
protected void |
internalIncludeItem(T item,
java.lang.Runnable addToCollection) |
boolean |
isCacheable() |
boolean |
isFirstId(K itemId) |
boolean |
isLastId(K itemId) |
boolean |
isSoftDeletion() |
K |
lastItemId() |
void |
modified(T item)
Invoked when the given instance is modified.
|
void |
modifyItem(T item)
Update an item in the collection if it is already there.
|
void |
mute()
Disables all event listeners on datasource data change.
|
K |
nextItemId(K itemId) |
K |
prevItemId(K itemId) |
protected void |
reattachListeners(java.util.Collection prevColl,
java.util.Collection coll) |
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 |
removeCollectionChangeListener(CollectionDatasource.CollectionChangeListener<? super T,K> listener) |
void |
removeItem(T item)
Remove an item from the collection.
|
void |
replaceItem(T item) |
void |
resetSortOrder()
Remove sort infos
|
void |
resumeListeners()
Resume invocation of
collectionChanged method of registered CollectionDatasource.CollectionChangeListener s
after calling CollectionDatasource.suspendListeners() . |
void |
revert()
Revert the datasource to its initial state before data modification.
|
void |
setCacheable(boolean cacheable)
Indicates that the datasource query results should be cached in the middleware query cache.
|
void |
setItem(T item)
Set current entity in the datasource.
|
void |
setMaxResults(int maxResults)
Set max number of rows.
|
void |
setQuery(java.lang.String query)
Set query string which is used to load data.
|
void |
setQuery(java.lang.String query,
QueryFilter filter)
Set query string and associated filter which is used to load data.
|
void |
setQueryFilter(QueryFilter filter)
Set query filter which is used to load data.
|
void |
setRefreshOnComponentValueChange(boolean refresh)
Whether to refresh datasource on changing value of a component which it depends on
(through
component$ parameter) |
void |
setSoftDeletion(boolean softDeletion)
Switch on/off Soft Deletion.
|
void |
setup(java.lang.String id,
Datasource masterDs,
java.lang.String property)
Setup the datasource right after creation.
|
int |
size() |
void |
sort(CollectionDatasource.Sortable.SortInfo[] sortInfos)
Perform sorting
|
void |
suspendListeners()
Suspend invocation of
collectionChanged method of registered CollectionDatasource.CollectionChangeListener s. |
void |
unmute(CollectionDatasource.UnmuteEventsMode mode)
Enables all event listeners.
|
void |
updateItem(T item)
Update an item in the collection if it is already there.
|
commit, getDataSupplier, getDsContext, getItem, getItemIfValid, getMaster, getMetaClass, getProperty, getState, getView, initialized, invalidate, reattachListeners, valid
addItemChangeListener, addItemPropertyChangeListener, addParentsToNested, addStateChangeListener, attachListener, clearCommitLists, deleted, detachListener, enableListeners, fireItemChanged, fireStateChanged, getCommitMode, getEventRouter, getId, getItemsToCreate, getItemsToDelete, getItemsToUpdate, getLoadDynamicAttributes, getParent, isAllowCommit, isModified, removeItemChangeListener, removeItemPropertyChangeListener, removeStateChangeListener, setAllowCommit, setCommitMode, setLoadDynamicAttributes, setModified, setParent, setup, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addItemChangeListener, addItemPropertyChangeListener, addStateChangeListener, commit, getCommitMode, getDataSupplier, getDsContext, getId, getItemIfValid, getLoadDynamicAttributes, getMetaClass, getState, getView, invalidate, isAllowCommit, isModified, removeItemChangeListener, removeItemPropertyChangeListener, removeStateChangeListener, setAllowCommit, setLoadDynamicAttributes, setup
clearCommitLists, deleted, enableListeners, getItemsToCreate, getItemsToDelete, getItemsToUpdate, getParent, setCommitMode, setModified, setParent
protected boolean cascadeProperty
protected CollectionDatasource.Sortable.SortInfo<com.haulmont.chile.core.model.MetaPropertyPath>[] sortInfos
protected boolean listenersSuspended
protected final java.util.LinkedList<CollectionDatasource.CollectionChangeEvent<T extends Entity<K>,K>> suspendedEvents
protected boolean doNotModify
protected java.util.List<CollectionDatasource.CollectionChangeListener<? super T extends Entity<K>,K>> collectionChangeListeners
protected AggregatableDelegate<K> aggregatableDelegate
public void setup(java.lang.String id, Datasource masterDs, java.lang.String property)
NestedDatasource
setup
in interface NestedDatasource<T extends Entity<K>>
setup
in class PropertyDatasourceImpl<T extends Entity<K>>
id
- datasource IDmasterDs
- master datasourceproperty
- property of the master datasource to bound this datasource toprotected void initParentDsListeners()
initParentDsListeners
in class PropertyDatasourceImpl<T extends Entity<K>>
protected void reattachListeners(java.util.Collection prevColl, java.util.Collection coll)
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 T getItem()
getItem
in interface Datasource<T extends Entity<K>>
getItem
in class PropertyDatasourceImpl<T extends Entity<K>>
public void setItem(T item)
Datasource
setItem
in interface Datasource<T extends Entity<K>>
setItem
in class PropertyDatasourceImpl<T extends Entity<K>>
item
- entity instancepublic void refresh()
Datasource
Datasource.State.VALID
staterefresh
in interface Datasource<T extends Entity<K>>
refresh
in class PropertyDatasourceImpl<T extends Entity<K>>
public int size()
protected java.util.Collection<T> getCollection()
protected void checkState()
protected void checkPermission()
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 addToCollection)
protected void addToCollectionFirst(T item)
protected boolean containsObjectInstance(T instance)
protected void initCollection()
public void removeItem(T item)
CollectionDatasource
removeItem
in interface CollectionDatasource<T extends Entity<K>,K>
public void excludeItem(T item)
CollectionDatasource
excludeItem
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 addToCollection)
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 void modified(T item)
DatasourceImplementation
modified
in interface DatasourceImplementation<T extends Entity<K>>
modified
in class PropertyDatasourceImpl<T extends Entity<K>>
public void replaceItem(T item)
public boolean containsItem(K itemId)
containsItem
in interface CollectionDatasource<T extends Entity<K>,K>
public java.lang.String getQuery()
public LoadContext getCompiledLoadContext()
getCompiledLoadContext
in interface CollectionDatasource<T extends Entity<K>,K>
public QueryFilter getQueryFilter()
getQueryFilter
in interface CollectionDatasource<T extends Entity<K>,K>
public void setQuery(java.lang.String query)
CollectionDatasource
ds$
- current item in the specified datasource
component$
- value of the specified UI component
param$
- value of parameter passed to the window when opening it
session$
- userId
represents current or substituted user ID,
userLogin
represents current or substituted user login in lower case,
any other string represents a user session attribute with this name
custom$
- value of parameter passed to the CollectionDatasource.refresh(java.util.Map)
method
public void setQuery(java.lang.String query, QueryFilter filter)
CollectionDatasource
CollectionDatasource.setQuery(String)
for the list of supported query parameters.public void setQueryFilter(QueryFilter filter)
CollectionDatasource
CollectionDatasource.setQuery(String)
for the list of supported query parameters.setQueryFilter
in interface CollectionDatasource<T extends Entity<K>,K>
public int getMaxResults()
getMaxResults
in interface CollectionDatasource<T extends Entity<K>,K>
public void setMaxResults(int maxResults)
CollectionDatasource
setMaxResults
in interface CollectionDatasource<T extends Entity<K>,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.
public java.util.Map<java.lang.String,java.lang.Object> getLastRefreshParameters()
CollectionDatasource
CollectionDatasource.refresh(Map)
method or empty map if there was no refresh with parametersgetLastRefreshParameters
in interface CollectionDatasource<T extends Entity<K>,K>
public boolean getRefreshOnComponentValueChange()
CollectionDatasource
component$
parameter)getRefreshOnComponentValueChange
in interface CollectionDatasource<T extends Entity<K>,K>
public void setRefreshOnComponentValueChange(boolean refresh)
CollectionDatasource
component$
parameter)setRefreshOnComponentValueChange
in interface CollectionDatasource<T extends Entity<K>,K>
public void addCollectionChangeListener(CollectionDatasource.CollectionChangeListener<? super T,K> listener)
addCollectionChangeListener
in interface CollectionDatasource<T extends Entity<K>,K>
public void removeCollectionChangeListener(CollectionDatasource.CollectionChangeListener<? super T,K> listener)
removeCollectionChangeListener
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 PropertyDatasourceImpl<T extends Entity<K>>
entities
- committed entities returned from middlewareprotected void fireCollectionChanged(CollectionDatasource.Operation operation, java.util.List<T> items)
public void suspendListeners()
CollectionDatasource
collectionChanged
method of registered CollectionDatasource.CollectionChangeListener
s.
It makes sense in case of massive updates of the datasource by CollectionDatasource.addItem(com.haulmont.cuba.core.entity.Entity)
or similar methods.
After that, collectionChanged
will be invoked once on CollectionDatasource.resumeListeners()
call.
ds.suspendListeners(); try { for (Object item : items) { ds.addItem(item); } } finally { ds.resumeListeners(); }
suspendListeners
in interface CollectionDatasource<T extends Entity<K>,K>
public void resumeListeners()
CollectionDatasource
collectionChanged
method of registered CollectionDatasource.CollectionChangeListener
s
after calling CollectionDatasource.suspendListeners()
.
It will call collectionChanged
just once, doesn't matter how many updates were issued
since the previous CollectionDatasource.suspendListeners()
call.
finally
section.resumeListeners
in interface CollectionDatasource<T extends Entity<K>,K>
public void mute()
CollectionDatasource
CollectionDatasource.unmute(UnmuteEventsMode)
for bulk data modification as a performance optimization.public void unmute(CollectionDatasource.UnmuteEventsMode mode)
CollectionDatasource
public boolean isSoftDeletion()
isSoftDeletion
in interface CollectionDatasource<T extends Entity<K>,K>
public void setSoftDeletion(boolean softDeletion)
CollectionDatasource
setSoftDeletion
in interface CollectionDatasource<T extends Entity<K>,K>
public boolean isCacheable()
isCacheable
in interface CollectionDatasource<T extends Entity<K>,K>
public void setCacheable(boolean cacheable)
CollectionDatasource
setCacheable
in interface CollectionDatasource<T extends Entity<K>,K>
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 void doSort()
protected EntityComparator<T> createEntityComparator()
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)
public java.util.Map<AggregationInfo,java.lang.String> aggregate(AggregationInfo[] aggregationInfos, java.util.Collection<K> 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)