org.openanzo.client
Class DatasetService

java.lang.Object
  extended by org.openanzo.client.DatasetService

public class DatasetService
extends java.lang.Object

The DatasetService is the central management point for a single connection to a Anzo Server. The Serivce contains methods for querying,replication, and notification. The Service provides the methods to get remote and local graphs/models. The graph/model is bound to the DatasetService that creates it, and all graphs/models created with a single DatasetService share a common TransactionQueue, NotificationService and persistence provider.

Author:
Matthew Roy ( mroy@cambridgesemantics.com )

Constructor Summary
DatasetService(java.util.Properties properties)
          Constructor for a DatasetService.
DatasetService(java.util.Properties properties, IModelService modelService, INotificationService notificationService, IReplicationService replicationService)
          Constructor for a DatasetService.
 
Method Summary
 void abort()
          Abort the current transaction
 void begin()
          Begin a transaction
 void beginNonBlocking()
          Begin a NonBlocking transaction
 void clearNotificationTransaction()
          Clear the current notificationTransaction
 void close()
          Close DatasetService by closing all Local and Remote graphs and disconnecting notification service if needed.
 void closeLocalGraph(LocalGraph baseGraph)
          Decrements usage count for Local NamedGraph.
 void closeRemoteGraph(RemoteGraph baseGraph)
          Decrements usage count for Remote NamedGraph.
 void commit()
          Commit the current transaction
 boolean currentThreadOwnsTransaction()
          Return true if current thread owns current transaction
 QueryResult execQuery(IDataset dataset, java.lang.String query)
          Execute a SPARQL query against graphs contained within the dataset passed in, using a local query engine.
 QueryResult execQuery(java.util.Set<org.openrdf.model.URI> defaultNamedGraphs, java.util.Set<org.openrdf.model.URI> namedGraphs, java.lang.String query)
          Execute a SPARQL query against graphs contained within this dataset service, using a local query engine.
 java.lang.Object executeInTransaction(Command command)
          Execute a command within a transaction
 void executeInTransaction(CommandChain commands)
          Execute a CommandChain within a transaction
 IContainer getBaseContainer()
          Get the transactionNamedgraphContainer
 IDataset getCurrentDataset()
          Return a Dataset that contains all the currently open NamedGraphs,either local or remote.
 IDataset getCurrentLocalDataset()
          Get the currentLocalDataset containing the open local NamedGraphs
 IDataset getCurrentRemoteDataset()
          Get the currentRemoteDataset containing the open remote NamedGraphs
 java.util.concurrent.Executor getCustomExecutor()
          Get the customExecutor for DatasetService.
 DatasetServiceReplicator getDatasetReplicator()
          Get the DatasetReplicator for the DatasetService
 DatasetServiceEventManager getEventManager()
          Get the DatasetService's EventManager
 IDataset getLocalDataSet(org.openrdf.model.URI datasetUri, boolean create, boolean createImmediately, boolean addNamedGraphTrackers, java.util.Set<org.openrdf.model.URI> defaultNamedGraphUris, java.util.Set<org.openrdf.model.URI> namedGraphUris)
          Create a new ClosableDatasetServiceDataset that contains the defaultNamedGraphUris listed and the NamedGraphs listed.
 LocalGraph getLocalGraph(org.openrdf.model.URI namedGraphUri, boolean create, boolean addNamedGraphTracker)
          Get a Local NamedGraph for the URI, creating one if it doesn't exist depending on the create flag
 LocalGraph getLocalGraph(org.openrdf.model.URI namedGraphUri, org.openrdf.model.URI metadataGraphUri, boolean create, boolean addNamedGraphTracker)
          Get a LocalGraph for the given URIs, creating one if it doesn't exist depending on the create flag
 LocalGraph getLocalSystemGraph(boolean addNamedGraphTracker)
          Get a Local NamedGraph representation of the Server's system graph.
 IModelService getModelService()
          Get the DatasetService's IModelService
 IContainer getNamedgraphContainer()
          Get the container that stores all local data
 IContainer getNotificationNamedgraphContainer()
          Get the notificationNamedgraphContainer
 INotificationService getNotificationService()
          Get the DatasetService's INotificationService
 ITransaction getNotificationTransaction()
          Get the notificationTransaction
 IDataset getRemoteDataSet(org.openrdf.model.URI datasetUri, boolean create, java.util.Set<org.openrdf.model.URI> defaultNamedGraphUris, java.util.Set<org.openrdf.model.URI> namedGraphUris)
          Create a new ClosableDatasetServiceDataset that contains the defaultNamedGraphUris listed and the NamedGraphs listed.
 RemoteGraph getRemoteGraph(org.openrdf.model.URI namedGraphUri, boolean create)
          Get a Remote NamedGraph for the given URI, creating one if it doesn't exist depending on the create flag.
 RemoteGraph getRemoteGraph(org.openrdf.model.URI namedGraphUri, org.openrdf.model.URI metadataGraphUri, boolean create)
          Get a Remote NamedGraph for the given URIs, creating one if it doesn't exist depending on the create flag.
 RemoteGraph getRemoteSystemGraph()
          Get a RemoteGraph representation of the Server's system graph.
 ITransactionQueueManager getTransactionManager()
          Get the DatasetService's TransactionQueueManager
 ITransactionQueue getTransactionQueue()
          Get the TransactionQueue for DatasetService.
 org.openrdf.model.ValueFactory getValueFactory()
          Get the ValueFactory for this DatasetService
 boolean isClosed()
          Determine if the datasetService is closed
 boolean isIndexSynchronousOnUpdate()
          Determine if indexer should update Synchronously.
 boolean isInTransaction()
          Determine if within currently within a transaction
 boolean isLocalGraphOpen(org.openrdf.model.URI namedGraphUri)
          Returns if the a LocalNamedGraph is open
 boolean isNamedGraphStored(org.openrdf.model.URI namedGraphUri)
          Returns if the NamedGraph is stored on the server
 boolean isPersisted()
          Get whether the Local NamedGraphs for this DatasetService will be persisted.
 boolean isRemoteGraphOpen(org.openrdf.model.URI namedGraphUri)
          Returns if the a RemoteNamedGraph is open
 void setCustomExecutor(java.util.concurrent.Executor customExecutor)
          Set the customExecutor for DatasetService.
 void setIndexSynchronousOnUpdate(boolean indexSynchronousOnUpdate)
          Set if the indexer should update Synchronous.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatasetService

public DatasetService(java.util.Properties properties)
Constructor for a DatasetService. The properties passed in are used for the configuration of the DatasetService object, as well as the NotificationService,ModelService, DatasetServiceReplicator and Model/Graph Persistence.

Parameters:
properties - Configuration properties.
See Also:
ModelServiceProperties, NotificationProperties, RDBProperties, DatasetServiceProperties

DatasetService

public DatasetService(java.util.Properties properties,
                      IModelService modelService,
                      INotificationService notificationService,
                      IReplicationService replicationService)
Constructor for a DatasetService. The properties passed in are used for the configuration of the DatasetService object, as well as the NotificationService,ModelService, DatasetServiceReplicator and Model/Graph Persistence.

Parameters:
properties - Configuration properties.
modelService - to use
notificationService - to use
replicationService - to use
See Also:
ModelServiceProperties, NotificationProperties, RDBProperties, DatasetServiceProperties
Method Detail

isNamedGraphStored

public boolean isNamedGraphStored(org.openrdf.model.URI namedGraphUri)
                           throws AnzoException
Returns if the NamedGraph is stored on the server

Parameters:
namedGraphUri - URI of NamedGraph to check for on server
Returns:
Is the namedGraph stored on the server
Throws:
AnzoException

isLocalGraphOpen

public boolean isLocalGraphOpen(org.openrdf.model.URI namedGraphUri)
Returns if the a LocalNamedGraph is open

Parameters:
namedGraphUri - URI of the NamedGraph
Returns:
is LocalNamedGraph open

isRemoteGraphOpen

public boolean isRemoteGraphOpen(org.openrdf.model.URI namedGraphUri)
Returns if the a RemoteNamedGraph is open

Parameters:
namedGraphUri - URI of the NamedGraph
Returns:
is RemoteNamedGraph open

isPersisted

public boolean isPersisted()
Get whether the Local NamedGraphs for this DatasetService will be persisted.

Returns:
persisted

getLocalGraph

public LocalGraph getLocalGraph(org.openrdf.model.URI namedGraphUri,
                                boolean create,
                                boolean addNamedGraphTracker)
                         throws AnzoException
Get a Local NamedGraph for the URI, creating one if it doesn't exist depending on the create flag

Parameters:
namedGraphUri - URI for the desired NamedGraph
create - Created new NamedGraph if it does not exist on the server
addNamedGraphTracker - Add a notification tracker for the graph in order to get current contents for NamedGraph
Returns:
LocalGraph for given URI
Throws:
AnzoException

getLocalGraph

public LocalGraph getLocalGraph(org.openrdf.model.URI namedGraphUri,
                                org.openrdf.model.URI metadataGraphUri,
                                boolean create,
                                boolean addNamedGraphTracker)
                         throws AnzoException
Get a LocalGraph for the given URIs, creating one if it doesn't exist depending on the create flag

Parameters:
namedGraphUri - URI for the desired NamedGraph
metadataGraphUri - metadata graph's URI for the desired NamedGraph
create - Created new NamedGraph if it does not exist on the server
addNamedGraphTracker - Add a notification tracker for the graph in order to get current contents for NamedGraph
Returns:
LocalGraph for given URI
Throws:
AnzoException

getLocalSystemGraph

public LocalGraph getLocalSystemGraph(boolean addNamedGraphTracker)
                               throws AnzoException
Get a Local NamedGraph representation of the Server's system graph.

Parameters:
addNamedGraphTracker - Add a NamedGraphTracker for graph in order to get current contents for NamedGraph
Returns:
LocalGraph representation of the Server's system graph.
Throws:
AnzoException

getRemoteGraph

public RemoteGraph getRemoteGraph(org.openrdf.model.URI namedGraphUri,
                                  boolean create)
                           throws AnzoException
Get a Remote NamedGraph for the given URI, creating one if it doesn't exist depending on the create flag.

Parameters:
namedGraphUri - URI for the desired NamedGraph
create - Created new NamedGraph if it does not exist on the server
Returns:
RemoteGraph
Throws:
AnzoException

getRemoteGraph

public RemoteGraph getRemoteGraph(org.openrdf.model.URI namedGraphUri,
                                  org.openrdf.model.URI metadataGraphUri,
                                  boolean create)
                           throws AnzoException
Get a Remote NamedGraph for the given URIs, creating one if it doesn't exist depending on the create flag.

Parameters:
namedGraphUri - URI for the desired NamedGraph
metadataGraphUri - metadata graph's URI for the desired NamedGraph
create - Created new NamedGraph if it does not exist on the server
Returns:
RemoteGraph
Throws:
AnzoException

getRemoteSystemGraph

public RemoteGraph getRemoteSystemGraph()
                                 throws AnzoException
Get a RemoteGraph representation of the Server's system graph.

Returns:
A RemoteGraph representation of the Server's system graph.
Throws:
AnzoException - if the User doesn't have the rights to see the system graph

getModelService

public IModelService getModelService()
Get the DatasetService's IModelService

Returns:
the DatasetService's IModelService

getNotificationService

public INotificationService getNotificationService()
Get the DatasetService's INotificationService

Returns:
the DatasetService's INotificationService

closeLocalGraph

public void closeLocalGraph(LocalGraph baseGraph)
                     throws AnzoException
Decrements usage count for Local NamedGraph. If last instance of graph, remove any trackers and close graph.

Parameters:
baseGraph - to close
Throws:
AnzoException

closeRemoteGraph

public void closeRemoteGraph(RemoteGraph baseGraph)
                      throws AnzoException
Decrements usage count for Remote NamedGraph. If last instance, close graph.

Parameters:
baseGraph - to close
Throws:
AnzoException

close

public void close()
Close DatasetService by closing all Local and Remote graphs and disconnecting notification service if needed.


getCustomExecutor

public java.util.concurrent.Executor getCustomExecutor()
Get the customExecutor for DatasetService.

Returns:
the customExecutor for DatasetService.

setCustomExecutor

public void setCustomExecutor(java.util.concurrent.Executor customExecutor)
Set the customExecutor for DatasetService.

Parameters:
customExecutor - for this DatasetService

isIndexSynchronousOnUpdate

public boolean isIndexSynchronousOnUpdate()
Determine if indexer should update Synchronously.

Returns:
true if indexer should update Synchronous.

setIndexSynchronousOnUpdate

public void setIndexSynchronousOnUpdate(boolean indexSynchronousOnUpdate)
Set if the indexer should update Synchronous.

Parameters:
indexSynchronousOnUpdate - if the indexer should update Synchronous.

getTransactionQueue

public ITransactionQueue getTransactionQueue()
Get the TransactionQueue for DatasetService.

Returns:
the TransactionQueue for DatasetService.

getEventManager

public DatasetServiceEventManager getEventManager()
Get the DatasetService's EventManager

Returns:
the DatasetService's EventManager

getTransactionManager

public ITransactionQueueManager getTransactionManager()
Get the DatasetService's TransactionQueueManager

Returns:
the DatasetService's TransactionQueueManager

getLocalDataSet

public IDataset getLocalDataSet(org.openrdf.model.URI datasetUri,
                                boolean create,
                                boolean createImmediately,
                                boolean addNamedGraphTrackers,
                                java.util.Set<org.openrdf.model.URI> defaultNamedGraphUris,
                                java.util.Set<org.openrdf.model.URI> namedGraphUris)
Create a new ClosableDatasetServiceDataset that contains the defaultNamedGraphUris listed and the NamedGraphs listed. All graphs are local.

Parameters:
datasetUri - URI for dataset
create - Create the NamedGraphs if they don't already exist
createImmediately - NamedGraphs should be created immediately when the dataset is created
addNamedGraphTrackers - Add a NamedGraphTracker for each LocalNamedGraph created threw the Dataset
defaultNamedGraphUris - Set of NamedGraphs to union as DefaultModel of Dataset
namedGraphUris - Set of NamedGraphs for Dataset
Returns:
New ClosableDatasetServiceDataset

getRemoteDataSet

public IDataset getRemoteDataSet(org.openrdf.model.URI datasetUri,
                                 boolean create,
                                 java.util.Set<org.openrdf.model.URI> defaultNamedGraphUris,
                                 java.util.Set<org.openrdf.model.URI> namedGraphUris)
Create a new ClosableDatasetServiceDataset that contains the defaultNamedGraphUris listed and the NamedGraphs listed. All graphs are remote.

Parameters:
datasetUri - URI for dataset
create - Create the NamedGraphs if they don't already exist
defaultNamedGraphUris - Set of NamedGraphs to union as DefaultModel of Dataset
namedGraphUris - Set of NamedGraphs for Dataset
Returns:
New ClosableDatasetServiceDataset

getDatasetReplicator

public DatasetServiceReplicator getDatasetReplicator()
Get the DatasetReplicator for the DatasetService

Returns:
DatasetReplicator for the DatasetService

getCurrentDataset

public IDataset getCurrentDataset()
Return a Dataset that contains all the currently open NamedGraphs,either local or remote. No defaultModel is provided.

Returns:
a Dataset that contains all the currently open NamedGraphs,either local or remote.

execQuery

public QueryResult execQuery(java.util.Set<org.openrdf.model.URI> defaultNamedGraphs,
                             java.util.Set<org.openrdf.model.URI> namedGraphs,
                             java.lang.String query)
Execute a SPARQL query against graphs contained within this dataset service, using a local query engine.

Parameters:
defaultNamedGraphs - Set of NamedGraphs using to make up default model in query
namedGraphs - Set of NamedGraphs using to make up named graphs in query
query - Query to run
Returns:
QueryResult object containing results from query

execQuery

public QueryResult execQuery(IDataset dataset,
                             java.lang.String query)
Execute a SPARQL query against graphs contained within the dataset passed in, using a local query engine.

Parameters:
dataset - Dataset to run query against
query - Query to run
Returns:
QueryResult object containing results from query

getCurrentLocalDataset

public IDataset getCurrentLocalDataset()
Get the currentLocalDataset containing the open local NamedGraphs

Returns:
the currentLocalDataset containing the open local NamedGraphs

getCurrentRemoteDataset

public IDataset getCurrentRemoteDataset()
Get the currentRemoteDataset containing the open remote NamedGraphs

Returns:
the currentRemoteDataset containing the open remote NamedGraphs

getNotificationTransaction

public ITransaction getNotificationTransaction()
Get the notificationTransaction

Returns:
the notificationTransaction

clearNotificationTransaction

public void clearNotificationTransaction()
Clear the current notificationTransaction


getNamedgraphContainer

public IContainer getNamedgraphContainer()
Get the container that stores all local data

Returns:
the container that stores all local data

getValueFactory

public org.openrdf.model.ValueFactory getValueFactory()
Get the ValueFactory for this DatasetService

Returns:
the ValueFactory for this DatasetService

abort

public void abort()
           throws AnzoException
Abort the current transaction

Throws:
AnzoException

begin

public void begin()
           throws AnzoException
Begin a transaction

Throws:
AnzoException

beginNonBlocking

public void beginNonBlocking()
                      throws AnzoException
Begin a NonBlocking transaction

Throws:
AnzoException

commit

public void commit()
            throws AnzoException
Commit the current transaction

Throws:
AnzoException

currentThreadOwnsTransaction

public boolean currentThreadOwnsTransaction()
Return true if current thread owns current transaction

Returns:
true if current thread owns current transaction

executeInTransaction

public java.lang.Object executeInTransaction(Command command)
                                      throws AnzoException
Execute a command within a transaction

Parameters:
command - Command to execute in transaction
Returns:
Result from executing command
Throws:
AnzoException

executeInTransaction

public void executeInTransaction(CommandChain commands)
                          throws AnzoException
Execute a CommandChain within a transaction

Parameters:
commands - CommandChain to execute in transaction
Throws:
AnzoException

isInTransaction

public boolean isInTransaction()
Determine if within currently within a transaction

Returns:
true if within a transaction

isClosed

public boolean isClosed()
Determine if the datasetService is closed

Returns:
the closed

getNotificationNamedgraphContainer

public IContainer getNotificationNamedgraphContainer()
Get the notificationNamedgraphContainer

Returns:
the notificationNamedgraphContainer

getBaseContainer

public IContainer getBaseContainer()
Get the transactionNamedgraphContainer

Returns:
the transactionNamedgraphContainer


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