uk.ac.ebi.intact.application.editor.business
Class EditUser

java.lang.Object
  |
  +--uk.ac.ebi.intact.application.editor.business.EditUser
All Implemented Interfaces:
EditUserI, java.util.EventListener, javax.servlet.http.HttpSessionBindingListener, IntactUserI, java.io.Serializable

public class EditUser
extends java.lang.Object
implements EditUserI, javax.servlet.http.HttpSessionBindingListener

This class stores information about an Intact Web user session. Instead of binding multiple objects, only an object of this class is bound to a session, thus serving a single access point for multiple information.

This class also implements the HttpSessionBindingListener interface for it can be notified of session time outs.

Version:
$Id: EditUser.java,v 1.53 2004/03/30 21:31:04 smudali Exp $
Author:
Sugath Mudali (smudali@ebi.ac.uk)
See Also:
Serialized Form

Constructor Summary
EditUser(java.lang.String mapping, java.lang.String dsClass)
          This constructor for Seralization test class.
EditUser(java.lang.String mapping, java.lang.String dsClass, java.lang.String user, java.lang.String password)
          Constructs an instance of this class with given mapping file and the name of the data source class.
 
Method Summary
 void addToCurrentExperiment(Experiment exp)
          Adds the experiment to the currently edited/added experiment list.
 void addToCurrentInteraction(Interaction intact)
          Adds the interaction to the currently edited/added interaction list.
 void addToSearchCache(java.util.Collection results)
          Collection of AnnotatedObjects to add to the search cache.
 void begin()
           
 void cancelEdit()
           
 void commit()
           
 void create(java.lang.Object object)
           
 void delete()
          This method clears the view of the current edit object, remove it from the search cache, deletes from the experiment list (if the current edit is an instance of an Experiment class), tand finally delete the current edit object.
 void delete(java.lang.Object object)
           
 boolean equals(java.lang.Object obj)
          Compares obj with this object according to Java's equals() contract.
 void fillSearchResult(org.apache.commons.beanutils.DynaBean dynaForm)
          Popluate the given form with search result.
 Annotation getAnnotation(CommentBean cb)
          Returns an Annotation constructed from the given bean.
 java.util.Set getCurrentExperiments()
          Returns a list of currently edited/added experiments.
 java.util.Set getCurrentInteractions()
          Returns a list of currently edited/added interactions.
 java.lang.String getDatabaseName()
          The name of the database connected to.
 GoServerProxy getGoProxy()
          Returns the Go server proxy assigned for the current session.
 java.lang.String getHelpTag()
          Returns the help tag for the current view bean.
 Institution getInstitution()
          Returns the Institution.
 NewtServerProxy getNewtProxy()
          Returns the Newt server proxy assigned for the current session.
 java.lang.Object getObjectByAc(java.lang.Class clazz, java.lang.String ac)
          Return an Object by ac for given class.
 java.lang.Object getObjectByLabel(java.lang.Class clazz, java.lang.String label)
          Return an Object by classname and shortLabel.
 java.lang.Object getObjectByLabel(java.lang.String className, java.lang.String label)
          Return an Object by classname and shortLabel.
 java.lang.Exception getProteinParseException()
          Returns the last protein parse exception.
 java.lang.String getSearchQuery()
          Returns the latest search query.
 java.util.List getSearchResult()
          Returns the search result as a list.
 java.lang.String getSelectedTopic()
           
 java.util.Collection getSPTRProteins(java.lang.String pid)
          Gets SPTR Proteins via SRS.
 java.lang.String getUniqueShortLabel(java.lang.String shortlabel)
          Returns a unique short label.
 java.lang.String getUniqueShortLabel(java.lang.String shortlabel, java.lang.String extAc)
          Returns a unique short label.
 java.lang.String getUserName()
          Returns the Intact user.
 AbstractEditViewBean getView()
          Returns the user's current edit view.
 Xref getXref(XreferenceBean xb)
          Returns a new instance of Xref constructed from the given bean.
 boolean isEditing()
          Returns the state of editing.
 boolean isPersistent()
          True if the current edit object is persistent.
 boolean isPersistent(java.lang.Object obj)
          True if given object is persistent.
 java.util.Date loginTime()
           
 void logoff()
          Logs off from the application.
 java.util.Date logoffTime()
           
 java.util.Collection lookup(java.lang.String className, java.lang.String value)
          Utility method to handle the logic for lookup, ie trying AC, label etc.
 void persist()
          Persists the object the user is editing.
 void releaseLock()
          Releases the lock held by the user.
 void removeFromCurrentExperiment(Experiment exp)
          Removes the current experiment from the currently edited/added experiment list.
 void removeFromCurrentInteraction(Interaction intact)
          Removes the current interaction from the currently edited/added interaction list.
 void rollback()
           
 java.util.Collection search(java.lang.String objectType, java.lang.String searchParam, java.lang.String searchValue)
          This method provides a means of searching intact objects, within the constraints provided by the parameters to the method.
 java.util.Collection search1(java.lang.String objectType, java.lang.String searchParam, java.lang.String searchValue)
          This method provides a means of searching intact objects, within the constraints provided by the parameters to the method.
 void setSelectedTopic(java.lang.String topic)
           
 void setView(java.lang.Object obj)
          Sets the view using given object.
 boolean shortLabelExists(java.lang.String label)
          Check for duplicity of short label for the current edit object.
 void startEditing()
          Starts editing session.
 void update(java.lang.Object object)
           
 void updateSearchCache(AnnotatedObject annotobj)
          Clears existing search cache and replace it with given bean.
 void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
          Will call this method when an object is bound to a session.
 void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
          Will call this method when an object is unbound from a session.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EditUser

public EditUser(java.lang.String mapping,
                java.lang.String dsClass,
                java.lang.String user,
                java.lang.String password)
         throws DataSourceException,
                IntactException
Constructs an instance of this class with given mapping file and the name of the data source class.

Parameters:
mapping - the name of the mapping file.
dsClass - the class name of the Data Source.
user - the user
password - the password of user.
Throws:
DataSourceException - for error in getting the data source; this could be due to the errors in repository files.
IntactException - for errors in creating IntactHelper; possibly due to an invalid user.

EditUser

public EditUser(java.lang.String mapping,
                java.lang.String dsClass)
         throws IntactException,
                DataSourceException
This constructor for Seralization test class. The user and password is set to null. This is equivalent to calling EditUser(String, String, String, String) with null values for user and password.

Parameters:
mapping - the name of the mapping file.
dsClass - the class name of the Data Source.
Throws:
DataSourceException - for error in getting the data source; this could be due to the errors in repository files.
IntactException - for errors in creating IntactHelper.
See Also:
uk.ac.ebi.intact.application.editor.test.SessionSerializationTest
Method Detail

valueBound

public void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
Will call this method when an object is bound to a session. Starts the user view.

Specified by:
valueBound in interface javax.servlet.http.HttpSessionBindingListener

valueUnbound

public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
Will call this method when an object is unbound from a session. This method sets the logout time.

Specified by:
valueUnbound in interface javax.servlet.http.HttpSessionBindingListener

equals

public boolean equals(java.lang.Object obj)
Compares obj with this object according to Java's equals() contract. Delegates the task to AbstractEditViewBean.equals(Object).

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 its wrapped view equals to this object's view. For all other instances, false is returned.

getUserName

public java.lang.String getUserName()
Description copied from interface: IntactUserI
Returns the Intact user.

Specified by:
getUserName in interface IntactUserI
Returns:
the Intact user currently logged in. This methods could return null if there is no user associated with the current session (e.g., Editor) or for errors in retrieving user information from the database.

getDatabaseName

public java.lang.String getDatabaseName()
Description copied from interface: IntactUserI
The name of the database connected to.

Specified by:
getDatabaseName in interface IntactUserI
Returns:
the name of the database. Could be null for an error in getting the information from the database.

search

public java.util.Collection search(java.lang.String objectType,
                                   java.lang.String searchParam,
                                   java.lang.String searchValue)
                            throws IntactException
Description copied from interface: IntactUserI
This method provides a means of searching intact objects, within the constraints provided by the parameters to the method.

Specified by:
search in interface IntactUserI
Parameters:
objectType - the object type to be searched
searchParam - the parameter to search on (eg field)
searchValue - the search value to match with the parameter
Returns:
the results of the search (empty if no matches were found).
Throws:
IntactException - thrown if problems are encountered during the search process.

getView

public AbstractEditViewBean getView()
Description copied from interface: EditUserI
Returns the user's current edit view.

Specified by:
getView in interface EditUserI
Returns:
user's current edit view.

setView

public void setView(java.lang.Object obj)
Description copied from interface: EditUserI
Sets the view using given object.

Specified by:
setView in interface EditUserI
Parameters:
obj - either an Annotated object or a Class. The class type is used when creating a view for a new object. For an existing object, AnnotatedObject is used.

getSelectedTopic

public java.lang.String getSelectedTopic()
Specified by:
getSelectedTopic in interface EditUserI

setSelectedTopic

public void setSelectedTopic(java.lang.String topic)
Specified by:
setSelectedTopic in interface EditUserI

getInstitution

public Institution getInstitution()
Description copied from interface: EditUserI
Returns the Institution.

Specified by:
getInstitution in interface EditUserI

isEditing

public boolean isEditing()
Description copied from interface: EditUserI
Returns the state of editing.

Specified by:
isEditing in interface EditUserI
Returns:
true if the user is in edit screen; false is returned for all other instances.

startEditing

public void startEditing()
Description copied from interface: EditUserI
Starts editing session. This is needed for Save & Continue operation as editing is turned off automatically upon comitting.

Specified by:
startEditing in interface EditUserI

begin

public void begin()
           throws IntactException
Specified by:
begin in interface EditUserI
IntactException

commit

public void commit()
            throws IntactException
Specified by:
commit in interface EditUserI
IntactException

rollback

public void rollback()
              throws IntactException
Specified by:
rollback in interface EditUserI
IntactException

create

public void create(java.lang.Object object)
            throws IntactException
Specified by:
create in interface EditUserI
IntactException

update

public void update(java.lang.Object object)
            throws IntactException
Specified by:
update in interface EditUserI
IntactException

delete

public void delete(java.lang.Object object)
            throws IntactException
Specified by:
delete in interface EditUserI
IntactException

persist

public void persist()
             throws IntactException,
                    SearchException
Description copied from interface: EditUserI
Persists the object the user is editing.

Specified by:
persist in interface EditUserI
Throws:
SearchException - for search errors (unable to find an object to update).
IntactException - for errors in updating the persistent system.

delete

public void delete()
            throws IntactException
Description copied from interface: EditUserI
This method clears the view of the current edit object, remove it from the search cache, deletes from the experiment list (if the current edit is an instance of an Experiment class), tand finally delete the current edit object.

Specified by:
delete in interface EditUserI
Throws:
IntactException - for errors in deleting the current edit object.

cancelEdit

public void cancelEdit()
Specified by:
cancelEdit in interface EditUserI

isPersistent

public boolean isPersistent(java.lang.Object obj)
Description copied from interface: EditUserI
True if given object is persistent.

Specified by:
isPersistent in interface EditUserI
Parameters:
obj - the object to check for persistency.
Returns:
true if obj is persistent.

isPersistent

public boolean isPersistent()
Description copied from interface: EditUserI
True if the current edit object is persistent. When a new edit object is created, it is not persistent until the form is submitted.

Specified by:
isPersistent in interface EditUserI
Returns:
true if the current edit object is persistent.

getObjectByLabel

public java.lang.Object getObjectByLabel(java.lang.String className,
                                         java.lang.String label)
                                  throws SearchException
Description copied from interface: EditUserI
Return an Object by classname and shortLabel.

Specified by:
getObjectByLabel in interface EditUserI
Parameters:
className - the name of the class to search.
label - the short label to search for.
Throws:
SearchException - thrown for a search failure; also thrown if label already exists in className.

getObjectByLabel

public java.lang.Object getObjectByLabel(java.lang.Class clazz,
                                         java.lang.String label)
                                  throws SearchException
Description copied from interface: EditUserI
Return an Object by classname and shortLabel.

Specified by:
getObjectByLabel in interface EditUserI
Parameters:
clazz - the class object to search.
label - the short label to search for.
Throws:
SearchException - thrown for a search failure; also thrown if label occurrs more than once for clazz.

getObjectByAc

public java.lang.Object getObjectByAc(java.lang.Class clazz,
                                      java.lang.String ac)
                               throws SearchException
Description copied from interface: EditUserI
Return an Object by ac for given class.

Specified by:
getObjectByAc in interface EditUserI
Parameters:
clazz - the class to search for.
ac - the accession number to search for.
Returns:
an Object of clazz type for ac.
Throws:
SearchException - thrown for a search failure; also thrown if ac occurs more than once for clazz; highly unlikely given that ac is the primary key!

getSPTRProteins

public java.util.Collection getSPTRProteins(java.lang.String pid)
Description copied from interface: EditUserI
Gets SPTR Proteins via SRS.

Specified by:
getSPTRProteins in interface EditUserI
Parameters:
pid - the primary id to search for.
Returns:
collection of Protein instances for pid.

getProteinParseException

public java.lang.Exception getProteinParseException()
Description copied from interface: EditUserI
Returns the last protein parse exception.

Specified by:
getProteinParseException in interface EditUserI
Returns:
the last protein parse exception`.

search1

public java.util.Collection search1(java.lang.String objectType,
                                    java.lang.String searchParam,
                                    java.lang.String searchValue)
                             throws SearchException
Description copied from interface: EditUserI
This method provides a means of searching intact objects, within the constraints provided by the parameters to the method.

This method is named as search1 to avoid conflict with the similar named method (with diffrent exception) of the super interface.

Specified by:
search1 in interface EditUserI
Parameters:
objectType - the object type to be searched
searchParam - the parameter to search on (eg field)
searchValue - the search value to match with the parameter
Returns:
the results of the search (empty if no matches were found).
Throws:
SearchException - thrown if problems are encountered during the search process.

getSearchQuery

public java.lang.String getSearchQuery()
Description copied from interface: EditUserI
Returns the latest search query.

Specified by:
getSearchQuery in interface EditUserI
Returns:
the latest search query.

addToSearchCache

public void addToSearchCache(java.util.Collection results)
Description copied from interface: EditUserI
Collection of AnnotatedObjects to add to the search cache. Previous results are removed before adding the new result.

Specified by:
addToSearchCache in interface EditUserI
Parameters:
results - a collection of AnnotatedObjects from the search.
 pre: results->forall(obj: Object | obj.oclIsTypeOf(AnnotatedObjects))
 

updateSearchCache

public void updateSearchCache(AnnotatedObject annotobj)
Description copied from interface: EditUserI
Clears existing search cache and replace it with given bean.

Specified by:
updateSearchCache in interface EditUserI
Parameters:
annotobj - the AnnotatedObject to set as the search cache.

lookup

public java.util.Collection lookup(java.lang.String className,
                                   java.lang.String value)
                            throws SearchException
Description copied from interface: EditUserI
Utility method to handle the logic for lookup, ie trying AC, label etc.

Specified by:
lookup in interface EditUserI
Parameters:
className - the intact type to search on
value - the user-specified value.
Returns:
Collection the results of the search - an empty Collection if no results found
Throws:
SearchException - thrown if there were any search problems

getUniqueShortLabel

public java.lang.String getUniqueShortLabel(java.lang.String shortlabel)
                                     throws SearchException
Description copied from interface: EditUserI
Returns a unique short label.

Specified by:
getUniqueShortLabel in interface EditUserI
Parameters:
shortlabel - the new short label.
Returns:
a unique short label as a String instance. This could be shortlabel if it is unique or current object's AC for otherwise.
Throws:
SearchException - for problems with searching the database.
See Also:
EditUserI.getUniqueShortLabel(String, String)

getUniqueShortLabel

public java.lang.String getUniqueShortLabel(java.lang.String shortlabel,
                                            java.lang.String extAc)
                                     throws SearchException
Description copied from interface: EditUserI
Returns a unique short label.

Specified by:
getUniqueShortLabel in interface EditUserI
Parameters:
shortlabel - the new short label.
extAc - the external ac to be used if shortlabel is not unique.
Returns:
a unique short label as a String instance.
Throws:
SearchException - for problems with searching the database.
See Also:
GoTools.getUniqueShortLabel( uk.ac.ebi.intact.business.IntactHelper, Class, String, String, String)

shortLabelExists

public boolean shortLabelExists(java.lang.String label)
                         throws SearchException
Description copied from interface: EditUserI
Check for duplicity of short label for the current edit object.

Specified by:
shortLabelExists in interface EditUserI
Parameters:
label - the short label to check for duplicity.
Returns:
true if shortlabel already exists (for the current edit object) in the database.
Throws:
SearchException - for errors in acccessing the database.

fillSearchResult

public void fillSearchResult(org.apache.commons.beanutils.DynaBean dynaForm)
Description copied from interface: EditUserI
Popluate the given form with search result.

Specified by:
fillSearchResult in interface EditUserI
Parameters:
dynaForm - the form to populate.

getSearchResult

public java.util.List getSearchResult()
Description copied from interface: EditUserI
Returns the search result as a list.

Specified by:
getSearchResult in interface EditUserI
Returns:
the search result; an empty list is returned if there are no search results.
 post: return != Null
 post: return->forall(obj: Object | obj.oclIsTypeOf(ResultBean))
 

logoff

public void logoff()
            throws IntactException
Description copied from interface: EditUserI
Logs off from the application. This will close the connection to the persistent storage.

Specified by:
logoff in interface EditUserI
Throws:
IntactException - for problems with logging off.

loginTime

public java.util.Date loginTime()
Specified by:
loginTime in interface EditUserI

logoffTime

public java.util.Date logoffTime()
Specified by:
logoffTime in interface EditUserI

getNewtProxy

public NewtServerProxy getNewtProxy()
Description copied from interface: EditUserI
Returns the Newt server proxy assigned for the current session.

Specified by:
getNewtProxy in interface EditUserI
Returns:
an instance of Newt server. A new instance is created if no server is created for the current session.

getGoProxy

public GoServerProxy getGoProxy()
Description copied from interface: EditUserI
Returns the Go server proxy assigned for the current session.

Specified by:
getGoProxy in interface EditUserI
Returns:
an instance of Go server. A new instance is created if no server is created for the current session.

getHelpTag

public java.lang.String getHelpTag()
Description copied from interface: EditUserI
Returns the help tag for the current view bean.

Specified by:
getHelpTag in interface EditUserI
Returns:
the help tag for the current view bean as a String object.

addToCurrentExperiment

public void addToCurrentExperiment(Experiment exp)
Description copied from interface: EditUserI
Adds the experiment to the currently edited/added experiment list.

Specified by:
addToCurrentExperiment in interface EditUserI
Parameters:
exp - the experiment to add to the list.

removeFromCurrentExperiment

public void removeFromCurrentExperiment(Experiment exp)
Description copied from interface: EditUserI
Removes the current experiment from the currently edited/added experiment list.

Specified by:
removeFromCurrentExperiment in interface EditUserI
Parameters:
exp - the experiment to remove from the list.

getCurrentExperiments

public java.util.Set getCurrentExperiments()
Description copied from interface: EditUserI
Returns a list of currently edited/added experiments.

Specified by:
getCurrentExperiments in interface EditUserI
Returns:
a set consists currently edited/added experiments. An empty set is returned if there are no experiments added or edited during the current session.
 post: results->forall(obj: Object | obj.oclIsTypeOf(Experiment))
 

addToCurrentInteraction

public void addToCurrentInteraction(Interaction intact)
Description copied from interface: EditUserI
Adds the interaction to the currently edited/added interaction list.

Specified by:
addToCurrentInteraction in interface EditUserI
Parameters:
intact - the interaction to add to the list.

removeFromCurrentInteraction

public void removeFromCurrentInteraction(Interaction intact)
Description copied from interface: EditUserI
Removes the current interaction from the currently edited/added interaction list.

Specified by:
removeFromCurrentInteraction in interface EditUserI
Parameters:
intact - the interaction to remove from the list.

getCurrentInteractions

public java.util.Set getCurrentInteractions()
Description copied from interface: EditUserI
Returns a list of currently edited/added interactions.

Specified by:
getCurrentInteractions in interface EditUserI
Returns:
a set consists currently edited/added interactions. An empty set is returned if there are no interactions added or edited during the current session.
 post: results->forall(obj: Object | obj.oclIsTypeOf(Interaction))
 

getAnnotation

public Annotation getAnnotation(CommentBean cb)
                         throws SearchException
Description copied from interface: EditUserI
Returns an Annotation constructed from the given bean.

Specified by:
getAnnotation in interface EditUserI
Parameters:
cb - the bean to extract information to construct an Anotation.
Returns:
an Annotation constructed from cb.
Throws:
SearchException - for errors in searching the database.

getXref

public Xref getXref(XreferenceBean xb)
             throws SearchException
Description copied from interface: EditUserI
Returns a new instance of Xref constructed from the given bean.

Specified by:
getXref in interface EditUserI
Parameters:
xb - the bean to extract information to construct an Xref.
Returns:
an instance of Xref constructed from xb.
Throws:
SearchException - for errors in searching the database.

releaseLock

public void releaseLock()
Description copied from interface: EditUserI
Releases the lock held by the user.

Specified by:
releaseLock in interface EditUserI


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