org.apache.cocoon.acting
Class AbstractDatabaseAction

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.AbstractDatabaseAction
All Implemented Interfaces:
Action, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.logger.Loggable
Direct Known Subclasses:
DatabaseAddAction, DatabaseAuthenticatorAction, DatabaseDeleteAction, DatabaseSelectAction, DatabaseUpdateAction

public abstract class AbstractDatabaseAction
extends AbstractComplementaryConfigurableAction
implements org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Disposable

Set up environment for configurable form handling data. It is important to note that all DatabaseActions use a common configuration format. This group of actions are unique in that they employ a terciary mapping. There is the Form parameter, the database column, and the type. Each configuration file must use the same format in order to be effective. The name of the root configuration element is irrelevant.

   <root>
     <connection>personnel<connection>
     <table>
       <keys>
         <key param="id" dbcol="id" type="int"/>
       </keys>
       <values>
         <value param="name" dbcol="name" type="string"/>
         <value param="department" dbcol="department_id" type="int"/>
       </values>
     </table>
   </root>
 
The types recognized by this system are:
Type Description
ascii ASCII Input Stream, a CLOB input
big-decimal a java.math.BigDecimal value
binary Binary Input Stream, a BLOB input
byte a Byte
string a String
date a Date
double a Double
float a Float
int an Integer
long a Long
short a Short
time a Time
time-stamp a Timestamp
now a Timestamp with the current day/time--the form value is ignored.
image a binary image file, we cache the attribute information
image-width the width attribute of the cached file attribute. NOTE: param attribute must equal the param for image with a "-width" suffix.
image-height the width attribute of the cached file attribute NOTE: param attribute must equal the param for image with a "-height" suffix.
image-size the size attribute of the cached file attribute NOTE: param attribute must equal the param for image with a "-size" suffix.

Version:
CVS $Id: AbstractDatabaseAction.java,v 1.6.2.2 2002/06/11 13:39:23 haul Exp $
Author:
Berin Loritsch, Donald Ball

Field Summary
protected  org.apache.avalon.framework.component.ComponentSelector dbselector
           
protected  java.util.Map files
           
protected static java.util.Map typeConstants
           
 
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
AbstractDatabaseAction()
           
 
Method Summary
 void compose(org.apache.avalon.framework.component.ComponentManager manager)
          Compose the Actions so that we can select our databases.
 void dispose()
          dispose
protected  java.lang.Object getColumn(java.sql.ResultSet set, Request request, org.apache.avalon.framework.configuration.Configuration entry)
          Get the Statement column so that the results are mapped correctly.
protected  org.apache.avalon.excalibur.datasource.DataSourceComponent getDataSource(org.apache.avalon.framework.configuration.Configuration conf)
          Get the Datasource we need.
protected  java.lang.Object getRequestAttribute(Request request, java.lang.String key)
          Retreive a value from the request attributes.
protected  boolean isLargeObject(java.lang.String type)
          Return whether a type is a Large Object (BLOB/CLOB).
protected  void setColumn(java.sql.PreparedStatement statement, int position, Request request, org.apache.avalon.framework.configuration.Configuration entry)
          Set the Statement column so that the results are mapped correctly.
protected  void setColumn(java.sql.PreparedStatement statement, int position, Request request, org.apache.avalon.framework.configuration.Configuration entry, java.lang.String param)
          Set the Statement column so that the results are mapped correctly.
protected  void setColumn(java.sql.PreparedStatement statement, int position, Request request, org.apache.avalon.framework.configuration.Configuration entry, java.lang.String param, java.lang.Object value)
          Set the Statement column so that the results are mapped correctly.
protected  void setColumn(java.sql.PreparedStatement statement, int position, Request request, org.apache.avalon.framework.configuration.Configuration entry, java.lang.String param, java.lang.Object value, int rowIndex)
          Set the Statement column so that the results are mapped correctly.
protected  void setRequestAttribute(Request request, java.lang.String key, java.lang.Object value)
          Store a key/value pair in the request attributes.
 
Methods inherited from class org.apache.cocoon.acting.AbstractComplementaryConfigurableAction
getConfiguration, getConfiguration, getConfiguration
 
Methods inherited from class org.apache.cocoon.acting.AbstractConfigurableAction
configure
 
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
 
Methods inherited from interface org.apache.avalon.framework.configuration.Configurable
configure
 
Methods inherited from interface org.apache.cocoon.acting.Action
act
 

Field Detail

files

protected java.util.Map files

typeConstants

protected static final java.util.Map typeConstants

dbselector

protected org.apache.avalon.framework.component.ComponentSelector dbselector
Constructor Detail

AbstractDatabaseAction

public AbstractDatabaseAction()
Method Detail

compose

public void compose(org.apache.avalon.framework.component.ComponentManager manager)
             throws org.apache.avalon.framework.component.ComponentException
Compose the Actions so that we can select our databases.
Overrides:
compose in class ConfigurableComposerAction

getDataSource

protected final org.apache.avalon.excalibur.datasource.DataSourceComponent getDataSource(org.apache.avalon.framework.configuration.Configuration conf)
                                                                                  throws org.apache.avalon.framework.component.ComponentException
Get the Datasource we need.

isLargeObject

protected final boolean isLargeObject(java.lang.String type)
Return whether a type is a Large Object (BLOB/CLOB).

getColumn

protected java.lang.Object getColumn(java.sql.ResultSet set,
                                     Request request,
                                     org.apache.avalon.framework.configuration.Configuration entry)
                              throws java.lang.Exception
Get the Statement column so that the results are mapped correctly.

setColumn

protected void setColumn(java.sql.PreparedStatement statement,
                         int position,
                         Request request,
                         org.apache.avalon.framework.configuration.Configuration entry)
                  throws java.lang.Exception
Set the Statement column so that the results are mapped correctly. The name of the parameter is retrieved from the configuration object.
Parameters:
statement - the prepared statement
position - the position of the column
request - the request
entry - the configuration object

setColumn

protected void setColumn(java.sql.PreparedStatement statement,
                         int position,
                         Request request,
                         org.apache.avalon.framework.configuration.Configuration entry,
                         java.lang.String param)
                  throws java.lang.Exception
Set the Statement column so that the results are mapped correctly. The value of the column is retrieved from the request object. If the named parameter exists in the request object's parameters, that value is used. Otherwise if the named parameter exists in the request object's attributes, that value is used. Otherwise the request object is retrieved using Request.get(attribute), which is documented to be the same as Request.getAttribute(attribute), so something weird must be going on.
Parameters:
statement - the prepared statement
position - the position of the column
request - the request
entry - the configuration object
param - the name of the request parameter

setColumn

protected void setColumn(java.sql.PreparedStatement statement,
                         int position,
                         Request request,
                         org.apache.avalon.framework.configuration.Configuration entry,
                         java.lang.String param,
                         java.lang.Object value)
                  throws java.lang.Exception
Set the Statement column so that the results are mapped correctly.
Parameters:
statement - the prepared statement
position - the position of the column
request - the request
entry - the configuration object
param - the name of the request parameter
value - the value of the column

setColumn

protected void setColumn(java.sql.PreparedStatement statement,
                         int position,
                         Request request,
                         org.apache.avalon.framework.configuration.Configuration entry,
                         java.lang.String param,
                         java.lang.Object value,
                         int rowIndex)
                  throws java.lang.Exception
Set the Statement column so that the results are mapped correctly.
Parameters:
statement - the prepared statement
position - the position of the column
request - the request
entry - the configuration object
param - the name of the request parameter
value - the value of the column
rowIndex - the index of the current row for manyrows inserts

dispose

public void dispose()
dispose
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable

setRequestAttribute

protected void setRequestAttribute(Request request,
                                   java.lang.String key,
                                   java.lang.Object value)
Store a key/value pair in the request attributes. We prefix the key with the name of this class to prevent potential name collisions.

getRequestAttribute

protected java.lang.Object getRequestAttribute(Request request,
                                               java.lang.String key)
Retreive a value from the request attributes.


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.