apollo.editor
Class Transaction

java.lang.Object
  extended by apollo.editor.Transaction
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AddTransaction, CompoundTransaction, DeleteTransaction, UpdateTransaction

public class Transaction
extends java.lang.Object
implements java.io.Serializable

Class for keeping track of transactions (changes to annotations or annotation subparts (transactions, exons)). Built and talked to by AnnotationChangeEvents and also by GAMEAdapter as it reads in old transactions. this class is in dire need of some spring cleaning!

See Also:
Serialized Form

Field Summary
protected  java.lang.String author
           
protected  java.util.Date date
           
protected static org.apache.log4j.Logger logger
           
static int NEW
           
protected  java.util.Hashtable newProperties
           
static int OLD
           
protected  java.util.Hashtable oldProperties
           
 
Constructor Summary
Transaction()
           
Transaction(FeatureChangeEvent ace)
           
 
Method Summary
 void addProperty(java.lang.String name, java.lang.String value, int oldOrNew)
          Add a new value to the Vector for this property name.
 AnnotationChangeEvent generateAnnotationChangeEvent(java.lang.Object source)
          different source than trans.
 AnnotationChangeEvent generateUndoChangeEvent(java.lang.Object source)
           
 java.lang.String getAuthor()
           
 java.lang.String getClassString()
           
 java.util.Date getDate()
           
 SeqFeatureI getDeletedFeature()
           
 java.util.List getLeafTransactions()
          Return all descendant leaves of this transaction.
 java.lang.String getNewId()
           
 AnnotatedFeatureI getNewSplitFeature()
          If split compound transaction, this returns the new split off feature.
 java.lang.Object getNewSubpartValue()
           
 TransactionClass getObjectClass()
           
 Comment getOldComment()
          Convenience method for getting old comment
 java.lang.String getOldId()
           
 java.lang.String getOldString()
           
 java.lang.Object getOldSubpartValue()
          Get the previous value.
 TransactionOperation getOperation()
           
protected  java.lang.String getOperationString()
           
 SeqFeatureI getParentFeature()
           
 SeqFeatureI getParentFeatureClone()
           
 CompoundTransaction getParentTransaction()
          If this is a child of a compound transactions, return compound transaction parent return null if have no parent.
 java.lang.String getProperty(java.lang.String name, int oldOrNew)
          Return a single property for name.
 int getRank()
           
 SeqFeatureI getSeqFeature()
          Get the touched SeqFeatureI object.
 SeqFeatureI getSeqFeatureClone()
          Return a clone of the touched SeqFeatureI object; it should reflect the state of the SeqFeatureI when the transaction actually ocurred.
 TransactionSubpart getSubpart()
           
 int getSubpartRank()
           
 java.lang.String getSubpartString()
           
 Transaction getTransaction(int i)
          Default return null.
 boolean hasKids()
          returns true for comp trans if actually has kid trans
 boolean hasParentTransaction()
           
 boolean isAdd()
           
 boolean isAddPeptide()
           
 boolean isCompound()
          default false.
 boolean isDelete()
           
 boolean isMerge()
           
 boolean isSplit()
           
 boolean isUpdate()
           
 boolean isUpdateParent()
           
 java.lang.String oneLineSummary()
          Short (one-line) summary of the object; concise alternative to toString()
 void setAuthor(java.lang.String name)
           
 void setDate(java.util.Date date)
           
 void setDate(java.lang.String date)
           
 void setNewId(java.lang.String newId)
           
 void setNewSubpartValue(java.lang.Object obj)
          Set the subpart value for this Transaction object.
 void setObjectClass(java.lang.String objectClass)
           
 void setOldId(java.lang.String id)
          feature id needs to be explictly set if id changes (type change)
 void setOldSubpartValue(java.lang.Object preValue)
          Set the previouse value for this UpdateTransaction.
 void setOperation(java.lang.String operation)
           
 void setOperation(TransactionOperation operation)
           
 void setParentFeature(SeqFeatureI parent)
           
 void setRank(int rank)
           
 void setSeqFeature(SeqFeatureI feature)
          Set the touched SeqFeatureI object.
 void setSource(java.lang.Object src)
           
 void setSubpart(TransactionSubpart transactionSubpart)
           
 void setSubpartRank(int rank)
           
 int size()
          overridded by CompositeTransaction.
 boolean subpartIsString()
           
 java.lang.String toString()
           
 java.lang.String toString(java.lang.String indent)
          Returns a String of XML representing this transaction.
 void updateClonedTranscriptIdsAndNames(Transaction t, boolean updateAllIds, boolean updateAllParentIds)
          Traverses a transaction and updates the ids/names of any cloned Transcript objects it finds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger

date

protected java.util.Date date

author

protected java.lang.String author

oldProperties

protected java.util.Hashtable oldProperties

newProperties

protected java.util.Hashtable newProperties

OLD

public static int OLD

NEW

public static int NEW
Constructor Detail

Transaction

public Transaction(FeatureChangeEvent ace)

Transaction

public Transaction()
Method Detail

setDate

public void setDate(java.lang.String date)

setDate

public void setDate(java.util.Date date)

getDate

public java.util.Date getDate()

setAuthor

public void setAuthor(java.lang.String name)

getAuthor

public java.lang.String getAuthor()

isUpdate

public boolean isUpdate()

isAdd

public boolean isAdd()

isAddPeptide

public boolean isAddPeptide()

isDelete

public boolean isDelete()

isCompound

public boolean isCompound()
default false. CompoundTransactions overrides with true.


isSplit

public boolean isSplit()

isMerge

public boolean isMerge()

isUpdateParent

public boolean isUpdateParent()

getNewSplitFeature

public AnnotatedFeatureI getNewSplitFeature()
If split compound transaction, this returns the new split off feature. getSeqFeature() returns the feature split off from.


getDeletedFeature

public SeqFeatureI getDeletedFeature()

setSubpart

public void setSubpart(TransactionSubpart transactionSubpart)

getSubpart

public TransactionSubpart getSubpart()

generateAnnotationChangeEvent

public AnnotationChangeEvent generateAnnotationChangeEvent(java.lang.Object source)
different source than trans. should trans even have a source? does it need it?


generateUndoChangeEvent

public AnnotationChangeEvent generateUndoChangeEvent(java.lang.Object source)

setSeqFeature

public void setSeqFeature(SeqFeatureI feature)
Set the touched SeqFeatureI object.

Parameters:
feature -

getSeqFeature

public SeqFeatureI getSeqFeature()
Get the touched SeqFeatureI object.

Returns:

getSeqFeatureClone

public SeqFeatureI getSeqFeatureClone()
Return a clone of the touched SeqFeatureI object; it should reflect the state of the SeqFeatureI when the transaction actually ocurred. Will return null unless Config.getSaveClonedFeaturesInTransactions() was set to true when the transaction was created.


setParentFeature

public void setParentFeature(SeqFeatureI parent)

getParentFeature

public SeqFeatureI getParentFeature()

getParentFeatureClone

public SeqFeatureI getParentFeatureClone()

setSource

public void setSource(java.lang.Object src)

setOldSubpartValue

public void setOldSubpartValue(java.lang.Object preValue)
Set the previouse value for this UpdateTransaction.

Parameters:
preValue - old value

getOldSubpartValue

public java.lang.Object getOldSubpartValue()
Get the previous value. This value is the one before update carried out. Or the value that was deleted.

Returns:

getOldComment

public Comment getOldComment()
Convenience method for getting old comment


getOldString

public java.lang.String getOldString()

setOldId

public void setOldId(java.lang.String id)
feature id needs to be explictly set if id changes (type change)


getOldId

public java.lang.String getOldId()

setNewId

public void setNewId(java.lang.String newId)

getNewId

public java.lang.String getNewId()

setRank

public void setRank(int rank)

getRank

public int getRank()

setSubpartRank

public void setSubpartRank(int rank)

getSubpartRank

public int getSubpartRank()

setNewSubpartValue

public void setNewSubpartValue(java.lang.Object obj)
Set the subpart value for this Transaction object. A subpart value is an object that is touched by this Transaction object. For example, a Comment object is updated, added or deleted. This Comment object should be the subpartValue. So for adds the added subpart is the subpart value(prevalue is null). For updates the new value is the subpart value, the old is the prevalue. For deletes previously deleted value was subpart value and prevalue was null. This seemed inconsistent to me and i changed it to prevaule having deleted value and subpart value being null. What this really means is subpartValue is really the post or new value. If this change is ok then this should be renamed getNewSubpartValue for clarity.

Parameters:
obj -

getNewSubpartValue

public java.lang.Object getNewSubpartValue()
Returns:
See Also:
setSubpartValue(Object).

subpartIsString

public boolean subpartIsString()

getSubpartString

public java.lang.String getSubpartString()

size

public int size()
overridded by CompositeTransaction. Number of child transactions.


hasKids

public boolean hasKids()
returns true for comp trans if actually has kid trans


getTransaction

public Transaction getTransaction(int i)
Default return null. Returns ith child transaction if composite.


getParentTransaction

public CompoundTransaction getParentTransaction()
If this is a child of a compound transactions, return compound transaction parent return null if have no parent.


hasParentTransaction

public boolean hasParentTransaction()

getLeafTransactions

public java.util.List getLeafTransactions()
Return all descendant leaves of this transaction. If not compound just return self as only item in list. CompoundTrans overrides and gets all leaves.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

oneLineSummary

public java.lang.String oneLineSummary()
Short (one-line) summary of the object; concise alternative to toString()


getOperationString

protected java.lang.String getOperationString()

getClassString

public java.lang.String getClassString()

setOperation

public void setOperation(TransactionOperation operation)

setOperation

public void setOperation(java.lang.String operation)

getOperation

public TransactionOperation getOperation()

setObjectClass

public void setObjectClass(java.lang.String objectClass)

getObjectClass

public TransactionClass getObjectClass()

addProperty

public void addProperty(java.lang.String name,
                        java.lang.String value,
                        int oldOrNew)
Add a new value to the Vector for this property name. Store in oldProperties or newProperties hash, as specified.


getProperty

public java.lang.String getProperty(java.lang.String name,
                                    int oldOrNew)
Return a single property for name. If there's more than one value, return the LAST one, not the first.


toString

public java.lang.String toString(java.lang.String indent)
Returns a String of XML representing this transaction. indent is a string of spaces. -> GAME adapter? this is old transactions -- delete


updateClonedTranscriptIdsAndNames

public void updateClonedTranscriptIdsAndNames(Transaction t,
                                              boolean updateAllIds,
                                              boolean updateAllParentIds)
Traverses a transaction and updates the ids/names of any cloned Transcript objects it finds. This is a workaround for the problem that the PureJDBCTransactionWriter can only manipulate objects with valid ids, but the AnnotationEditor frequently creates transactions in which the Transcripts (and other objects) have no valid id or name. In addition, the claimed order of ID and NAME udpate transactions does not always match the actual order, making it necessary in some cases to retroactively update the ids used in lookups to the current id of the feature in question.

Parameters:
updateAllIds - If false then only cloned feature ids/names that are either null or "no_name" will be updated. If true then all cloned seq feature ids and names will be updated (but not parent feature ids/names.)
updateAllParentIds - Same as updateAllIds, but applies only to cloned parent features.