public abstract class AbstractDatasource<T extends Entity> extends java.lang.Object implements Datasource<T>, DatasourceImplementation<T>
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractDatasource.ItemListener |
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 boolean |
allowCommit |
protected BackgroundWorker |
backgroundWorker |
protected Datasource.CommitMode |
commitMode |
protected java.lang.String |
id |
protected java.util.Collection<Entity> |
itemsToCreate |
protected java.util.Collection<Entity> |
itemsToDelete |
protected java.util.Collection<Entity> |
itemsToUpdate |
protected com.haulmont.chile.core.model.Instance.PropertyChangeListener |
listener |
protected boolean |
listenersEnabled |
protected boolean |
loadDynamicAttributes |
protected Metadata |
metadata |
protected boolean |
modified |
protected Datasource |
parentDs |
Constructor and Description |
---|
AbstractDatasource() |
Modifier and Type | Method and Description |
---|---|
void |
addItemChangeListener(Datasource.ItemChangeListener<T> listener) |
void |
addItemPropertyChangeListener(Datasource.ItemPropertyChangeListener<T> listener) |
protected void |
addParentsToNested() |
void |
addStateChangeListener(Datasource.StateChangeListener<T> listener) |
protected void |
attachListener(com.haulmont.chile.core.model.Instance item) |
void |
clearCommitLists()
Clear new, modified and deleted lists.
|
void |
deleted(T item)
Invoked when the given instance is deleted.
|
protected void |
detachListener(com.haulmont.chile.core.model.Instance item) |
boolean |
enableListeners(boolean enable)
Enables or disables datasource listeners.
|
protected void |
fireItemChanged(T prevItem) |
protected void |
fireStateChanged(Datasource.State prevStatus) |
Datasource.CommitMode |
getCommitMode() |
protected com.haulmont.bali.events.EventRouter |
getEventRouter()
Use EventRouter for listeners instead of fields with listeners List.
|
java.lang.String |
getId() |
java.util.Collection<T> |
getItemsToCreate()
New instances to be committed.
|
java.util.Collection<T> |
getItemsToDelete()
Deleted instances to be committed.
|
java.util.Collection<T> |
getItemsToUpdate()
Modified instances to be committed.
|
boolean |
getLoadDynamicAttributes() |
Datasource |
getParent()
Returns parent datasource or null.
|
boolean |
isAllowCommit() |
boolean |
isModified() |
void |
modified(T item)
Invoked when the given instance is modified.
|
void |
removeItemChangeListener(Datasource.ItemChangeListener<T> listener) |
void |
removeItemPropertyChangeListener(Datasource.ItemPropertyChangeListener<T> listener) |
void |
removeStateChangeListener(Datasource.StateChangeListener<T> listener) |
void |
setAllowCommit(boolean allowCommit)
Switch on/off ability to commit.
|
void |
setCommitMode(Datasource.CommitMode commitMode)
Sets commit mode explicitly.
|
void |
setLoadDynamicAttributes(boolean value) |
void |
setModified(boolean modified)
Sets "modified" state.
|
void |
setParent(Datasource datasource)
Sets parent datasource.
|
void |
setup(DsContext dsContext,
DataSupplier dataSupplier,
java.lang.String id,
com.haulmont.chile.core.model.MetaClass metaClass,
View view)
Setup the datasource right after creation.
|
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
committed, initialized, valid
commit, getDataSupplier, getDsContext, getItem, getItemIfValid, getMetaClass, getState, getView, invalidate, refresh, setItem
protected java.lang.String id
protected boolean modified
protected boolean allowCommit
protected Datasource.CommitMode commitMode
protected Datasource parentDs
protected Metadata metadata
protected BackgroundWorker backgroundWorker
protected java.util.Collection<Entity> itemsToCreate
protected java.util.Collection<Entity> itemsToUpdate
protected java.util.Collection<Entity> itemsToDelete
protected com.haulmont.chile.core.model.Instance.PropertyChangeListener listener
protected boolean listenersEnabled
protected boolean loadDynamicAttributes
protected com.haulmont.bali.events.EventRouter getEventRouter()
EventRouter
instance.EventRouter
public void setup(DsContext dsContext, DataSupplier dataSupplier, java.lang.String id, com.haulmont.chile.core.model.MetaClass metaClass, @Nullable View view)
Datasource
setup
in interface Datasource<T extends Entity>
dsContext
- DsContext instancedataSupplier
- DataSupplier instanceid
- datasource IDmetaClass
- MetaClass of an entity that will be stored in this datasourceview
- a view that will be used to load entities form DB, can be nullpublic java.lang.String getId()
getId
in interface Datasource<T extends Entity>
public boolean isModified()
isModified
in interface Datasource<T extends Entity>
public void setModified(boolean modified)
DatasourceImplementation
setModified
in interface DatasourceImplementation<T extends Entity>
public boolean isAllowCommit()
isAllowCommit
in interface Datasource<T extends Entity>
public void setAllowCommit(boolean allowCommit)
Datasource
Datasource.isModified()
always returns false and Datasource.commit()
has no effect.setAllowCommit
in interface Datasource<T extends Entity>
public java.util.Collection<T> getItemsToCreate()
DatasourceImplementation
getItemsToCreate
in interface DatasourceImplementation<T extends Entity>
public java.util.Collection<T> getItemsToUpdate()
DatasourceImplementation
getItemsToUpdate
in interface DatasourceImplementation<T extends Entity>
public java.util.Collection<T> getItemsToDelete()
DatasourceImplementation
getItemsToDelete
in interface DatasourceImplementation<T extends Entity>
public void modified(T item)
DatasourceImplementation
modified
in interface DatasourceImplementation<T extends Entity>
public void deleted(T item)
DatasourceImplementation
deleted
in interface DatasourceImplementation<T extends Entity>
public boolean enableListeners(boolean enable)
DatasourceImplementation
enableListeners
in interface DatasourceImplementation<T extends Entity>
enable
- true to enable, false to disablepublic Datasource.CommitMode getCommitMode()
getCommitMode
in interface Datasource<T extends Entity>
public void setCommitMode(Datasource.CommitMode commitMode)
DatasourceImplementation
setCommitMode
in interface DatasourceImplementation<T extends Entity>
DatasourceImplementation.setParent(Datasource)
public Datasource getParent()
DatasourceImplementation
If a parent datasource is set, it will receive changed data from the current datasource on commit. Otherwise, the datasource commits to the database.
getParent
in interface DatasourceImplementation<T extends Entity>
public void setParent(Datasource datasource)
DatasourceImplementation
If a parent datasource is set, it will receive changed data from the current datasource on commit. Otherwise, the datasource commits to the database.
setParent
in interface DatasourceImplementation<T extends Entity>
protected void addParentsToNested()
public void addItemChangeListener(Datasource.ItemChangeListener<T> listener)
addItemChangeListener
in interface Datasource<T extends Entity>
public void removeItemChangeListener(Datasource.ItemChangeListener<T> listener)
removeItemChangeListener
in interface Datasource<T extends Entity>
public void addItemPropertyChangeListener(Datasource.ItemPropertyChangeListener<T> listener)
addItemPropertyChangeListener
in interface Datasource<T extends Entity>
public void removeItemPropertyChangeListener(Datasource.ItemPropertyChangeListener<T> listener)
removeItemPropertyChangeListener
in interface Datasource<T extends Entity>
public void addStateChangeListener(Datasource.StateChangeListener<T> listener)
addStateChangeListener
in interface Datasource<T extends Entity>
public void removeStateChangeListener(Datasource.StateChangeListener<T> listener)
removeStateChangeListener
in interface Datasource<T extends Entity>
public void clearCommitLists()
DatasourceImplementation
clearCommitLists
in interface DatasourceImplementation<T extends Entity>
public boolean getLoadDynamicAttributes()
getLoadDynamicAttributes
in interface Datasource<T extends Entity>
public void setLoadDynamicAttributes(boolean value)
setLoadDynamicAttributes
in interface Datasource<T extends Entity>
value
- whether to load dynamic attributesprotected void attachListener(com.haulmont.chile.core.model.Instance item)
protected void detachListener(com.haulmont.chile.core.model.Instance item)
protected void fireItemChanged(T prevItem)
protected void fireStateChanged(Datasource.State prevStatus)
public java.lang.String toString()
toString
in class java.lang.Object