gr.forth.ics.rdfsuite.swkm.model.db.impl
Class RDFDB_Model

java.lang.Object
  extended by gr.forth.ics.rdfsuite.swkm.model.impl.RDF_Model
      extended by gr.forth.ics.rdfsuite.swkm.model.db.impl.RDFDB_Model
All Implemented Interfaces:
IRDFDB_Model, IRDF_Model

public class RDFDB_Model
extends RDF_Model
implements IRDFDB_Model


Field Summary
static int EMPTY
          Indicates that db is empty
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
 
Fields inherited from class gr.forth.ics.rdfsuite.swkm.model.impl.RDF_Model
available_streams, class_dag, class_instances, comments, comments_hashed_on_object, comments_hashed_on_subject_object, containers, domains, domains_hashed_on_object, domains_hashed_on_subject_object, fetch_all_ns, graphspaces, hlabel, isdefinedbys, isdefinedbys_hashed_on_object, isdefinedbys_hashed_on_subject_object, label_created, labels, labels_hashed_on_object, labels_hashed_on_subject_object, literals, log, members, members_hashed_on_object, members_hashed_on_subject_object, meta_class_dag, meta_property_dag, monitor, namespaces, objects, objects_hashed_on_object, objects_hashed_on_subject_object, PLAIN_TRIPLES, predicates, predicates_hashed_on_object, predicates_hashed_on_subject_object, predicatesMaps, property_dag, property_instances, property_instances_hashed_on_all, property_instances_hashed_on_object, property_instances_hashed_on_predicate_object, property_instances_hashed_on_subject, property_instances_hashed_on_subject_object, property_instances_hashed_on_subject_predicate, ranges, ranges_hashed_on_object, ranges_hashed_on_subject_object, RDF_XML, resources, seealsos, seealsos_hashed_on_object, seealsos_hashed_on_subject_object, strict, subclasses, subclasses_hashed_on_object, subclasses_hashed_on_subject_object, subjects, subjects_hashed_on_object, subjects_hashed_on_subject_object, subproperties, subproperties_hashed_on_object, subproperties_hashed_on_subject_object, time, TRIG, types, types_hashed_on_object, types_hashed_on_subject_object, validation_params
 
Constructor Summary
RDFDB_Model(java.lang.String dbPath, java.lang.String db_login, java.lang.String db_passwd, int representation, boolean cluster)
           
 
Method Summary
 void addGsInDB(int db_id, java.lang.String graphspace_uri)
           
 void addNsInDB(int db_id, java.lang.String namespace_uri)
           
protected  void addResource(IRDF_Resource resource)
           
protected  void castResourcesToClasses(IRDF_MetaClass rdf_meta_class)
          This method iterates over the type triples and casts to classes all resources that are subjects of triples with object this metaclass
protected  void castResourcesToClassInstances(IRDF_Class rdf_class)
          This method iterates over the type triples and casts to class instances all resources that are subjects of triples with object this class
protected  void castResourcesToProperties(IRDF_MetaClass rdf_meta_class)
          This method iterates over the type triples and casts to properties all resources that are subjects of triples with object this metaclass(of properties)
protected  void createPostorder(RDF_DAG subClassDag, RDF_DAG subPropertyDag, RDF_DAG subMetaClassDag, RDF_DAG subMetaPropertyDag)
          Creates the labeling
protected  int enter_property_instance(java.lang.String subject, java.lang.String predicate, java.lang.String object, Position pos, java.lang.String graphspace_uri, java.lang.String namespace_uri, boolean strict)
           
protected  int enter_type(java.lang.String subject, java.lang.String predicate, java.lang.String object, Position pos, java.lang.String graphspace_uri, boolean strict, java.lang.String namespace_uri)
           
 void fetchDirectDescsFromDB(java.util.Collection<IRDF_Schema_Resource> nodes)
          Fetches the direct descendants of a class in main memory
 void fetchSubsumptionClassHierarchyInMainMemory(java.util.Collection<IntervalLabel> parentTreeLabels)
          This methods fetched from database and creates the whole subsumption hierarchy starting from these labels
 void fetchSubsumptionMetaClassHierarchyInMainMemory(java.util.Collection<IntervalLabel> parentTreeLabels)
          This methods fetches from database and creates the whole subsumption hierarchy starting from these labels
 void fetchSubsumptionPropertyHierarchyInMainMemory(java.util.Collection<IntervalLabel> parentTreeLabels)
          This methods fetched from database and creates the whole subsumption hierarchy starting from these labels
 DBRepresentation getDb_representation()
           
 DBValidator getDb_validator()
           
 DBMSValues getDbms_values()
           
 int getGsInDB(java.lang.String graphsapce_uri)
           
 java.util.HashMap<java.lang.String,java.lang.Integer> getGsInDBs()
           
 int getNsInDB(java.lang.String namesapce_uri)
           
 java.util.HashMap<java.lang.String,java.lang.Integer> getNsInDBs()
           
 IRDF_Graphspace getOrCreateGraphspace(java.lang.String graphspace_uri)
          >>>>>>> .r2656 This method retrieves an RDF_Graphspace with a given uri.
 IRDFDB_Namespace getOrCreateNamespace(java.lang.String namespace_uri)
          This method retrieves an RDF_Namespace with a given uri from MM.
protected  IRDF_Resource getResource(java.lang.String resource_uri)
           
protected  java.util.HashMap getResources()
           
 java.util.HashMap<java.lang.String,java.lang.Boolean> getStorableNSs()
           
 StorageMetaData getStorage_metadata()
           
 StorageParameters getStorage_parameters()
           
 StorageUtilities getStorage_utilities()
           
protected  org.apache.commons.collections.MultiMap getTypes_hashed_on_object()
           
protected  java.util.Map getTypes_hashed_on_subject_object()
           
protected  void import_namespace(java.lang.String import_namespace, parser rdf_parser)
           
 void import_namespaces(java.util.ArrayList import_namespaces, java.lang.String base_uri)
          VRP Comments: Will be called by the parser if he reached the EOF of the current file.
 void initDbSchema_()
           
 void initDbSchema()
          Creates the primitive tables in the database
 void initStoringParameters()
           
 boolean isGsStorable(java.lang.String graphspace_uri)
          Opines whether the given namespace is storable due to its own and its dependencies storability
 java.lang.Boolean isNsStorable(java.lang.String namespace_uri)
          If a namespace is not explicitly set to non storable it is considered as storable
protected  void read_rdf_xml(java.io.InputStream file, java.lang.String base_uri, boolean fetch_dependencies, boolean strict)
          This method parses an RDF/XML file using vrp parser and creates the corresponding RDF_Namespace and RDF_Graphspace objects
 void read(java.io.InputStream file, java.lang.String base_uri, java.lang.String triple_format, boolean fetch_dependencies, boolean strict)
          Receives input from an Input Stream an loads the corresponding namespaces/graphspaces to the model The base_uri given as a parameter should be the same as the one included in the file(if one)
 void read(java.lang.String filename, java.lang.String base_uri, java.lang.String triple_format, boolean fetch_dependencies, boolean strict)
          Receives input from a file an loads the corresponding namespaces/graphspaces to the model The base_uri given as a parameter should be the same as the one included in the file(if one)
protected  void removeSubClassTriplesOf(IRDF_Class rdf_class)
           
 void restoreReferences(java.lang.String uri, IRDF_Resource new_resource)
          Searches in all related namespaces for an RDF_Resource with uri "uri" and replaces it with new_resource Searches all triples in model for the occurence of a resource with uri "uri" and replaces it with new_resource Used in data dbvalidation
 void setDb_representation(DBRepresentation db_representation)
           
 void setDb_validator(DBValidator db_validator)
           
 void setDbms_values(DBMSValues dbms_values)
           
 void setNsStorable(java.lang.String namespace_uri, boolean storable)
           
protected  void setResources(java.util.HashMap resources)
           
 void setStorage_metadata(StorageMetaData storage_metadata)
           
 void setStorage_parameters(StorageParameters storage_parameters)
           
 void setStorage_utilities(StorageUtilities storage_utilities)
           
 void setStoreableNSs(java.util.HashMap<java.lang.String,java.lang.Boolean> storeableNS)
           
 void store(boolean validate)
          Stores the schema and data loaded in this model
 void storeData()
          Stores the data loaded in this model
 void storeSchema()
          Stores the schemas loaded in main memory It is the user's responsibility to call validateSchema before if he requires validation
protected  void updateResourceReferencesInTriples(IRDF_Resource original_rdf_resource, IRDF_Resource new_rdf_resource)
          Replaces rdf_class with rdf_meta_class in all triples that rdf_class occures
 int validateData(DBValidator dbv)
          Validates the data loaded in main memory.
 int validateSchema(DBValidator dbv)
          Validates the schemas loaded in main memory with respect to possibly already stored schemas
 
Methods inherited from class gr.forth.ics.rdfsuite.swkm.model.impl.RDF_Model
addClassInstance, addComment, addContainer, addDomain, addGraphspace, addIsDefinedBy, addLabel, addLiteral, addMember, addNamespace, addObject, addPredicate, addPropertyInstance, addRange, addSeeAlso, addStatement, addSubClass, addSubject, addSubProperty, addType, createClassDag, createClassDag, createClassInstance, createContainer, createDags, createLabels, createMetaClassDag, createMetaClassDag, createMetaPropertyDag, createMetaPropertyDag, createPropertyDag, createPropertyInstance, createResource, eliminateRedundancies, enter_alt, enter_bag, enter_class_instance, enter_comment, enter_label, enter_sequence, getAvailableStreams, getClass_dag, getClasses, getClassInstance, getClassInstances, getComment, getComments, getCommentWithSubjectAndObject, getContainer, getContainers, getDomain, getDomains, getDomainWithSubjectAndObject, getFetch_all_ns, getGraphspace, getGraphspaces, getHlabel, getInstances, getIsDefinedBy, getIsDefinedBys, getIsDefinedByWithSubjectAndObject, getLabel, getLabels, getLabelsCreated, getLabelWithSubjectAndObject, getLiteral, getLiterals, getMember, getMembers, getMemberWithSubjectAndObject, getMemberWithSubjectAndObject, getMetaClass_dag, getMetaProperty_dag, getNamespace, getNamespaces, getObject, getObjects, getOrCreateCommentTriple, getOrCreateLabelTriple, getOrCreateLiteral, getOrCreateMemberTriple, getOrCreateResource, getOrCreateTypeTriple, getPredicate, getPredicates, getProperties, getProperty_dag, getPropertyInstance, getPropertyInstances, getPropertyInstanceWithObject, getPropertyInstanceWithSubject, getPropertyInstanceWithSubjectAndObject, getPropertyInstanceWithSubjectPredicateAndObject, getRange, getRanges, getRangeWithSubjectAndObject, getSeeAlso, getSeeAlsos, getSeeAlsoWithSubjectAndObject, getSubClasses, getSubClassOf, getSubClassWithSubjectAndObject, getSubject, getSubjects, getSubProperties, getSubProperty, getSubPropertyOf, getSubPropertyWithSubjectAndObject, getSuperClassOf, getSuperProperty, getSuperPropertyOf, getType, getTypes, getTypeWithSubjectAndObject, getValidation_params, import_default_namespaces, import_graphspaces, import_namespace, import_namespaces, import_rdfsuite_namespace, import_xmlschema_namespace, initResourceIDs, isStrict, read_Trig, read_triple, readAll, retrieveResource, retrieveTriples, retrieveTriples, retrieveTriplesByObject, retrieveTriplesByPredicate, retrieveTriplesBySubject, setAvailableStreams, setClass_dag, setClassInstances, setComments, setComments, setContainers, setDomains, setDomains, setFetch_all_ns, setGraphspaces, setHlabel, setIsDefinedBys, setIsDefinedBys, setLabels, setLabels, setLabelsCreated, setLiterals, setMembers, setMembers, setMetaClass_dag, setMetaProperty_dag, setNamespaces, setObjects, setPredicates, setProperty_dag, setPropertyInstances, setRanges, setRanges, setSeeAlsos, setSeeAlsos, setStrict, setSubClasses, setSubjects, setSubProperties, setSubProperties, setSuperClassesOf, setTypes, setTypes, setValidation_params, toTriples, toTriples, toTriples, validate, write_file, write_original_and_inferred_in_file, write_original_and_inferred_in_string, write_string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gr.forth.ics.rdfsuite.swkm.model.IRDF_Model
addClassInstance, addComment, addContainer, addDomain, addGraphspace, addIsDefinedBy, addLabel, addMember, addNamespace, addObject, addPredicate, addPropertyInstance, addRange, addSeeAlso, addStatement, addSubClass, addSubject, addSubProperty, addType, createClassDag, createDags, createLabels, createMetaClassDag, createMetaPropertyDag, createPropertyDag, eliminateRedundancies, getAvailableStreams, getClasses, getClassInstance, getClassInstances, getComment, getComments, getContainer, getContainers, getDomain, getDomains, getGraphspace, getGraphspaces, getInstances, getIsDefinedBy, getIsDefinedBys, getLabel, getLabels, getLabelsCreated, getMember, getMembers, getNamespace, getNamespaces, getObject, getObjects, getPredicate, getPredicates, getProperties, getPropertyInstance, getPropertyInstances, getPropertyInstanceWithSubjectAndObject, getPropertyInstanceWithSubjectPredicateAndObject, getRange, getRanges, getSeeAlso, getSeeAlsos, getSubClasses, getSubClassOf, getSubject, getSubjects, getSubProperties, getSubProperty, getSuperClassOf, getSuperProperty, getType, getTypes, import_default_namespaces, import_graphspaces, import_rdfsuite_namespace, import_xmlschema_namespace, readAll, retrieveResource, retrieveTriples, retrieveTriples, setAvailableStreams, setClassInstances, setComments, setComments, setContainers, setDomains, setDomains, setGraphspaces, setIsDefinedBys, setIsDefinedBys, setLabels, setLabels, setLabelsCreated, setMembers, setNamespaces, setObjects, setPredicates, setPropertyInstances, setRanges, setRanges, setSeeAlsos, setSeeAlsos, setSubClasses, setSubjects, setSubProperties, setSubProperties, setSuperClassesOf, setTypes, setTypes, toTriples, toTriples, validate, write_file, write_original_and_inferred_in_file, write_original_and_inferred_in_string, write_string
 

Field Detail

EMPTY

public static final int EMPTY
Indicates that db is empty

See Also:
Constant Field Values

SPECIFIC

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

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

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

See Also:
Constant Field Values
Constructor Detail

RDFDB_Model

public RDFDB_Model(java.lang.String dbPath,
                   java.lang.String db_login,
                   java.lang.String db_passwd,
                   int representation,
                   boolean cluster)
            throws gr.forth.ics.rdfsuite.services.exceptions.InvalidDatabaseRepresentationException,
                   gr.forth.ics.rdfsuite.services.exceptions.InvalidDatabaseRepresentationException
Parameters:
dbPath - The host/port the dbms listens at. Example localhost:5432/testdb
db_login - The username to connect to the dbms
db_passwd - The password to connect to the dbms
representation - The desired db representation. Predefined values DBRepresentation.SS DBRepresentation.SSWS and DBRepresentation.Hybrid
cluster - If true clustering will be performed to the db tables
Throws:
gr.forth.ics.rdfsuite.services.exceptions.InvalidDatabaseRepresentationException - if the given representation is not one of the predefined in RDFDB_Model
Method Detail

getDb_validator

public DBValidator getDb_validator()

setDb_validator

public void setDb_validator(DBValidator db_validator)

getDbms_values

public DBMSValues getDbms_values()

setDbms_values

public void setDbms_values(DBMSValues dbms_values)

getStorage_metadata

public StorageMetaData getStorage_metadata()

setStorage_metadata

public void setStorage_metadata(StorageMetaData storage_metadata)

getStorage_parameters

public StorageParameters getStorage_parameters()

setStorage_parameters

public void setStorage_parameters(StorageParameters storage_parameters)

getStorage_utilities

public StorageUtilities getStorage_utilities()

setStorage_utilities

public void setStorage_utilities(StorageUtilities storage_utilities)

read

public void read(java.lang.String filename,
                 java.lang.String base_uri,
                 java.lang.String triple_format,
                 boolean fetch_dependencies,
                 boolean strict)
          throws java.sql.SQLException,
                 java.lang.ClassNotFoundException,
                 java.io.IOException,
                 gr.forth.ics.rdfsuite.services.exceptions.ParsingException,
                 gr.forth.ics.rdfsuite.services.exceptions.TrigException,
                 gr.forth.ics.rdfsuite.services.exceptions.InvalidTripleFormatException
Description copied from interface: IRDF_Model
Receives input from a file an loads the corresponding namespaces/graphspaces to the model The base_uri given as a parameter should be the same as the one included in the file(if one)

Specified by:
read in interface IRDF_Model
Overrides:
read in class RDF_Model
Parameters:
filename - A String
base_uri - The base uri of the file.
triple_format - RDF_Model.RDF_XML( For rdf/xml files),RDF_Model.TRIG( for trig files)
fetch_dependencies - If true all the dependent namespacies will be fetched from their actual location(Requires a valid uri to be set)
strict - If true all the necessary checks will be performed while if it is false we will perform a "good will" building
Throws:
java.sql.SQLException - if some query aborts
java.lang.ClassNotFoundException - If postgres driver is not found
java.io.IOException - In case the input stream is malformed
gr.forth.ics.rdfsuite.services.exceptions.ParsingException - In case something went wrong in the parsing of the file
gr.forth.ics.rdfsuite.services.exceptions.TrigException - In case the trig parser throws an Exception
gr.forth.ics.rdfsuite.services.exceptions.InvalidTripleFormatException - in case parameter triple format is not one of the predefined values
gr.forth.ics.rdfsuite.services.exceptions.NamespaceStoringException - in RDF_Model

read

public void read(java.io.InputStream file,
                 java.lang.String base_uri,
                 java.lang.String triple_format,
                 boolean fetch_dependencies,
                 boolean strict)
          throws java.sql.SQLException,
                 java.lang.ClassNotFoundException,
                 java.io.IOException,
                 gr.forth.ics.rdfsuite.services.exceptions.ParsingException,
                 gr.forth.ics.rdfsuite.services.exceptions.TrigException,
                 gr.forth.ics.rdfsuite.services.exceptions.InvalidTripleFormatException
Description copied from interface: IRDF_Model
Receives input from an Input Stream an loads the corresponding namespaces/graphspaces to the model The base_uri given as a parameter should be the same as the one included in the file(if one)

Specified by:
read in interface IRDF_Model
Overrides:
read in class RDF_Model
Parameters:
file - An RDF/XML or TRIG Input Stream
base_uri - If null then we retrieve the base uri from the file itself
triple_format - RDF_Model.RDF_XML( For rdf/xml files),RDF_Model.TRIG( for trig files)
fetch_dependencies - If true all the dependent namespacies will be fetched from their actual location(Requires
strict - If true all the necessary checks will be performed while if it is false we will perform a good will building
Throws:
java.sql.SQLException - if some query aborts
java.lang.ClassNotFoundException - If postgres driver is not found
java.io.IOException - In case the input stream is malformed
gr.forth.ics.rdfsuite.services.exceptions.ParsingException - In case something went wrong in the parsing of the file
gr.forth.ics.rdfsuite.services.exceptions.TrigException - In case the trig parser throws an Exception
gr.forth.ics.rdfsuite.services.exceptions.InvalidTripleFormatException - in case parameter triple format is not one of the predefined values
gr.forth.ics.rdfsuite.services.exceptions.NamespaceStoringException - in RDF_Model

initStoringParameters

public void initStoringParameters()
                           throws java.sql.SQLException,
                                  java.lang.ClassNotFoundException
Throws:
java.sql.SQLException - If some sql query aborts
java.lang.ClassNotFoundException - If postgres driver is not found

import_namespaces

public void import_namespaces(java.util.ArrayList import_namespaces,
                              java.lang.String base_uri)
Description copied from class: RDF_Model
VRP Comments: Will be called by the parser if he reached the EOF of the current file. The explicit stated namespaces are inside the Array List. The idea is to include everything in advance and do not allow to fetch during validation to provide a determinitic result of the validator. new since 08. Aug 2001 entered by Karsten Tolle My comments: When a a namespace imports other namespaces in its header these namespaces must be fetched in advance For these namespaces to be fetched a new parser instance must be created that will fetch them, so this work must be done in the level of the model 16/10/2006 The fetch namespace handling changes Details in the two relevant documents original name:public void fetch_all(ArrayList ex_ns, parser par)

Specified by:
import_namespaces in interface IRDF_Model
Overrides:
import_namespaces in class RDF_Model
Parameters:
import_namespaces - the namespaces to be loaded in the model
base_uri - the base uri

getNsInDBs

public java.util.HashMap<java.lang.String,java.lang.Integer> getNsInDBs()

addNsInDB

public void addNsInDB(int db_id,
                      java.lang.String namespace_uri)

getNsInDB

public int getNsInDB(java.lang.String namesapce_uri)

getGsInDBs

public java.util.HashMap<java.lang.String,java.lang.Integer> getGsInDBs()

addGsInDB

public void addGsInDB(int db_id,
                      java.lang.String graphspace_uri)

getGsInDB

public int getGsInDB(java.lang.String graphsapce_uri)

getStorableNSs

public java.util.HashMap<java.lang.String,java.lang.Boolean> getStorableNSs()

isNsStorable

public java.lang.Boolean isNsStorable(java.lang.String namespace_uri)
If a namespace is not explicitly set to non storable it is considered as storable

Parameters:
namespace_uri -
Returns:

setStoreableNSs

public void setStoreableNSs(java.util.HashMap<java.lang.String,java.lang.Boolean> storeableNS)

setNsStorable

public void setNsStorable(java.lang.String namespace_uri,
                          boolean storable)
Parameters:
namespace_uri -
storable -

store

public void store(boolean validate)
           throws java.sql.SQLException,
                  java.lang.ClassNotFoundException,
                  gr.forth.ics.rdfsuite.services.exceptions.LabelCreationException,
                  gr.forth.ics.rdfsuite.services.exceptions.InvalidDatabaseRepresentationException,
                  gr.forth.ics.rdfsuite.services.exceptions.NamespaceStoringException,
                  gr.forth.ics.rdfsuite.services.exceptions.ValidationException
Stores the schema and data loaded in this model

Specified by:
store in interface IRDFDB_Model
Parameters:
if - true validates and stores else stores only (It is highly recommended to validate first)
Throws:
java.sql.SQLException - if some sql query aborts
java.lang.ClassNotFoundException - if postgres driver is not found
gr.forth.ics.rdfsuite.services.exceptions.LabelCreationException - if something went wrong in the label creation
gr.forth.ics.rdfsuite.services.exceptions.InvalidDatabaseRepresentationException - if the given database representation is not one of the predefined in RDFDB_Model
gr.forth.ics.rdfsuite.services.exceptions.NamespaceStoringException - if the stored representation is not the same with the given one
gr.forth.ics.rdfsuite.services.exceptions.ValidationException - if the schema or data are not valid

validateSchema

public int validateSchema(DBValidator dbv)
                   throws java.sql.SQLException
Validates the schemas loaded in main memory with respect to possibly already stored schemas

Parameters:
dbv - DBValidator You can obtain it calling RDFDB_Model.getDb_validator()
Returns:
1 if schema is invalid 2 if schema is valid 0 for abnormal termination
Throws:
java.sql.SQLException - if some sql query aborts

storeSchema

public void storeSchema()
                 throws java.sql.SQLException,
                        gr.forth.ics.rdfsuite.services.exceptions.InvalidDatabaseRepresentationException,
                        java.lang.ClassNotFoundException,
                        gr.forth.ics.rdfsuite.services.exceptions.LabelCreationException,
                        gr.forth.ics.rdfsuite.services.exceptions.NamespaceStoringException
Stores the schemas loaded in main memory It is the user's responsibility to call validateSchema before if he requires validation

Throws:
java.sql.SQLException - if some sql query aborts
gr.forth.ics.rdfsuite.services.exceptions.InvalidDatabaseRepresentationException - if the given representation is not one of the predefined in the RDFDB_Model
java.lang.ClassNotFoundException - if postgres driver is not found
gr.forth.ics.rdfsuite.services.exceptions.LabelCreationException - if something went wrong in the label creation
gr.forth.ics.rdfsuite.services.exceptions.NamespaceStoringException - if the stored representation is not the same to the given one
See Also:
RDFDB_Model.validateSchema(DBValidator dbv)

validateData

public int validateData(DBValidator dbv)
                 throws java.sql.SQLException
Validates the data loaded in main memory. In order for the data to be validated schema must be first stored

Parameters:
dbv - DBValidator You can obtain it calling RDFDB_Model.getDb_Validator
Returns:
2 if data are valid, 1 if they are invalid
Throws:
java.sql.SQLException - if some query aborts

createPostorder

protected void createPostorder(RDF_DAG subClassDag,
                               RDF_DAG subPropertyDag,
                               RDF_DAG subMetaClassDag,
                               RDF_DAG subMetaPropertyDag)
                        throws gr.forth.ics.rdfsuite.services.exceptions.LabelCreationException
Creates the labeling

Overrides:
createPostorder in class RDF_Model
Throws:
gr.forth.ics.rdfsuite.services.exceptions.LabelCreationException - if something goes wrong in the label creation
java.sql.SQLException - if some sql query aborts

storeData

public void storeData()
               throws java.sql.SQLException
Stores the data loaded in this model

Parameters:
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
db_representation - Database Represenation
Throws:
java.sql.SQLException - if some sql query aborts

isGsStorable

public boolean isGsStorable(java.lang.String graphspace_uri)
Opines whether the given namespace is storable due to its own and its dependencies storability

Parameters:
graphspace_uri -
Returns:

getDb_representation

public DBRepresentation getDb_representation()

setDb_representation

public void setDb_representation(DBRepresentation db_representation)

restoreReferences

public void restoreReferences(java.lang.String uri,
                              IRDF_Resource new_resource)
Searches in all related namespaces for an RDF_Resource with uri "uri" and replaces it with new_resource Searches all triples in model for the occurence of a resource with uri "uri" and replaces it with new_resource Used in data dbvalidation

Parameters:
uri - An existing resource uri
new_resource - The new resource with which it must me substituted

enter_type

protected int enter_type(java.lang.String subject,
                         java.lang.String predicate,
                         java.lang.String object,
                         Position pos,
                         java.lang.String graphspace_uri,
                         boolean strict,
                         java.lang.String namespace_uri)
                  throws gr.forth.ics.rdfsuite.services.exceptions.TripleCreationException
Overrides:
enter_type in class RDF_Model
Returns:
0 for false,needs to be fed to model, 1 for true, 2 for false and should not be fed to model(error)
Throws:
gr.forth.ics.rdfsuite.services.exceptions.TripleCreationException - Essentially if some sql query aborts

enter_property_instance

protected int enter_property_instance(java.lang.String subject,
                                      java.lang.String predicate,
                                      java.lang.String object,
                                      Position pos,
                                      java.lang.String graphspace_uri,
                                      java.lang.String namespace_uri,
                                      boolean strict)
                               throws gr.forth.ics.rdfsuite.services.exceptions.TripleCreationException
Overrides:
enter_property_instance in class RDF_Model
Returns:
0 for false,needs to be fed to model, 1 for true, 2 for false and should not be fed to model(error)
Throws:
gr.forth.ics.rdfsuite.services.exceptions.TripleCreationException - Essentially if some sql query aborts

getOrCreateNamespace

public IRDFDB_Namespace getOrCreateNamespace(java.lang.String namespace_uri)
Description copied from class: RDF_Model
This method retrieves an RDF_Namespace with a given uri from MM. If it does not exist it creates it

Specified by:
getOrCreateNamespace in interface IRDF_Model
Overrides:
getOrCreateNamespace in class RDF_Model
Parameters:
namespace_uri - the uri of the namespace
Returns:
the IRDF_Namespace that was retrieved or created

getOrCreateGraphspace

public IRDF_Graphspace getOrCreateGraphspace(java.lang.String graphspace_uri)
>>>>>>> .r2656 This method retrieves an RDF_Graphspace with a given uri. If it does not exist it creates it

Specified by:
getOrCreateGraphspace in interface IRDF_Model
Overrides:
getOrCreateGraphspace in class RDF_Model
Parameters:
graphspace_uri - the uri of the graphspace
Returns:
the IRDF_Graphspace that was retrieved or created

read_rdf_xml

protected void read_rdf_xml(java.io.InputStream file,
                            java.lang.String base_uri,
                            boolean fetch_dependencies,
                            boolean strict)
                     throws java.io.IOException,
                            gr.forth.ics.rdfsuite.services.exceptions.ParsingException
This method parses an RDF/XML file using vrp parser and creates the corresponding RDF_Namespace and RDF_Graphspace objects

Overrides:
read_rdf_xml in class RDF_Model
Parameters:
strict - If true all the necessary checks will be performed while if it is false we will perform a good will building
Throws:
java.io.IOException - if the input stream is malformed
gr.forth.ics.rdfsuite.services.exceptions.ParsingException - if something went wrong in the parsing of the file

import_namespace

protected void import_namespace(java.lang.String import_namespace,
                                parser rdf_parser)
                         throws gr.forth.ics.rdfsuite.services.exceptions.UnresolvedDependencyException
Overrides:
import_namespace in class RDF_Model
Throws:
gr.forth.ics.rdfsuite.services.exceptions.UnresolvedDependencyException - if a namespace referenced by another namespace can be fetched neither from a file nor from db nor from its actual web location

updateResourceReferencesInTriples

protected void updateResourceReferencesInTriples(IRDF_Resource original_rdf_resource,
                                                 IRDF_Resource new_rdf_resource)
Replaces rdf_class with rdf_meta_class in all triples that rdf_class occures

Overrides:
updateResourceReferencesInTriples in class RDF_Model
Parameters:
original_rdf_resource -
new_rdf_resource -

addResource

protected void addResource(IRDF_Resource resource)
Overrides:
addResource in class RDF_Model

getResource

protected IRDF_Resource getResource(java.lang.String resource_uri)
Overrides:
getResource in class RDF_Model

getResources

protected java.util.HashMap getResources()
Overrides:
getResources in class RDF_Model

setResources

protected void setResources(java.util.HashMap resources)
Overrides:
setResources in class RDF_Model

castResourcesToClassInstances

protected void castResourcesToClassInstances(IRDF_Class rdf_class)
This method iterates over the type triples and casts to class instances all resources that are subjects of triples with object this class

Overrides:
castResourcesToClassInstances in class RDF_Model
Parameters:
rdf_class -

castResourcesToClasses

protected void castResourcesToClasses(IRDF_MetaClass rdf_meta_class)
This method iterates over the type triples and casts to classes all resources that are subjects of triples with object this metaclass

Overrides:
castResourcesToClasses in class RDF_Model
Parameters:
rdf_class -

castResourcesToProperties

protected void castResourcesToProperties(IRDF_MetaClass rdf_meta_class)
This method iterates over the type triples and casts to properties all resources that are subjects of triples with object this metaclass(of properties)

Overrides:
castResourcesToProperties in class RDF_Model
Parameters:
rdf_meta_class -

removeSubClassTriplesOf

protected void removeSubClassTriplesOf(IRDF_Class rdf_class)
Overrides:
removeSubClassTriplesOf in class RDF_Model

getTypes_hashed_on_object

protected org.apache.commons.collections.MultiMap getTypes_hashed_on_object()
Overrides:
getTypes_hashed_on_object in class RDF_Model

getTypes_hashed_on_subject_object

protected java.util.Map getTypes_hashed_on_subject_object()
Overrides:
getTypes_hashed_on_subject_object in class RDF_Model

fetchSubsumptionClassHierarchyInMainMemory

public void fetchSubsumptionClassHierarchyInMainMemory(java.util.Collection<IntervalLabel> parentTreeLabels)
                                                throws java.sql.SQLException
This methods fetched from database and creates the whole subsumption hierarchy starting from these labels

Specified by:
fetchSubsumptionClassHierarchyInMainMemory in interface IRDFDB_Model
Parameters:
parentLabels - the set containing all the tree labels of the parents of a new node
Throws:
java.sql.SQLException

fetchSubsumptionPropertyHierarchyInMainMemory

public void fetchSubsumptionPropertyHierarchyInMainMemory(java.util.Collection<IntervalLabel> parentTreeLabels)
                                                   throws java.sql.SQLException
This methods fetched from database and creates the whole subsumption hierarchy starting from these labels

Specified by:
fetchSubsumptionPropertyHierarchyInMainMemory in interface IRDFDB_Model
Parameters:
labels - A set of IntervalLabel objects
Throws:
java.sql.SQLException

fetchSubsumptionMetaClassHierarchyInMainMemory

public void fetchSubsumptionMetaClassHierarchyInMainMemory(java.util.Collection<IntervalLabel> parentTreeLabels)
                                                    throws java.sql.SQLException
This methods fetches from database and creates the whole subsumption hierarchy starting from these labels

Specified by:
fetchSubsumptionMetaClassHierarchyInMainMemory in interface IRDFDB_Model
Parameters:
labels - A set of IntervalLabel objects
Throws:
java.sql.SQLException

fetchDirectDescsFromDB

public void fetchDirectDescsFromDB(java.util.Collection<IRDF_Schema_Resource> nodes)
                            throws java.sql.SQLException
Fetches the direct descendants of a class in main memory

Throws:
java.sql.SQLException

initDbSchema_

public void initDbSchema_()
                   throws java.lang.ClassNotFoundException,
                          java.sql.SQLException
Throws:
java.sql.SQLException - if some sql query aborts
java.lang.ClassNotFoundException - if postgres driver is not found

initDbSchema

public void initDbSchema()
                  throws java.sql.SQLException,
                         gr.forth.ics.rdfsuite.services.exceptions.PostgresConnectionException
Description copied from interface: IRDFDB_Model
Creates the primitive tables in the database

Specified by:
initDbSchema in interface IRDFDB_Model
Throws:
java.sql.SQLException - if some sql query aborts
gr.forth.ics.rdfsuite.services.exceptions.PostgresConnectionException - if postgres driver is not found