org.openanzo.model.embedded
Class EmbeddedModelService

java.lang.Object
  extended by org.openanzo.model.embedded.EmbeddedModelService
All Implemented Interfaces:
IModelService, IService

public class EmbeddedModelService
extends java.lang.Object
implements IModelService

An Embedded version of the IModelService which has a direct connection to the Anzo server.

Author:
Matthew Roy ( mroy@cambridgesemantics.com )

Constructor Summary
EmbeddedModelService(EmbeddedServiceBase baseService)
          Get an instance of the EmbeddedModelService
 
Method Summary
 void addInferredObject(org.openrdf.model.URI prop, org.openrdf.model.URI obj, org.openrdf.model.URI inferredObj)
          Add a mapping between a property/object pair, and the inferred property inferred object pair.
 void addInferredProperty(org.openrdf.model.URI prop, org.openrdf.model.URI inferredProp)
          Add a mapping between a property , and the inferred property.
 void close()
          Close the ModelService
 QueryResult execQuery(java.util.Set<org.openrdf.model.URI> defaultNamedGraphs, java.util.Set<org.openrdf.model.URI> graphs, java.lang.String query, java.lang.String queryLanguage)
          ExecQuery runs a query on the server and returns the results in a graph.
 info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> execQueryIndex(java.lang.String query, int startIndex, int numResults)
          ExecQueryIndex runs a query against the index on the server and returns the results in a graph.
 QueryResult executeQuery(java.util.Set<org.openrdf.model.URI> defaultNamedGraphs, java.util.Set<org.openrdf.model.URI> graphs, java.lang.String query)
          ExecuteQuery runs a SPARQL query on the server and returns the results in a QueryResult object.
 QueryResult executeQuery(java.util.Set<org.openrdf.model.URI> defaultNamedGraphs, java.util.Set<org.openrdf.model.URI> graphs, java.lang.String query, org.openrdf.model.URI base)
          ExecuteQuery runs a SPARQL query on the server and returns the results in a QueryResult object.
 info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> findStatements(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.Resource g)
          FindStatements returns an iterator of statements that match a Statement pattern and no inferred triples
 info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> findStatements(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.Resource g, boolean includeInferedTriples)
          FindStatements returns an iterator of statements that match a Statement pattern
 info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> findStatements(org.openrdf.model.Statement statement)
          FindStatements returns an iterator of statements that match a Statement pattern and no inferred triples
 info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> findStatements(org.openrdf.model.Statement statement, boolean includeInferedTriples)
          FindStatements returns an iterator of statements that match a Statement pattern
 INamedGraphWithMetaData getCurrentNamedGraphRevision(org.openrdf.model.URI namedGraphUri)
          GetNamedGraphRevision returns a INamedGraphWithMetaData for a specific NamedGraph at the current revision
static IModelService getInstance(java.lang.Object parent, java.util.Properties props)
          Get an instance of the EmbeddedModelService
 org.openrdf.model.URI getMetadataGraphUri(org.openrdf.model.URI namedGraphUri)
           
 INamedGraphWithMetaData getNamedGraphRevision(org.openrdf.model.URI namedGraphUri, long revision)
          GetNamedGraphRevision returns a INamedGraphWithMetaData for a specific NamedGraph at a certain revision
 java.lang.String getServicePassword()
          Get the Password for the current thread
 java.lang.String getServiceUser()
          Get the UserId for the current thread
 long getSize(org.openrdf.model.URI namedGraphUri)
           
 java.util.Set<org.openrdf.model.URI> getStoredNamedGraphs()
           
 void reset(java.util.Collection<org.openrdf.model.Statement> statements)
          Reset is a utility method that resets all data on the Anzo Server and sets system graph to some data.
 void setServicePassword(java.lang.String password)
          Set the password for the current thread's operations
 void setServiceUser(java.lang.String userId)
          Set the UserID for the current thread's operations
 IModelUpdate updateServer(ITransaction[] transactions, boolean returnResults, boolean isSynchronous)
          UpdateServer sends a set of transactions to the server to be processed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmbeddedModelService

public EmbeddedModelService(EmbeddedServiceBase baseService)
Get an instance of the EmbeddedModelService

Parameters:
baseService - the base embedded service which this service is built upon
Method Detail

getInstance

public static IModelService getInstance(java.lang.Object parent,
                                        java.util.Properties props)
Get an instance of the EmbeddedModelService

Parameters:
parent - The object creating this service
props - The configuration properties for this service
Returns:
A newly created EmbeddedModelService

updateServer

public IModelUpdate updateServer(ITransaction[] transactions,
                                 boolean returnResults,
                                 boolean isSynchronous)
                          throws AnzoException
Description copied from interface: IModelService
UpdateServer sends a set of transactions to the server to be processed.

Specified by:
updateServer in interface IModelService
Parameters:
transactions - Set of transactions to commit on the server.
returnResults - Should operation return the additions and deletions within the IModelUpdate object
isSynchronous - Should indexer run synchronously after committal of transactions.
Returns:
IModelUpdate object containing any errors and/or results of committal if returnResults is set
Throws:
AnzoException - if there was an error updating the server

reset

public void reset(java.util.Collection<org.openrdf.model.Statement> statements)
           throws AnzoException
Description copied from interface: IModelService
Reset is a utility method that resets all data on the Anzo Server and sets system graph to some data. This should only be used for testing. Operation can be turned off on the server.

Specified by:
reset in interface IModelService
Parameters:
statements - Set of statements that should be added to server as initial system data
Throws:
AnzoException - if there was an error reseting the server

getSize

public long getSize(org.openrdf.model.URI namedGraphUri)
             throws AnzoException
Specified by:
getSize in interface IModelService
Parameters:
namedGraphUri - URI of NamedGraph
Returns:
Number of triples in NamedGraph
Throws:
AnzoException - if there was an error getting size of NamedGraph from server

getMetadataGraphUri

public org.openrdf.model.URI getMetadataGraphUri(org.openrdf.model.URI namedGraphUri)
                                          throws AnzoException
Specified by:
getMetadataGraphUri in interface IModelService
Parameters:
namedGraphUri - URI of NamedGraph
Returns:
the URI of the MetadataGraph for a certain NamedGraph
Throws:
AnzoException - if there was an error getting NamedGraph's metadata URI from server

findStatements

public info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> findStatements(org.openrdf.model.Resource s,
                                                                                                      org.openrdf.model.URI p,
                                                                                                      org.openrdf.model.Value o,
                                                                                                      org.openrdf.model.Resource g)
                                                                                               throws AnzoException
Description copied from interface: IModelService
FindStatements returns an iterator of statements that match a Statement pattern and no inferred triples

Specified by:
findStatements in interface IModelService
Parameters:
s - Subject resource to match, or wildcard if null
p - Predicate uri to match, or wildcard if null
o - Object value to match, or wildcard if null
g - Context values to match, or wildcard if null
Returns:
an iterator of all statements that match the pattern of subj,prop,obj,context
Throws:
AnzoException - if there was an error finding statements on the server

findStatements

public info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> findStatements(org.openrdf.model.Statement statement)
                                                                                               throws AnzoException
Description copied from interface: IModelService
FindStatements returns an iterator of statements that match a Statement pattern and no inferred triples

Specified by:
findStatements in interface IModelService
Parameters:
statement - statement to match
Returns:
Iterator of matching statements
Throws:
AnzoException - if there was an error finding statements on the server

findStatements

public info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> findStatements(org.openrdf.model.Resource s,
                                                                                                      org.openrdf.model.URI p,
                                                                                                      org.openrdf.model.Value o,
                                                                                                      org.openrdf.model.Resource g,
                                                                                                      boolean includeInferedTriples)
                                                                                               throws AnzoException
Description copied from interface: IModelService
FindStatements returns an iterator of statements that match a Statement pattern

Specified by:
findStatements in interface IModelService
Parameters:
s - Subject resource to match, or wildcard if null
p - Predicate uri to match, or wildcard if null
o - Object value to match, or wildcard if null
g - Context values to match, or wildcard if null
includeInferedTriples - should inferred statements be included in find results
Returns:
Iterator of matching statements
Throws:
AnzoException - if there was an error finding statements on the server

findStatements

public info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> findStatements(org.openrdf.model.Statement statement,
                                                                                                      boolean includeInferedTriples)
                                                                                               throws AnzoException
Description copied from interface: IModelService
FindStatements returns an iterator of statements that match a Statement pattern

Specified by:
findStatements in interface IModelService
Parameters:
statement - statement to match
includeInferedTriples - should inferred statements be included in find results
Returns:
Iterator of matching statements
Throws:
AnzoException - if there was an error finding statements on the server

execQuery

public QueryResult execQuery(java.util.Set<org.openrdf.model.URI> defaultNamedGraphs,
                             java.util.Set<org.openrdf.model.URI> graphs,
                             java.lang.String query,
                             java.lang.String queryLanguage)
                      throws AnzoException
Description copied from interface: IModelService
ExecQuery runs a query on the server and returns the results in a graph.

Specified by:
execQuery in interface IModelService
Parameters:
defaultNamedGraphs - URIS of NamedGraphs to union together as the defaultModel for the dataset the query is run against
graphs - URIS of NamedGraphs for the dataset the query is run against
query - Query string
queryLanguage - Language of query
Returns:
result of query in graph form
Throws:
AnzoException - if there was an error querying the server

executeQuery

public QueryResult executeQuery(java.util.Set<org.openrdf.model.URI> defaultNamedGraphs,
                                java.util.Set<org.openrdf.model.URI> graphs,
                                java.lang.String query)
                         throws AnzoException
Description copied from interface: IModelService
ExecuteQuery runs a SPARQL query on the server and returns the results in a QueryResult object.

Specified by:
executeQuery in interface IModelService
Parameters:
defaultNamedGraphs - URIS of NamedGraphs to union together as the defaultModel for the dataset the query is run against
graphs - URIS of NamedGraphs for the dataset the query is run against
query - Query string
Returns:
QueryResult with results from running query
Throws:
AnzoException - if there was an error querying the server

executeQuery

public QueryResult executeQuery(java.util.Set<org.openrdf.model.URI> defaultNamedGraphs,
                                java.util.Set<org.openrdf.model.URI> graphs,
                                java.lang.String query,
                                org.openrdf.model.URI base)
                         throws AnzoException
Description copied from interface: IModelService
ExecuteQuery runs a SPARQL query on the server and returns the results in a QueryResult object.

Specified by:
executeQuery in interface IModelService
Parameters:
defaultNamedGraphs - URIS of NamedGraphs to union together as the defaultModel for the dataset the query is run against
graphs - URIS of NamedGraphs for the dataset the query is run against
query - Query string
base - The base URI for resolving relative URIs in the SPARQL query.
Returns:
QueryResult with results from running query
Throws:
AnzoException - if there was an error querying the server

execQueryIndex

public info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> execQueryIndex(java.lang.String query,
                                                                                                      int startIndex,
                                                                                                      int numResults)
                                                                                               throws AnzoException
Description copied from interface: IModelService
ExecQueryIndex runs a query against the index on the server and returns the results in a graph.

Specified by:
execQueryIndex in interface IModelService
Parameters:
query - Query string
startIndex - offset into the number of results to return
numResults - number of results to return
Returns:
Iterator of statements
Throws:
AnzoException - if there was an error querying the indexer on the server

getNamedGraphRevision

public INamedGraphWithMetaData getNamedGraphRevision(org.openrdf.model.URI namedGraphUri,
                                                     long revision)
                                              throws AnzoException
Description copied from interface: IModelService
GetNamedGraphRevision returns a INamedGraphWithMetaData for a specific NamedGraph at a certain revision

Specified by:
getNamedGraphRevision in interface IModelService
Parameters:
namedGraphUri - URI of NamedGraph to retrieve
revision - Revision of NamedGraph to retrieve
Returns:
INamedGraphWithMetaData of NamedGraph at given revision
Throws:
AnzoException - if there was an error getting NamedGraph from server

getCurrentNamedGraphRevision

public INamedGraphWithMetaData getCurrentNamedGraphRevision(org.openrdf.model.URI namedGraphUri)
                                                     throws AnzoException
Description copied from interface: IModelService
GetNamedGraphRevision returns a INamedGraphWithMetaData for a specific NamedGraph at the current revision

Specified by:
getCurrentNamedGraphRevision in interface IModelService
Parameters:
namedGraphUri - URI of NamedGraph to retrieve
Returns:
INamedGraphWithMetaData of NamedGraph at current revision
Throws:
AnzoException - if there was an error getting NamedGraph from server

getStoredNamedGraphs

public java.util.Set<org.openrdf.model.URI> getStoredNamedGraphs()
                                                          throws AnzoException
Specified by:
getStoredNamedGraphs in interface IModelService
Returns:
Set of NamedGraph URIs that user can read
Throws:
AnzoException - if there was an error getting NamedGraph's authenticated client can read from server

getServicePassword

public java.lang.String getServicePassword()
Description copied from interface: IService
Get the Password for the current thread

Specified by:
getServicePassword in interface IService
Returns:
the Password for the current thread

getServiceUser

public java.lang.String getServiceUser()
Description copied from interface: IService
Get the UserId for the current thread

Specified by:
getServiceUser in interface IService
Returns:
the UserId for the current thread

setServicePassword

public void setServicePassword(java.lang.String password)
Description copied from interface: IService
Set the password for the current thread's operations

Specified by:
setServicePassword in interface IService
Parameters:
password - Password to use in current thread's operations

setServiceUser

public void setServiceUser(java.lang.String userId)
Description copied from interface: IService
Set the UserID for the current thread's operations

Specified by:
setServiceUser in interface IService
Parameters:
userId - UserId to use in current thread's operations

close

public void close()
Description copied from interface: IModelService
Close the ModelService

Specified by:
close in interface IModelService

addInferredObject

public void addInferredObject(org.openrdf.model.URI prop,
                              org.openrdf.model.URI obj,
                              org.openrdf.model.URI inferredObj)
                       throws AnzoException
Description copied from interface: IModelService
Add a mapping between a property/object pair, and the inferred property inferred object pair. NOTE:Inferred data not currently used on the server

Specified by:
addInferredObject in interface IModelService
Parameters:
prop - property with inferred object
obj - object
inferredObj - inferred object
Throws:
AnzoException - if there was an error adding inferred object to server

addInferredProperty

public void addInferredProperty(org.openrdf.model.URI prop,
                                org.openrdf.model.URI inferredProp)
                         throws AnzoException
Description copied from interface: IModelService
Add a mapping between a property , and the inferred property. NOTE:Inferred data not currently used on the server

Specified by:
addInferredProperty in interface IModelService
Parameters:
prop - property that has an inferred property
inferredProp - inferred property
Throws:
AnzoException - if there was an error adding inferred property to server


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