|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--edu.ucsb.adl.bucket99.PythonQueryTranslator
Query translator that translates queries by executing a Python
script. The script is loaded once (only) and the vocabularies
associated with hierarchical buckets, i.e., an object of Java type
Vocabulary[], is bound to Python variable
vocabularies. To translate a query, the translator
binds the query's root constraint node to Python variable
constraint, the query's ranking method (or
None if not present) to Python variable
rankingMethod, and the query's result limit (or -1 if
not present) to Python variable maximumResults, and
invokes Python function translate(). The function
should return either an SQL query as a string if successful, or a
MiddlewareException (specifically, an
UnsupportedException or an
InternalErrorException) if not. Any exception thrown
by the Python interpreter itself is treated as an
InternalErrorException.
This class reads the following properties from Bucket99
configuration files. Property values may be indirectly specified
using the notation @P where P is the
name of another property (see ExtendedProperties for more information).
translator.script
translator.python_module_path
/python/modules:../python/lib". The pathlist is
appended to Python's python.path registry variable.
Directories that are not absolute are interpreted relative to the
directory containing the Bucket99 configuration file. (Note: this
property is in addition to property jython.module_path
in the main middleware configuration file.)
translator.python_class_path
../../../classes". Directories that are not absolute
are interpreted relative to the directory containing the Bucket99
configuration file. (Note: this property is in addition to
property jython.class_path in the main middleware
configuration file.)
translator.python_jar_path
../../../lib". Directories that are not absolute are
interpreted relative to the directory containing the Bucket99
configuration file. (Note: this property is in addition to
property jython.jar_path in the main middleware
configuration file.)
translator.vocabularies
TYPES,FORMATS".
.class
edu.ucsb.adl.bucket99.DatabaseCodedVocabulary".
$Log: PythonQueryTranslator.java,v $
Revision 1.8 2007/02/14 22:11:21 gjanee
The query ranking method and result limit are now passed to the
Python script.
Revision 1.7 2004/09/23 17:20:44 gjanee
Rewrite to use class
edu.ucsb.adl.middleware.ExtendedProperties.
Revision 1.6 2004/09/14 21:20:54 gjanee
Added some documentation.
Revision 1.5 2002/09/28 21:15:33 gjanee
Configuration file renames. Renamed the Bucket99 configuration
file to bucket99.conf.
Revision 1.4 2001/10/14 14:27:52 gjanee
To get the Jython implementation of Python to work when the
middleware is packaged as a JAR file within a web application,
added the translator.python_class_path and
translator.python_jar_path properties. Renamed the
translator.python_path property to
translator.python_module_path.
Revision 1.3 2001/10/10 03:01:20 gjanee
Added the translator.python_path property.
Revision 1.2 2001/10/09 20:36:27 gjanee
Added support for relative filenames.
Revision 1.1 2000/10/15 02:35:33 gjanee
Initial revision
| Method Summary | |
static edu.ucsb.adl.bucket99.PythonQueryTranslator |
createTranslator(edu.ucsb.adl.middleware.ExtendedProperties propertyList)
Creates a PythonQueryTranslator. |
void |
destroy()
Frees all resources held by the translator. |
static void |
main(java.lang.String[] args)
Test driver. |
java.lang.String |
translate(edu.ucsb.adl.middleware.Query query)
Translates a query to SQL. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static edu.ucsb.adl.bucket99.PythonQueryTranslator createTranslator(edu.ucsb.adl.middleware.ExtendedProperties propertyList)
throws InternalErrorException
PythonQueryTranslator.
propertyList - The source for the above-mentioned properties.
PythonQueryTranslator.
InternalErrorException - If any error is encountered.
public java.lang.String translate(edu.ucsb.adl.middleware.Query query)
throws MiddlewareException
translate in interface QueryTranslatorquery - The query.
UnsupportedException - If the query is not supported.
InternalErrorException - If any other error occurs.
MiddlewareExceptionpublic void destroy()
destroy in interface QueryTranslator
public static void main(java.lang.String[] args)
throws java.io.IOException,
MiddlewareException
java.io.IOException
MiddlewareException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||