flex.data.assemblers
Class SQLAssembler

java.lang.Object
  extended by flex.data.assemblers.AbstractAssembler
      extended by flex.data.assemblers.SQLAssembler
All Implemented Interfaces:
Assembler, SQLAssemblerConstants, FlexComponent, FlexConfigurable

public class SQLAssembler
extends AbstractAssembler
implements SQLAssemblerConstants


Field Summary
static String LOG_CATEGORY
          Log category for SQLAssembler.
 
Fields inherited from interface flex.data.assemblers.SQLAssemblerConstants
COUNT, CREATE_ITEM, DATABASE, DATASOURCE, DELETE_ITEM, DRIVER_CLASS, DRIVER_PASSWORD, DRIVER_URL, DRIVER_USER, FILL, GET_ITEM, ID_QUERY, LOGIN_TIMEOUT, PROCEDURE_NAME, PROCEDURE_PARAM, PROCEDURE_TYPE, PROPERTY_VALUE, QUERY_NAME, SQL, SQL_PROCEDURE, UPDATE_ITEM
 
Fields inherited from interface flex.data.assemblers.Assembler
APPEND_TO_FILL, DO_NOT_EXECUTE_FILL, EXECUTE_FILL, REMOVE_FROM_FILL
 
Constructor Summary
SQLAssembler()
          Default constructor for SQLAssembler.
 
Method Summary
 void addCountProcedure(flex.data.config.NamedSQLProcedureSettings sqlSettings)
          The method is used for dynamically adding a procedure call for execution during count.
 void addCountSQL(flex.data.config.NamedSQLSettings sqlSettings)
          The method is used for dynamically adding a sql statement for execution during count.
 void addFillProcedure(flex.data.config.NamedSQLProcedureSettings sqlSettings)
          The method is used for dynamically adding a procedure call for execution during fill.
 void addFillSQL(flex.data.config.NamedSQLSettings sqlSettings)
          The method is used for dynamically adding a sql statement for execution during fill.
 boolean autoRefreshFill(List fillParams)
          This returns false because we always push refresh fill methods for this sample.
 int count(List countParameters)
          Retrieve the number of items for a given query with the supplied parameters.
 void createItem(Object createItem)
          Creates the item.
 void deleteItem(Object deleteItem)
          This is called when the client application removes an item managed by the destination corresponding to this assembler.
 Collection fill(List fillParameters)
          The first fill parameter is the name of the fill query to execute.
 String getActionscriptClass()
          Returns actionscript-class property.
 Map getCountSQLStructure()
          Returns the sql statements for count.
 List getCreateItemSQL()
          Returns the sql statements for create-item.
 flex.data.config.DatabaseDriverSettings getDatabaseDriverSettings()
          Gets the DatabaseDriverSettings property.
 flex.data.config.DatasourceSettings getDatasourceSettings()
          Gets the DatasourceSettings property.
 flex.data.assemblers.SQLFactory.SQL getDeleteItemSQLStructure()
          Returns the sql statement for delete-item.
 Map getFillSQLStructure()
          Returns the sql statements for fill.
 flex.data.assemblers.SQLFactory.SQL getGetItemSQLStructure()
          Returns the sql statements for get-item.
 Object getItem(Map m)
          Retrieves an item with the specified Map of ids.
 String getJavaClass()
          Returns java-class property.
 void initialize(String id, ConfigMap properties)
          This initialize method is called once for each destination.
 void removeCountSQL(String name)
          The method is used for dynamically removing a sql statement for count.
 void removeFillSQL(String name)
          The method is used for dynamically removing a sql statement for fill.
 void setActionscriptClass(String actionscriptClass)
          Sets actionscript-class property.
 void setCreateItemProcedure(flex.data.config.SQLProcedureSettings sqlSettings)
          The method is used for dynamically adding a procedure call for execution during createItem.
 void setCreateItemSQL(String sql, String idQuery, boolean processIdQueryFirst)
          The method is used for dynamically adding a sql statement for executing during getItem.
 void setDatabaseDriverSettings(flex.data.config.DatabaseDriverSettings ds)
          Sets the DatabaseDriverSettings property.
 void setDatasourceSettings(flex.data.config.DatasourceSettings ds)
          Sets the DatasourceSettings property.
 void setDeleteItemProcedure(flex.data.config.SQLProcedureSettings sqlSettings)
          The method is used for dynamically adding a procedure call for execution during deleteItem.
 void setDeleteItemSQL(String sql)
          Sets the sql statement for delete-item.
 void setGetItemProcedure(flex.data.config.SQLProcedureSettings sqlSettings)
          The method is used for dynamically adding a procedure call for execution during getItem.
 void setGetItemSQL(String sql)
          Sets the sql statement for get-item.
 void setJavaClass(String javaClass)
          Sets java-class property.
 void setUpdateItemProcedure(flex.data.config.SQLProcedureSettings sqlSettings)
          The method is used for dynamically adding a procedure call for execution during updateItem.
 void setUpdateItemSQL(String sql)
          The method is used for dynamically adding a sql statement for execution during updateItem.
 void start()
          Starts the SQLAssembler.
 void stop()
          Stops the SQLAssembler.
 void updateItem(Object newVersion, Object prevVersion, List changes)
          Updates the item.
 
Methods inherited from class flex.data.assemblers.AbstractAssembler
addItemToFill, fill, getItems, isStarted, refreshFill, refreshFillStatusToName, removeItemFromFill, useFillPage
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_CATEGORY

public static final String LOG_CATEGORY
Log category for SQLAssembler.

See Also:
Constant Field Values
Constructor Detail

SQLAssembler

public SQLAssembler()
Default constructor for SQLAssembler.

Method Detail

initialize

public void initialize(String id,
                       ConfigMap properties)
This initialize method is called once for each destination. You can override this method if you want to add additional configuration properties. The ConfigMap class contains the properties inside of the properties tag for a given destination. The id parameter is the name of the destination.

The hibernate assembler uses two utility classes. The HibernateManager is a class which is created for each hibernate configuration file you specify. It manages the Data Management Services state for a group of related hibernate entitites. The HibernateType class is created for each assembler instance.

Specified by:
initialize in interface FlexConfigurable
Overrides:
initialize in class AbstractAssembler
Parameters:
id - the destination name for this assembler.
properties - the properties used to configure this destination underneath the properties tag.

start

public void start()
Starts the SQLAssembler.

Specified by:
start in interface FlexComponent
Overrides:
start in class AbstractAssembler

stop

public void stop()
Stops the SQLAssembler.

Specified by:
stop in interface FlexComponent
Overrides:
stop in class AbstractAssembler

getDatasourceSettings

public flex.data.config.DatasourceSettings getDatasourceSettings()
Gets the DatasourceSettings property.

Returns:
DatasourceSettings property

setDatasourceSettings

public void setDatasourceSettings(flex.data.config.DatasourceSettings ds)
Sets the DatasourceSettings property.

Parameters:
ds -

getDatabaseDriverSettings

public flex.data.config.DatabaseDriverSettings getDatabaseDriverSettings()
Gets the DatabaseDriverSettings property.

Returns:
DatabaseDriverSettings property

setDatabaseDriverSettings

public void setDatabaseDriverSettings(flex.data.config.DatabaseDriverSettings ds)
Sets the DatabaseDriverSettings property.

Parameters:
ds -

getActionscriptClass

public String getActionscriptClass()
Returns actionscript-class property.

Returns:
actionscript class name property

setActionscriptClass

public void setActionscriptClass(String actionscriptClass)
Sets actionscript-class property. Specify an ActionScript class name for the strongly typed objects returned by the fill and getItem. In order for the client to receive strongly typed objects from the fill and getItem operations, the return class must be specified by either actionscript-class or java-class. In either case, the fields returned from the SQL should match the property names for the Object. In both cases, a RemoteClass metadata is required. The RemoteClass metadata on an ActionScript class is an indicator that the class can be used in serialization from the server. A map of these classes is built up where the key is equal to the string specified in the alias. If no alias is specified, the ActionScript class name is used instead. During serialization from the server,the map is checked and the appropriate type returned. If you have an existing ActionScript type with a [RemoteClass(alias=server.javaClass)] metadata designation, use java-class pointing to the same server-side class as the alias specifies. In this case, the RemoteClass map is using the Java class as the key. Using java-class appropriately sets the type so that the ActionScript type may be found in the RemoteClass map during serialization to the client. samples.crm.Employee If you have an ActionScript type but no corresponding server-side class, then you'll want to add [RemoteClass] (without an alias), and use actionscript-class pointing to the ActionScript type. In this case, the RemoteClass map is using the ActionScript class as the key. Using actionscript-class appropriately sets the type so that the ActionScript type may be found in the RemoteClass map during serialization to the client.

Parameters:
actionscriptClass - The ActionScript class name for the strongly type object returned.

getJavaClass

public String getJavaClass()
Returns java-class property.

Returns:
java class name property

setJavaClass

public void setJavaClass(String javaClass)
Sets java-class property. Specify a Java class name that is an alias of the strongly typed objects returned by the fill and getItem. Refer to the javadoc ActionScript class for a detailed explanation.

Parameters:
javaClass - The java class name pointing to the server-side class
See Also:
SQLAssembler.setActionscriptClass(java.lang.String)

getFillSQLStructure

public Map getFillSQLStructure()
Returns the sql statements for fill.

Returns:
sql statements for fill.

addFillSQL

public void addFillSQL(flex.data.config.NamedSQLSettings sqlSettings)
The method is used for dynamically adding a sql statement for execution during fill.

Parameters:
sqlSettings - Settings for the sql statement.

addFillProcedure

public void addFillProcedure(flex.data.config.NamedSQLProcedureSettings sqlSettings)
The method is used for dynamically adding a procedure call for execution during fill. Usage: NamedSQLProcedureSettings sqlSettings = new NamedSQLProcedureSettings(); sqlSettings.setName("findEmployeesByCompany"); SQLProcedureSettings procedureSetting = new SQLProcedureSettings(); procedureSetting.setName("find_company_employees"); sqlSettings.setProcedureSettings(procedureSetting); SQLParamSettings sqlParam = new SQLParamSettings(); sqlParam.setPropertyValue("companyId"); sqlParam.setType("IN"); procedureSetting.addProcedureParamSettings(sqlParam); assembler.addFillProcedure(sqlSettings);


removeFillSQL

public void removeFillSQL(String name)
The method is used for dynamically removing a sql statement for fill.

Parameters:
name - Name of the sql statement.

addCountSQL

public void addCountSQL(flex.data.config.NamedSQLSettings sqlSettings)
The method is used for dynamically adding a sql statement for execution during count.

Parameters:
sqlSettings - Settings for the sql statement.

getCountSQLStructure

public Map getCountSQLStructure()
Returns the sql statements for count.

Returns:
sql statements for count.

addCountProcedure

public void addCountProcedure(flex.data.config.NamedSQLProcedureSettings sqlSettings)
The method is used for dynamically adding a procedure call for execution during count. Usage:

Parameters:
sqlSettings - The SQLProcedureSettings object representing the procedure configuration.
See Also:
SQLAssembler.addFillProcedure(NamedSQLProcedureSettings sqlSettings);

removeCountSQL

public void removeCountSQL(String name)
The method is used for dynamically removing a sql statement for count.

Parameters:
name - Name of the sql statement.

getGetItemSQLStructure

public flex.data.assemblers.SQLFactory.SQL getGetItemSQLStructure()
Returns the sql statements for get-item.

Returns:
sql statements for get-item.

setGetItemSQL

public void setGetItemSQL(String sql)
Sets the sql statement for get-item.

Parameters:
sql - statement for get-item.

getCreateItemSQL

public List getCreateItemSQL()
Returns the sql statements for create-item.

Returns:
sql statements for create-item.

setGetItemProcedure

public void setGetItemProcedure(flex.data.config.SQLProcedureSettings sqlSettings)
The method is used for dynamically adding a procedure call for execution during getItem.

Parameters:
sqlSettings - The SQLProcedureSettings object representing the procedure configuration.

setCreateItemSQL

public void setCreateItemSQL(String sql,
                             String idQuery,
                             boolean processIdQueryFirst)
The method is used for dynamically adding a sql statement for executing during getItem.

Parameters:
sql -
idQuery -
processIdQueryFirst -

setCreateItemProcedure

public void setCreateItemProcedure(flex.data.config.SQLProcedureSettings sqlSettings)
The method is used for dynamically adding a procedure call for execution during createItem.

Parameters:
sqlSettings - The SQLProcedureSettings object representing the procedure configuration.

getDeleteItemSQLStructure

public flex.data.assemblers.SQLFactory.SQL getDeleteItemSQLStructure()
Returns the sql statement for delete-item.

Returns:
sql statement for delete-item.

setDeleteItemSQL

public void setDeleteItemSQL(String sql)
Sets the sql statement for delete-item.


setDeleteItemProcedure

public void setDeleteItemProcedure(flex.data.config.SQLProcedureSettings sqlSettings)
The method is used for dynamically adding a procedure call for execution during deleteItem.

Parameters:
sqlSettings - The SQLProcedureSettings object representing the procedure configuration.

setUpdateItemSQL

public void setUpdateItemSQL(String sql)
The method is used for dynamically adding a sql statement for execution during updateItem.

Parameters:
sql - statement for update-item.

setUpdateItemProcedure

public void setUpdateItemProcedure(flex.data.config.SQLProcedureSettings sqlSettings)
The method is used for dynamically adding a procedure call for execution during updateItem.

Parameters:
sqlSettings - The SQLProcedureSettings object representing the procedure configuration.

count

public int count(List countParameters)
Description copied from class: AbstractAssembler
Retrieve the number of items for a given query with the supplied parameters. This method is only necessary if your client code uses the corresponding count method on the DataService class.

This default implementation throws an error indicating that a count method for the supplied parameters is not defined.

When paging is enabled and this method is defined to return -1 , the client will be sent the number of records for the given query dynamically with each page request. This allows you to avoid an expensive count query for large data sets. *

Specified by:
count in interface Assembler
Overrides:
count in class AbstractAssembler
Parameters:
countParameters - a list of parameters to the count method provided by the client invocation.
Returns:
the number of items in the collection specified by the countParameters.

createItem

public void createItem(Object createItem)
Description copied from class: AbstractAssembler
Creates the item. Often, you fill in the identity properties unless those values were supplied by the client. If any errors occur for this operation, you can throw an exception of your choice to indicate that fact. The message of the exception is delivered to the client.

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.

Specified by:
createItem in interface Assembler
Overrides:
createItem in class AbstractAssembler
Parameters:
createItem - the initial instance of the item to create.

deleteItem

public void deleteItem(Object deleteItem)
Description copied from class: AbstractAssembler
This is called when the client application removes an item managed by the destination corresponding to this assembler. In this case, your deleteItem method is called with the version of the item intended for removal on the client. This method can do conflict detection to ensure that the item has not been modified since this deletion event was scheduled. In this case, your deleteItem method can throw the flex.data.DataSyncException where it should provide the current version of the item as the serverVersion parameter.

This method can also thrown any runtime exception to indicate a general error to be returned to the client.

Specified by:
deleteItem in interface Assembler
Overrides:
deleteItem in class AbstractAssembler
Parameters:
deleteItem - the original version of the item on the client which the client intends to remove

fill

public Collection fill(List fillParameters)
The first fill parameter is the name of the fill query to execute. The second fill parameter is the anonymous and/or strongly typed object used in SQL parameter replacement.

Specified by:
fill in interface Assembler
Overrides:
fill in class AbstractAssembler
Parameters:
fillParameters -
Returns:
a collection containing a list of items to be managed by the client. This collection should contain instances which all have valid identity properties and should not contain more than one instance with the same identity.

getItem

public Object getItem(Map m)
Description copied from class: AbstractAssembler
Retrieves an item with the specified Map of ids. Ids are stored with the key as the property name of the id property, the value as the value of the identity property.

Specified by:
getItem in interface Assembler
Overrides:
getItem in class AbstractAssembler
Parameters:
m - a java.util.Map which contains key/value pairs for each identity property.
Returns:
the item corresponding to this identity property or null if there is no item for this identity.

updateItem

public void updateItem(Object newVersion,
                       Object prevVersion,
                       List changes)
Description copied from class: AbstractAssembler
Updates the item. The newVersion is always going to be present and contains the new version of the item. The previousVersion contains any state required for maintaining the integrity of this instance. Currently, it is always fully populated. However, in the future, Adobe anticipates this method to selectively include only the properties of the item required to maintain an item's integrity during an update. It might be null to disable optimistic concurrency detection.

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.

Specified by:
updateItem in interface Assembler
Overrides:
updateItem in class AbstractAssembler
Parameters:
newVersion - the new version of the item with which to perform the update
prevVersion - the original version of the item before these changes were made (used for conflict detection).
changes - the list of changed property names.

autoRefreshFill

public boolean autoRefreshFill(List fillParams)
This returns false because we always push refresh fill methods for this sample.

Specified by:
autoRefreshFill in interface Assembler
Overrides:
autoRefreshFill in class AbstractAssembler
Parameters:
fillParams - Client-side parameters to a fill method that created a managed collection still managed by one or more clients.
Returns:
true if the fill identified by the fill parameters should be auto-refreshed or false if auto-refresh is off for this fill.


Copyright © 2007 Adobe Systems Inc. All Rights Reserved.

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/lcdsjavadoc/flex/data/assemblers/SQLAssembler.html