edu.ucsb.adl.bucket99
Class DatabaseCodedVocabulary

java.lang.Object
  |
  +--edu.ucsb.adl.bucket99.DatabaseCodedVocabulary
All Implemented Interfaces:
Vocabulary

public final class DatabaseCodedVocabulary
extends java.lang.Object
implements Vocabulary

A vocabulary that is stored in a database, and which translates terms to sets of integer codes.

This class reads the following properties from Bucket99 configuration files given property name prefix X. Property values may be indirectly specified using the notation @P where P is the name of another property (see ExtendedProperties for more information).

X.name
The vocabulary's name, e.g., "ADL Feature Type Thesaurus".
X.bucket
The bucket the vocabulary is used for, e.g., "types".
X.vocabulary_database_driver_class
The fully-qualified name of the vocabulary database's driver class, e.g., "com.informix.jdbc.IfxDriver".
X.vocabulary_database_url
The vocabulary database's connection URL.
X.vocabulary_database_properties
The name of a Java properties file containing vocabulary database connection properties, or the string "none". If the filename is not absolute, it is interpreted relative to the directory containing the Bucket99 configuration file.
X.term_code_query
An SQL query of the form "select term, code from table" in which term, a non-null string, is a vocabulary term and code, a non-null integer, is a code associated with the term. The relationship between terms and codes may be many to many.
X.code_graph_query
Either the string "none" or an SQL query of the form "select code, subcode from table" in which code and subcode, both non-null integers, are vocabulary codes. If a query is specified, the returned rows define a directed graph of codes, and the graph is used to recursively augment the term-code associations established by X.term_code_query above. Specifically, if term T is associated with code C, and if S is a subcode of C, then T is also associated with S.
X.code_usage_query
Either the string "none" or an SQL query of the form "select code from table" in which code, a non-null integer, is a vocabulary code. If a query is specified, it defines the codes that actually occur in the collection, and term-code associations are limited to these codes.
X.usage_database_driver_class
If X.code_usage_query is not "none", the fully-qualified name of the usage database's driver class, e.g., "com.informix.jdbc.IfxDriver".
X.usage_database_url
If X.code_usage_query is not "none", the usage database's connection URL.
X.usage_database_properties
If X.code_usage_query is not "none", the name of a Java properties file containing usage database connection properties, or the string "none". If the filename is not absolute, it is interpreted relative to the directory containing the Bucket99 configuration file.

Version:
$Header: /export/home/gjanee/bucket99/edu/ucsb/adl/bucket99/RCS/DatabaseCodedVocabulary.java,v 1.4 2004/09/23 17:25:44 gjanee Exp $

$Log: DatabaseCodedVocabulary.java,v $ Revision 1.4 2004/09/23 17:25:44 gjanee
Rewrite to use class edu.ucsb.adl.middleware.ExtendedProperties.

Revision 1.3 2002/09/28 21:14:13 gjanee
Configuration file renames. Renamed the Bucket99 configuration file to bucket99.conf.

Revision 1.2 2002/09/26 16:38:26 gjanee
Added support for a separate Java properties file containing database connection properties. Added properties X.vocabulary_database_properties and X.usage_database_properties.

Revision 1.1 2000/10/17 05:08:23 gjanee
Initial revision

Author:
Greg Janée
Alexandria Digital Library

Method Summary
static edu.ucsb.adl.bucket99.DatabaseCodedVocabulary createVocabulary(edu.ucsb.adl.middleware.ExtendedProperties propertyList, java.lang.String prefix)
          Creates a DatabaseCodedVocabulary.
 void destroy()
          Frees all resources held by the vocabulary.
 java.lang.String getBucket()
          Returns the bucket the vocabulary is used for.
 java.lang.String getName()
          Returns the vocabulary's name.
 boolean isValidTerm(java.lang.String term)
          Tests if a term is a valid term in the vocabulary.
static void main(java.lang.String[] args)
          Test driver.
 java.lang.Object translateTerm(java.lang.String term)
          Translates a term into an array of zero or more integer codes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createVocabulary

public static edu.ucsb.adl.bucket99.DatabaseCodedVocabulary createVocabulary(edu.ucsb.adl.middleware.ExtendedProperties propertyList,
                                                                             java.lang.String prefix)
                                                                      throws InternalErrorException
Creates a DatabaseCodedVocabulary.

Parameters:
propertyList - The source for the above-mentioned properties.
prefix - The property name prefix.
Returns:
A DatabaseCodedVocabulary.
Throws:
InternalErrorException - If any error occurs.

getName

public java.lang.String getName()
Returns the vocabulary's name.

Specified by:
getName in interface Vocabulary
Returns:
The vocabulary's name, e.g., "ADL Feature Type Thesaurus".

getBucket

public java.lang.String getBucket()
Returns the bucket the vocabulary is used for.

Specified by:
getBucket in interface Vocabulary
Returns:
The bucket name, e.g., "types".

isValidTerm

public boolean isValidTerm(java.lang.String term)
Tests if a term is a valid term in the vocabulary.

Specified by:
isValidTerm in interface Vocabulary
Parameters:
term - The term.
Returns:
true if the term is valid.

translateTerm

public java.lang.Object translateTerm(java.lang.String term)
Translates a term into an array of zero or more integer codes.

Specified by:
translateTerm in interface Vocabulary
Parameters:
term - The term.
Returns:
An array of one or more integer codes, or an empty array if the term is valid but does not occur in the collection, or null if the term is invalid.

destroy

public void destroy()
Frees all resources held by the vocabulary.

Specified by:
destroy in interface Vocabulary

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        InternalErrorException
Test driver.

java.io.IOException
InternalErrorException