|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectproject.biota.biotaInterface.BiotaRequestHandler
BiotaRequestHandler is an abstract class extended by classes that wish to handle
requests for a particular type of resources. For example, class
BiotaServerRequestHandler
extends this class to handle DiGIR requests
for resources served via a 4D Server, while class BiotaWebRequestHandler
extends this class to handle DiGIR requests for resources served via a Biota
onboard Web Server.
This class provides the commom functionality of all DiGIR query handlers, such as processing the query arguments and building responses.
BiotaDefaultHandler
,
BiotaServerRequestHandler
,
BiotaWebRequestHandler
Field Summary | |
protected Namespace |
conceptualSchemaNamespace
The JDOM Namespace for the conceptual schema used in the DiGIR request. |
protected String |
conceptualSchemaURI
The URI for the conceptual schema used in the DiGIR request. |
protected SimpleDateFormat |
formatter
Format a Java date to conform the XML schema dateTime data type. |
protected String |
left_index
A parameter indicates the left-hand side argument in a binary logical relationship like "and". |
protected static Logger |
logger
The Apache log4j Logger object for this class. |
protected int |
maxDepth
The maximum depth of the query structure. |
protected int |
maxlevel
A parameter indicates the level of the query structure. |
protected DiGIRRequestParser |
requestParser
The DiGIRRequestParser that parses the request. |
protected Set |
requiredConcepts
A set of schema concepts required to build the DiGIR response. |
protected Map |
requiredTablesFields
Maps database tables to a set of fields in that table that are mapped to the schema concepts. |
protected Element |
responseRecords
The JDOM Element that holds the records for the DiGIR response. |
protected String |
right_index
A parameter indicates the right-hand side argument in a binary logical relationship like "and". |
protected ResourceObject |
rscObject
An object that holds all the information for the requested resource. |
Constructor Summary | |
BiotaRequestHandler(DiGIRRequestParser parser)
Constructs a BiotaRequestHandler to handle a DiGIR request. |
Method Summary | |
protected Element |
addRecordConceptElem(RecordConcept recordConcept,
Object fieldsValues)
Constructs a JDOM element for each record concept and checks whether the it is a complex concept that contains a sequence of schema/complex concept. |
protected abstract void |
buildDiGIRResult(String filterString)
Makes database queries and processes the response returned by the database to build the records for the DiGIR response. |
Element |
buildResult()
Returns a JDOM element of the records for the DiGIR response. |
protected void |
createInventoryResponseElem(Map resultMap)
Creates all the "record" JDOM element for a DiGIR response to a inventory request. |
protected void |
findRequiredTablesFields()
Finds the database tables/fields that are required to build the DiGIR response. |
protected abstract String |
getConceptValue(String conceptName,
Object fieldsValues)
Constructs the value for a schema concept from the fieldsValues
object. |
protected String |
getQueryString(String filter)
Processes the string representation of the DiGIR request filter contents to a string that has the depth info of the structure, and replaces the schema concept to whatever database tables/fields that concept maps to. |
protected String |
parseValue(project.biota.resource.Field field,
String value)
Extracts the value from a string for a field that needs parsing using the separator(parseSymbol) and position(pos) specified for that field in the resource's configuaration file. |
protected abstract void |
updateResourceMetadata(ResourceObject rscObj)
Updates the metadata for the resource specified by the ResourceObject object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected DiGIRRequestParser requestParser
protected Element responseRecords
protected int maxlevel
protected int maxDepth
protected String left_index
protected String right_index
protected String conceptualSchemaURI
protected Namespace conceptualSchemaNamespace
protected ResourceObject rscObject
protected Set requiredConcepts
protected Map requiredTablesFields
protected SimpleDateFormat formatter
protected static Logger logger
Constructor Detail |
public BiotaRequestHandler(DiGIRRequestParser parser)
parser
- the DiGIRRequestParser that parses the DiGIR requestMethod Detail |
public Element buildResult()
buildDiGIRResult()
method to build a JDOM element that contains
the query result.
buildDiGIRResult(String)
protected abstract void buildDiGIRResult(String filterString)
Subclasses of BiotaRequestHandler need to implement this method. Different types of resources require different codes to make the database connection. For example, a resource hosted in a 4D Server requires a JDBC conncetion while a resource hosted in a Biota onboard Web Server reqireds a HTTP connection.
filterString
- the string representation of the filter in the DiGIR requestprotected abstract void updateResourceMetadata(ResourceObject rscObj)
Subclasses of BiotaRequestHandler need to implement this method to query
the resource about its total number of records and the date the resource is
last updated and call ResourceObject.setNumberOfRecords()
method and
ResourceObject.setDateLastUpdated()
on the ResourceObject object
that represents the requested resource.
rscObj
- the ResourceObject object that represents a resourceResourceObject.setNumberOfRecords(int)
,
ResourceObject.setDateLastUpdated(String)
protected abstract String getConceptValue(String conceptName, Object fieldsValues)
fieldsValues
object. Subclasses of BiotaRequestHandler need to implement this method to
extract value from a collection of database field values returned from the
resource. This method needs to implement ways to build the concept value from
multiple database fields or to call parseValue()
method when a
field needs parsing.
conceptName
- the name for the schema conceptfieldsValues
- a collection of field values for one record
parseValue(Field, String)
protected String getQueryString(String filter)
((Concpet_A EQUALS Value_A AND Concept_B EQUALS Value_B ) OR Concept_C NOTEQUALS Value_C)
will be processed to
0a( 1a( 2a([field_A_table]field_A=value_A)2a or 2b([field_B_table]field_B=value_B)2b )1a or 1b([field_C_table]field_C=value_C)1b )0a
It returns an empty string if the content of the DiGIR filter is empty.
protected void findRequiredTablesFields()
protected String parseValue(project.biota.resource.Field field, String value)
position >= (value.split(separator)).length
field
- the Field that needs parsingvalue
- the string that contains the value for the field
protected Element addRecordConceptElem(RecordConcept recordConcept, Object fieldsValues)
getConceptValue()
method to find the value for that concept. It then
checks check whether the value is null. If so, it sets the xsi:nil attribute of
that concept element to "true".
recordConcept
- a concept specified by the record schema in the DiGIR requestfieldsValues
- a collection of field values for one record
getConceptValue(String, Object)
protected void createInventoryResponseElem(Map resultMap)
resultMap
- a Java Map object mapping each concept value to its count
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |