|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sage.swt.client.sdata.datasource.DataSourceProxy
public class DataSourceProxy
Fields inherited from interface com.sage.swt.client.sdata.DataSource |
---|
ACTION_DELETE, ACTION_GETENTITIES, ACTION_GETENTITIES_ALL, ACTION_GETENTITIES_FROMKEY, ACTION_INSERT, ACTION_MOVEFIRST, ACTION_MOVELAST, ACTION_MOVENEXT, ACTION_MOVEPREVIOUS, ACTION_MOVETO, ACTION_MOVETOINSERT, ACTION_MOVETOKEY, ACTION_MOVETOSPECIFIED, ACTION_UPDATE |
Fields inherited from interface com.sage.swt.client.sdata.BindableDataProvider |
---|
PROPERTY_NAME_SEGMENT_ESCAPE_SEPARATOR, PROPERTY_NAME_SEGMENT_SEPARATOR, PROPERTY_NAME_SEGMENT_SPLITTER |
Constructor Summary | |
---|---|
DataSourceProxy(TypeSchemaCache cache,
SwtRequestDispatcher requestDispatcher,
SwtErrorStack errorStack)
The DataSourceProxy is used to instantiate datasources only when they are actually used. |
Method Summary | |
---|---|
com.google.gwt.event.shared.HandlerRegistration |
addBindableDataChangedHandler(BindableDataChangedHandler handler)
Adds a BindableDataEvent handler. |
com.google.gwt.event.shared.HandlerRegistration |
addBindableDataChangingAsyncHandler(BindableDataChangingAsyncHandler handler)
Adds a BindableDataChangingEvent handler. |
com.google.gwt.event.shared.HandlerRegistration |
addBindableDataChangingHandler(BindableDataChangingHandler handler)
Adds a BindableDataChangingEvent handler. |
com.google.gwt.event.shared.HandlerRegistration |
addDataSourceCursorMovedHandler(DataSourceCursorMovedHandler handler)
Adds a DataSourceCursorMovedEvent handler. |
com.google.gwt.event.shared.HandlerRegistration |
addDataSourceCursorMovingHandler(DataSourceCursorMovingHandler handler)
Adds a DataSourceCursorMovingEvent handler. |
com.google.gwt.event.shared.HandlerRegistration |
addDataSourceDataChangedHandler(DataSourceDataChangedHandler handler)
Adds a DataSourceDataChangedEvent event. |
com.google.gwt.event.shared.HandlerRegistration |
addDataSourceDataChangingHandler(DataSourceDataChangingHandler handler)
Adds a DataSourceDataChangingEvent event. |
void |
checkDirty(DataRequestCallback callback)
Checks whether the current entity is dirty |
protected void |
createDataSource()
Retrieves the type info that has been downloaded from the cache and uses it to create the proper type of datasource. |
void |
createDelayedDataSource(DataSourceProxyCallback proxyCallback)
Initializes the creation of a datasource and the download of the related type schema. |
void |
delete(DataRequestCallback callback)
Deletes the current entity. |
boolean |
equals(java.lang.Object obj)
|
void |
fireEvent(com.google.gwt.event.shared.GwtEvent<?> event)
|
DataSource |
getChildDataSource(java.lang.String propertyName)
Gets the datasource that is linked to a property of this datasource. |
DataSource |
getCopy()
Creates a copy of this datasource. |
EntityData |
getCurrentEntity()
Gets the current entity (in other words, the entity at the cursor) from this datasource. |
DataSource |
getDataSource(java.lang.String propertyName)
Gets the datasource that is linked to a property of this datasource. |
void |
getEntities(DataRequestCallback callback)
Gets all the entities in the current result set. |
void |
getEntities(int startIndex,
int count,
DataRequestCallback callback)
Gets up to the specified number of entities in the current result set. |
void |
getEntities(java.lang.Object startKey,
int count,
DataRequestCallback callback)
Gets up to the specified number of entities in the current result set. |
DataProviderMetaData |
getMetaData()
Gets the metadata for this data provider. |
java.lang.Object |
getPropertyValue(java.lang.String propertyName)
Gets the value of the specified property in the current entity of this bindable data provider. |
SortSpecification |
getSort()
Get the SortSpecification associated with this datasource. |
TypeInfo |
getTypeInfo()
Gets the type information object associated with this bindable data provider. |
int |
hashCode()
|
void |
insert(DataRequestCallback callback)
Inserts a new entity. |
boolean |
isDataSourceCreated()
Returns true if the datasource held by this proxy has been created. |
boolean |
isDeleted()
Check whether the current entity is deleted or not. |
boolean |
isInserting()
Checks if we are on the insert entity. |
void |
moveFirst(DataRequestCallback callback)
Moves the cursor to the first entity in the current result set. |
void |
moveLast(DataRequestCallback callback)
Moves the cursor to the last entity in the current result set. |
void |
moveNext(DataRequestCallback callback)
Moves the cursor to the next entity in the current result set. |
void |
movePrevious(DataRequestCallback callback)
Moves the cursor to the previous entity in the current result set. |
void |
moveTo(int index,
DataRequestCallback callback)
Moves the cursor to the given index in the current result set. |
void |
moveTo(java.lang.Object key,
DataRequestCallback callback)
Moves the cursor to the given key in the current result set. |
void |
moveToByPropertyName(java.util.Map<java.lang.String,java.lang.Object> properties,
DataRequestCallback callback)
Move the cursor to a record whose property values match the values in the property map currently. |
void |
moveToCurrent(DataRequestCallback callback)
Moves the cursor to the remembered cursor position, which is usually the current entity. |
void |
moveToInsert(DataRequestCallback callback)
Moves the cursor to the "insert" entity. |
void |
removeBindableDataChangedHandler(BindableDataChangedHandler handler)
Removes the specified BindableDataChangedHandler |
void |
removeBindableDataChangingAsyncHandler(BindableDataChangingAsyncHandler handler)
Removes the specified BindableDataChangingHandler |
void |
removeBindableDataChangingHandler(BindableDataChangingHandler handler)
Removes the specified BindableDataChangingHandler |
void |
removeDataSourceCursorHandler(DataSourceCursorMovedHandler handler)
Removes the specified DataSourceCursorMovedHandler |
void |
removeDataSourceCursorMovingHandler(DataSourceCursorMovingHandler handler)
Removes the specified DataSourceCursorMovingHandler |
void |
removeDataSourceDataChangingHandler(DataSourceDataChangingHandler handler)
Removes the specified DataSourceDataChangingHandler |
void |
removeDataSourceDataHandler(DataSourceDataChangedHandler handler)
Removes the specified DataSourceDataChangedHandler |
protected void |
reportError(java.lang.String message)
|
void |
setFilter(com.sage.swt.common.filter.QueryExpression filter)
Sets the filter for this datasource. |
void |
setPropertyValue(java.lang.String propertyName,
java.lang.Object value)
Sets the value of a property in the current entity of this bindable data provider. |
void |
setPropertyValue(java.lang.String propertyName,
java.lang.Object value,
DataRequestCallback callback)
Sets the value of a property in the current entity of this bindable data provider. |
void |
setProxyDataSourceInfo(DataSourceInfo dataSourceInfo,
ConnectionInfo connectionInfo)
Sets the information needed to create a datasource and download type schemas. |
void |
setSort(SortSpecification sortSpecification)
Sets the sorting parameters for this datasource. |
void |
shutdown()
Shuts down the data provider. |
void |
update(DataRequestCallback callback)
Sends to the server any updated data that was set by BindableDataProvider.setPropertyValue(String, Object) or via a child datasource. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected TypeSchemaCache cache
protected DataSource dataSource
protected SwtRequestDispatcher requestDispatcher
protected SwtErrorStack errorStack
protected DataSourceInfo dataSourceInfo
protected ConnectionInfo connectionInfo
protected java.util.List<BindableDataChangingAsyncHandler> bindableDataChangingAsyncHandlers
protected java.util.List<BindableDataChangingHandler> bindableDataChangingHandlers
protected java.util.List<BindableDataChangedHandler> bindableDataChangedHandlers
protected java.util.List<DataSourceCursorMovingHandler> dataSourceCursorMovingHandlers
protected java.util.List<DataSourceCursorMovedHandler> dataSourceCursorHandlers
protected java.util.List<DataSourceDataChangedHandler> dataSourceDataHandlers
protected java.util.List<DataSourceDataChangingHandler> dataSourceDataChangingHandlers
protected com.sage.swt.common.filter.QueryExpression filter
protected SortSpecification sortSpecification
protected java.lang.String sdataURL
protected com.google.gwt.event.shared.SimpleEventBus eventBus
Constructor Detail |
---|
public DataSourceProxy(TypeSchemaCache cache, SwtRequestDispatcher requestDispatcher, SwtErrorStack errorStack)
cache
- A cache of all the downloaded type schemasrequestDispatcher
- Dispatches requests to the servererrorStack
- Holds all errors that occur during executionMethod Detail |
---|
public void shutdown()
shutdown
in interface BindableDataProvider
public com.google.gwt.event.shared.HandlerRegistration addDataSourceCursorMovingHandler(DataSourceCursorMovingHandler handler)
DataSourceCursorMovingEvent
handler.
addDataSourceCursorMovingHandler
in interface HasDataSourceCursorMovingHandlers
handler
- the handler
public com.google.gwt.event.shared.HandlerRegistration addDataSourceCursorMovedHandler(DataSourceCursorMovedHandler handler)
DataSourceCursorMovedEvent
handler.
addDataSourceCursorMovedHandler
in interface DataSource
addDataSourceCursorMovedHandler
in interface HasDataSourceCursorMovedHandlers
handler
- the handler
public com.google.gwt.event.shared.HandlerRegistration addDataSourceDataChangingHandler(DataSourceDataChangingHandler handler)
DataSourceDataChangingEvent
event.
addDataSourceDataChangingHandler
in interface HasDataSourceDataChangingHandlers
handler
- the handler
public com.google.gwt.event.shared.HandlerRegistration addDataSourceDataChangedHandler(DataSourceDataChangedHandler handler)
DataSourceDataChangedEvent
event.
addDataSourceDataChangedHandler
in interface DataSource
addDataSourceDataChangedHandler
in interface HasDataSourceDataChangedHandlers
handler
- the handler
public void delete(DataRequestCallback callback)
Deletes the current entity.
After deletion, the cursor is placed on the previous entity.
delete
in interface DataSource
callback
- The callback for receiving the notification that the deletion is
done.public DataSource getChildDataSource(java.lang.String propertyName)
getChildDataSource
in interface DataSource
propertyName
- The name of property whose linked datasource we want to get.
null
if the property is a primitive type.public DataSource getCopy()
Creates a copy of this datasource.
getCopy
in interface DataSource
public EntityData getCurrentEntity()
getCurrentEntity
in interface DataSource
public DataSource getDataSource(java.lang.String propertyName)
getDataSource
in interface DataSource
propertyName
- The name of property whose linked datasource we want to get.
null
if the property is a primitive type.public void getEntities(DataRequestCallback callback)
Gets all the entities in the current result set.
The requested entities are returned via the callback. Warning! Only use this method when the result set is known to be small. Getting all entities in a large result set will have severe performance repercussions.
getEntities
in interface DataSource
callback
- The callback for receiving the notification that the entities
are gotten and for receiving the entities themselves.public void getEntities(int startIndex, int count, DataRequestCallback callback)
Gets up to the specified number of entities in the current result set.
The requested entities are returned via the callback. The number of entities actually delivered may be less that the number requested if there are not enough entities left in the current result set that are at or past the specified starting index.
getEntities
in interface DataSource
startIndex
- The index of the first entity to get.count
- The maximum number of entities to get.callback
- The callback for receiving the notification that the entities
are gotten and for receiving the entities themselves.public void getEntities(java.lang.Object startKey, int count, DataRequestCallback callback)
Gets up to the specified number of entities in the current result set.
The requested entities are returned via the callback. The number of entities actually delivered may be less that the number requested if there are not enough entities left in the current result set that are at or past the specified starting key.
getEntities
in interface DataSource
startKey
- The key of the first entity to get.count
- The maximum number of entities to get.callback
- The callback for receiving the notification that the entities
are gotten and for receiving the entities themselves.public void insert(DataRequestCallback callback)
Inserts a new entity.
This method can only be called when the cursor is on an "insert" entity.
insert
in interface DataSource
callback
- The callback for receiving the notification that the insertion
is done.public boolean isInserting()
Checks if we are on the insert entity.
isInserting
in interface DataSource
public void checkDirty(DataRequestCallback callback)
checkDirty
in interface DataSource
callback
- The callback for receiving the dirty status.public void moveFirst(DataRequestCallback callback)
Moves the cursor to the first entity in the current result set.
Cursor move operations are asynchronous. Between the time a cursor move
method is called and the callback is invoked, the position of the cursor
is undefined. Therefore, the behaviour of DataSource.getCurrentEntity()
,
BindableDataProvider.getPropertyValue(String)
and
BindableDataProvider.setPropertyValue(String, Object)
are undefined during that time.
moveFirst
in interface DataSource
callback
- The callback for receiving the notification that the move is
done.public void moveLast(DataRequestCallback callback)
Moves the cursor to the last entity in the current result set.
Cursor move operations are asynchronous. Between the time a cursor move
method is called and the callback is invoked, the position of the cursor
is undefined. Therefore, the behaviour of DataSource.getCurrentEntity()
,
BindableDataProvider.getPropertyValue(String)
and
BindableDataProvider.setPropertyValue(String, Object)
are undefined during that time.
Prior to calling this method the sort specification must be set by calling
DataSource.setSort(SortSpecification)
. Failure to do so will result in an
IllegalStateException.
moveLast
in interface DataSource
callback
- The callback for receiving the notification that the move is
done.public void moveNext(DataRequestCallback callback)
Moves the cursor to the next entity in the current result set.
Cursor move operations are asynchronous. Between the time a cursor move
method is called and the callback is invoked, the position of the cursor
is undefined. Therefore, the behaviour of DataSource.getCurrentEntity()
,
BindableDataProvider.getPropertyValue(String)
and
BindableDataProvider.setPropertyValue(String, Object)
are undefined during that time.
moveNext
in interface DataSource
callback
- The callback for receiving the notification that the move is
done.public void movePrevious(DataRequestCallback callback)
Moves the cursor to the previous entity in the current result set.
Cursor move operations are asynchronous. Between the time a cursor move
method is called and the callback is invoked, the position of the cursor
is undefined. Therefore, the behaviour of DataSource.getCurrentEntity()
,
BindableDataProvider.getPropertyValue(String)
and
BindableDataProvider.setPropertyValue(String, Object)
are undefined during that time.
movePrevious
in interface DataSource
callback
- The callback for receiving the notification that the move is
done.public void moveTo(int index, DataRequestCallback callback)
Moves the cursor to the given index in the current result set.
Cursor move operations are asynchronous. Between the time a cursor move
method is called and the callback is invoked, the position of the cursor
is undefined. Therefore, the behaviour of DataSource.getCurrentEntity()
,
BindableDataProvider.getPropertyValue(String)
and
BindableDataProvider.setPropertyValue(String, Object)
are undefined during that time.
moveTo
in interface DataSource
index
- The index to move the cursor to in the current result set.callback
- The callback for receiving the notification that the move is
done.public void moveTo(java.lang.Object key, DataRequestCallback callback)
Moves the cursor to the given key in the current result set.
Cursor move operations are asynchronous. Between the time a cursor move
method is called and the callback is invoked, the position of the cursor
is undefined. Therefore, the behaviour of DataSource.getCurrentEntity()
,
BindableDataProvider.getPropertyValue(String)
and
BindableDataProvider.setPropertyValue(String, Object)
are undefined during that time.
moveTo
in interface DataSource
key
- The key to move the cursor to in the current result set.callback
- The callback for receiving the notification that the move is
done.public void moveToByPropertyName(java.util.Map<java.lang.String,java.lang.Object> properties, DataRequestCallback callback)
Note that there may be more than one record that matches, or no record. If there is no record then the cursor will remain in its current position.
moveToByPropertyName
in interface DataSource
properties
- the map of properties to use.callback
- The callback for receiving the notification that the operation
is done.public void moveToCurrent(DataRequestCallback callback)
Moves the cursor to the remembered cursor position, which is usually the current entity.
This method has no effect if the cursor is not on the "insert" entity.
moveToCurrent
in interface DataSource
callback
- The callback for receiving the notification that the move is
done.public void moveToInsert(DataRequestCallback callback)
Moves the cursor to the "insert" entity.
The current cursor position is remembered while the cursor is positioned
on the "insert" entity. The "insert" entity is a special entity associated
with an updatable result set. It is essentially a buffer where a new
entity may be constructed by calling
BindableDataProvider.setPropertyValue(String, Object)
prior to inserting the entity
into the result set. Only the BindableDataProvider.setPropertyValue(String, Object)
,
BindableDataProvider.getPropertyValue(String)
, DataSource.insert(DataRequestCallback)
and DataSource.moveToCurrent(DataRequestCallback)
methods may be called when
the cursor is on the "insert" entity.
moveToInsert
in interface DataSource
callback
- The callback for receiving the notification that the move is
done.public void removeDataSourceCursorMovingHandler(DataSourceCursorMovingHandler handler)
handler
- the handler to removepublic void removeDataSourceCursorHandler(DataSourceCursorMovedHandler handler)
handler
- the handler to removepublic void removeDataSourceDataHandler(DataSourceDataChangedHandler handler)
handler
- the handler to removepublic void setFilter(com.sage.swt.common.filter.QueryExpression filter)
Sets the filter for this datasource. Changes the resultset and causes
DataSourceDataChangedHandler.dataChanged(DataSourceDataChangedEvent)
to fire. The cursor is also reset to before the first entity.
setFilter
in interface DataSource
filter
- filter for this datasource. The value of the "where" parameter
in an SData URL.public void setSort(SortSpecification sortSpecification)
Sets the sorting parameters for this datasource. Changes the resultset and
causes
DataSourceDataChangedHandler.dataChanged(DataSourceDataChangedEvent)
to fire. The cursor is also reset to before the first entity.
setSort
in interface DataSource
sortSpecification
- sorting parameters for this datasource. The value of the
"orderBy" parameter in an SData URL.public SortSpecification getSort()
DataSource
getSort
in interface DataSource
SortSpecification
for this datasource.public void update(DataRequestCallback callback)
BindableDataProvider.setPropertyValue(String, Object)
or via a child datasource.
update
in interface DataSource
callback
- The callback for receiving the notification that the update is
done.public com.google.gwt.event.shared.HandlerRegistration addBindableDataChangedHandler(BindableDataChangedHandler handler)
BindableDataEvent
handler.
addBindableDataChangedHandler
in interface HasBindableDataChangedHandlers
handler
- the handler
public com.google.gwt.event.shared.HandlerRegistration addBindableDataChangingAsyncHandler(BindableDataChangingAsyncHandler handler)
HasBindableDataChangingAsyncHandlers
BindableDataChangingEvent
handler.
addBindableDataChangingAsyncHandler
in interface HasBindableDataChangingAsyncHandlers
handler
- the handler
public com.google.gwt.event.shared.HandlerRegistration addBindableDataChangingHandler(BindableDataChangingHandler handler)
BindableDataChangingEvent
handler.
addBindableDataChangingHandler
in interface HasBindableDataChangingHandlers
handler
- the handler
public DataProviderMetaData getMetaData()
getMetaData
in interface BindableDataProvider
public java.lang.Object getPropertyValue(java.lang.String propertyName)
Gets the value of the specified property in the current entity of this bindable data provider.
When a property is an EntityData
object, the value of a
sub-property can be obtained directly by using "." notation in the
property name. For example, if the bindable data provider's current entity
has a complex "fromAddress" property that contains a "streetName"
sub-property, use "fromAddress.streetName"
to get the value of the
"streetName" sub-property directly.
Note that the "." notation is meant for cases where the main property (such as the "fromAddress" in the example) does not have a child or a reference relationship to the bindable data provider's current entity, but is instead just a complex property that's part of that current entity.
Also note that for primitive or simple properties that include a "." in their property name, use the "{dot}" escape sequence instead. For example, if the primitive property happens to be called "my.property" in the schema, use "my{dot}property" as the property name.
For datasources: while the cursor is being moved, the behaviour of this method is undefined.
getPropertyValue
in interface BindableDataProvider
propertyName
- The name of the property in question.
public TypeInfo getTypeInfo()
getTypeInfo
in interface BindableDataProvider
public void removeBindableDataChangedHandler(BindableDataChangedHandler handler)
handler
- the handler to removepublic void removeBindableDataChangingAsyncHandler(BindableDataChangingAsyncHandler handler)
handler
- the handler to removepublic void removeBindableDataChangingHandler(BindableDataChangingHandler handler)
handler
- the handler to removepublic void removeDataSourceDataChangingHandler(DataSourceDataChangingHandler handler)
handler
- the handler to removepublic void setPropertyValue(java.lang.String propertyName, java.lang.Object value)
Sets the value of a property in the current entity of this bindable data provider.
When a property is an EntityData
object, the value of a
sub-property can be set directly by using "." notation in the property
name. For example, if the bindable data provider's current entity has a
complex "fromAddress" property that contains a "streetName" sub-property,
use "fromAddress.streetName"
to set the value of the "streetName"
sub-property directly. (If "fromAddress" or any of its sub-properties have
not been set yet, an EntityData
object is created for
"fromAddress", and then its "streetName" property is set.)
Note that the "." notation is meant for cases where the main property (such as the "fromAddress" in the example) does not have a child or a reference relationship to the bindable data provider's current entity, but is instead just a complex property that's part of that current entity.
Also note that for primitive or simple properties that include a "." in their property name, use the "{dot}" escape sequence instead. For example, if the primitive property happens to be called "my.property" in the schema, use "my{dot}property" as the property name.
For datasources: While the cursor is being moved, the behaviour of this
method is undefined. Properties set via this method are not sent to the
server until the update
method is called.
setPropertyValue
in interface BindableDataProvider
propertyName
- The name of the property in question.value
- The new value of the property.public void setPropertyValue(java.lang.String propertyName, java.lang.Object value, DataRequestCallback callback)
Sets the value of a property in the current entity of this bindable data provider.
setPropertyValue
in interface BindableDataProvider
propertyName
- The name of the property in question.value
- The new value of the property.callback
- The callback for success and failure notification of the
property set.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public void setProxyDataSourceInfo(DataSourceInfo dataSourceInfo, ConnectionInfo connectionInfo)
dataSourceInfo
- Holds relationship types, children, and other datasource related
information.connectionInfo
- Holds the information necessary to create a connection to a
datasource.public void createDelayedDataSource(DataSourceProxyCallback proxyCallback)
proxyCallback
- This callback will be notified when the datasource has been
created.protected void reportError(java.lang.String message)
message
- public boolean isDataSourceCreated()
protected void createDataSource()
public void fireEvent(com.google.gwt.event.shared.GwtEvent<?> event)
fireEvent
in interface com.google.gwt.event.shared.HasHandlers
public boolean isDeleted()
isDeleted
in interface DataSource
true
if the current entity is deleted. Otherwise
false
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |