org.openanzo.server.repository.querybuilder
Class SubjectGrounding

java.lang.Object
  extended by org.openanzo.server.repository.querybuilder.SubjectGrounding

public class SubjectGrounding
extends java.lang.Object

Provides a grounding from an RDF subject to a database column. Predicates and objects are grounded by adding PropertyGroundings and ObjectGroundings. SubjectGroundings, once constructed, are able to convert RDF triple pattern requests into SQL queries, execute the queries and convert the SQL query results into RDF statements satisfying the triple pattern request. A SubjectGrounding is constructed by providing a subject uri column, PredicateGroudings for all the predicates this type of subject can have and any constraints needed to either join tables in the database or limit results.

Author:
Joe Betz
See Also:
RdbGraph, PropertyGrounding, ObjectGrounding

Constructor Summary
SubjectGrounding(Column uriColumn, Column ngColumn)
          Constructs a QueryBuilder where the subject of RDF statements queries is specified by the given SQL column and table.
SubjectGrounding(Column uriColumn, Column ngColumn, java.util.Collection<Constraint> constraints, java.util.Collection<PropertyGrounding> propertyGroundings)
          Constructs a QueryBuilder where the subject of RDF statements queries is specified by the given SQL column and table.
SubjectGrounding(Column uriColumn, Column ngColumn, java.util.Collection<Constraint> constraints, java.util.Collection<PropertyGrounding> propertyGroundings, NodeConverter<java.lang.Long> uriColumnConverter)
          Constructs a QueryBuilder where the subject of RDF statements queries is specified by the given SQL column and table.
SubjectGrounding(Column uriColumn, Column ngColumn, NodeConverter<java.lang.Long> uriColumnConverter)
          Constructs a QueryBuilder where the subject of RDF statements queries is specified by the given SQL column and table.
 
Method Summary
 void addConstraint(Constraint constraint)
          Adds a constraint as well as additional tables that are required by the constraint.
 void addProperty(PropertyGrounding propertyGrounding)
          Adds a PropertyGrounding to query builder.
 void addProperty(org.openrdf.model.URI property, Column column, ObjectGrounding literalGrounding)
          Add a property to the results, where its value is retrieved from the given column
 void addProperty(org.openrdf.model.URI property, Column column, ObjectGrounding literalGrounding, Constraint constraint)
          Add a property to the results, where its value is retrieved from the given column, and is limited by the given constaint
 void addProperty(org.openrdf.model.URI property, org.openrdf.model.Value value)
          Add a property and value to include in results
 java.util.Collection<Quad> findMatches(RepositoryConnection repositoryConnection, org.openrdf.model.Resource subj, org.openrdf.model.URI prop, org.openrdf.model.Value obj, long graphId)
          Merges the provided property mappings and constraints with the statement constraints and builds an SQL query to find the relational database elements meeting the constraints and converts these back RDF statements.
 java.util.Collection<Quad> findMatches(RepositoryConnection repositoryConnection, org.openrdf.model.Resource subj, org.openrdf.model.URI prop, org.openrdf.model.Value obj, java.lang.Long graphId, java.util.Map<java.lang.String,java.lang.Object> variables)
          Merges the provided property mappings and constraints with the statement constraints and builds an SQL query to find the relational database elements meeting the constraints and converts these back RDF statements.
 java.util.Collection<org.openrdf.model.Statement> findMatchesPrepared(CompositeNodeLayout nodeLayout, java.sql.ResultSet resultSet)
          accepts the results of a relational query where the ResultSet columns match the column names mapped for this ResourceGrounding instance and converts each entry in the ResultSet to RDF triples.
 void findMatchProperties(CompositeNodeLayout nodeLayout, java.sql.ResultSet resultSet, java.util.Collection<org.openrdf.model.Statement> statements)
          accepts the results of a relational query where the ResultSet columns match the column names mapped for this ResourceGrounding instance and converts each entry in the ResultSet to a statement, and adds it to the set of statements.
 void removeConstraint(Constraint constraint)
          Remove a constraint
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubjectGrounding

public SubjectGrounding(Column uriColumn,
                        Column ngColumn)
Constructs a QueryBuilder where the subject of RDF statements queries is specified by the given SQL column and table.

Parameters:
uriColumn - Column containing the URI of the subject
ngColumn - Column containing the URI of the namedGraph containing the statement

SubjectGrounding

public SubjectGrounding(Column uriColumn,
                        Column ngColumn,
                        NodeConverter<java.lang.Long> uriColumnConverter)
Constructs a QueryBuilder where the subject of RDF statements queries is specified by the given SQL column and table. The given column converter must convert the values in the column to valid RDF resources. *

Parameters:
uriColumn - Column containing the URI of the subject
ngColumn - Column containing the URI of the namedGraph containing the statement
uriColumnConverter - Converter that converts a column value into an ID

SubjectGrounding

public SubjectGrounding(Column uriColumn,
                        Column ngColumn,
                        java.util.Collection<Constraint> constraints,
                        java.util.Collection<PropertyGrounding> propertyGroundings)
Constructs a QueryBuilder where the subject of RDF statements queries is specified by the given SQL column and table. The given column converter must convert the values in the column to valid RDF resources. *

Parameters:
uriColumn - Column containing the URI of the subject
ngColumn - Column containing the URI of the namedGraph containing the statement
constraints - Set of constraints to include in query
propertyGroundings - Set of properties to include in query

SubjectGrounding

public SubjectGrounding(Column uriColumn,
                        Column ngColumn,
                        java.util.Collection<Constraint> constraints,
                        java.util.Collection<PropertyGrounding> propertyGroundings,
                        NodeConverter<java.lang.Long> uriColumnConverter)
Constructs a QueryBuilder where the subject of RDF statements queries is specified by the given SQL column and table. The given column converter must convert the values in the column to valid RDF resources. *

Parameters:
uriColumn - Column containing the URI of the subject
ngColumn - Column containing the URI of the namedGraph containing the statement
constraints - Set of constraints to include in query
propertyGroundings - Set of properties to include in query
uriColumnConverter - Converter that converts a column value into an ID
Method Detail

addProperty

public void addProperty(PropertyGrounding propertyGrounding)
Adds a PropertyGrounding to query builder.

Parameters:
propertyGrounding - property grounding to add to query

addProperty

public void addProperty(org.openrdf.model.URI property,
                        org.openrdf.model.Value value)
Add a property and value to include in results

Parameters:
property - URI of property to add
value - value of property to add

addProperty

public void addProperty(org.openrdf.model.URI property,
                        Column column,
                        ObjectGrounding literalGrounding)
Add a property to the results, where its value is retrieved from the given column

Parameters:
property - URI of property to include in the results
column - name of column containing the value of property
literalGrounding - grounding for the value in the column

addProperty

public void addProperty(org.openrdf.model.URI property,
                        Column column,
                        ObjectGrounding literalGrounding,
                        Constraint constraint)
Add a property to the results, where its value is retrieved from the given column, and is limited by the given constaint

Parameters:
property - URI of property to include in the results
column - name of column containing the value of property
literalGrounding - grounding for the value in the column
constraint - constraint on the property

addConstraint

public void addConstraint(Constraint constraint)
Adds a constraint as well as additional tables that are required by the constraint.

Parameters:
constraint - constraint to add

removeConstraint

public void removeConstraint(Constraint constraint)
Remove a constraint

Parameters:
constraint - constraint to remove

findMatches

public java.util.Collection<Quad> findMatches(RepositoryConnection repositoryConnection,
                                              org.openrdf.model.Resource subj,
                                              org.openrdf.model.URI prop,
                                              org.openrdf.model.Value obj,
                                              long graphId)
                                       throws AnzoException
Merges the provided property mappings and constraints with the statement constraints and builds an SQL query to find the relational database elements meeting the constraints and converts these back RDF statements.

Parameters:
repositoryConnection - ` connection to the database
subj - subject to match, or wildcard if null
prop - property to match, or wildcard if null
obj - object or match, or wildcard if null
graphId - id of the NamedGraph's URI
Returns:
A collection of the resulting quads.
Throws:
AnzoException

findMatches

public java.util.Collection<Quad> findMatches(RepositoryConnection repositoryConnection,
                                              org.openrdf.model.Resource subj,
                                              org.openrdf.model.URI prop,
                                              org.openrdf.model.Value obj,
                                              java.lang.Long graphId,
                                              java.util.Map<java.lang.String,java.lang.Object> variables)
                                       throws AnzoException
Merges the provided property mappings and constraints with the statement constraints and builds an SQL query to find the relational database elements meeting the constraints and converts these back RDF statements.

Parameters:
repositoryConnection - ` connection to the database
subj - subject to match, or wildcard if null
prop - property to match, or wildcard if null
obj - object or match, or wildcard if null
graphId - id of the NamedGraph's URI
variables - map of variable names and values used in queries
Returns:
A collection of the resulting quads.
Throws:
AnzoException

findMatchesPrepared

public java.util.Collection<org.openrdf.model.Statement> findMatchesPrepared(CompositeNodeLayout nodeLayout,
                                                                             java.sql.ResultSet resultSet)
                                                                      throws java.sql.SQLException
accepts the results of a relational query where the ResultSet columns match the column names mapped for this ResourceGrounding instance and converts each entry in the ResultSet to RDF triples.

Parameters:
nodeLayout - CompositeNodeLayout to retrieve URIs and Node values
resultSet - ResultSet containing the results of running the query
Returns:
set of statements that match this grounding
Throws:
java.sql.SQLException

findMatchProperties

public void findMatchProperties(CompositeNodeLayout nodeLayout,
                                java.sql.ResultSet resultSet,
                                java.util.Collection<org.openrdf.model.Statement> statements)
                         throws java.sql.SQLException
accepts the results of a relational query where the ResultSet columns match the column names mapped for this ResourceGrounding instance and converts each entry in the ResultSet to a statement, and adds it to the set of statements.

Parameters:
nodeLayout - CompositeNodeLayout to retrieve URIs and Node values
resultSet - ResultSet containing the results of running the query
statements - set of statements containg results
Throws:
java.sql.SQLException


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.