org.openanzo.services.impl
Class WSModelService

java.lang.Object
  extended by org.openanzo.services.impl.WSBaseService
      extended by org.openanzo.services.impl.WSModelService
All Implemented Interfaces:
IModelService, IService

public class WSModelService
extends WSBaseService
implements IModelService

Implementation of IModelService that uses WebService/Soap to talk to a remote Anzo Server.

Author:
Matthew Roy ( mroy@cambridgesemantics.com )

Constructor Summary
WSModelService(java.util.Properties properties)
          Create new WSModelService with configuration properties provided in Properties object
WSModelService(java.lang.String serviceHostName, int servicePort, java.lang.String serviceUser, java.lang.String servicePassword, int serviceTimeout)
          Create new WSModelService with given configuration properties
 
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> defaultGraphUris, java.util.Set<org.openrdf.model.URI> graphs, java.lang.String query, java.lang.String queryLanguage)
          Deprecated.  
 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> defaultGraphUris, 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> defaultGraphUris, 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 subj, org.openrdf.model.URI prop, org.openrdf.model.Value obj, org.openrdf.model.Resource context)
          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 subj, org.openrdf.model.URI prop, org.openrdf.model.Value obj, org.openrdf.model.Resource context, 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
 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
 long getSize(org.openrdf.model.URI namedGraphUri)
           
 java.util.Set<org.openrdf.model.URI> getStoredNamedGraphs()
           
 void reset(java.util.Collection<org.openrdf.model.Statement> metaData)
          Reset is a utility method that resets all data on the Anzo Server and sets system graph to some data.
 IModelUpdate updateServer(ITransaction[] transactions, boolean returnResults, boolean isIndexSynchronous)
          UpdateServer sends a set of transactions to the server to be processed.
 
Methods inherited from class org.openanzo.services.impl.WSBaseService
getServiceHostName, getServicePassword, getServicePort, getServiceUser, setServiceHostName, setServicePassword, setServicePort, setServiceUser
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openanzo.services.IService
getServicePassword, getServiceUser, setServicePassword, setServiceUser
 

Constructor Detail

WSModelService

public WSModelService(java.lang.String serviceHostName,
                      int servicePort,
                      java.lang.String serviceUser,
                      java.lang.String servicePassword,
                      int serviceTimeout)
Create new WSModelService with given configuration properties

Parameters:
serviceHostName - Hostname for Anzo server
servicePort - Port for Anzo server
serviceUser - Username for Anzo server
servicePassword - Password for Anzo server
serviceTimeout - Number of milliseconds to wait before timeing out call to server

WSModelService

public WSModelService(java.util.Properties properties)
Create new WSModelService with configuration properties provided in Properties object

Parameters:
properties - Configuration properties
Method Detail

updateServer

public IModelUpdate updateServer(ITransaction[] transactions,
                                 boolean returnResults,
                                 boolean isIndexSynchronous)
                          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
isIndexSynchronous - 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> metaData)
           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:
metaData - 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.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

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 subj,
                                                                                                      org.openrdf.model.URI prop,
                                                                                                      org.openrdf.model.Value obj,
                                                                                                      org.openrdf.model.Resource context)
                                                                                               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:
subj - Subject resource to match, or wildcard if null
prop - Predicate uri to match, or wildcard if null
obj - Object value to match, or wildcard if null
context - 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.Resource subj,
                                                                                                      org.openrdf.model.URI prop,
                                                                                                      org.openrdf.model.Value obj,
                                                                                                      org.openrdf.model.Resource context,
                                                                                                      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:
subj - Subject resource to match, or wildcard if null
prop - Predicate uri to match, or wildcard if null
obj - Object value to match, or wildcard if null
context - 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

execQuery

public QueryResult execQuery(java.util.Set<org.openrdf.model.URI> defaultGraphUris,
                             java.util.Set<org.openrdf.model.URI> graphs,
                             java.lang.String query,
                             java.lang.String queryLanguage)
                      throws AnzoException
Deprecated. 

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:
defaultGraphUris - 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> defaultGraphUris,
                                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:
defaultGraphUris - 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> defaultGraphUris,
                                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:
defaultGraphUris - 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

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

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

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

close

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

Specified by:
close in interface IModelService

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

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.