|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.hp.hpl.mesa.rdf.jena.rdb.DriverGenericGeneric
Base database driver for implementing ModelRDB and StoreRDB. Different drivers are needed for different databases and different layout schemes.
This driver is a base implemention from which database-specific drivers can inherit. It is not generic in the sense that it will work on any minimal SQL store and so should be treated as if it were an abstract class.
The SQL statements which implement each of the functions are
loaded in a separate file etc/[layout]_[database].sql from the classpath.
See SQLCache documentation for more information on the
format of this file.
| Field Summary | |
static java.lang.String |
ANON_NAMESPACE
Namesapce used to flag anonymous resources |
| Constructor Summary | |
DriverGenericGeneric()
Create a bare instance of the driver. |
|
| Method Summary | |
void |
addStatement(Statement s,
ModelRDB m)
Register a statement in the database. |
IDBID |
allocateModelID(java.lang.String modelName)
Allocate a new databaseID for a new model in the same database. |
void |
attachStore(StoreRDB store)
Register a store as a user of this driver. |
void |
cleanDB()
Remove all RDF information from a database. |
void |
clear(ModelRDB m)
Remove all the statements from the given model. |
void |
close()
Close the database connection. |
IConstraints |
createConstraints(ModelRDB model)
Create a constraint object appropriate for this type of database layout |
void |
deleteModel(java.lang.String modelName)
Delete the named from from within the database. |
boolean |
deleteStatement(IDBID statementID,
ModelRDB m)
Delete the statement in the model corresponding to the given statement ID |
boolean |
deleteStatement(Resource subject,
Property predicate,
RDFNode object,
ModelRDB m)
Delete the statements in the model which match the given subject, predicate object. |
void |
detachStore(StoreRDB store)
Notify that a store is no longer using this driver. |
void |
formatDB()
Initialise a database ready to store RDF tables. |
StatementImplRDB |
getBareStatementResource(IDBID id,
ModelRDB m)
Fetch a reiefied statement resource just knowing its resource rdb-id. |
java.sql.Connection |
getConnection()
Return the jdbc connection to the database, opening it if necessary |
Literal |
getLiteral(IDBID id)
Fetch a literal just knowing its literal rdb-id. |
Literal |
getLiteralFromCache(IDBID id)
Fetch a literal from the cache just knowing its literal rdb-id. |
IDBID |
getLiteralID(Literal l)
Return the database ID for the literal, if it exists |
IDBID |
getModelID(java.lang.String modelName)
Return the databaseID for an existing named model within the database. |
java.lang.String |
getNamespace(IDBID nsid)
Return the namespace string corresponding to a given namespace id. |
Property |
getProperty(IDBID id,
ModelRDB m)
Fetch a property just knowing its resource rdb-id. |
Property |
getProperty(java.lang.String uri,
ModelRDB m)
Fetch a property, knowing its uri. |
Property |
getPropertyFromCache(IDBID id,
ModelRDB m)
Fetch a property from the cache just knowing its resource rdb-id. |
Resource |
getResource(IDBID id,
ModelRDB m)
Fetch a resource just knowing its resource rdb-id. |
Resource |
getResource(java.lang.String uri,
ModelRDB m)
Fetch a resource, knowing its uri. |
Resource |
getResourceFromCache(IDBID id,
ModelRDB m)
Fetch a resource from the cache just knowing its resource rdb-id. |
IDBID |
getResourceID(Resource resource)
Lookup the unique ID for a resource. |
SQLCache |
getSQLCache()
Return the SQLCache used for database commands. |
void |
hintPropertyTable(Property p)
Hint to the store that the given property could be stored as an attribute table. |
boolean |
isDBFormatOK()
Check that the database has a legal set of RDF tables. |
boolean |
isStatementPresent(Resource subject,
Property predicate,
RDFNode object,
ModelRDB m)
Check if a statement is in the database. |
java.util.Iterator |
listModels()
List the names of all models in this database |
ResultSetIterator |
listNamespaces(ModelRDB m)
List all namespaces referenced in the model |
ResultSetIterator |
listReifiedStatements(ModelRDB m)
Return an iterator over all statements which are have been added as reified statements. |
ResultSetIterator |
listStatements(IConstraints constraints,
ModelRDB m)
List all the statements in the given moddel which make the given set of constraints (a constraint set can be obtained using createConstraints(com.hp.hpl.mesa.rdf.jena.rdb.ModelRDB)). |
ResultSetIterator |
listStatements(Resource subject,
Property predicate,
RDFNode object,
ModelRDB m)
List all the statements in the model which match the given subject, predicate object - each of which can be null (meaning wildcard). |
ResultSetIterator |
listSubjects(ModelRDB m)
List all the subject resources in the model |
void |
loadDatabaseDriver()
Force a load of the jdbc driver. |
void |
loadProperties(java.util.Properties props)
Load a set of configuration parameters into the driver. |
Property |
makeProperty(IDBID id,
java.lang.String localname,
IDBID nsid,
ModelRDB m)
Re-create a property from its local name and namespace identifier |
Resource |
makeResource(IDBID id,
java.lang.String localname,
IDBID nsid,
ModelRDB m)
Re-create a resource from its local name and namespace identifier |
Resource |
makeResource(IDBID id,
java.lang.String localname,
IDBID nsid,
ModelRDB m,
IDBID stmtID)
Re-create a resource from its local name and namespace identifier. |
void |
preloadCaches(ModelRDB m)
Preload the resource and literal caches with all data in the DB. |
void |
saveProperties()
Store the configuration parameters onto the database layout table in the attached database |
void |
setCacheLimits(int literalLimit,
int resourceLimit)
Set cache limits for caching resources and literals. |
void |
setConnection(IDBConnection dbcon)
Link an existing instance of the driver to a specific jdbc connection |
static int |
splitNamespace(java.lang.String uri)
Given a URI, determine the split point between the namespace part and the localname part. |
boolean |
supportsJenaReification()
Returns true if the database layout supports implicit reification of statements (i.e. |
boolean |
supportsMultipleModels()
Returns true of the database layout supports multiple RDF models in the same database. |
java.lang.String |
toString()
Printable name for the driver configuration |
IDBID |
wrapDBID(java.lang.Object id)
Convert the raw SQL object used to store a database identifier into a java object which meets the IDBID interface |
java.lang.Object |
wrapFlag(boolean flag)
Wrap up a boolean flag as a object which the jdbc driver can assert into a boolean/short column |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final java.lang.String ANON_NAMESPACE
| Constructor Detail |
public DriverGenericGeneric()
| Method Detail |
public void setConnection(IDBConnection dbcon)
throws RDFRDBException
setConnection in interface IRDBDriverRDFRDBException
public void close()
throws RDFRDBException
This closes all the prepared statements but will leave the jdbc connection itself alone.
close in interface IRDBDriverRDFRDBException - if there is an access problem
public java.sql.Connection getConnection()
throws RDFRDBException
getConnection in interface IRDBDriverRDFRDBExceptionpublic SQLCache getSQLCache()
getSQLCache in interface IRDBDriver
public boolean isDBFormatOK()
throws RDFRDBException
isDBFormatOK in interface IRDBDriverRDFRDBException - typtically due to internal programming errors, might trap
and change to logging operations in the future.
public void formatDB()
throws RDFRDBException
formatDB in interface IRDBDriverRDFRDBException - typtically due to internal programming errors, might trap
and change to logging operations in the future.public void cleanDB()
cleanDB in interface IRDBDriverpublic void loadProperties(java.util.Properties props)
loadProperties in interface IRDBDriver
public void saveProperties()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.String toString()
toString in class java.lang.Object
public void setCacheLimits(int literalLimit,
int resourceLimit)
setCacheLimits in interface IRDBDriverliteralLimit - limit on number of literals to cache
public void preloadCaches(ModelRDB m)
throws RDFException
There is an issue with reification support in here (isn't there always?!). To avoid having to revisit the database for every reified statement we create dummy StatementImplRDB's for all resources that are actually reified statements and then fix up the content of these dummies when the referenced statements are actually loaded. This is fine in the context of a "loadAll" command but if you try to use preloadCaches in any other situation this behaviour could leave the dangling reification references unless you are careful.
preloadCaches in interface IRDBDriverRDFExceptionpublic void attachStore(StoreRDB store)
attachStore in interface IRDBDriverpublic void detachStore(StoreRDB store)
detachStore in interface IRDBDriver
public void addStatement(Statement s,
ModelRDB m)
throws RDFException
addStatement in interface IRDBDriverRDFException
public ResultSetIterator listSubjects(ModelRDB m)
throws RDFRDBException
listSubjects in interface IRDBDriverm - the model whose subjects are to be listed
RDFRDBException
public ResultSetIterator listNamespaces(ModelRDB m)
throws RDFRDBException
listNamespaces in interface IRDBDriverRDFRDBException
public ResultSetIterator listStatements(Resource subject,
Property predicate,
RDFNode object,
ModelRDB m)
throws RDFException
listStatements in interface IRDBDriverRDFException
public boolean isStatementPresent(Resource subject,
Property predicate,
RDFNode object,
ModelRDB m)
throws RDFException
isStatementPresent in interface IRDBDriverRDFException
public ResultSetIterator listStatements(IConstraints constraints,
ModelRDB m)
throws RDFException
createConstraints(com.hp.hpl.mesa.rdf.jena.rdb.ModelRDB)).
listStatements in interface IRDBDriverRDFExceptionpublic IConstraints createConstraints(ModelRDB model)
createConstraints in interface IRDBDriver
public boolean deleteStatement(Resource subject,
Property predicate,
RDFNode object,
ModelRDB m)
throws RDFException
deleteStatement in interface IRDBDriverRDFException
public boolean deleteStatement(IDBID statementID,
ModelRDB m)
throws RDFException
deleteStatement in interface IRDBDriverRDFException
public void clear(ModelRDB m)
throws RDFRDBException
clear in interface IRDBDriverRDFRDBException
public Resource getResource(java.lang.String uri,
ModelRDB m)
throws RDFException
getResource in interface IRDBDriverRDFException
public Property getProperty(java.lang.String uri,
ModelRDB m)
throws RDFException
getProperty in interface IRDBDriverRDFExceptionpublic boolean supportsJenaReification()
supportsJenaReification in interface IRDBDriver
public ResultSetIterator listReifiedStatements(ModelRDB m)
throws RDFException
listReifiedStatements in interface IRDBDriverRDFExceptionpublic boolean supportsMultipleModels()
supportsMultipleModels in interface IRDBDriver
public IDBID allocateModelID(java.lang.String modelName)
throws RDFRDBException
allocateModelID in interface IRDBDriverRDFRDBException
public IDBID getModelID(java.lang.String modelName)
throws RDFRDBException
getModelID in interface IRDBDriverRDFRDBException
public void deleteModel(java.lang.String modelName)
throws RDFRDBException
deleteModel in interface IRDBDriverRDFRDBException
public java.util.Iterator listModels()
throws RDFRDBException
listModels in interface IRDBDriverRDFRDBException
public java.lang.String getNamespace(IDBID nsid)
throws RDFRDBException
getNamespace in interface IRDBDriverRDFRDBException
public Literal getLiteral(IDBID id)
throws RDFException
getLiteral in interface IRDBDriverRDFExceptionpublic Literal getLiteralFromCache(IDBID id)
getLiteralFromCache in interface IRDBDriver
public IDBID getLiteralID(Literal l)
throws RDFRDBException
getLiteralID in interface IRDBDriverRDFRDBException
public IDBID getResourceID(Resource resource)
throws RDFException
getResourceID in interface IRDBDriverRDFException
public Resource getResource(IDBID id,
ModelRDB m)
throws RDFException
getResource in interface IRDBDriverRDFException
public Resource getResourceFromCache(IDBID id,
ModelRDB m)
throws RDFException
getResourceFromCache in interface IRDBDriverRDFException
public Property getPropertyFromCache(IDBID id,
ModelRDB m)
throws RDFException
getPropertyFromCache in interface IRDBDriverRDFException
public StatementImplRDB getBareStatementResource(IDBID id,
ModelRDB m)
throws RDFException
getBareStatementResource in interface IRDBDriverRDFException
public Property getProperty(IDBID id,
ModelRDB m)
throws RDFException
getProperty in interface IRDBDriverRDFException
public IDBID wrapDBID(java.lang.Object id)
throws RDFRDBException
wrapDBID in interface IRDBDriverRDFRDBExceptionpublic java.lang.Object wrapFlag(boolean flag)
public Property makeProperty(IDBID id,
java.lang.String localname,
IDBID nsid,
ModelRDB m)
throws RDFException
makeProperty in interface IRDBDriverRDFException
public Resource makeResource(IDBID id,
java.lang.String localname,
IDBID nsid,
ModelRDB m)
throws RDFException
makeResource in interface IRDBDriverRDFException
public Resource makeResource(IDBID id,
java.lang.String localname,
IDBID nsid,
ModelRDB m,
IDBID stmtID)
throws RDFException
makeResource in interface IRDBDriverRDFException
public void loadDatabaseDriver()
throws RDFRDBException
RDFRDBException - if the driver fails to load
public void hintPropertyTable(Property p)
throws RDFException
hintPropertyTable in interface IRDBDriverRDFExceptionpublic static int splitNamespace(java.lang.String uri)
uri -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||