org.openanzo.model.transaction.impl
Class Transaction

java.lang.Object
  extended by org.openanzo.model.transaction.impl.Transaction
All Implemented Interfaces:
ITransaction
Direct Known Subclasses:
RDBPersistedTransaction

public class Transaction
extends java.lang.Object
implements ITransaction

Standard implementation of ITransation.

Author:
Matthew Roy ( mroy@cambridgesemantics.com )

Constructor Summary
Transaction(ITransactionQueue queue)
          Create a new transaction
 
Method Summary
 ITransactionCommand createNewCommand(java.lang.String commandType, java.util.Set<IPrecondition> preconditions)
          Create a new command for this queue, but do not add it to queue yet
 void delete()
          Delete the transaction from its store.
 void filter(java.util.Collection<org.openrdf.model.Statement> results, org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.Resource... context)
          Use contents of ITransaction to filter the statements contained within the results collection
 int getCommandCount()
          Get the number of the commands within this transaction.
 java.util.List<ITransactionCommand> getCommands()
          Get a List of all the commands within this transaction.
 ITransactionCommand getCurrentCommand(boolean create)
          Get the current command if one exists, and create if empty and create flag is true
 long getId()
           
 ITransactionQueue getTransactionQueue()
          Get the transactionQueue that this transaction is associated with.
 java.lang.Long getTransactionTimestamp()
          Get the transactionTimestamp
 boolean isEmpty()
          Does this transaction have any commands
 ITransactionCommand nextCommand(java.lang.String commandType)
          Create a new command with given type, and set it as the current command in this transaction
 void redo()
          Redo the last command undone.
 void save()
          Save the transaction to its store.
 void setId(long id)
          Set the unique id for this transaction, useful when dealing with server transactions.
 void setTransactionQueue(ITransactionQueue transactionQueue)
          Set the transaction queue that this transaction will be associated with.
 void setTransactionTimestamp(java.lang.Long transactionTimestamp)
          Set the the transactionTimestamp
 void undo()
          Undo the last command.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transaction

public Transaction(ITransactionQueue queue)
Create a new transaction

Parameters:
queue - Parent transaction queue
Method Detail

createNewCommand

public ITransactionCommand createNewCommand(java.lang.String commandType,
                                            java.util.Set<IPrecondition> preconditions)
Create a new command for this queue, but do not add it to queue yet

Parameters:
commandType - Type of command
preconditions - Precondition for command
Returns:
New command, not yet added to queue

nextCommand

public ITransactionCommand nextCommand(java.lang.String commandType)
Create a new command with given type, and set it as the current command in this transaction

Specified by:
nextCommand in interface ITransaction
Parameters:
commandType - Type of command
Returns:
The newly create command

getCurrentCommand

public ITransactionCommand getCurrentCommand(boolean create)
Description copied from interface: ITransaction
Get the current command if one exists, and create if empty and create flag is true

Specified by:
getCurrentCommand in interface ITransaction
Parameters:
create - Whether to create a new command if one doesn't exist.
Returns:
current command, or new command if create flag is true

save

public void save()
          throws AnzoException
Description copied from interface: ITransaction
Save the transaction to its store.

Specified by:
save in interface ITransaction
Throws:
AnzoException - if there is an error saving tranaction

delete

public void delete()
            throws AnzoException
Description copied from interface: ITransaction
Delete the transaction from its store.

Specified by:
delete in interface ITransaction
Throws:
AnzoException - if there is an error deleting tranaction

isEmpty

public boolean isEmpty()
Description copied from interface: ITransaction
Does this transaction have any commands

Specified by:
isEmpty in interface ITransaction
Returns:
True if this transaction has any commands

getCommandCount

public int getCommandCount()
Description copied from interface: ITransaction
Get the number of the commands within this transaction.

Specified by:
getCommandCount in interface ITransaction
Returns:
the number of the commands within this transaction

getCommands

public java.util.List<ITransactionCommand> getCommands()
Description copied from interface: ITransaction
Get a List of all the commands within this transaction.

Specified by:
getCommands in interface ITransaction
Returns:
List of all the commands within this transaction

filter

public void filter(java.util.Collection<org.openrdf.model.Statement> results,
                   org.openrdf.model.Resource s,
                   org.openrdf.model.URI p,
                   org.openrdf.model.Value o,
                   org.openrdf.model.Resource... context)
Description copied from interface: ITransaction
Use contents of ITransaction to filter the statements contained within the results collection

Specified by:
filter in interface ITransaction
Parameters:
results - The collection to overlay with the additions and deletions within this transaction.
s - The subject of the statement pattern being searched on.
p - The property of the statement pattern being searched on.
o - The object of the statement pattern being searched on.
context - The contexts of the statement pattern being searched on.

undo

public void undo()
          throws AnzoException
Description copied from interface: ITransaction
Undo the last command. This consists of removing the command from the transaction queue.

Specified by:
undo in interface ITransaction
Throws:
AnzoException - if there was an error undoing transaction

redo

public void redo()
Description copied from interface: ITransaction
Redo the last command undone. This consists of placing the command back on the transaction queue.

Specified by:
redo in interface ITransaction

getTransactionQueue

public ITransactionQueue getTransactionQueue()
Description copied from interface: ITransaction
Get the transactionQueue that this transaction is associated with.

Specified by:
getTransactionQueue in interface ITransaction
Returns:
transactionQueue that this transaction is associated with

setTransactionQueue

public void setTransactionQueue(ITransactionQueue transactionQueue)
Description copied from interface: ITransaction
Set the transaction queue that this transaction will be associated with.

Specified by:
setTransactionQueue in interface ITransaction
Parameters:
transactionQueue - to which this transaction belongs

getId

public long getId()
Specified by:
getId in interface ITransaction
Returns:
the unique id for this transaction, useful when dealing with server transactions.

setId

public void setId(long id)
Description copied from interface: ITransaction
Set the unique id for this transaction, useful when dealing with server transactions.

Specified by:
setId in interface ITransaction
Parameters:
id - unique if for this transaction

getTransactionTimestamp

public java.lang.Long getTransactionTimestamp()
Get the transactionTimestamp

Specified by:
getTransactionTimestamp in interface ITransaction
Returns:
the transactionTimestamp

setTransactionTimestamp

public void setTransactionTimestamp(java.lang.Long transactionTimestamp)
Set the the transactionTimestamp

Specified by:
setTransactionTimestamp in interface ITransaction
Parameters:
transactionTimestamp - the transactionTimestamp to set


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