apollo.editor
Class TransactionManager

java.lang.Object
  extended by apollo.editor.TransactionManager
All Implemented Interfaces:
AnnotationChangeListener, java.io.Serializable, java.util.EventListener

public class TransactionManager
extends java.lang.Object
implements AnnotationChangeListener, java.io.Serializable

Author:
wgm rename TransactionList?
See Also:
Serialized Form

Field Summary
protected static org.apache.log4j.Logger logger
           
 
Constructor Summary
TransactionManager()
          Default constructor.
 
Method Summary
 void addTransaction(Transaction trans)
           
 void clear()
           
 void coalesce()
          Coalesce all Transaction instances in this TransactionManager.
 void emptyTransactions()
          Remove all transactions in the memory.
 boolean featureHasBeenEdited(SeqFeatureI feat)
          convenience function.
protected  java.util.List generateTransaction(AnnotationChangeEvent e)
          Generate a Transaction based on a specified AnnotationChangeEvent.
 java.lang.String getAuthor()
           
 java.util.List getFlattenedTransactions()
          Flattens out transactions.
 Transaction getTransaction(int i)
           
 java.util.List getTransactions()
          Get the list of Transaction instances managed by this object.
 boolean handleAnnotationChangeEvent(AnnotationChangeEvent evt)
          Implements the method from AnnotationChangeListener.
 boolean hasTransactions()
           
 boolean isCoalescedDone()
          Check if coalescing is done.
 int numberOfTransactions()
           
 Transaction popTransaction()
           
 void replaceIdUpdatesWithDelAndAdd()
          Change all id update transactions to delete and add.
 void setAnnotationChangeListener(AnnotationChangeListener acl)
          For firing annot change events from undos
 void setAuthor(java.lang.String author)
           
 void setCurationState(CurationState cs)
           
 void setTransactions(java.util.List list)
          Set a list of Transactions for this TransactionManager.
 int size()
           
 void undo(java.lang.Object source)
          direct undo - to replace undo via ACE
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger
Constructor Detail

TransactionManager

public TransactionManager()
Default constructor.

Method Detail

setAuthor

public void setAuthor(java.lang.String author)

getAuthor

public java.lang.String getAuthor()

addTransaction

public void addTransaction(Transaction trans)

coalesce

public void coalesce()
Coalesce all Transaction instances in this TransactionManager. This method should be called for a TransactionManager instance whose needCoalesce is false before Transaction instances are saved. This presently has the side effect of flattening unflattened transactions.


generateTransaction

protected java.util.List generateTransaction(AnnotationChangeEvent e)
Generate a Transaction based on a specified AnnotationChangeEvent. The generated Transaction should be one of subclasses to Transaction. old way - annotation change event does not have transaction - have to create a transaction from the annotation change event new way - annotation change event just holds the transaction - just get it and we're done

Parameters:
e -

getFlattenedTransactions

public java.util.List getFlattenedTransactions()
Flattens out transactions. Compound transactions are reduced to their children. children still have


replaceIdUpdatesWithDelAndAdd

public void replaceIdUpdatesWithDelAndAdd()
Change all id update transactions to delete and add. Current rice/fly chado trigger for creating new ids only, doesnt give new ids for id updates scott may have ammended this - check this out - no scott hasnt ammended this yet but its not urgent. this will modify flattened list of trans(if there is an id update), which will invalidate the unflattened list, for now that means just setting the unflattened = flattened, which i think will be ok. in other words once we've flattened i dont think theres any need to go back to unflattened


handleAnnotationChangeEvent

public boolean handleAnnotationChangeEvent(AnnotationChangeEvent evt)
Implements the method from AnnotationChangeListener. Basically, this method just delegates to addTransaction(AnnotationChangeEvent).

Specified by:
handleAnnotationChangeEvent in interface AnnotationChangeListener
Returns:
always return true for the time being

setTransactions

public void setTransactions(java.util.List list)
Set a list of Transactions for this TransactionManager. This method should be called during opening a new file to load saved Transaction instances.

Parameters:
list -

getTransactions

public java.util.List getTransactions()
Get the list of Transaction instances managed by this object. A new List object (cloned) is returned. why are we cloning the list? taking out clone for now - dont think we need it.

Returns:

undo

public void undo(java.lang.Object source)
direct undo - to replace undo via ACE


popTransaction

public Transaction popTransaction()

setAnnotationChangeListener

public void setAnnotationChangeListener(AnnotationChangeListener acl)
For firing annot change events from undos


hasTransactions

public boolean hasTransactions()

numberOfTransactions

public int numberOfTransactions()

size

public int size()

getTransaction

public Transaction getTransaction(int i)

isCoalescedDone

public boolean isCoalescedDone()
Check if coalescing is done.

Returns:

emptyTransactions

public void emptyTransactions()
Remove all transactions in the memory. This method should be called after Transactions are saved to the database to keep the data synchronization.


clear

public void clear()

featureHasBeenEdited

public boolean featureHasBeenEdited(SeqFeatureI feat)
convenience function. returns true if feat has been edited or a descendant of feat has been edited. (looks through compound trans as well)


setCurationState

public void setCurationState(CurationState cs)