com.ibm.etill.framework.xdm
Class QueryRequest

com.ibm.etill.framework.xdm.QueryRequest
All Implemented Interfaces:
QueryRequestConstants
Direct Known Subclasses:
PaymentSystemQueryRequest

public abstract class QueryRequest
implements QueryRequestConstants

An abstract base class for all of the query request objects. The QueryRequest object encapsulates the standard parameters that are required for all queries on Payment Server objects.

Its direct known subclasses are AccountQueryRequest, CassetteQueryRequest, ErrorQueryRequest, EventListenerQueryRequest, FinancialObjectQueryRequest, MerchantQueryRequest, PayServerQueryRequest, PaymentSystemQueryRequest.

Cassettes extend this class to build their own classes which perform database query. A substantial amount of cassette processing is centered around getting and using persistent objects data.


Inner Class Summary
protected  class QueryRequest.QueryCondition
          An inner class used to build a query condition.
 
Field Summary
protected  Vector objects
          A vector to hold PSServerObjects objects.
protected static int QueryRequestAll
           
protected  int resultCount
           
protected  Integer returnAtMost
           
protected static String RS_COUNT
           
 
Fields inherited from interface com.ibm.etill.framework.xdm.QueryRequestConstants
DTD_SIZE, QUERY_ACCOUNTNUMBER, QUERY_AMOUNTEXP10, QUERY_APPROVESALLOWED, QUERY_BATCHNUMBER, QUERY_BEGINTIME, QUERY_BRAND, QUERY_CASSETTENAME, QUERY_CLOSEALLOWED, QUERY_CLOSEBEGINTIME, QUERY_CLOSEENDTIME, QUERY_CREATEBEGINTIME, QUERY_CREATEENDTIME, QUERY_CREDITNUMBER, QUERY_CURRENCY, QUERY_DTDPATH, QUERY_ENDTIME, QUERY_EVENTTYPE, QUERY_FILTER, QUERY_KEYSONLY, QUERY_LISTENERURL, QUERY_MAX_KEYS_TO_RETURN, QUERY_MAX_OBJECTS_TO_RETURN, QUERY_MAXAMOUNT, QUERY_MAXAPPROVEAMOUNT, QUERY_MAXDEPOSITAMOUNT, QUERY_MAXUNAPPROVEDAMOUNT, QUERY_MERCHANTNUMBER, QUERY_MINAMOUNT, QUERY_MINAPPROVEAMOUNT, QUERY_MINDEPOSITAMOUNT, QUERY_MINUNAPPROVEDAMOUNT, QUERY_MODIFYBEGINTIME, QUERY_MODIFYENDTIME, QUERY_OPENBEGINTIME, QUERY_OPENENDTIME, QUERY_ORDERDATA1, QUERY_ORDERNUMBER, QUERY_PAYMENTNUMBER, QUERY_PAYMENTTYPE, QUERY_PURGEALLOWED, QUERY_REFERENCENUMBER, QUERY_RETURNATMOST, QUERY_ROLE, QUERY_STATE, QUERY_STATUS, QUERY_TIMEREGISTERED, QUERY_TRANSACTIONID, QUERY_USERNAME, QUERY_VERSION, QUERY_WITHCREDITS, QUERY_WITHORDERS, QUERY_WITHPAYMENTS
 
Constructor Summary
protected QueryRequest(int kind)
          Constructor used to retrieveAll Admin queries
protected QueryRequest(QueryRequest originalRequest)
          A copy constructor for Payment/Credit queries within OrderQuery
  QueryRequest(String command, Hashtable keywords, Hashtable srcMapping)
          A constructor with parameters
 
Method Summary
protected abstract  String fromClause()
           
 int getApproximateXDMSize()
          Sums the approximate sizes of all of the PSServerObjects contained in the QueryRequest
protected  Boolean getBooleanParameter(String keyword)
          Returns true or false value from a boolean parameter.
protected  String[] getCassetteListParameter(String keyword)
          Returns an array of strings from a cassette list parameter.
protected  String getCassetteParameter(String keyword)
          Returns a string value from a cassette parameter.
 String getCommand()
          Gets the QueryRequest command.
protected  Short getCurrencyParameter(String keyword)
          Returns a Short value from a currency parameter.
 String getDTDPath()
          Gets the value of the DTD Path.
protected  Integer[] getIntegerListParameter(String keyword)
          Returns an array of Integer values from an integer list parameter.
protected  Integer getIntegerParameter(String keyword)
          Returns an Integer value from an integer parameter.
 boolean getKeysOnly()
          Gets the boolean value indicating whether the request is for keys only or not.
 Hashtable getKeywords()
          Gets the hash table of keywords.
protected  Long getLongParameter(String keyword)
          Returns a long value from a long parameter.
protected  Integer getMaxObjectsToReturn()
          Gets the maximum number of objects to be returned in the query request.
protected  Integer[] getNonNegativeIntegerListParameter(String keyword)
          Returns an array of Integer values from non-negative integer list parameter.
protected  Integer getNonNegativeIntegerParameter(String keyword)
          Returns an array of Integer values from non-negative integer parameter.
protected  String[] getNumericTokenListParameter(String keyword)
          Returns a list of string from numeric token list parameters.
protected  String getNumericTokenParameter(String keyword)
          Returns a string from a numeric token parameter.
 Vector getObjects()
          Gets the PSServerObjects objects.
 QueryRequest getOriginalRequest()
          Gets the original request.
 int getResultCount()
          Gets a count of this query result.
protected  Integer getReturnAtMost()
          Retrieves the maximum number of objects to be returned in the query request.
protected  Short getShortParameter(String keyword)
          Returns a Short value from a short parameter.
 boolean getShowSensitiveData()
          Indicates whether this request should return the cassette's sensitive data to the user or hide it by masking with asterisks.
protected  String[] getStringListParameter(String keyword)
          Returns a list of string list parameters.
protected  String getStringParameter(String keyword)
          Returns a string parameter value.
protected  Timestamp getTimestampParameter(String keyword)
          Returns a Timestamp value from a timestamp parameter.
protected static void initializeSrcMapping(Hashtable srcMapping)
          Initializes the srcMapping hash table.
protected  String orderBy()
           
protected abstract  int processQueryResults(ResultSet resultSet)
           
protected  void query()
          Builds the query statement and executes the SQL query command.
 void queryCassettes(Vector allObjectsList)
          Builds a hash table mapping payment type to a vector of PSServerObject.
protected abstract  String selectStatement()
          These are abstract methods used to build a query statement.
protected abstract  String tableName()
           
protected  void validateAmounts(String minKeyword, Integer minAmount, String maxKeyword, Integer maxAmount)
          Returns an array of Integer values from an integer list parameter.
protected  void validateModifiers()
          Validates constrained parameters.
protected  void validateTimeInterval(String beginKeyword, Timestamp beginTime, String endKeyword, Timestamp endTime)
          Returns an array of Integer values from an integer list parameter.
abstract  String whereCondition()
           
 

Field Detail

resultCount

protected int resultCount

returnAtMost

protected Integer returnAtMost

objects

protected Vector objects
A vector to hold PSServerObjects objects.

RS_COUNT

protected static final String RS_COUNT

QueryRequestAll

protected static final int QueryRequestAll
Constructor Detail

QueryRequest

public QueryRequest(String command,
                    Hashtable keywords,
                    Hashtable srcMapping)
             throws com.ibm.etill.framework.payapi.ETillAbortOperation
A constructor with parameters
Parameters:
command - a string representing the query command which is one of the constants defined in PaymentServletConstants and PaymentCommandConstants
keywords - a hash table of query key words; for example, RC_MERCHANTNUMBER
srcMapping - a hash table of keywords and requests return codes mapping
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if catastrophic errors are encountered

QueryRequest

protected QueryRequest(QueryRequest originalRequest)
A copy constructor for Payment/Credit queries within OrderQuery
Parameters:
originalRequest - a QueryRequest to be cloned

QueryRequest

protected QueryRequest(int kind)
Constructor used to retrieveAll Admin queries
Parameters:
kind - an unused integer value representing kind of request
Method Detail

getObjects

public Vector getObjects()
Gets the PSServerObjects objects.
Returns:
objects a list of PSServerObjects objects

getApproximateXDMSize

public int getApproximateXDMSize()
Sums the approximate sizes of all of the PSServerObjects contained in the QueryRequest
Returns:
size an integer representing the result of adding these PSServerObjects objects in bytes

getCommand

public String getCommand()
Gets the QueryRequest command.
Returns:
String the query command

getKeywords

public Hashtable getKeywords()
Gets the hash table of keywords.
Returns:
keywords The hash table.

getDTDPath

public String getDTDPath()
Gets the value of the DTD Path.
Returns:
String The DTD path.

getReturnAtMost

protected Integer getReturnAtMost()
Retrieves the maximum number of objects to be returned in the query request.
Returns:
returnAtMost an Integer representing the maximun number of obejcts to return

getKeysOnly

public boolean getKeysOnly()
Gets the boolean value indicating whether the request is for keys only or not.
Returns:
boolean TRUE if keys only and FALSE otherwise.

getShowSensitiveData

public boolean getShowSensitiveData()
Indicates whether this request should return the cassette's sensitive data to the user or hide it by masking with asterisks. This indicator is based on the SensitiveAccessLevel configuration parameter.
Returns:
boolean TRUE if user's role allows access to sensitive data, FALSE otherwise.

getResultCount

public int getResultCount()
Gets a count of this query result.
Returns:
int the number of rows returned in the query result

getOriginalRequest

public QueryRequest getOriginalRequest()
Gets the original request.
Returns:
originalRequest a QueryRequest object

getMaxObjectsToReturn

protected Integer getMaxObjectsToReturn()
Gets the maximum number of objects to be returned in the query request.
Returns:
Integer returns returnAtMost if not null else the constant QUERY_MAX_KEYS_TO_RETURN if KeysOnly flag is set otherwise QUERY_MAX_OBJECTS_TO_RETURN is returned

validateModifiers

protected void validateModifiers()
                          throws com.ibm.etill.framework.payapi.ETillAbortOperation
Validates constrained parameters.
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if number of objects to return is less than 0 or greater than QUERY_MAX_KEYS_TO_RETURN
See Also:
QueryRequestConstants

getStringListParameter

protected String[] getStringListParameter(String keyword)
                                   throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns a list of string list parameters.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
result an array of string values that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

getStringParameter

protected String getStringParameter(String keyword)
                             throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns a string parameter value.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
result a string value that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

getNumericTokenListParameter

protected String[] getNumericTokenListParameter(String keyword)
                                         throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns a list of string from numeric token list parameters.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
resultStrings an array of string values that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

getNumericTokenParameter

protected String getNumericTokenParameter(String keyword)
                                   throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns a string from a numeric token parameter.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
result a string value that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

getCassetteListParameter

protected String[] getCassetteListParameter(String keyword)
                                     throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns an array of strings from a cassette list parameter.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
resultStrings a string value that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

getCassetteParameter

protected String getCassetteParameter(String keyword)
                               throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns a string value from a cassette parameter.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
result a string value that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

getLongParameter

protected Long getLongParameter(String keyword)
                         throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns a long value from a long parameter.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
result a long value that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

getIntegerListParameter

protected Integer[] getIntegerListParameter(String keyword)
                                     throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns an array of Integer values from an integer list parameter.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
results a Integer value that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

getIntegerParameter

protected Integer getIntegerParameter(String keyword)
                               throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns an Integer value from an integer parameter.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
result an Integer value that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

getNonNegativeIntegerListParameter

protected Integer[] getNonNegativeIntegerListParameter(String keyword)
                                                throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns an array of Integer values from non-negative integer list parameter.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
results an Integer value that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

getNonNegativeIntegerParameter

protected Integer getNonNegativeIntegerParameter(String keyword)
                                          throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns an array of Integer values from non-negative integer parameter.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
result an Integer value that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

getShortParameter

protected Short getShortParameter(String keyword)
                           throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns a Short value from a short parameter.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
result a Short value that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

getCurrencyParameter

protected Short getCurrencyParameter(String keyword)
                              throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns a Short value from a currency parameter. The value is validated against currency code length constraints.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
result a Short value that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

getBooleanParameter

protected Boolean getBooleanParameter(String keyword)
                               throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns true or false value from a boolean parameter.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
result a value of true if the string value is 1 or false if string value is 0
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

getTimestampParameter

protected Timestamp getTimestampParameter(String keyword)
                                   throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns a Timestamp value from a timestamp parameter. The result is validated against an upper bound timestamp. If the upper bound time is exceeded an error condition is thrown.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
result a Timestamp value that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

validateAmounts

protected void validateAmounts(String minKeyword,
                               Integer minAmount,
                               String maxKeyword,
                               Integer maxAmount)
                        throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns an array of Integer values from an integer list parameter.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
results a Integer value that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

validateTimeInterval

protected void validateTimeInterval(String beginKeyword,
                                    Timestamp beginTime,
                                    String endKeyword,
                                    Timestamp endTime)
                             throws com.ibm.etill.framework.payapi.ETillAbortOperation
Returns an array of Integer values from an integer list parameter.
Parameters:
keyword - a string to be matched with entries in the keywords hash table
Returns:
results a Integer value that matched the keyword
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during the processing

initializeSrcMapping

protected static void initializeSrcMapping(Hashtable srcMapping)
Initializes the srcMapping hash table.
Parameters:
srcMapping - a hash table of query commands and return codes.

selectStatement

protected abstract String selectStatement()
These are abstract methods used to build a query statement. The implementation of these methods must be provided by the subclass. That is, if you extend the QueryRequest class.

tableName

protected abstract String tableName()

fromClause

protected abstract String fromClause()

whereCondition

public abstract String whereCondition()

orderBy

protected String orderBy()

processQueryResults

protected abstract int processQueryResults(ResultSet resultSet)
                                    throws com.ibm.etill.framework.payapi.ETillAbortOperation

query

protected void query()
              throws com.ibm.etill.framework.payapi.ETillAbortOperation
Builds the query statement and executes the SQL query command.
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if an error is encountered during processing

queryCassettes

public void queryCassettes(Vector allObjectsList)
                    throws com.ibm.etill.framework.payapi.ETillAbortOperation
Builds a hash table mapping payment type to a vector of PSServerObject.

For each cassette, build a CassetteQuery by querying the cassette for its objects. The output from this query is usually combined with non-cassette specific information to form a query result.

Parameters:
allObjectsList - a vector of PSSeverObject
Throws:
com.ibm.etill.framework.payapi.ETillAbortOperation - thrown if unrecoverable error is encountered