org.openanzo.model.transaction.impl
Class TransactionNamedGraphProxy

java.lang.Object
  extended by org.openanzo.model.transaction.impl.TransactionNamedGraphProxy
All Implemented Interfaces:
INamedGraph, IProxyGraph, ITransactionGraph

public class TransactionNamedGraphProxy
extends java.lang.Object
implements ITransactionGraph, IProxyGraph

Graph that contains a transaction queue, so all operations go into transactions before they are applied to a parent graph. All calls to find contain the results of the parentGraph overlaid with the contents of the transactions.

Author:
Matthew Roy ( mroy@cambridgesemantics.com )

Constructor Summary
TransactionNamedGraphProxy(INamedGraph baseGraph, ITransactionQueueManager transactionQueueManager, boolean isMetadataGraph)
          Create new TransactionNamedGraphProxy for baseGraph with given ITransactionQueueManager
TransactionNamedGraphProxy(INamedGraph baseGraph, org.openrdf.model.URI namedGraphUri, boolean isMetadataGraph)
          Create new TransactionNamedGraphProxy for baseGraph with given URI
TransactionNamedGraphProxy(org.openrdf.model.URI namedGraphUri, INamedGraph baseGraph, ITransactionQueueManager transactionQueueHandler, boolean isMetadataGraph)
          Create new TransactionNamedGraphProxy for baseGraph with given ITransactionQueueManager
 
Method Summary
 void add(info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> statements)
          Add a set of statements from graph
 void add(org.openrdf.model.Resource subj, org.openrdf.model.URI pred, org.openrdf.model.Value obj)
          Add a new statement with given subj,pred,obj
 void add(org.openrdf.model.Statement... statements)
          Add one or more statements to graph
 void clear()
          Delete all statements in graph
 void close()
          Close the graph.
 boolean commitTransactionQueue()
          Commit the transaction queue.
 boolean contains(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o)
          Return true if the graph contains at least 1 statement that matches the pattern of subj,prop,obj
 boolean contains(org.openrdf.model.Statement statement)
          Return true if the graph contains at least 1 statement that matches the statement provided
 void delete(info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> statements)
          Delete a set of statements from graph
 void delete(org.openrdf.model.Resource subj, org.openrdf.model.URI pred, org.openrdf.model.Value obj)
          Delete a statement from graph
 void delete(org.openrdf.model.Statement... statements)
          Delete a set of statements from graph
 info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> find(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o)
          Return an iterator of all statements that match the pattern of subj,prop,obj
 org.openrdf.model.URI getBaseNamedGraphUri()
          Get the NamedGraphURI for this proxy
 INamedGraphEventManager getEventManager()
          Return INamedGraphEventManager for this graph
 org.openrdf.model.URI getNamedGraphUri()
          Get the NamedGraphURI for the parent graph
 INamedGraph getParentGraph()
          Get the graph to which this proxy is proxing information.
 info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> getStatements()
          Get an iterator of all statements within this graph
 ITransactionManager getTransactionManager()
          Return ITransactionManager for this graph
 ITransactionQueueManager getTransactionQueueManager()
          Get the ITransactionQueueManager for this graph.
 boolean isClosed()
          Return if graph is closed
 boolean isEmpty()
          Return if graph is empty
 boolean isMetadataGraph()
          Determine if this is a proxy for a metadata graph
 boolean processTransactions(java.util.List<ITransaction> transactionQueue)
          Process a list of transactions, most commonly from another ITransactionGraph.
 void redo()
          Redo the last command in the current transaction.
 void setITransactionQueueHandler(ITransactionQueueManager transactionQueueManager)
          Set the transactionQueueManager for this proxy
 void setNamedGraphUri(org.openrdf.model.URI namedGraphUri)
          Set NamedGraph's URI
 void setParentGraph(INamedGraph graph)
          Set the base graph for this proxy if not already set
 int size()
          Return number of statements in graph
 void undo()
          Undo the last command in the current transaction.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionNamedGraphProxy

public TransactionNamedGraphProxy(INamedGraph baseGraph,
                                  org.openrdf.model.URI namedGraphUri,
                                  boolean isMetadataGraph)
Create new TransactionNamedGraphProxy for baseGraph with given URI

Parameters:
baseGraph - Parent graph
namedGraphUri - URI for graph
isMetadataGraph - true if basegraph is a metadata graph

TransactionNamedGraphProxy

public TransactionNamedGraphProxy(INamedGraph baseGraph,
                                  ITransactionQueueManager transactionQueueManager,
                                  boolean isMetadataGraph)
Create new TransactionNamedGraphProxy for baseGraph with given ITransactionQueueManager

Parameters:
baseGraph - Parent graph
isMetadataGraph - true if basegraph is a metadata graph
transactionQueueManager - TransactionQueueManager to use

TransactionNamedGraphProxy

public TransactionNamedGraphProxy(org.openrdf.model.URI namedGraphUri,
                                  INamedGraph baseGraph,
                                  ITransactionQueueManager transactionQueueHandler,
                                  boolean isMetadataGraph)
Create new TransactionNamedGraphProxy for baseGraph with given ITransactionQueueManager

Parameters:
namedGraphUri - URI for this graph
baseGraph - graph which proxy is operating upon
isMetadataGraph - true if baseGraph is a metadata graph
transactionQueueHandler -
Method Detail

getBaseNamedGraphUri

public org.openrdf.model.URI getBaseNamedGraphUri()
Get the NamedGraphURI for this proxy

Returns:
the NamedGraphURI for this proxy

getNamedGraphUri

public org.openrdf.model.URI getNamedGraphUri()
Get the NamedGraphURI for the parent graph

Specified by:
getNamedGraphUri in interface INamedGraph
Returns:
NamedGraphURI for the parent graph

setNamedGraphUri

public void setNamedGraphUri(org.openrdf.model.URI namedGraphUri)
Description copied from interface: INamedGraph
Set NamedGraph's URI

Specified by:
setNamedGraphUri in interface INamedGraph

isMetadataGraph

public boolean isMetadataGraph()
Determine if this is a proxy for a metadata graph

Returns:
true if this is a proxy for a metadata graph

getParentGraph

public INamedGraph getParentGraph()
Description copied from interface: IProxyGraph
Get the graph to which this proxy is proxing information.

Specified by:
getParentGraph in interface IProxyGraph
Returns:
parent graph to which this proxy is proxing information

setParentGraph

public void setParentGraph(INamedGraph graph)
                    throws TransactionGraphException
Set the base graph for this proxy if not already set

Parameters:
graph - parent graph
Throws:
TransactionGraphException - if the baseGraph is already set

add

public void add(org.openrdf.model.Resource subj,
                org.openrdf.model.URI pred,
                org.openrdf.model.Value obj)
Description copied from interface: INamedGraph
Add a new statement with given subj,pred,obj

Specified by:
add in interface INamedGraph
Parameters:
subj - Subject of statement
pred - Predicate of statement
obj - Object of statement

delete

public void delete(org.openrdf.model.Resource subj,
                   org.openrdf.model.URI pred,
                   org.openrdf.model.Value obj)
Description copied from interface: INamedGraph
Delete a statement from graph

Specified by:
delete in interface INamedGraph
Parameters:
subj - Subject of statement
pred - Predicate of statement
obj - Object of statement

add

public void add(org.openrdf.model.Statement... statements)
Description copied from interface: INamedGraph
Add one or more statements to graph

Specified by:
add in interface INamedGraph
Parameters:
statements - statements to add to graph

delete

public void delete(org.openrdf.model.Statement... statements)
Description copied from interface: INamedGraph
Delete a set of statements from graph

Specified by:
delete in interface INamedGraph
Parameters:
statements - statements to delete from graph

add

public void add(info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> statements)
Description copied from interface: INamedGraph
Add a set of statements from graph

Specified by:
add in interface INamedGraph
Parameters:
statements - statements to delete from graph

delete

public void delete(info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> statements)
Description copied from interface: INamedGraph
Delete a set of statements from graph

Specified by:
delete in interface INamedGraph
Parameters:
statements - statements to delete from graph

setITransactionQueueHandler

public void setITransactionQueueHandler(ITransactionQueueManager transactionQueueManager)
Set the transactionQueueManager for this proxy

Parameters:
transactionQueueManager - for this proxy

getTransactionQueueManager

public ITransactionQueueManager getTransactionQueueManager()
Description copied from interface: ITransactionGraph
Get the ITransactionQueueManager for this graph.

Specified by:
getTransactionQueueManager in interface ITransactionGraph
Returns:
the ITransactionQueueManager for this graph.

clear

public void clear()
Description copied from interface: INamedGraph
Delete all statements in graph

Specified by:
clear in interface INamedGraph

getStatements

public info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> getStatements()
Description copied from interface: INamedGraph
Get an iterator of all statements within this graph

Specified by:
getStatements in interface INamedGraph
Returns:
CloseableIterator of all statements within this graph

close

public void close()
Description copied from interface: INamedGraph
Close the graph.

Specified by:
close in interface INamedGraph

contains

public boolean contains(org.openrdf.model.Resource s,
                        org.openrdf.model.URI p,
                        org.openrdf.model.Value o)
Description copied from interface: INamedGraph
Return true if the graph contains at least 1 statement that matches the pattern of subj,prop,obj

Specified by:
contains in interface INamedGraph
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
Returns:
true if the graph contains at least 1 statement that matches the pattern of subj,prop,obj

contains

public boolean contains(org.openrdf.model.Statement statement)
Description copied from interface: INamedGraph
Return true if the graph contains at least 1 statement that matches the statement provided

Specified by:
contains in interface INamedGraph
Parameters:
statement - Statement to check for existence in graph
Returns:
true if the graph contains at least 1 statement that matches the statement provided

find

public info.aduna.collections.iterators.CloseableIterator<org.openrdf.model.Statement> find(org.openrdf.model.Resource s,
                                                                                            org.openrdf.model.URI p,
                                                                                            org.openrdf.model.Value o)
Description copied from interface: INamedGraph
Return an iterator of all statements that match the pattern of subj,prop,obj

Specified by:
find in interface INamedGraph
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
Returns:
an iterator of all statements that match the pattern of subj,prop,obj

isEmpty

public boolean isEmpty()
Description copied from interface: INamedGraph
Return if graph is empty

Specified by:
isEmpty in interface INamedGraph
Returns:
true if graph is empty

size

public int size()
Description copied from interface: INamedGraph
Return number of statements in graph

Specified by:
size in interface INamedGraph
Returns:
number of statements in graph

processTransactions

public boolean processTransactions(java.util.List<ITransaction> transactionQueue)
Description copied from interface: ITransactionGraph
Process a list of transactions, most commonly from another ITransactionGraph. Useful when applying transactions from different graph types in order to filter or transform the format of the triples from one graph to another.

Specified by:
processTransactions in interface ITransactionGraph
Parameters:
transactionQueue - List of transactions to apply to local queue.
Returns:
Whether or not processing of list was successful.

commitTransactionQueue

public boolean commitTransactionQueue()
                               throws java.lang.Throwable
Description copied from interface: ITransactionGraph
Commit the transaction queue.

Specified by:
commitTransactionQueue in interface ITransactionGraph
Returns:
if committing was successful
Throws:
java.lang.Throwable

undo

public void undo()
          throws AnzoException
Description copied from interface: ITransactionGraph
Undo the last command in the current transaction.

Specified by:
undo in interface ITransactionGraph
Throws:
AnzoException - if there was an error undoing last command on graph

redo

public void redo()
          throws AnzoException
Description copied from interface: ITransactionGraph
Redo the last command in the current transaction.

Specified by:
redo in interface ITransactionGraph
Throws:
AnzoException - if there was an error undoing last command on graph

isClosed

public boolean isClosed()
Description copied from interface: INamedGraph
Return if graph is closed

Specified by:
isClosed in interface INamedGraph
Returns:
true if graph is closed

getEventManager

public INamedGraphEventManager getEventManager()
Description copied from interface: INamedGraph
Return INamedGraphEventManager for this graph

Specified by:
getEventManager in interface INamedGraph
Returns:
INamedGraphEventManager for this graph

getTransactionManager

public ITransactionManager getTransactionManager()
Description copied from interface: INamedGraph
Return ITransactionManager for this graph

Specified by:
getTransactionManager in interface INamedGraph
Returns:
ITransactionManager for this graph


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