uk.ac.ebi.intact.application.editor.struts.framework.util
Class AbstractEditViewBean

java.lang.Object
  |
  +--uk.ac.ebi.intact.application.editor.struts.framework.util.AbstractEditViewBean
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BioSourceViewBean, CvViewBean, ExperimentViewBean, InteractionViewBean

public abstract class AbstractEditViewBean
extends java.lang.Object
implements java.io.Serializable

This super bean encapsulates behaviour for a common editing session. This class must be extended to provide editor specific behaviour.

Version:
$Id: AbstractEditViewBean.java,v 1.44 2004/03/29 10:35:09 smudali Exp $
Author:
Sugath Mudali (smudali@ebi.ac.uk)
See Also:
Serialized Form

Constructor Summary
AbstractEditViewBean()
           
 
Method Summary
 void addAnnotation(CommentBean cb)
          Adds an annotation.
 void addToRecentList(EditUserI user)
          Adds the current edit object to the recent edited item list.
 void addXref(XreferenceBean xb)
          Adds an xref.
 void clear()
          Deletes all the links to sub objects of the current edit object.
 void clearTransactions()
          Clears any pending xrefs and annotations stored in the transaction containers.
 void delAnnotation(CommentBean cb)
          Removes an annotation
 void delXref(XreferenceBean xb)
          Removes a xref.
 boolean equals(java.lang.Object obj)
          Compares obj with this object according to Java's equals() contract.
 java.lang.String getAc()
          Returns accession number.
 java.lang.String getAcLink()
          Returns a link to the search application.
 java.util.List getAddDatabaseMenu()
           
 java.util.List getAddTopicMenu()
          Returns the add menu for annotations.
 java.util.Map getAddXrefMenus()
          Returns the add menu for xrefs.
 AnnotatedObject getAnnotatedObject()
          Returns the Annotated object.
 java.util.List getAnnotations()
          Returns a collection of CommentBean objects.
 java.lang.String getDefaultXrefQualifier()
          Returns the default xref qualifier.
 java.lang.Class getEditClass()
          Returns the edit class.
 java.util.List getEditDatabaseMenu()
           
 java.util.Map getEditorMenus()
          Returns the editor specific menus.
 java.util.List getEditTopicMenu()
          Returns the topic menu for editing an existing annotation.
 java.util.Map getEditXrefMenus()
          Returns the edit menu for xrefs.
 java.lang.String getFullName()
          Return the full name.
 java.lang.String getHelpTag()
          Returns the help tag link for the current view bean; subclasses must override this method to return the help tag (if necessary) or else the link to the CV editor is returned.
protected  EditorMenuFactory getMenuFactory()
          Allows access to menu factory.
 java.lang.Boolean getReadOnly()
          False as this object is editable.
 java.lang.String getShortLabel()
          Returns the short label.
 java.util.List getXrefs()
          Returns a collection Xref objects.
 void persist(EditUserI user)
          Persists the current state to the persistent system.
 void persistOthers(EditUserI user)
          Persist any sub objects of the edited object.
 void removeFromRecentList(EditUserI user)
          Removes the current edit object from the recent edited item list.
protected  void reset(AnnotatedObject annot)
          Resets with the bean using an existing Annotated object.
protected  void reset(java.lang.Class clazz)
          Resets the bean with the current edit class.
 void reset(java.lang.Object obj)
          Resets the bean with given object.
 void sanityCheck(EditUserI user)
          Performs sanity check on a bean.
 void saveComment(CommentBean oldcb, CommentBean newcb)
          Replaces an existing annotation bean with a new bean.
 void saveXref(XreferenceBean oldxb, XreferenceBean newxb)
          Replaces an existing xref bean with a new bean.
protected  void setAnnotatedObject(AnnotatedObject annot)
          Sets the annotated object for the bean.
 void setFullName(java.lang.String fullName)
          Sets the full name.
 void setLayout(org.apache.struts.tiles.ComponentContext context)
          Sets the layout in given context.
 void setMenuFactory(EditorMenuFactory factory)
          Sets the menu factory to create menus.
 void setShortLabel(java.lang.String shortLabel)
          Sets the short label.
protected abstract  void updateAnnotatedObject(EditUserI user)
          Gathers values in the view bean and updates the existing AnnotatedObject if it exists or create a new annotated object for the view and sets the annotated object.
 void updateFromForm(org.apache.struts.action.DynaActionForm dynaform)
          Updates the internal data from given form.
 void validate(EditUserI user)
          Validates the data in the view bean.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractEditViewBean

public AbstractEditViewBean()
Method Detail

equals

public boolean equals(java.lang.Object obj)
Compares obj with this object according to Java's equals() contract. Only used for testing a serialized objects.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare.
Returns:
true only if obj is an instance of this class and all non transient fields are equal to given object's non tranient fields. For all other instances, false is returned.

reset

public void reset(java.lang.Object obj)
Resets the bean with given object.

Parameters:
obj - either an Annotated object or a Class. The class type is used when creating a view bean for a new object. For an existing object, AnnotatedObject is used.

reset

protected void reset(java.lang.Class clazz)
Resets the bean with the current edit class. This method is called when creating a new annotated object (only the class or the type is known at that time).

Parameters:
clazz - the Class of the new annotated object.

reset

protected void reset(AnnotatedObject annot)
Resets with the bean using an existing Annotated object.

Parameters:
annot - AnnotatedObject object to set this bean.

setMenuFactory

public void setMenuFactory(EditorMenuFactory factory)
Sets the menu factory to create menus.

Parameters:
factory - the factory to create menus.

getAnnotatedObject

public AnnotatedObject getAnnotatedObject()
Returns the Annotated object. Could be null if the object is not persisted.

Returns:
AnnotatedObject this instace is wrapped around.

getAc

public java.lang.String getAc()
Returns accession number.

Returns:
the accession number as a String instance; null if the current view is not persisted.

getAcLink

public java.lang.String getAcLink()
Returns a link to the search application.

Returns:
ac as a link to the seatch application or an empty string if this object is not yet persisted (i.r., ac is not yet set).

getEditClass

public java.lang.Class getEditClass()
Returns the edit class.

Returns:
the class name of the current edit object.

setShortLabel

public final void setShortLabel(java.lang.String shortLabel)
Sets the short label.

Parameters:
shortLabel - the short label to set.

getShortLabel

public java.lang.String getShortLabel()
Returns the short label.

Returns:
the short label as a String instance.

setFullName

public final void setFullName(java.lang.String fullName)
Sets the full name.

Parameters:
fullName - the full name to set for the current edit object. An empty name (set by tag library when submitting the form) is set to null to avoid equals method returning false for identical objects apart from the full name.

getFullName

public java.lang.String getFullName()
Return the full name.

Returns:
the full name as a String instance.

getAnnotations

public java.util.List getAnnotations()
Returns a collection of CommentBean objects.
 post: return != null
 post: return->forall(obj : Object | obj.oclIsTypeOf(CommentBean))
 


addAnnotation

public void addAnnotation(CommentBean cb)
Adds an annotation.

Parameters:
cb - the bean to add.
 post: myAnnotsToAdd = myAnnotsToAdd@pre + 1
 post: myAnnotations = myAnnotations@pre + 1
 

delAnnotation

public void delAnnotation(CommentBean cb)
Removes an annotation

Parameters:
cb - the comment bean to remove.
 post: myAnnotsToDel = myAnnotsToDel@pre - 1
 post: myAnnotations = myAnnotations@pre - 1
 

getXrefs

public java.util.List getXrefs()
Returns a collection Xref objects.
 post: return->forall(obj: Object | obj.oclIsTypeOf(XreferenceBean))
 


addXref

public void addXref(XreferenceBean xb)
Adds an xref.

Parameters:
xb - the bean to add.
 post: myXrefsToAdd = myXrefsToAdd@pre + 1
 post: myXrefs = myXrefs@pre + 1
 

delXref

public void delXref(XreferenceBean xb)
Removes a xref.

Parameters:
xb - the X'reference bean to remove.
 post: myXrefsToDel = myXrefsToDel@pre + 1
 post: myXrefs = myXrefs@pre - 1
 

saveComment

public void saveComment(CommentBean oldcb,
                        CommentBean newcb)
Replaces an existing annotation bean with a new bean. This method takes care of refreshing relevant lists. For example, if the existing bean is in the new collection, it will be removed from the new collection before the new bean is added.

Parameters:
oldcb - the existing bean to replace.
newcb - the new bean to replace oldcb.

saveXref

public void saveXref(XreferenceBean oldxb,
                     XreferenceBean newxb)
Replaces an existing xref bean with a new bean. This method takes care of refreshing relevant lists. For example, if the existing bean is in the new collection, it will be removed from the new collection before the new bean is added.

Parameters:
oldxb - the existing bean to replace.
newxb - the new bean to replace oldexb.

clearTransactions

public void clearTransactions()
Clears any pending xrefs and annotations stored in the transaction containers.
 post: myAnnotsToAdd->isEmpty
 post: myAnnotsToDel->isEmpty
 post: myAnnotsToUpdate->isEmpty
 post: myXrefsToAdd->isEmpty
 post: myXrefsToDel->isEmpty
 post: myXrefsToUpdate->isEmpty
 


persist

public void persist(EditUserI user)
             throws IntactException,
                    SearchException
Persists the current state to the persistent system. After this method is called the persistent view is as same as the current view.

Parameters:
user - handler to access the persistent method calls.
Throws:
IntactException - for errors in updating the persistent system.
SearchException

clear

public void clear()
Deletes all the links to sub objects of the current edit object.


getEditTopicMenu

public java.util.List getEditTopicMenu()
                                throws SearchException
Returns the topic menu for editing an existing annotation.

Returns:
the topic menu for annotations
Throws:
SearchException - thrown for failures with database access.

getAddTopicMenu

public java.util.List getAddTopicMenu()
                               throws SearchException
Returns the add menu for annotations.

Returns:
the add menu for annotations
Throws:
SearchException - thrown for failures with database access.

getEditDatabaseMenu

public java.util.List getEditDatabaseMenu()
                                   throws SearchException
SearchException

getAddDatabaseMenu

public java.util.List getAddDatabaseMenu()
                                  throws SearchException
SearchException

getEditXrefMenus

public java.util.Map getEditXrefMenus()
                               throws SearchException
Returns the edit menu for xrefs.

Returns:
the edit menu for xrefs.
Throws:
SearchException - thrown for failures with database access.

getAddXrefMenus

public java.util.Map getAddXrefMenus()
                              throws SearchException
Returns the add menu for xrefs.

Returns:
the add menu for xrefs
Throws:
SearchException - thrown for failures with database access.

getDefaultXrefQualifier

public java.lang.String getDefaultXrefQualifier()
Returns the default xref qualifier.

Returns:
the default xref qualifier as a string.

getEditorMenus

public java.util.Map getEditorMenus()
                             throws SearchException
Returns the editor specific menus. All the editors must override this method to provide its own implementation.

Returns:
the editor specific menus.
Throws:
SearchException - thrown for failures with database access.

setLayout

public void setLayout(org.apache.struts.tiles.ComponentContext context)
Sets the layout in given context. This method is currently empty as the layout defaults to cv layout. Override this method to provide editor specific layout.

Parameters:
context - the Tiles context to set the layout.

getHelpTag

public java.lang.String getHelpTag()
Returns the help tag link for the current view bean; subclasses must override this method to return the help tag (if necessary) or else the link to the CV editor is returned.

Returns:
the tag as a String for the current view bean.

validate

public void validate(EditUserI user)
              throws SearchException,
                     ValidationException
Validates the data in the view bean.

Parameters:
user - handler to the user to access the DB.
Throws:
ValidationException - thrown when this bean contains invalid data. For example, an experiment must contain non null values for organism, interaction and identification. Currently this method is empty as no validations are preformed.
SearchException

updateFromForm

public void updateFromForm(org.apache.struts.action.DynaActionForm dynaform)
Updates the internal data from given form.

Parameters:
dynaform - the form to update the internal data.

persistOthers

public void persistOthers(EditUserI user)
                   throws IntactException,
                          SearchException
Persist any sub objects of the edited object. For example, proteins need to be persisted in a separate transaction for an Interaction

Parameters:
user - handler to the user to persist sub objects.
Throws:
IntactException - for errors in persisting.
SearchException - for errors in searching for objects in the persistent system.

addToRecentList

public void addToRecentList(EditUserI user)
Adds the current edit object to the recent edited item list. Interaction or Experiment beans must override this method.

Parameters:
user - the user handle to add to the recent list.

removeFromRecentList

public void removeFromRecentList(EditUserI user)
Removes the current edit object from the recent edited item list. Interaction or Experiment beans must override this method.

Parameters:
user - the user handle to remove from the recent list.

sanityCheck

public void sanityCheck(EditUserI user)
                 throws ValidationException,
                        SearchException
Performs sanity check on a bean. Currently this method doesn't provide checks. Subclass must override this method to provide checks relevant to a view bean.

Throws:
ValidationException - if sanity check fails.
SearchException - for errors in searching for objects in the persistent system.

getReadOnly

public java.lang.Boolean getReadOnly()
False as this object is editable. Sublcasses such as ExperimentViewBean must override this method if it has a large number of interactions. This method is used by actions.jsp to disable saving a large Intact object.

Returns:
false as all the edit beans are editable by default.

setAnnotatedObject

protected void setAnnotatedObject(AnnotatedObject annot)
Sets the annotated object for the bean.

Parameters:
annot - AnnotatedObject to set the bean.

updateAnnotatedObject

protected abstract void updateAnnotatedObject(EditUserI user)
                                       throws SearchException
Gathers values in the view bean and updates the existing AnnotatedObject if it exists or create a new annotated object for the view and sets the annotated object.

Parameters:
user - to access the persistent system.
Throws:
SearchException - for errors in searching the persistent system.
 post: getAnnotatedObject() != null
 

getMenuFactory

protected EditorMenuFactory getMenuFactory()
Allows access to menu factory.

Returns:
the menu factory for sub classes to create menus.


IntAct Project - EMBL-EBI 2004 - intact-help@ebi.ac.uk