|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
One option for implementing a Data Management Services Assembler is to write a Java class which implements this interface. If you define a Data Management Services destination which refers to a class which implements this interface you do not have to use the XML method tags such as sync-method, get-method to define your destination. Instead of directly implementing this interface, it is recommended that you extend the AbstractAssembler class. There is some chance this interface could be extended in future versions of the product but every effort will be made to ensure extensions of AbstractAssembler continue to work without code change.
AbstractAssembler,
DataServiceTransaction| Field Summary | |
static int |
APPEND_TO_FILL
Constant used as the return value from the refreshFill method. |
static int |
DO_NOT_EXECUTE_FILL
Constant used as the return value from the refreshFill method. |
static int |
EXECUTE_FILL
Constant used as the return value from the refreshFill method. |
static int |
REMOVE_FROM_FILL
Constant used as the return value from the refreshFill method. |
| Method Summary | |
void |
addItemToFill(List fillParameters,
int position,
Map identity)
Called when a client adds an item to a filled collection. |
boolean |
autoRefreshFill(List fillParameters)
This method can be used to help control how fill methods are refreshed by Data Management Services. |
int |
count(List countParameters)
Retrieve the number of items for a given query with the supplied parameters. |
void |
createItem(Object item)
Creates the item. |
void |
deleteItem(Object previousVersion)
This is called when the client application removes an item managed by the destination corresponding to this assembler. |
Collection |
fill(List fillParameters)
This method is called by the Data Management Service for any fill methods called by the client which are not configured in the configuration file explicitly using the fill-method tag. |
Object |
getItem(Map identity)
Retrieves an item with the specified Map of ids. |
List |
getItems(List identityList)
Given a list of identity Maps, returns the list of items. |
int |
refreshFill(List fillParameters,
Object item,
boolean isCreate)
If your fill methods are auto-refreshed, this method is called for each item that changes (either created or updated as indicated by the isCreate parameter). |
void |
removeItemFromFill(List fillParameters,
int position,
Map identity)
Called when a client removes an item from a filled collection. |
void |
updateItem(Object newVersion,
Object previousVersion,
List changes)
Updates the item. |
| Field Detail |
public static final int DO_NOT_EXECUTE_FILL
public static final int EXECUTE_FILL
public static final int APPEND_TO_FILL
public static final int REMOVE_FROM_FILL
| Method Detail |
public Object getItem(Map identity)
identity - a java.util.Map which contains key/value pairs for
each identity property.
public List getItems(List identityList)
identityList - a list of java.util.Map objects specifying
the list of items.
public void createItem(Object item)
The Java class of the item supplied depends on the ActionScript class used by your client application. ActionScript to Java rules are by default used to convert the client object into a Java object. This will produce a java.util.Map for the item parameter if the client object is dynamic object or if that object does not have a RemoteClass alias mapping it to a Java class. If your assembler expects instances of a single specific Java class, you can use the item-class tag in your destination's configuration to specify a single class of which all java.util.Map instances are converted into before being passed to the assembler.
item - the initial instance of the item to create.
public void updateItem(Object newVersion,
Object previousVersion,
List changes)
The changes array provides the list of properties changed. You should interpret a null value as "any properties may have changed". If you have a property which has its own properties, only the top level property name will be included.
If the previousVersion conflicts with the current database copy of the item, you can throw a flex.data.DataSyncException to indicate this fact. In this case, you should provide the current version of the item in the database as the serverVersion parameter. This allows the client to resolve the conflict and resubmit a non-conflicting change or revert to the server's version. Your method can also throw any runtime exception to indicate that a general fault has occurred while processing this update.
Your updateItem method can modify changes sent in from the client and add additional properties. To do this you update properties in the newVersion and add additional property names to the changes property.
The Java class of the items supplied depends on the ActionScript class used by your client application. ActionScript to Java rules are by default used to convert the client object into a Java object. This will produce a java.util.Map for the item parameter if the client object is dynamic object or if that object does not have a RemoteClass alias mapping it to a Java class. If your assembler expects instances of a single specific Java class, you can use the item-class tag in your destination's configuration to specify a single class of which all java.util.Map instances are converted into before being passed to the assembler.
newVersion - the new version of the item with which to perform the updatepreviousVersion - the original version of the item before these changes were
made (used for conflict detection).changes - the list of changed property names.public void deleteItem(Object previousVersion)
This method can also thrown any runtime exception to indicate a general error to be returned to the client.
previousVersion - the original version of the item on the client which
the client intends to removepublic Collection fill(List fillParameters)
In general a fill method corresponds to a database query made on the server. The results of a fill method should be based solely on the parameters provided here - do not return different results of a fill for the same parameter set since Data Management Services is designed to try and keep all clients which use the same set of fill parameters viewing the same results.
Depending upon the number and type of fill method you need for this destination, it can be a good practice to use the first parameter as the name of the fill and the rest as the parameters to make it easier to identify the particular fill you are dealing with.
fillParameters - the list of fill parameters provided to the DataService.fill
method on the client. Note that the first parameter - the ArrayCollection is not
included in this list.
public int count(List countParameters)
countParameters - a list of parameters to the count method provided by the
client invocation.
public void addItemToFill(List fillParameters,
int position,
Map identity)
You can use this method to track changes made to a filled collection by client applications. Usually the results of a fill are maintained by a query made on the server and so changes made by the client are temporary or replaced when the server has a chance to update the fill based on reexecuting the query. In some cases though, you may want to turn auto-refresh off for the fill, and track the changes made by the client to the filled collection. You might do this if the list of items returned for a given fill is maintained by an explicit list of object ids.
Warning: if you need clients to maintain a consistent order of items, you may not want to use this technique. If two clients insert different items into the same position at roughly the same time, each will have processed the inserts in different orders and so will have the two items swapped. You can ignore the position and maintain consistent lists where order is not critical or the client sorts the list.
fillParameters - the list of parameters which identify the fill
that the client changed.position - the index where a new item was addedidentity - the identity of the item added at the specified position
public void removeItemFromFill(List fillParameters,
int position,
Map identity)
fillParameters - the list of parameters which identify the fill
that the client changed.position - the index where a new item was removedidentity - the identity of the item removed at the specified positionpublic boolean autoRefreshFill(List fillParameters)
fillParameters - Client-side parameters to a fill method that
created a managed collection still managed by one or more clients.
public int refreshFill(List fillParameters,
Object item,
boolean isCreate)
fillParameters - the parameters which identify a fill method that
is still actively being managed by one or more clients connected to this
server.item - The item which is being created or updated in a recently committed
transactino.isCreate - true if this item was just created operation, false if it was just
updated.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||