|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectEDU.utwente.CoCompose.util.Library
CoCompose component library based on a relational database.
Field Summary | |
static int |
ATLEAST
|
static int |
ATMOST
|
protected static java.sql.Connection |
conn
|
static java.lang.String |
databaseName
Constants |
static int |
INF_DEPTH
|
protected static java.io.PrintStream |
log
|
static java.lang.String |
tableLibraryFilename
|
static java.lang.String |
tablePropertiesFilename
|
static java.lang.String |
tableSavedQueriesFilename
|
static java.lang.String |
tableTaxonomyFilename
|
Constructor Summary | |
protected |
Library()
Singleton constructor |
Method Summary | |
protected void |
addFacets(java.lang.String uri,
java.util.Properties props)
Subfunction to add the facets from the given Properties object to the database |
java.lang.Object[] |
CRQLtoSQL(java.lang.String query,
java.util.AbstractMap propnames)
Translate CRQL to ordinary SQL |
void |
deleteQuery(java.lang.String name)
Delete a stored query (if found) |
void |
finalize()
|
java.util.AbstractMap |
findAtleastValues(java.lang.String propname,
java.lang.String propvalue,
int limit)
Find the legal values for an ATLEAST predicate |
java.util.AbstractMap |
findAtmostValues(java.lang.String propname,
java.lang.String propvalue,
int limit)
Find the legal values for an ATMOST predicate |
java.util.AbstractMap |
findOtherAtleastValues(java.lang.String propname,
java.lang.String propvalue,
int limit,
int depth)
Recursive companion of findAtleastValues |
java.util.AbstractMap |
findOtherAtmostValues(java.lang.String propname,
java.lang.String propvalue,
int limit,
int depth)
Recursive companion of findAtmostValues |
java.util.AbstractMap |
findTableNames(java.lang.String query)
Find the table names and the names of the properties they're used for |
static void |
getFileTree(java.io.File dir,
java.lang.String ext,
java.util.List result)
Get a file tree (files in given directory and all subdirs) |
void |
indexComponent(java.io.File file)
Indexes a single component |
void |
indexComponents()
(Re)Indexes all components |
protected void |
indexComposite(java.lang.String uri,
Composite c)
Subfunction to index the given Composite |
protected void |
indexConcept(java.lang.String uri,
Concept c)
Subfunction to index the given Concept |
protected void |
indexSolutionPattern(java.lang.String uri,
Model m)
Subfunction to index the given SolutionPattern (or plain vanilla Model) |
static Library |
instance()
Singleton accessor; initialises library when first accessed |
java.lang.String |
loadQuery(java.lang.String name)
Retrieve a saved query with a given name. |
static void |
main(java.lang.String[] args)
Stand-alone debugging method |
java.util.Vector |
query(java.lang.String expression)
Execute a CRQL query, returning the complete result table in the format of sqlQuery. |
double |
rank(java.lang.String id,
java.util.List predicates)
Rank a single result |
double |
rankOne(java.lang.String id,
java.lang.String propname,
java.util.AbstractMap values)
Rank a single property of a single result |
void |
refreshComponents(boolean updateAll)
|
void |
saveQuery(java.lang.String name,
java.lang.String query)
Save a given query in the database |
void |
setLog(java.io.PrintStream stream)
Use a different log stream |
protected void |
setupTables()
Create the DB tables (if necessary, for example when first used), and connect them to their physical (text) files. |
void |
shutdown()
Closes database connection |
java.lang.String |
singleCRQLtoSQL(java.lang.String propname,
int type,
java.lang.String propvalue,
int limit)
Generate translated SQL for a single CRQL predicate |
java.util.Vector |
sqlQuery(java.lang.String expression)
Execute a query in SQL and return the results as a Vector of rows A row is represented as a Vector of String The first entry contains the table names The rest of the rows contain the table's contents |
java.util.Vector |
sqlQuerySimple(java.lang.String expression,
java.lang.String colname)
Execute a SQL query, returning a single column |
void |
sqlUpdate(java.lang.String expression)
Execute a SQL command that doesn't return any useful results, like INSERT or DELETE |
void |
sqlUpdateBlind(java.lang.String expression)
Identical in behaviour to sqlUpdate, but ignores any exceptions. |
int |
tableSize(java.lang.String name)
Check how many rows the given table contains, and if it exists |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String databaseName
public static final java.lang.String tableLibraryFilename
public static final java.lang.String tablePropertiesFilename
public static final java.lang.String tableTaxonomyFilename
public static final java.lang.String tableSavedQueriesFilename
public static final int INF_DEPTH
public static final int ATLEAST
public static final int ATMOST
protected static java.sql.Connection conn
protected static java.io.PrintStream log
Constructor Detail |
protected Library()
Method Detail |
public static void main(java.lang.String[] args)
args
- Command-line argumentspublic java.util.AbstractMap findAtleastValues(java.lang.String propname, java.lang.String propvalue, int limit)
propname
- The property's namepropvalue
- The property's ideal valuelimit
- Maximal search depth (may be INF_DEPTH)
public java.util.AbstractMap findOtherAtleastValues(java.lang.String propname, java.lang.String propvalue, int limit, int depth)
public java.util.AbstractMap findAtmostValues(java.lang.String propname, java.lang.String propvalue, int limit)
propname
- The property's namepropvalue
- The property's ideal valuelimit
- Maximal search depth (may be INF_DEPTH)
public java.util.AbstractMap findOtherAtmostValues(java.lang.String propname, java.lang.String propvalue, int limit, int depth)
public java.lang.String singleCRQLtoSQL(java.lang.String propname, int type, java.lang.String propvalue, int limit)
propname
- The property's nametype
- The kind of predicate (ATLEAST or ATMOST)propvalue
- The property's ideal valuelimit
- The maximal search depth (may be INF_DEPTH)
public java.util.AbstractMap findTableNames(java.lang.String query)
query
- A query in CRQL
public java.lang.Object[] CRQLtoSQL(java.lang.String query, java.util.AbstractMap propnames)
query
- The input querypropnames
- A map (table name --> property name), as given by findTableNames
public double rank(java.lang.String id, java.util.List predicates)
id
- The URI of the resultpredicates
- A list of predicates (as returned by CRQLtoSQL)
public double rankOne(java.lang.String id, java.lang.String propname, java.util.AbstractMap values)
id
- The URI of the resultpropname
- The property's namevalues
- A map (property value --> depth)
public java.util.Vector query(java.lang.String expression)
public java.util.Vector sqlQuery(java.lang.String expression)
public static Library instance()
public void shutdown()
public void finalize() throws java.lang.Throwable
java.lang.Throwable
public void setLog(java.io.PrintStream stream)
stream
- The stream receiving the logging information, eg. System.outpublic void deleteQuery(java.lang.String name)
name
- The query's namepublic void saveQuery(java.lang.String name, java.lang.String query)
name
- The name you want to give to the query (avoid spaces and the like!)query
- The query itselfpublic java.lang.String loadQuery(java.lang.String name)
name
- The query's name
public void sqlUpdate(java.lang.String expression) throws java.sql.SQLException
expression
- A SQL expression
java.sql.SQLException
- if an error occurs while updatingpublic void sqlUpdateBlind(java.lang.String expression)
expression
- A SQL expressionsqlUpdate(String)
public java.util.Vector sqlQuerySimple(java.lang.String expression, java.lang.String colname)
expression
- The query
public void indexComponents()
public void refreshComponents(boolean updateAll)
updateAll
- If true, all components are indexed, otherwise only
the modified components are updatedpublic static void getFileTree(java.io.File dir, java.lang.String ext, java.util.List result)
dir
- The topmost directoryext
- The suffix of the valid files (e.g. ".xml")result
- The resulting list of filenamespublic void indexComponent(java.io.File file)
file
- The XML file containing the component
protected void indexComposite(java.lang.String uri, Composite c)
uri
- The Composite's filenamec
- The Composite to indexprotected void indexConcept(java.lang.String uri, Concept c)
uri
- The concept's filenamec
- The concept to indexprotected void indexSolutionPattern(java.lang.String uri, Model m)
uri
- The solution's filenamem
- The solution to indexprotected void addFacets(java.lang.String uri, java.util.Properties props)
uri
- The filenameprops
- The Properties object containing the facetsprotected void setupTables()
public int tableSize(java.lang.String name)
name
- The table name to check
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |