gr.forth.ics.rssdb.storage
Class DBStorage

java.lang.Object
  |
  +--gr.forth.ics.rssdb.storage.DBStorage
Direct Known Subclasses:
SpecReprDBStorage

public abstract class DBStorage
extends java.lang.Object

This is the main class required for the storage of RDF descriptions. For every different DB representation, a class that extends the class DBStorage should be implemented.

Version:
2.0 (23 July 2003)
Author:
Sofia Alexaki

Field Summary
protected  java.sql.Connection con
           
static java.lang.String DATA_PROPERTY
          The name of the table in which are stored all data properties
static int EMPTY
          Indicates that db is empty
static java.lang.String ENUMERATION_ELEMENT_PROPERTY
           
 HierarchyLabel hlabel
           
static java.lang.String RDFSUITE_NS
          The name of the table in which are stored all data properties
protected  int repr
          Indicates the representation under which the RDF descriptions will be stored
protected  java.util.HashMap resourcesIDs
           
static int SPECIFIC
          Represents the Specific representation suitable for ORDBMS
static int SPECIFIC_NOSUBTABLE
          Represents the variation of Specific representation suitable for RDBMS.
static int SPECIFIC_UNIQUETABLE
          Represents the variation of Specific representation where a unique table is created for all classes and a unique table for each property type
 java.sql.Statement stmt
           
protected  gr.forth.ics.vrp.corevrp.model.RDF_DAG subclass_dag
          Contains the RDF classes of the VRP model in hierarchical order.
protected  gr.forth.ics.vrp.corevrp.model.RDF_DAG subproperty_dag
          Contains the RDF properties of the VRP model in hierarchical order.
 gr.forth.ics.vrp.corevrp.model.Model VRPModel
          VRP Model of RDF descriptions.
 
Constructor Summary
DBStorage()
           
 
Method Summary
static void closeConnection(java.sql.Connection con)
           
protected  void commitTransaction()
           
protected abstract  boolean existMultipleLevelClassifiedResource()
          Checks if there are resources in the db that are stored both at schema and data level.
 java.sql.Connection getConnection()
           
 boolean getCreateIndex()
           
 java.lang.String getCurrentNS()
          Returns the current namespace URI
static int getDBMSRepresentation(java.lang.String dbURL, java.util.Properties prop)
          Returns the type of the db Representation (SPECIFIC, SPECIFIC_NOSUBTABLE, SPECIFIC_UNIQUETABLE, EMPTY)
 int[] getDomainRangeTypeIds(gr.forth.ics.vrp.corevrp.model.RDF_Property rdf_property)
          Returns an array
 DBStoragePanel getGUI()
           
 int getMaxLiteralLength()
          Returns the maximum length of a literal value
 int getMaxLpartLength()
          Returns
 int getMaxPrefixLength()
          Returns the maximum length of a namespace URI(e.g., http://www.w3.org/1999/XMLSchema-datatypes)
 int getMaxURILength()
          Returns the maximum length of the URI of a resource
 int getNamespaceID(java.lang.String ns)
          Returns the db id of the namespace
 boolean getNewData()
           
 boolean getNewSchema()
           
 int getNextAnonID()
           
 int getNextNSID()
           
 int getNextThesTypeEnumID()
           
 java.lang.String getOutFile()
          Returns the output file
 StorageOutput getOutput()
           
 boolean getPermitSchemaRendundancies()
          Returns true if we permit Rendundant information in the schema to be stored, otherwise false.
 java.lang.String getPropertyTableID(gr.forth.ics.vrp.corevrp.model.RDF_Property rdf_property)
           
 int getRepr()
          Returns the representation under which the RDF descriptions will be stored
 int getResourceID(java.lang.String resource_uri)
          Returns the DBMS identifier of the resource.
 java.util.HashMap getResourceIDs()
           
 int[] getResourceLabel(java.lang.String resource_uri)
          Returns the post number and the index of the .
 java.lang.String getResourceURI(int id)
          Returns the URI identifier of the resource.
 java.sql.Statement getStatement()
           
(package private)  void getStatistics(gr.forth.ics.vrp.corevrp.model.Model outModel, gr.forth.ics.vrp.corevrp.model.RDF_DAG class_dag, gr.forth.ics.vrp.corevrp.model.RDF_DAG property_dag)
          Prints statistics
 boolean getStoredData()
           
 java.util.ArrayList getStoredNS()
          Contains the URIs namespace of the stored schemas
 boolean getStoredSchema()
           
 boolean getVerbose()
           
 gr.forth.ics.vrp.corevrp.model.Model getVRPModel()
          Returns the VRP Model of the RDF descriptions
static int getXMLSchemaDTID(java.lang.String xmlSchemaDT_uri)
          Returns the DBMS identifier of the xml datatype.
static int getXMLSchemaDTRQLID(java.lang.String xmlSchemaDT_uri)
           
protected abstract  void initPreparedStatements()
          Initialize prepared statements used for the storage
 void initResourceIDs()
           
 boolean isHierarchyDAG()
          Returns true if the stored class/metaclass/property hierarchies are dags.
static void isJDBCDriverAccessible()
           
static boolean isXMLSchemaDTID(int id)
           
static java.sql.Connection openConnection(java.lang.String dbURL, java.util.Properties prop)
           
 void rollbackTransaction()
          Rollback the transaction
 void setAuthentication(java.lang.String log, java.lang.String pass)
          Sets your login and password.
 void setCreateIndex(boolean b)
           
 void setDBFunctionsPath(java.lang.String dbfunctionsPath)
          Sets the path for the rql-spi-api.so path.
 void setDomainRangeTypeIds(gr.forth.ics.vrp.corevrp.model.RDF_Property rdf_property, int[] dRType)
           
 void setGUI(DBStoragePanel gui)
           
 void setHierarchyDAG(boolean b)
          Sets the type (i.e., dag or tree) of the class/metaclass/property hierarchy.
 void setMaxLiteralLength(int len)
          Sets the maximum length of a literal value
 void setMaxLpartLength(int len)
          Sets the maximum length of a class or property name (e.g., Artist)
 void setMaxPrefixLength(int len)
          Sets the maximum length of a namespace URI(e.g., http://www.w3.org/1999/XMLSchema-datatypes)
 void setMaxURILength(int len)
          Sets the maximum length of the URI of a resource
 void setModelStatistics(int i, boolean b)
          Set the desired model statistics setModelStatistics(0, true): Prints the number of triples, RDF class, properties, containers, statements and resources found in the input file setModelStatistics(1, true): For subclass hierarchy, prints the number of classes contained, the average/maximum number of subclasses and the average/maximum number length of the paths setModelStatistics(2, true): similar to setModelStatistics(1, true) for property hierachy setModelStatistics(3, true): Prints the number of instances per classes setModelStatistics(4, true): Similar to setModelStatistics(1, true) but prints the statistics for every subclass hierarchy setModelStatistics(5, true): Similar to setModelStatistics(2, true) but prints the statistics for every subproperty hierarchy and not totally
 void setModifiedNamespace(java.lang.String modifiedNS)
          Set the namespace you wish to be stored in the db for the input local file/thesaurus
 void setNewData(boolean b)
          Validation and Storage of data descriptions is performed.
 void setNewSchema(boolean b)
          Validation and storage of schema descriptions of a new RDF schema.
 void setOutFile(java.lang.String file)
          Sets the output file
 void setPropertyTableID(gr.forth.ics.vrp.corevrp.model.RDF_Property rdf_property, java.lang.String tableID)
           
 void setResourceID(java.lang.String resource_uri, int[] label)
          Sets the DBMS identifier of the resource
 void setResourceIDs(java.util.HashMap hm)
           
 void setResourceURI(int id, java.lang.String resource_uri)
          Sets the URI identifier of the resource
 void setStoredData(boolean b)
          Validation and Storage of data descriptions is performed.
 void setStoredSchema(boolean b)
          Validation and storage of schema descriptions of a new RDF schema.
 void setTimeStatistics(boolean b)
          Enable the time statistics for validation and storage
 void setVerbose(boolean b)
          Prints messages about the actions that are being performed by the RSSDB and the descriptions are being stored.
protected  boolean store(java.lang.String input, java.lang.String dbPath)
          Validates and store RDF descriptions.
protected abstract  int storeClass(DBValidator dbv)
          Stores classes
protected abstract  void storeClassDescriptions()
          Stores classes data descriptions
protected abstract  int storeMetaClass()
          Stores metaclasses
protected  void storePrimitiveFunctions(java.sql.Statement stmt)
          Stores the primitive functions
protected abstract  void storePrimitiveSchema()
          Stores primitive schema
protected abstract  int storeProperty(DBValidator dbv)
          Stores properties
protected abstract  void storePropertyLinks()
          Stores property data descriptions
protected abstract  void storeResource()
          Stores data resources
protected  boolean storeThesaurus(java.lang.String input, java.lang.String dbPath)
          Stores thesauri that conform to the CWTH DTD.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPECIFIC

public static final int SPECIFIC
Represents the Specific representation suitable for ORDBMS

SPECIFIC_NOSUBTABLE

public static final int SPECIFIC_NOSUBTABLE
Represents the variation of Specific representation suitable for RDBMS. No subtable relations are defined between the tables of metaclasses, classes or properties.

SPECIFIC_UNIQUETABLE

public static final int SPECIFIC_UNIQUETABLE
Represents the variation of Specific representation where a unique table is created for all classes and a unique table for each property type

EMPTY

public static final int EMPTY
Indicates that db is empty

DATA_PROPERTY

public static final java.lang.String DATA_PROPERTY
The name of the table in which are stored all data properties

RDFSUITE_NS

public static final java.lang.String RDFSUITE_NS
The name of the table in which are stored all data properties

ENUMERATION_ELEMENT_PROPERTY

public static final java.lang.String ENUMERATION_ELEMENT_PROPERTY

repr

protected int repr
Indicates the representation under which the RDF descriptions will be stored

con

protected java.sql.Connection con

stmt

public java.sql.Statement stmt

hlabel

public HierarchyLabel hlabel

resourcesIDs

protected java.util.HashMap resourcesIDs

VRPModel

public gr.forth.ics.vrp.corevrp.model.Model VRPModel
VRP Model of RDF descriptions.

subclass_dag

protected gr.forth.ics.vrp.corevrp.model.RDF_DAG subclass_dag
Contains the RDF classes of the VRP model in hierarchical order.

subproperty_dag

protected gr.forth.ics.vrp.corevrp.model.RDF_DAG subproperty_dag
Contains the RDF properties of the VRP model in hierarchical order.
Constructor Detail

DBStorage

public DBStorage()
Method Detail

setGUI

public void setGUI(DBStoragePanel gui)

getGUI

public DBStoragePanel getGUI()

getConnection

public java.sql.Connection getConnection()

getStatement

public java.sql.Statement getStatement()

setDBFunctionsPath

public void setDBFunctionsPath(java.lang.String dbfunctionsPath)
Sets the path for the rql-spi-api.so path.

setOutFile

public void setOutFile(java.lang.String file)
Sets the output file

getOutFile

public java.lang.String getOutFile()
Returns the output file

getOutput

public StorageOutput getOutput()

setVerbose

public void setVerbose(boolean b)
Prints messages about the actions that are being performed by the RSSDB and the descriptions are being stored.

getVerbose

public boolean getVerbose()

setCreateIndex

public void setCreateIndex(boolean b)

getCreateIndex

public boolean getCreateIndex()

setTimeStatistics

public void setTimeStatistics(boolean b)
Enable the time statistics for validation and storage

getMaxURILength

public int getMaxURILength()
Returns the maximum length of the URI of a resource

setMaxURILength

public void setMaxURILength(int len)
Sets the maximum length of the URI of a resource

getMaxLiteralLength

public int getMaxLiteralLength()
Returns the maximum length of a literal value

setMaxLiteralLength

public void setMaxLiteralLength(int len)
Sets the maximum length of a literal value

getMaxPrefixLength

public int getMaxPrefixLength()
Returns the maximum length of a namespace URI(e.g., http://www.w3.org/1999/XMLSchema-datatypes)

setMaxPrefixLength

public void setMaxPrefixLength(int len)
Sets the maximum length of a namespace URI(e.g., http://www.w3.org/1999/XMLSchema-datatypes)

getMaxLpartLength

public int getMaxLpartLength()
Returns

setMaxLpartLength

public void setMaxLpartLength(int len)
Sets the maximum length of a class or property name (e.g., Artist)

getStoredNS

public java.util.ArrayList getStoredNS()
Contains the URIs namespace of the stored schemas

getVRPModel

public gr.forth.ics.vrp.corevrp.model.Model getVRPModel()
Returns the VRP Model of the RDF descriptions

getResourceIDs

public java.util.HashMap getResourceIDs()

setResourceIDs

public void setResourceIDs(java.util.HashMap hm)

getCurrentNS

public java.lang.String getCurrentNS()
Returns the current namespace URI

setModifiedNamespace

public void setModifiedNamespace(java.lang.String modifiedNS)
Set the namespace you wish to be stored in the db for the input local file/thesaurus
Parameters:
modifiedNS - The namespace that will be stored in the db for the input local file/thesaurus

initResourceIDs

public void initResourceIDs()

setNewSchema

public void setNewSchema(boolean b)
Validation and storage of schema descriptions of a new RDF schema.

getNewSchema

public boolean getNewSchema()

setStoredSchema

public void setStoredSchema(boolean b)
Validation and storage of schema descriptions of a new RDF schema. Set this option in case the input namespace has already been stored. Updates made on the schema will be reported and if all of them are consistent (e.g., refinements to stored classes/properties) they will be stored. In case the input namespace has not already been stored this option is equivalent to the 'newSchema' one.

getStoredSchema

public boolean getStoredSchema()

setNewData

public void setNewData(boolean b)
Validation and Storage of data descriptions is performed. Data validation should be based only on data descriptions found in current namespace. Checks for redundant information are disabled.

getNewData

public boolean getNewData()

getRepr

public int getRepr()
Returns the representation under which the RDF descriptions will be stored

isHierarchyDAG

public boolean isHierarchyDAG()
Returns true if the stored class/metaclass/property hierarchies are dags. If they are trees, returns false.

setHierarchyDAG

public void setHierarchyDAG(boolean b)
Sets the type (i.e., dag or tree) of the class/metaclass/property hierarchy.
Parameters:
b - if the hierarchies are DAGS b should be true. If the hierarchies are treis b should be false.

getPermitSchemaRendundancies

public boolean getPermitSchemaRendundancies()
Returns true if we permit Rendundant information in the schema to be stored, otherwise false. For the time being we doesn't permit Rendundant information
Returns:
 

setStoredData

public void setStoredData(boolean b)
Validation and Storage of data descriptions is performed. Data validation should be based also on data descriptions stored in the DB. Checks for redundant information are enabled.

getStoredData

public boolean getStoredData()

setModelStatistics

public void setModelStatistics(int i,
                               boolean b)
Set the desired model statistics
  1. setModelStatistics(0, true): Prints the number of triples, RDF class, properties, containers, statements and resources found in the input file
  2. setModelStatistics(1, true): For subclass hierarchy, prints the number of classes contained, the average/maximum number of subclasses and the average/maximum number length of the paths
  3. setModelStatistics(2, true): similar to setModelStatistics(1, true) for property hierachy
  4. setModelStatistics(3, true): Prints the number of instances per classes
  5. setModelStatistics(4, true): Similar to setModelStatistics(1, true) but prints the statistics for every subclass hierarchy
  6. setModelStatistics(5, true): Similar to setModelStatistics(2, true) but prints the statistics for every subproperty hierarchy and not totally

getNamespaceID

public int getNamespaceID(java.lang.String ns)
                   throws java.sql.SQLException
Returns the db id of the namespace

getDBMSRepresentation

public static int getDBMSRepresentation(java.lang.String dbURL,
                                        java.util.Properties prop)
                                 throws java.sql.SQLException,
                                        java.lang.ClassNotFoundException
Returns the type of the db Representation (SPECIFIC, SPECIFIC_NOSUBTABLE, SPECIFIC_UNIQUETABLE, EMPTY)

getXMLSchemaDTID

public static int getXMLSchemaDTID(java.lang.String xmlSchemaDT_uri)
Returns the DBMS identifier of the xml datatype.

isXMLSchemaDTID

public static boolean isXMLSchemaDTID(int id)

getXMLSchemaDTRQLID

public static int getXMLSchemaDTRQLID(java.lang.String xmlSchemaDT_uri)

getNextAnonID

public int getNextAnonID()

getNextNSID

public int getNextNSID()

getNextThesTypeEnumID

public int getNextThesTypeEnumID()

setAuthentication

public void setAuthentication(java.lang.String log,
                              java.lang.String pass)
Sets your login and password.
Parameters:
login - as a postgreSQL user
pass - password as a postgreSQL user

setResourceID

public void setResourceID(java.lang.String resource_uri,
                          int[] label)
Sets the DBMS identifier of the resource

getResourceID

public int getResourceID(java.lang.String resource_uri)
Returns the DBMS identifier of the resource.

getResourceLabel

public int[] getResourceLabel(java.lang.String resource_uri)
Returns the post number and the index of the .
Returns:
and int array which contains the the post number and the index of the . Returns null if the resource is not found.

getDomainRangeTypeIds

public int[] getDomainRangeTypeIds(gr.forth.ics.vrp.corevrp.model.RDF_Property rdf_property)
Returns an array
Parameters:
rdf_property -  
Returns:
 

setDomainRangeTypeIds

public void setDomainRangeTypeIds(gr.forth.ics.vrp.corevrp.model.RDF_Property rdf_property,
                                  int[] dRType)

setPropertyTableID

public void setPropertyTableID(gr.forth.ics.vrp.corevrp.model.RDF_Property rdf_property,
                               java.lang.String tableID)

getPropertyTableID

public java.lang.String getPropertyTableID(gr.forth.ics.vrp.corevrp.model.RDF_Property rdf_property)

setResourceURI

public void setResourceURI(int id,
                           java.lang.String resource_uri)
Sets the URI identifier of the resource

getResourceURI

public java.lang.String getResourceURI(int id)
Returns the URI identifier of the resource.

commitTransaction

protected void commitTransaction()
                          throws java.sql.SQLException

rollbackTransaction

public void rollbackTransaction()
                         throws java.sql.SQLException
Rollback the transaction

isJDBCDriverAccessible

public static void isJDBCDriverAccessible()
                                   throws java.lang.ClassNotFoundException

openConnection

public static java.sql.Connection openConnection(java.lang.String dbURL,
                                                 java.util.Properties prop)
                                          throws java.sql.SQLException

closeConnection

public static void closeConnection(java.sql.Connection con)
                            throws java.sql.SQLException

existMultipleLevelClassifiedResource

protected abstract boolean existMultipleLevelClassifiedResource()
                                                         throws java.sql.SQLException
Checks if there are resources in the db that are stored both at schema and data level.

storePrimitiveSchema

protected abstract void storePrimitiveSchema()
                                      throws java.sql.SQLException
Stores primitive schema

storeMetaClass

protected abstract int storeMetaClass()
                               throws java.sql.SQLException
Stores metaclasses

storeClass

protected abstract int storeClass(DBValidator dbv)
                           throws java.sql.SQLException
Stores classes

storeClassDescriptions

protected abstract void storeClassDescriptions()
                                        throws java.sql.SQLException
Stores classes data descriptions

storeProperty

protected abstract int storeProperty(DBValidator dbv)
                              throws java.sql.SQLException
Stores properties

storePropertyLinks

protected abstract void storePropertyLinks()
                                    throws java.sql.SQLException
Stores property data descriptions

storeResource

protected abstract void storeResource()
                               throws java.sql.SQLException
Stores data resources

initPreparedStatements

protected abstract void initPreparedStatements()
                                        throws java.sql.SQLException
Initialize prepared statements used for the storage

storePrimitiveFunctions

protected void storePrimitiveFunctions(java.sql.Statement stmt)
                                throws java.sql.SQLException
Stores the primitive functions

getStatistics

void getStatistics(gr.forth.ics.vrp.corevrp.model.Model outModel,
                   gr.forth.ics.vrp.corevrp.model.RDF_DAG class_dag,
                   gr.forth.ics.vrp.corevrp.model.RDF_DAG property_dag)
Prints statistics

storeThesaurus

protected boolean storeThesaurus(java.lang.String input,
                                 java.lang.String dbPath)
Stores thesauri that conform to the CWTH DTD. It considers that thesaurus is valid.
Parameters:
input - the thesaurus file.
dbPath - The database URL. The format is: <postgreSQL server>:<port>/<dbname> postgreSQL server: The machine where postgreSQL server is running. port: The port where postgreSQL server is running. dbname: database name, e.g., athena.ics.forth.gr:8080/testdb
Returns:
True if the thesaurus has been stored in the db, otherwise returns false

store

protected boolean store(java.lang.String input,
                        java.lang.String dbPath)
Validates and store RDF descriptions.
Parameters:
input - The file or the URL you want to store (e.g., http://www.ics.forth.gr/isl/RDF/VRP/Examples/cweb.rdf).
dbPath - The database URL. The format is: <postgreSQL server>:<port>/<dbname> postgreSQL server: The machine where postgreSQL server is running. port: The port where postgreSQL server is running. dbname: database name, e.g., athena.ics.forth.gr:8080/testdb
Returns:
True if the file is valid and has been stored in the db, otherwise returns false