edu.lehigh.swat.hawk.storage.simpledb
Class DatabaseStorage

java.lang.Object
  extended by edu.lehigh.swat.hawk.storage.StorageModel
      extended by edu.lehigh.swat.hawk.storage.PersistentStorageModel
          extended by edu.lehigh.swat.hawk.storage.simpledb.DatabaseStorage
Direct Known Subclasses:
DldbStorage, PerDbStorage

public class DatabaseStorage
extends PersistentStorageModel


Field Summary
protected  java.util.Hashtable cachedDocs
           
protected  java.sql.Connection con
           
protected  java.lang.String dbName
           
protected  java.lang.String emptyTableState
           
protected  java.util.Hashtable knownDocs
           
protected  java.util.Hashtable knownOntos
           
protected  java.util.Hashtable knownUrls
           
protected  java.util.Hashtable loadedDocs
           
protected  int loadedTripleNum
           
protected  int maxUrlNum
           
protected  int ontSeqNum
           
protected  java.util.Hashtable propertyTypes
           
protected  boolean queryOnly
           
protected  java.lang.String queryOnto
           
protected  int sourceSeqNum
           
protected  java.sql.Statement stmt
           
 
Constructor Summary
DatabaseStorage(java.lang.String DBName)
          Constructor.
 
Method Summary
 void addDocument(Document d)
          Add a document to this model.
 void clearViewDefinitions()
           
 void close()
          Close the database connection.
 Document createDocument()
          Create an Document object.
 void createKb()
          Initialize the database.
 Ontology createOntology()
          Create an Ontology object.
 int[] decideCommitOnto(Document doc, ObjectId id)
          Decide which ontology would commit to giving the resource doc and objectId.
protected  void flushLoadedDocs()
           
 void forcedExit()
          Forced exit.
 java.lang.String getDBName()
          Get the database name.
 Document getDocument(java.lang.String url)
          Get the specified document.
 java.util.Iterator getDocumentIterator()
          Get all the documents in the model.
 java.util.Hashtable getKnownOntologies()
          retrieval ontologies already exist in database
 java.util.Hashtable getKnownUrls()
          Retrieval Urls already exist in database
 int getOntSeq(java.lang.String ns)
          Get the sequence number for giving ontology.
 java.util.Hashtable getPropertyTypes()
          Get the types of properties.
 java.lang.String getQueryOntology()
          Get the query ontology.
 int getSeqNum(DocId did)
          Get the sequence number for giving Document
 void getSourceNum()
          Get the maximum source sequence number in the databade.
 java.sql.Statement getStatement()
          Get the sql statement.
 java.lang.String getTableName(ObjectId id)
          Get the table name for giving id.
 java.util.Hashtable getUpdatedViewDefs()
           
protected  int getUrlIndex(java.lang.String url)
          Get the index for given uri.
 java.lang.String getViewDefinition(java.lang.String vName)
          Get sql definition for giving view name.
 ResultSet issueQuery(Query qry)
          Execute query and return results.
 ResultSet issueQuery(SparqlQuery query)
          Execute query and return results.
 void open()
          Open a connection to the database.
 void open(boolean readOnly)
          open kb with arguments
 void pushImports(Ontology ont)
          Add imports objects to ontology, for the use of memory-based storage model.
 void setConnection(java.sql.Connection Conn)
          Sets the connection to the database.
 void setImplictImports(boolean imp)
          Set whether or not include implictly imported documents.
 void setKnownOntologies(java.util.Hashtable KnownOntos)
          Sets the hashtable that contains the known ontologies.
 void setQueryOntology(java.lang.String uri)
          Set the query ontology.
 void setViewDefinition(java.lang.String vName, java.lang.String vDef)
           
 void storeOntology(Ontology ontd)
           
 void updateDocument(Document d)
          Update a document.
 void updatePropertyTypes()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ontSeqNum

protected int ontSeqNum

sourceSeqNum

protected int sourceSeqNum

maxUrlNum

protected int maxUrlNum

knownOntos

protected java.util.Hashtable knownOntos

knownDocs

protected java.util.Hashtable knownDocs

knownUrls

protected java.util.Hashtable knownUrls

propertyTypes

protected java.util.Hashtable propertyTypes

dbName

protected java.lang.String dbName

queryOnto

protected java.lang.String queryOnto

con

protected java.sql.Connection con

stmt

protected java.sql.Statement stmt

cachedDocs

protected java.util.Hashtable cachedDocs

loadedDocs

protected java.util.Hashtable loadedDocs

emptyTableState

protected java.lang.String emptyTableState

loadedTripleNum

protected int loadedTripleNum

queryOnly

protected boolean queryOnly
Constructor Detail

DatabaseStorage

public DatabaseStorage(java.lang.String DBName)
Constructor.

Parameters:
DBName -
Method Detail

open

public void open()
Open a connection to the database.

Specified by:
open in class PersistentStorageModel

open

public void open(boolean readOnly)
open kb with arguments


close

public void close()
Close the database connection.

Specified by:
close in class PersistentStorageModel

getStatement

public java.sql.Statement getStatement()
Get the sql statement.


flushLoadedDocs

protected void flushLoadedDocs()

storeOntology

public void storeOntology(Ontology ontd)

addDocument

public void addDocument(Document d)
Add a document to this model.

Specified by:
addDocument in class StorageModel

getDocument

public Document getDocument(java.lang.String url)
Get the specified document.

Specified by:
getDocument in class StorageModel

updateDocument

public void updateDocument(Document d)
Update a document.

Specified by:
updateDocument in class StorageModel

getDocumentIterator

public java.util.Iterator getDocumentIterator()
Get all the documents in the model.

Specified by:
getDocumentIterator in class StorageModel

setImplictImports

public void setImplictImports(boolean imp)
Set whether or not include implictly imported documents.

Specified by:
setImplictImports in class StorageModel

createOntology

public Ontology createOntology()
Create an Ontology object.

Specified by:
createOntology in class StorageModel

createDocument

public Document createDocument()
Create an Document object.

Specified by:
createDocument in class StorageModel

getKnownOntologies

public java.util.Hashtable getKnownOntologies()
retrieval ontologies already exist in database


getSourceNum

public void getSourceNum()
Get the maximum source sequence number in the databade.


createKb

public void createKb()
Initialize the database. Create the index tables and utility tables.


getTableName

public java.lang.String getTableName(ObjectId id)
Get the table name for giving id.


getKnownUrls

public java.util.Hashtable getKnownUrls()
Retrieval Urls already exist in database


getUrlIndex

protected int getUrlIndex(java.lang.String url)
Get the index for given uri.


getSeqNum

public int getSeqNum(DocId did)
Get the sequence number for giving Document


setViewDefinition

public void setViewDefinition(java.lang.String vName,
                              java.lang.String vDef)

getUpdatedViewDefs

public java.util.Hashtable getUpdatedViewDefs()

clearViewDefinitions

public void clearViewDefinitions()

getViewDefinition

public java.lang.String getViewDefinition(java.lang.String vName)
Get sql definition for giving view name.


getOntSeq

public int getOntSeq(java.lang.String ns)
Get the sequence number for giving ontology.


forcedExit

public void forcedExit()
Forced exit.


issueQuery

public ResultSet issueQuery(Query qry)
Execute query and return results.


issueQuery

public ResultSet issueQuery(SparqlQuery query)
Execute query and return results.


getPropertyTypes

public java.util.Hashtable getPropertyTypes()
Get the types of properties.


updatePropertyTypes

public void updatePropertyTypes()

decideCommitOnto

public int[] decideCommitOnto(Document doc,
                              ObjectId id)
Decide which ontology would commit to giving the resource doc and objectId.


setQueryOntology

public void setQueryOntology(java.lang.String uri)
Set the query ontology.


getQueryOntology

public java.lang.String getQueryOntology()
Get the query ontology.


getDBName

public java.lang.String getDBName()
Get the database name.


setKnownOntologies

public void setKnownOntologies(java.util.Hashtable KnownOntos)
Sets the hashtable that contains the known ontologies.

Parameters:
KnownOntos - the hashtable of known ontologies

setConnection

public void setConnection(java.sql.Connection Conn)
                   throws java.sql.SQLException
Sets the connection to the database.

Parameters:
Conn - a Connection object.
Throws:
java.sql.SQLException

pushImports

public void pushImports(Ontology ont)
Add imports objects to ontology, for the use of memory-based storage model.

Specified by:
pushImports in class StorageModel
Parameters:
ont - Ontology