|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.avalon.framework.logger.AbstractLoggable | +--org.apache.cocoon.acting.AbstractAction | +--org.apache.cocoon.acting.AbstractConfigurableAction | +--org.apache.cocoon.acting.ConfigurableComposerAction | +--org.apache.cocoon.acting.AbstractComplementaryConfigurableAction | +--org.apache.cocoon.acting.modular.DatabaseAction
Abstract action for common function needed by database actions. The difference to the other Database*Actions is, that the actions in this package use additional components ("modules") for reading and writing parameters. In addition the descriptor format has changed to accomodate the new features.
This action is heavily based upon the original DatabaseAddActions.
Modes have to be configured in cocoon.xconf. Mode names from descriptor.xml file are looked up in the component service. Default mode names can only be set during action setup.
The number of affected rows is returned to the sitemap with the "row-count" parameter if at least one row was affected.
All known column types can be found in
JDBCTypeConversions
.
Configuration options (setup): | |
input | default mode name for reading values |
autoincrement | default mode name for obtaining values from autoincrement columns |
Configuration options (setup and per invocation): | |
throw-exception | throw an exception when an error occurs (default: false) |
descriptor | file containing database description |
table-set | table-set name to work with |
output | mode name for writing values |
JDBCTypeConversions
Inner Class Summary | |
protected class |
DatabaseAction.CacheHelper
Structure that takes all processed data for a table depending on current default modes |
protected class |
DatabaseAction.Column
Structure that takes all processed data for one column. |
protected class |
DatabaseAction.LookUpKey
Structure that takes up both current mode types for database operations and table configuration data. |
Field Summary | |
protected HashMap |
cachedQueryData
|
protected org.apache.avalon.framework.component.ComponentSelector |
dbselector
|
protected java.util.Map |
defaultModeNames
|
Fields inherited from class org.apache.cocoon.acting.ConfigurableComposerAction |
manager |
Fields inherited from class org.apache.cocoon.acting.AbstractConfigurableAction |
settings |
Fields inherited from class org.apache.cocoon.acting.AbstractAction |
EMPTY_MAP |
Fields inherited from interface org.apache.cocoon.acting.Action |
ROLE |
Constructor Summary | |
DatabaseAction()
|
Method Summary | |
java.util.Map |
act(Redirector redirector,
SourceResolver resolver,
java.util.Map objectModel,
java.lang.String source,
org.apache.avalon.framework.parameters.Parameters param)
Add a record to the database. |
void |
compose(org.apache.avalon.framework.component.ComponentManager manager)
Compose the Actions so that we can select our databases. |
void |
configure(org.apache.avalon.framework.configuration.Configuration conf)
Configures the Action. |
void |
dispose()
dispose |
protected void |
fillModes(org.apache.avalon.framework.configuration.Configuration[] conf,
boolean isKey,
java.util.Map defaultModeNames,
java.util.Map modeTypes,
DatabaseAction.CacheHelper set)
Setup parsed attribute configuration object |
protected java.lang.Object[] |
getColumnValue(org.apache.avalon.framework.configuration.Configuration tableConf,
DatabaseAction.Column column,
java.util.Map objectModel)
|
protected org.apache.avalon.excalibur.datasource.DataSourceComponent |
getDataSource(org.apache.avalon.framework.configuration.Configuration conf,
org.apache.avalon.framework.parameters.Parameters parameters)
Get the Datasource we need. |
protected org.apache.avalon.framework.configuration.Configuration |
getMode(org.apache.avalon.framework.configuration.Configuration conf,
java.lang.String type)
Choose a mode configuration based on its name. |
protected java.lang.String |
getOutputName(org.apache.avalon.framework.configuration.Configuration tableConf,
org.apache.avalon.framework.configuration.Configuration columnConf)
compose name for output a long the lines of "table.column" |
protected java.lang.String |
getOutputName(org.apache.avalon.framework.configuration.Configuration tableConf,
org.apache.avalon.framework.configuration.Configuration columnConf,
int rowIndex)
compose name for output a long the lines of "table.column[row]" or "table.column" if rowIndex is -1. |
protected abstract DatabaseAction.CacheHelper |
getQuery(org.apache.avalon.framework.configuration.Configuration table,
java.util.Map modeTypes,
java.util.Map defaultModeNames)
Get the String representation of the PreparedStatement. |
protected abstract boolean |
honourAutoIncrement()
determine whether autoincrement columns should be honoured by this operation. |
protected boolean |
isLargeObject(java.lang.String type)
Return whether a type is a Large Object (BLOB/CLOB). |
protected abstract int |
processRow(java.util.Map objectModel,
java.sql.Connection conn,
java.sql.PreparedStatement statement,
java.lang.String outputMode,
org.apache.avalon.framework.configuration.Configuration table,
DatabaseAction.CacheHelper queryData,
java.lang.Object[][] columnValues,
int rowIndex,
java.util.Map results)
set all necessary ? |
protected int |
processTable(org.apache.avalon.framework.configuration.Configuration table,
java.sql.Connection conn,
java.util.Map objectModel,
java.util.Map results,
java.util.Map modeTypes)
Inserts a row or a set of rows into the given table based on the request parameters |
protected abstract java.lang.String |
selectMode(boolean isAutoIncrement,
java.util.Map modes)
determine which mode to use as default mode This method is intended to be overridden by classes that implement other operations e.g. delete |
protected void |
setColumn(java.util.Map objectModel,
java.lang.String outputMode,
java.util.Map results,
org.apache.avalon.framework.configuration.Configuration table,
org.apache.avalon.framework.configuration.Configuration column,
int rowIndex,
java.lang.Object value,
java.sql.PreparedStatement statement,
int position)
set a column in a statement using the appropriate JDBC setXXX method and propagate the value to the output module and results map if present. |
protected void |
setColumn(java.sql.PreparedStatement statement,
int position,
org.apache.avalon.framework.configuration.Configuration entry,
java.lang.Object value)
set a column in a statement using the appropriate JDBC setXXX method. |
protected void |
setOutput(java.util.Map objectModel,
java.lang.String outputMode,
java.util.Map results,
org.apache.avalon.framework.configuration.Configuration table,
org.apache.avalon.framework.configuration.Configuration column,
int rowIndex,
java.lang.Object value)
create a unique name using the getOutputName method and write the value to the output module and the results map if present. |
protected void |
setOutputAttribute(java.util.Map objectModel,
java.lang.String outputMode,
java.lang.String key,
java.lang.Object value)
Store a key/value pair in the output attributes. |
Methods inherited from class org.apache.cocoon.acting.AbstractComplementaryConfigurableAction |
getConfiguration, getConfiguration, getConfiguration |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable |
getLogger, setLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected org.apache.avalon.framework.component.ComponentSelector dbselector
protected java.util.Map defaultModeNames
protected final HashMap cachedQueryData
Constructor Detail |
public DatabaseAction()
Method Detail |
public void configure(org.apache.avalon.framework.configuration.Configuration conf) throws org.apache.avalon.framework.configuration.ConfigurationException
AbstractConfigurableAction
Configuration
and stores them
them as key (configuration name) and value (configuration value)
in settings
.
configure
in interface org.apache.avalon.framework.configuration.Configurable
configure
in class AbstractConfigurableAction
public void compose(org.apache.avalon.framework.component.ComponentManager manager) throws org.apache.avalon.framework.component.ComponentException
compose
in class ConfigurableComposerAction
public void dispose()
dispose
in interface org.apache.avalon.framework.activity.Disposable
protected org.apache.avalon.excalibur.datasource.DataSourceComponent getDataSource(org.apache.avalon.framework.configuration.Configuration conf, org.apache.avalon.framework.parameters.Parameters parameters) throws org.apache.avalon.framework.component.ComponentException
protected final boolean isLargeObject(java.lang.String type)
protected void setOutputAttribute(java.util.Map objectModel, java.lang.String outputMode, java.lang.String key, java.lang.Object value)
protected int processTable(org.apache.avalon.framework.configuration.Configuration table, java.sql.Connection conn, java.util.Map objectModel, java.util.Map results, java.util.Map modeTypes) throws java.sql.SQLException, org.apache.avalon.framework.configuration.ConfigurationException, java.lang.Exception
table
- the table's configurationconn
- the database connectionobjectModel
- the objectModelprotected org.apache.avalon.framework.configuration.Configuration getMode(org.apache.avalon.framework.configuration.Configuration conf, java.lang.String type) throws org.apache.avalon.framework.configuration.ConfigurationException
conf
- Configuration (i.e. a column's configuration) that might have
several children configurations named "mode".type
- desired type (i.e. every mode has a type
attribute), find the first mode that has a compatible type.
Special mode "all" matches all queried types.protected java.lang.String getOutputName(org.apache.avalon.framework.configuration.Configuration tableConf, org.apache.avalon.framework.configuration.Configuration columnConf)
protected java.lang.String getOutputName(org.apache.avalon.framework.configuration.Configuration tableConf, org.apache.avalon.framework.configuration.Configuration columnConf, int rowIndex)
protected java.lang.Object[] getColumnValue(org.apache.avalon.framework.configuration.Configuration tableConf, DatabaseAction.Column column, java.util.Map objectModel) throws org.apache.avalon.framework.configuration.ConfigurationException, org.apache.avalon.framework.component.ComponentException
protected void fillModes(org.apache.avalon.framework.configuration.Configuration[] conf, boolean isKey, java.util.Map defaultModeNames, java.util.Map modeTypes, DatabaseAction.CacheHelper set) throws org.apache.avalon.framework.configuration.ConfigurationException
protected void setOutput(java.util.Map objectModel, java.lang.String outputMode, java.util.Map results, org.apache.avalon.framework.configuration.Configuration table, org.apache.avalon.framework.configuration.Configuration column, int rowIndex, java.lang.Object value)
protected void setColumn(java.sql.PreparedStatement statement, int position, org.apache.avalon.framework.configuration.Configuration entry, java.lang.Object value) throws java.lang.Exception
protected void setColumn(java.util.Map objectModel, java.lang.String outputMode, java.util.Map results, org.apache.avalon.framework.configuration.Configuration table, org.apache.avalon.framework.configuration.Configuration column, int rowIndex, java.lang.Object value, java.sql.PreparedStatement statement, int position) throws java.lang.Exception
public java.util.Map act(Redirector redirector, SourceResolver resolver, java.util.Map objectModel, java.lang.String source, org.apache.avalon.framework.parameters.Parameters param) throws java.lang.Exception
org.apache.cocoon.acting.Action
resolver
- The SourceResolver
in chargeobjectModel
- The Map
with object of the
calling environment which can be used
to select values this controller may need
(ie Request, Response).source
- A source String
to the Actionparameters
- The Parameters
for this invocationMap
object with
sitemap substitution values which can be used
in subsequent elements attributes like src=
using a xpath like expression: src="mydir/{myval}/foo"
If the return value is null the processing inside
the java.lang.Exception
- Indicates something is totally wrongprotected abstract int processRow(java.util.Map objectModel, java.sql.Connection conn, java.sql.PreparedStatement statement, java.lang.String outputMode, org.apache.avalon.framework.configuration.Configuration table, DatabaseAction.CacheHelper queryData, java.lang.Object[][] columnValues, int rowIndex, java.util.Map results) throws java.sql.SQLException, org.apache.avalon.framework.configuration.ConfigurationException, java.lang.Exception
protected abstract java.lang.String selectMode(boolean isAutoIncrement, java.util.Map modes)
protected abstract boolean honourAutoIncrement()
protected abstract DatabaseAction.CacheHelper getQuery(org.apache.avalon.framework.configuration.Configuration table, java.util.Map modeTypes, java.util.Map defaultModeNames) throws org.apache.avalon.framework.configuration.ConfigurationException, org.apache.avalon.framework.component.ComponentException
table
- the table's configuration object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |