com.sri.common.controller
Class AbstractDBController

java.lang.Object
  extended by org.apache.struts.action.Action
      extended by com.jcorporate.expresso.core.controller.Controller
          extended by com.jcorporate.expresso.core.controller.DBController
              extended by com.sri.common.controller.AbstractDBController
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AbstractComponentController, EmoAction, ImportExportModel, PartAction, PermissionController, PicklistAction

public abstract class AbstractDBController
extends DBController

Superclass for all TI controllers, for common behavior like logging.

See Also:
Serialized Form

Field Summary
static String COLUMN
          Column Constant.
static String COMMON_FOOTER_HANDLER
          Constant for common footer handler.
static String COMMON_HEADER_HANDLER
          Constant for common header handler.
static String DELIMIT
          Delimiter constant.
static String EDIT_GROUP_DISPLAY
          Jsp constant.
static String EMBEDDED_MODE
          Parameter to indicate 'embedded mode'.
static String FOOTER
          Footer constant.
static int MAX_CHARS_OUTPUT
          Limit number of chars that appear in display for a given field.
static int MAX_TEXTAREA_LENGTH
          Max Text Area Length constant.
static int MULTIPLE_TEXTAREA_NUM_LINES
          Number of lines for multiple text area.
static String REQUEST_CONTAINER
          Key where the RequestContainer is stored in the session.
static String ROW
          Row Constant.
static String ROW_BLOCK
          Row Block Constant.
static String SESSION_CONTAINER
          Key where the session container is stored.
static int SINGLE_TEXTAREA_NUM_LINES
          Number of lines for a text area.
static int TEXTAREA_NUM_COLS
          Number of columns for a test area.
static String WARNING_LIST
          Constant for warning list location.
 
Fields inherited from class com.jcorporate.expresso.core.controller.DBController
CACHE_NAME
 
Fields inherited from class com.jcorporate.expresso.core.controller.Controller
CONTROLLER_PARAM_KEY, CTL_SUCC_CTL, CTL_SUCC_STATE, CTL_SUCC_TRAN, mLog, NEWSTATE_EXCEPTION_KEY, ORIGINAL_URL_KEY, REQUEST_KEY, RESPONSE_KEY, RETURN_TO_SENDER_TRAN, STATE_ERR_CTL, STATE_ERR_STATE, STATE_ERR_TRAN, STATE_PARAM_KEY, STATE_SUCC_CTL, STATE_SUCC_STATE, STATE_SUCC_TRAN
 
Fields inherited from class org.apache.struts.action.Action
defaultLocale, servlet
 
Constructor Summary
AbstractDBController()
           
 
Method Summary
static Transition addEmbeddedParameter(Transition transitionToModify)
          Adds the 'embedded mode' parameter to a transition.
 void addWarning(ExpressoRequest request, String s)
          Adds warning to request scope, creating list if necessary.
protected  List addWarningList(ExpressoRequest request)
          Add list to request scope.
protected  String getActionForwarding(String forward, String state)
          Look up the forward used for 'state' param, suitable for use with setStyle().
static Input getCheckbox(String name, String label, String defVal, boolean isSelected)
          Get a checkbox with the given name, label, default value, and optionally select it.
 Transition getPermsTrans(RowSecuredDBObject obj)
          Retrieve the permission transition for the row secured dbobject.
static String getPrettyXML(org.dom4j.Element elem)
          Get nicely formatted XML.
static Input getTextArea(String name, String defVal)
          Get a text area with 4 rows and 40 columns.
static Input getTextArea(String name, String defVal, int rows, int cols)
          Get a text area with the given name and default value.
protected  List getWarningList(ExpressoRequest request)
          Get list from request scope.
static boolean isEmbeddedMode(ExpressoRequest request)
          Checks the controller request for the 'embedded mode' parameter.
 boolean isValidAndPopulated(DBObject object, String[] requiredFields, String failureState, ExpressoRequest request, ExpressoResponse response)
          Populates DBObject with any parameters which match field names.
 void outputXML(org.dom4j.Document document, ExpressoRequest request)
          Output XML for given document.
static void populateDBObject(DBObject obj, ExpressoRequest request)
          fill in any fields found in request
protected  void postPerform(State nextState, ExpressoRequest request, ExpressoResponse response)
          Template Method, allowing a subclass to into actions before any state in this controller is performed.
protected  void prePerform(State nextState, ExpressoRequest request, ExpressoResponse response)
          Template Method, allowing a subclass to do an action after any state in this controller is performed.
 boolean stateAllowed(String newState, ExpressoRequest myRequest)
          Override to permit any logged in user.
static String str(String item)
          Make sure output strings are not empty for tables, and insure that anchor tags are completed.
 String strTrunc(String item, int max)
          Ensure a non-empty string (for <td columns), and also truncate as specified WHILE INSURING that an anchor link (<a ) is not cut in half.
static void trimAllTextFields(DBObject object)
           
 
Methods inherited from class com.jcorporate.expresso.core.controller.DBController
getString, isAllowed
 
Methods inherited from class com.jcorporate.expresso.core.controller.Controller
addFinalState, addPromptTransitions, addRegDomainParamtoSession, addRequestedURLtoSession, addState, addStatePairing, endTimer, execute, findControllerForm, generateToken, getActionForward, getControllerChainingTransition, getControllerSecurityTransition, getFinalState, getInitialState, getLogger, getParamValues, getRequestURL, getSchema, getSchemaHierarchy, getSchemaInstance, getSchemaStack, getState, getStates, getString, getString, getTitle, handleException, instantiate, isFinalState, isHandleState, isPromptState, isTokenValid, loadStateForm, newExpressoState, newState, nextHandleState, nextPromptState, populateStateForm, postPerform, prePerform, previousPromptState, processRequestTransitions, processTransitions, redirectRequest, redirectRequest, remapFromExtension, resetToken, saveToken, setControllerChainingTransition, setControllerSecurityTransition, setCurrentState, setInitialState, setSchema, setSchema, setupDefaultValues, setupReturnToSender, setupSubclassLog, transition, transition, transition, unloadStateForm
 
Methods inherited from class org.apache.struts.action.Action
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FOOTER

public static final String FOOTER
Footer constant.

See Also:
Constant Field Values

COLUMN

public static final String COLUMN
Column Constant.

See Also:
Constant Field Values

ROW_BLOCK

public static final String ROW_BLOCK
Row Block Constant.

See Also:
Constant Field Values

ROW

public static final String ROW
Row Constant.

See Also:
Constant Field Values

WARNING_LIST

public static final String WARNING_LIST
Constant for warning list location.

See Also:
Constant Field Values

COMMON_FOOTER_HANDLER

public static final String COMMON_FOOTER_HANDLER
Constant for common footer handler.

See Also:
Constant Field Values

COMMON_HEADER_HANDLER

public static final String COMMON_HEADER_HANDLER
Constant for common header handler.

See Also:
Constant Field Values

MAX_CHARS_OUTPUT

public static final int MAX_CHARS_OUTPUT
Limit number of chars that appear in display for a given field.

See Also:
Constant Field Values

SINGLE_TEXTAREA_NUM_LINES

public static final int SINGLE_TEXTAREA_NUM_LINES
Number of lines for a text area.

See Also:
Constant Field Values

MULTIPLE_TEXTAREA_NUM_LINES

public static final int MULTIPLE_TEXTAREA_NUM_LINES
Number of lines for multiple text area.

See Also:
Constant Field Values

TEXTAREA_NUM_COLS

public static final int TEXTAREA_NUM_COLS
Number of columns for a test area.

See Also:
Constant Field Values

MAX_TEXTAREA_LENGTH

public static final int MAX_TEXTAREA_LENGTH
Max Text Area Length constant.

See Also:
Constant Field Values

DELIMIT

public static final String DELIMIT
Delimiter constant.

See Also:
Constant Field Values

EDIT_GROUP_DISPLAY

public static final String EDIT_GROUP_DISPLAY
Jsp constant.

See Also:
Constant Field Values

EMBEDDED_MODE

public static final String EMBEDDED_MODE
Parameter to indicate 'embedded mode'. Most likely it will just need to be passed around to the save states. Necessary for 'view'

See Also:
Constant Field Values

REQUEST_CONTAINER

public static final String REQUEST_CONTAINER
Key where the RequestContainer is stored in the session.

See Also:
Constant Field Values

SESSION_CONTAINER

public static final String SESSION_CONTAINER
Key where the session container is stored.

See Also:
Constant Field Values
Constructor Detail

AbstractDBController

public AbstractDBController()
Method Detail

isValidAndPopulated

public boolean isValidAndPopulated(DBObject object,
                                   String[] requiredFields,
                                   String failureState,
                                   ExpressoRequest request,
                                   ExpressoResponse response)
                            throws ControllerException,
                                   DBException
Populates DBObject with any parameters which match field names. Will forward any validation errors to failureState

Parameters:
object - the DBObject to check
requiredFields - an array of strings that are required to check
failureState - the state to transition to on failure
request - the ExpressoRequest object
response - the ExpressoResponse object
Returns:
true if NO errors exist
Throws:
ControllerException - upon error.
DBException - upon database metadata access/validation error.

populateDBObject

public static void populateDBObject(DBObject obj,
                                    ExpressoRequest request)
                             throws DBException
fill in any fields found in request

Throws:
DBException

trimAllTextFields

public static void trimAllTextFields(DBObject object)
                              throws DBException
Throws:
DBException

str

public static String str(String item)
Make sure output strings are not empty for tables, and insure that anchor tags are completed.

Parameters:
item - the current value for the table.
Returns:
Resulting String.

stateAllowed

public boolean stateAllowed(String newState,
                            ExpressoRequest myRequest)
                     throws ControllerException
Override to permit any logged in user.

Overrides:
stateAllowed in class DBController
Parameters:
newState - The name of the new state that is being requested
myRequest - the ExpressoRequest object
Returns:
True if the state is permitted for this user, else false
Throws:
ControllerException - if another undefined error takes place while checking security.

outputXML

public void outputXML(org.dom4j.Document document,
                      ExpressoRequest request)
               throws IOException,
                      ControllerException
Output XML for given document.

Parameters:
document - The XML Document (Dom4J)
request - The ExpressoRequest object.
Throws:
IOException - upon io error.
ControllerException - upon error getting to the ServletResponse.

getPrettyXML

public static String getPrettyXML(org.dom4j.Element elem)
                           throws IOException
Get nicely formatted XML.

Parameters:
elem - The XML Element to pretty print.
Returns:
formatting String.
Throws:
IOException - upon printing exception.

postPerform

protected void postPerform(State nextState,
                           ExpressoRequest request,
                           ExpressoResponse response)
                    throws ControllerException
Template Method, allowing a subclass to into actions before any state in this controller is performed. For example, a common footer for web pages could be created here, so long as the web pages in question, with the common footer, were all in the same controller which overrides this method.

Overrides:
postPerform in class Controller
Parameters:
nextState - the state to be performed
request - the request object
response - the response object
Throws:
ControllerException - upon controller error.

isEmbeddedMode

public static boolean isEmbeddedMode(ExpressoRequest request)
Checks the controller request for the 'embedded mode' parameter. Embedded mode does not display any headers and footers and must be passed to other links and submit buttons.

Parameters:
request - ExpressoRequest the request parameters to query.
Returns:
boolean true if the embedded mode parameter is detected.

addEmbeddedParameter

public static Transition addEmbeddedParameter(Transition transitionToModify)
Adds the 'embedded mode' parameter to a transition.

Parameters:
transitionToModify - Transition
Returns:
Transition

addWarningList

protected List addWarningList(ExpressoRequest request)
Add list to request scope.

Parameters:
request - the ExpressoRequest object.
Returns:
list of warnings.

getWarningList

protected List getWarningList(ExpressoRequest request)
Get list from request scope.

Parameters:
request - The ExpressoRequest object.
Returns:
list, or null

addWarning

public void addWarning(ExpressoRequest request,
                       String s)
Adds warning to request scope, creating list if necessary.

Parameters:
request - The ExpressoRequest object.
s - the warning string.

getCheckbox

public static Input getCheckbox(String name,
                                String label,
                                String defVal,
                                boolean isSelected)
Get a checkbox with the given name, label, default value, and optionally select it.

Parameters:
name - The input's name.
label - The Input's label.
defVal - The default value.
isSelected - true if the checkbox is selected.
Returns:
and input of type checkbox

getTextArea

public static Input getTextArea(String name,
                                String defVal,
                                int rows,
                                int cols)
Get a text area with the given name and default value.

Parameters:
name - Name for the text area
defVal - Default value for the text area
rows - Rows for the text area
cols - Columns for the text area
Returns:
a text area with specified values

getTextArea

public static Input getTextArea(String name,
                                String defVal)
Get a text area with 4 rows and 40 columns.

Parameters:
name - Name for the text area
defVal - Default value for the text area
Returns:
a text area with 4 lines and 40 columns

getActionForwarding

protected String getActionForwarding(String forward,
                                     String state)
Look up the forward used for 'state' param, suitable for use with setStyle().

Parameters:
forward - default forwarding path to use in case none is found
state - final state for which forward is looked up
Returns:
forward for given state
See Also:
ExpressoResponse.setStyle(java.lang.String)

strTrunc

public String strTrunc(String item,
                       int max)
Ensure a non-empty string (for <td columns), and also truncate as specified WHILE INSURING that an anchor link (<a ) is not cut in half. (extend max if neccesary)

Parameters:
item - The item to parse
max - ?
Returns:
the modified string.

getPermsTrans

public Transition getPermsTrans(RowSecuredDBObject obj)
Retrieve the permission transition for the row secured dbobject.

Parameters:
obj - RowSecuredDBObject the object to get the transition for.
Returns:
Transition the transition for permissions.

prePerform

protected void prePerform(State nextState,
                          ExpressoRequest request,
                          ExpressoResponse response)
                   throws ControllerException
Template Method, allowing a subclass to do an action after any state in this controller is performed.

This implementation initializes any request-level services if needed.

Overrides:
prePerform in class Controller
Parameters:
nextState - the state to be performed
request - the request object
response - the response object
Throws:
ControllerException


Copyright © 2004-2006 Codeguild, Inc.. All Rights Reserved.