org.apache.jetspeed.modules.actions.portlets.browser
Class DatabaseBrowserAction

java.lang.Object
  extended byorg.apache.turbine.modules.Assembler
      extended byorg.apache.turbine.modules.Action
          extended byorg.apache.turbine.modules.ActionEvent
              extended byorg.apache.jetspeed.modules.actions.portlets.PortletActionEvent
                  extended byorg.apache.jetspeed.modules.actions.portlets.PortletAction
                      extended byorg.apache.jetspeed.modules.actions.portlets.GenericMVCAction
                          extended byorg.apache.jetspeed.modules.actions.portlets.VelocityPortletAction
                              extended byorg.apache.jetspeed.modules.actions.portlets.browser.DatabaseBrowserAction
All Implemented Interfaces:
BrowserQuery

public class DatabaseBrowserAction
extends VelocityPortletAction
implements BrowserQuery

This action sets up the template context for retrieving paged data from the resultSet according to the quey speciified by the user.

Version:
$Id: DatabaseBrowserAction.java,v 1.34 2004/02/23 02:51:19 jford Exp $
Author:
David Sean Taylor

Field Summary
protected static java.lang.String BROWSER_ITERATOR
           
protected static java.lang.String BROWSER_TABLE_SIZE
           
protected static java.lang.String BROWSER_TITLE_ITERATOR
           
protected static java.lang.String CUSTOMIZE_TEMPLATE
           
protected static java.lang.String DATABASE_BROWSER_ACTION_KEY
           
protected static java.lang.String LINKS_READ
           
protected static java.lang.String NEXT
           
protected static java.lang.String PEID
           
protected static java.lang.String POOLNAME
           
protected static java.lang.String PREVIOUS
           
protected static java.lang.String ROW_LINK
           
protected static java.lang.String ROW_LINK_IDS
           
protected static java.lang.String ROW_LINK_TARGETS
           
protected static java.lang.String ROW_LINK_TYPES
           
protected static java.lang.String SORT_COLUMN_NAME
           
protected static java.lang.String SQL
           
protected static java.lang.String SQL_PARAM_PREFIX
           
protected  java.util.List sqlParameters
           
protected static java.lang.String START
           
protected static java.lang.String TABLE_LINK
           
protected static java.lang.String TABLE_LINK_IDS
           
protected static java.lang.String TABLE_LINK_TARGETS
           
protected static java.lang.String TABLE_LINK_TYPES
           
protected static java.lang.String USER_OBJECT_NAMES
           
protected static java.lang.String USER_OBJECT_TYPES
           
protected static java.lang.String USER_OBJECTS
           
protected static java.lang.String VELOCITY_NULL_ENTRY
           
protected static java.lang.String WINDOW_SIZE
           
 
Fields inherited from class org.apache.turbine.modules.ActionEvent
BUTTON, BUTTON_LENGTH, LENGTH, METHOD_NAME_LENGTH, METHOD_NAME_PREFIX
 
Constructor Summary
DatabaseBrowserAction()
           
 
Method Summary
protected  void buildConfigureContext(VelocityPortlet portlet, org.apache.velocity.context.Context context, org.apache.turbine.util.RunData rundata)
          Subclasses should override this method if they wish to provide their own customization behavior.
protected  void buildMaximizedContext(VelocityPortlet portlet, org.apache.velocity.context.Context context, org.apache.turbine.util.RunData rundata)
          Build the maximized state content for this portlet.
protected  void buildNormalContext(VelocityPortlet portlet, org.apache.velocity.context.Context context, org.apache.turbine.util.RunData rundata)
          Build the normal state content for this portlet.
protected  void clearDatabaseBrowserIterator(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata)
          Centralizes the calls to runData.getUser.removeTemp() - to clear the DatabaseBrowserIterator from the temp storage.
protected  void clearParameterFromPSML(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata, java.lang.String attributeName)
           
protected  void clearParameterFromTemp(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata, java.lang.String attrName)
           
protected  void clearQueryString(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata)
           
 void doRefresh(org.apache.turbine.util.RunData rundata, org.apache.velocity.context.Context context)
          This method is called when the user hits refresh to refetch the result set.
 void doUpdate(org.apache.turbine.util.RunData rundata, org.apache.velocity.context.Context context)
          This method is called when the user configures any of the parameters.
 boolean filter(java.util.List row, org.apache.turbine.util.RunData rundata)
          Filter the row programmatically on a query.
protected  BrowserIterator getDatabaseBrowserIterator(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata)
          Centralizes the calls to runData.getUser.getTemp() - to retrieve the DatabaseBrowserIterator.
protected  java.lang.String getParameterFromPSML(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata, java.lang.String attrName, java.lang.String attrDefValue)
           
protected  java.lang.String getParameterFromRegistry(VelocityPortlet portlet, java.lang.String attrName, java.lang.String attrDefValue)
           
protected  java.lang.Object getParameterFromTemp(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata, java.lang.String attrName)
           
protected  java.lang.String getParameterUsingFallback(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata, java.lang.String attrName, java.lang.String attrDefValue)
           
 java.lang.String getQueryString(org.apache.turbine.util.RunData rundata, org.apache.velocity.context.Context context)
          This method returns the query to be executed to get the results which will be opened in the browser.
protected  java.lang.String getQueryString(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata, org.apache.velocity.context.Context context)
          This method returns the sql from the getQuery method which can be overwritten according to the needs of the application.
protected  java.lang.String getRequestParameter(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata, java.lang.String attrName)
           
protected  void getRows(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata, java.lang.String sql, int windowSize)
          Execute the sql statement as specified by the user or the default, and store the resultSet in a vector.
 java.util.List getSQLParameters()
           
protected  int getStartIndex()
          to be used if sorting behavior to be overwritten
protected  int getStartVariable(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata, java.lang.String attrName, java.lang.String sortColName, BrowserIterator iterator)
           
protected  boolean isMyRequest(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata)
           
 void populate(int rowIndex, int columnIndex, java.util.List row)
          This method should be overwritten every time the user object needs to be populated with some user specific constraints.
protected  void readLinkParameters(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata, org.apache.velocity.context.Context context)
           
protected  void readSqlParameters(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata)
           
protected  void readUserParameters(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata, org.apache.velocity.context.Context context)
           
protected  void setDatabaseBrowserIterator(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata, BrowserIterator iterator)
          Centralizes the calls to runData.getUser.setTemp() - to set the DatabaseBrowserIterator.
protected  void setParameterToPSML(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata, java.lang.String attrName, java.lang.String attrValue)
           
protected  void setParameterToTemp(VelocityPortlet portlet, org.apache.turbine.util.RunData rundata, java.lang.String attrName, java.lang.Object attrValue)
           
 void setSQLParameters(java.util.List parameters)
           
 
Methods inherited from class org.apache.jetspeed.modules.actions.portlets.VelocityPortletAction
buildConfigureContext, buildMaximizedContext, buildNormalContext
 
Methods inherited from class org.apache.jetspeed.modules.actions.portlets.GenericMVCAction
checkAdministrativeAction, doPerform, getAttribute, getAttribute, getPortletInstance, perform, setAttribute
 
Methods inherited from class org.apache.jetspeed.modules.actions.portlets.PortletAction
doPerform, getContext, getPortlet, getTemplate, resetTemplate, setTemplate, setTemplate
 
Methods inherited from class org.apache.jetspeed.modules.actions.portlets.PortletActionEvent
executeEvents, fireEvent
 
Methods inherited from class org.apache.turbine.modules.ActionEvent
executeEvents, formatString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SQL

protected static final java.lang.String SQL
See Also:
Constant Field Values

POOLNAME

protected static final java.lang.String POOLNAME
See Also:
Constant Field Values

START

protected static final java.lang.String START
See Also:
Constant Field Values

CUSTOMIZE_TEMPLATE

protected static final java.lang.String CUSTOMIZE_TEMPLATE
See Also:
Constant Field Values

WINDOW_SIZE

protected static final java.lang.String WINDOW_SIZE
See Also:
Constant Field Values

USER_OBJECT_NAMES

protected static final java.lang.String USER_OBJECT_NAMES
See Also:
Constant Field Values

USER_OBJECT_TYPES

protected static final java.lang.String USER_OBJECT_TYPES
See Also:
Constant Field Values

USER_OBJECTS

protected static final java.lang.String USER_OBJECTS
See Also:
Constant Field Values

SQL_PARAM_PREFIX

protected static final java.lang.String SQL_PARAM_PREFIX
See Also:
Constant Field Values

LINKS_READ

protected static final java.lang.String LINKS_READ
See Also:
Constant Field Values

ROW_LINK

protected static final java.lang.String ROW_LINK
See Also:
Constant Field Values

TABLE_LINK

protected static final java.lang.String TABLE_LINK
See Also:
Constant Field Values

ROW_LINK_IDS

protected static final java.lang.String ROW_LINK_IDS
See Also:
Constant Field Values

ROW_LINK_TYPES

protected static final java.lang.String ROW_LINK_TYPES
See Also:
Constant Field Values

ROW_LINK_TARGETS

protected static final java.lang.String ROW_LINK_TARGETS
See Also:
Constant Field Values

TABLE_LINK_IDS

protected static final java.lang.String TABLE_LINK_IDS
See Also:
Constant Field Values

TABLE_LINK_TYPES

protected static final java.lang.String TABLE_LINK_TYPES
See Also:
Constant Field Values

TABLE_LINK_TARGETS

protected static final java.lang.String TABLE_LINK_TARGETS
See Also:
Constant Field Values

BROWSER_TABLE_SIZE

protected static final java.lang.String BROWSER_TABLE_SIZE
See Also:
Constant Field Values

DATABASE_BROWSER_ACTION_KEY

protected static final java.lang.String DATABASE_BROWSER_ACTION_KEY
See Also:
Constant Field Values

BROWSER_ITERATOR

protected static final java.lang.String BROWSER_ITERATOR
See Also:
Constant Field Values

BROWSER_TITLE_ITERATOR

protected static final java.lang.String BROWSER_TITLE_ITERATOR
See Also:
Constant Field Values

NEXT

protected static final java.lang.String NEXT
See Also:
Constant Field Values

PREVIOUS

protected static final java.lang.String PREVIOUS
See Also:
Constant Field Values

VELOCITY_NULL_ENTRY

protected static final java.lang.String VELOCITY_NULL_ENTRY
See Also:
Constant Field Values

PEID

protected static final java.lang.String PEID
See Also:
Constant Field Values

SORT_COLUMN_NAME

protected static final java.lang.String SORT_COLUMN_NAME
See Also:
Constant Field Values

sqlParameters

protected java.util.List sqlParameters
Constructor Detail

DatabaseBrowserAction

public DatabaseBrowserAction()
Method Detail

buildMaximizedContext

protected void buildMaximizedContext(VelocityPortlet portlet,
                                     org.apache.velocity.context.Context context,
                                     org.apache.turbine.util.RunData rundata)
Build the maximized state content for this portlet. (Same as normal state).

Overrides:
buildMaximizedContext in class VelocityPortletAction
Parameters:
portlet - The velocity-based portlet that is being built.
context - The velocity context for this request.
rundata - The turbine rundata context for this request.

buildConfigureContext

protected void buildConfigureContext(VelocityPortlet portlet,
                                     org.apache.velocity.context.Context context,
                                     org.apache.turbine.util.RunData rundata)
Subclasses should override this method if they wish to provide their own customization behavior. Default is to use Portal base customizer action

Overrides:
buildConfigureContext in class VelocityPortletAction

buildNormalContext

protected void buildNormalContext(VelocityPortlet portlet,
                                  org.apache.velocity.context.Context context,
                                  org.apache.turbine.util.RunData rundata)
Build the normal state content for this portlet.

Specified by:
buildNormalContext in class VelocityPortletAction
Parameters:
portlet - The velocity-based portlet that is being built.
context - The velocity context for this request.
rundata - The turbine rundata context for this request.

doUpdate

public void doUpdate(org.apache.turbine.util.RunData rundata,
                     org.apache.velocity.context.Context context)
This method is called when the user configures any of the parameters.

Parameters:
context - The velocity context for this request.

doRefresh

public void doRefresh(org.apache.turbine.util.RunData rundata,
                      org.apache.velocity.context.Context context)
This method is called when the user hits refresh to refetch the result set.

Parameters:
context - The velocity context for this request.

filter

public boolean filter(java.util.List row,
                      org.apache.turbine.util.RunData rundata)
Description copied from interface: BrowserQuery
Filter the row programmatically on a query. By returning true, instruct the database browser to filter the row. By returning false, instruct the database browser to keep the row. (Filtering means removing the row from the final result set).

Specified by:
filter in interface BrowserQuery
Parameters:
row - The row being inspected for filtration.
Returns:
True to filter the row, false to keep it.

getRows

protected void getRows(VelocityPortlet portlet,
                       org.apache.turbine.util.RunData rundata,
                       java.lang.String sql,
                       int windowSize)
                throws java.lang.Exception
Execute the sql statement as specified by the user or the default, and store the resultSet in a vector.

Parameters:
sql - The sql statement to be executed.
Throws:
java.lang.Exception

getDatabaseBrowserIterator

protected BrowserIterator getDatabaseBrowserIterator(VelocityPortlet portlet,
                                                     org.apache.turbine.util.RunData rundata)
Centralizes the calls to runData.getUser.getTemp() - to retrieve the DatabaseBrowserIterator.


setDatabaseBrowserIterator

protected void setDatabaseBrowserIterator(VelocityPortlet portlet,
                                          org.apache.turbine.util.RunData rundata,
                                          BrowserIterator iterator)
Centralizes the calls to runData.getUser.setTemp() - to set the DatabaseBrowserIterator.


clearDatabaseBrowserIterator

protected void clearDatabaseBrowserIterator(VelocityPortlet portlet,
                                            org.apache.turbine.util.RunData rundata)
Centralizes the calls to runData.getUser.removeTemp() - to clear the DatabaseBrowserIterator from the temp storage.


getQueryString

public java.lang.String getQueryString(org.apache.turbine.util.RunData rundata,
                                       org.apache.velocity.context.Context context)
This method returns the query to be executed to get the results which will be opened in the browser.

Specified by:
getQueryString in interface BrowserQuery

getQueryString

protected java.lang.String getQueryString(VelocityPortlet portlet,
                                          org.apache.turbine.util.RunData rundata,
                                          org.apache.velocity.context.Context context)
This method returns the sql from the getQuery method which can be overwritten according to the needs of the application. If the getQuery() returns null, then it gets the value from the psml file. If the psml value is null then it returns the value from the xreg file.


clearQueryString

protected void clearQueryString(VelocityPortlet portlet,
                                org.apache.turbine.util.RunData rundata)

getStartIndex

protected int getStartIndex()
to be used if sorting behavior to be overwritten


getParameterUsingFallback

protected java.lang.String getParameterUsingFallback(VelocityPortlet portlet,
                                                     org.apache.turbine.util.RunData rundata,
                                                     java.lang.String attrName,
                                                     java.lang.String attrDefValue)

clearParameterFromPSML

protected void clearParameterFromPSML(VelocityPortlet portlet,
                                      org.apache.turbine.util.RunData rundata,
                                      java.lang.String attributeName)

setParameterToPSML

protected void setParameterToPSML(VelocityPortlet portlet,
                                  org.apache.turbine.util.RunData rundata,
                                  java.lang.String attrName,
                                  java.lang.String attrValue)

getParameterFromPSML

protected java.lang.String getParameterFromPSML(VelocityPortlet portlet,
                                                org.apache.turbine.util.RunData rundata,
                                                java.lang.String attrName,
                                                java.lang.String attrDefValue)

getParameterFromRegistry

protected java.lang.String getParameterFromRegistry(VelocityPortlet portlet,
                                                    java.lang.String attrName,
                                                    java.lang.String attrDefValue)

getParameterFromTemp

protected java.lang.Object getParameterFromTemp(VelocityPortlet portlet,
                                                org.apache.turbine.util.RunData rundata,
                                                java.lang.String attrName)

setParameterToTemp

protected void setParameterToTemp(VelocityPortlet portlet,
                                  org.apache.turbine.util.RunData rundata,
                                  java.lang.String attrName,
                                  java.lang.Object attrValue)

clearParameterFromTemp

protected void clearParameterFromTemp(VelocityPortlet portlet,
                                      org.apache.turbine.util.RunData rundata,
                                      java.lang.String attrName)

isMyRequest

protected boolean isMyRequest(VelocityPortlet portlet,
                              org.apache.turbine.util.RunData rundata)

getRequestParameter

protected java.lang.String getRequestParameter(VelocityPortlet portlet,
                                               org.apache.turbine.util.RunData rundata,
                                               java.lang.String attrName)

getStartVariable

protected int getStartVariable(VelocityPortlet portlet,
                               org.apache.turbine.util.RunData rundata,
                               java.lang.String attrName,
                               java.lang.String sortColName,
                               BrowserIterator iterator)

setSQLParameters

public void setSQLParameters(java.util.List parameters)
Specified by:
setSQLParameters in interface BrowserQuery

getSQLParameters

public java.util.List getSQLParameters()
Specified by:
getSQLParameters in interface BrowserQuery

readSqlParameters

protected void readSqlParameters(VelocityPortlet portlet,
                                 org.apache.turbine.util.RunData rundata)

readUserParameters

protected void readUserParameters(VelocityPortlet portlet,
                                  org.apache.turbine.util.RunData rundata,
                                  org.apache.velocity.context.Context context)

readLinkParameters

protected void readLinkParameters(VelocityPortlet portlet,
                                  org.apache.turbine.util.RunData rundata,
                                  org.apache.velocity.context.Context context)

populate

public void populate(int rowIndex,
                     int columnIndex,
                     java.util.List row)
This method should be overwritten every time the user object needs to be populated with some user specific constraints. As an example if the user wanted to track the parent of an object based on some calculation per row, it could be done here.



Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.