org.intermine.api.profile
Class Profile

java.lang.Object
  extended by org.intermine.api.profile.Profile

public class Profile
extends java.lang.Object

Class to represent a user of the webapp


Field Summary
protected  ProfileManager manager
           
protected  java.lang.String password
           
protected  java.util.Map queryHistory
           
protected  java.util.Map<java.lang.String,InterMineBag> savedBags
           
protected  java.util.Map<java.lang.String,SavedQuery> savedQueries
           
protected  java.util.Map<java.lang.String,TemplateQuery> savedTemplates
           
protected  java.lang.Integer userId
           
protected  java.lang.String username
           
 
Constructor Summary
Profile(ProfileManager manager, java.lang.String username, java.lang.Integer userId, java.lang.String password, java.util.Map<java.lang.String,SavedQuery> savedQueries, java.util.Map<java.lang.String,InterMineBag> savedBags, java.util.Map<java.lang.String,TemplateQuery> savedTemplates)
          Construct a Profile
 
Method Summary
 InterMineBag createBag(java.lang.String name, java.lang.String type, java.lang.String description)
          Create a bag and save it to the userprofile database.
 void deleteBag(java.lang.String name)
          Delete a bag from the user account, if user is logged in also deletes from the userprofile database.
 void deleteHistory(java.lang.String name)
          Remove an item from the query history.
 void deleteQuery(java.lang.String name)
          Delete a query
 void deleteTemplate(java.lang.String name)
          Delete a template
 void disableSaving()
          Disable saving until enableSaving() is called.
 void enableSaving()
          Re-enable saving when saveTemplate(), deleteQuery() etc. are called.
 java.util.Map<java.lang.String,SavedQuery> getHistory()
          Get the session query history.
 java.lang.String getPassword()
          Get the value of password
 ProfileManager getProfileManager()
          Return the ProfileManager that was passed to the constructor.
 java.util.Map<java.lang.String,InterMineBag> getSavedBags()
          Get the value of savedBags
 java.util.Map<java.lang.String,SavedQuery> getSavedQueries()
          Get the value of savedQueries
 java.util.Map<java.lang.String,TemplateQuery> getSavedTemplates()
          Get the users saved templates
 SearchRepository getSearchRepository()
          Get the SearchRepository for this Profile.
 TemplateQuery getTemplate(java.lang.String name)
          get a template
 java.lang.Integer getUserId()
          Get the value of userId
 java.lang.String getUsername()
          Get the value of username
 java.util.Map<java.lang.String,? extends WebSearchable> getWebSearchablesByType(java.lang.String type)
          Return a WebSearchable Map for the given type.
 boolean isLoggedIn()
          Return true if and only if the user is logged is (and the Profile will be written to the userprofile).
 void renameBag(java.lang.String oldName, java.lang.String newName)
          Rename an existing bag, throw exceptions when bag doesn't exist of if new name already exists.
 void renameHistory(java.lang.String oldName, java.lang.String newName)
          Rename an item in the history.
 void saveBag(java.lang.String name, InterMineBag bag)
          Stores a new bag in the profile.
 void saveHistory(SavedQuery query)
          Save a query to the query history.
 void saveQuery(java.lang.String name, SavedQuery query)
          Save a query
 void saveTemplate(java.lang.String name, TemplateQuery template)
          Save a template
 void setUserId(java.lang.Integer userId)
          Set the userId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

manager

protected ProfileManager manager

username

protected java.lang.String username

userId

protected java.lang.Integer userId

password

protected java.lang.String password

savedQueries

protected java.util.Map<java.lang.String,SavedQuery> savedQueries

savedBags

protected java.util.Map<java.lang.String,InterMineBag> savedBags

savedTemplates

protected java.util.Map<java.lang.String,TemplateQuery> savedTemplates

queryHistory

protected java.util.Map queryHistory
Constructor Detail

Profile

public Profile(ProfileManager manager,
               java.lang.String username,
               java.lang.Integer userId,
               java.lang.String password,
               java.util.Map<java.lang.String,SavedQuery> savedQueries,
               java.util.Map<java.lang.String,InterMineBag> savedBags,
               java.util.Map<java.lang.String,TemplateQuery> savedTemplates)
Construct a Profile

Parameters:
manager - the manager for this profile
username - the username for this profile
userId - the id of this user
password - the password for this profile
savedQueries - the saved queries for this profile
savedBags - the saved bags for this profile
savedTemplates - the saved templates for this profile
Method Detail

getProfileManager

public ProfileManager getProfileManager()
Return the ProfileManager that was passed to the constructor.

Returns:
the ProfileManager

getUsername

public java.lang.String getUsername()
Get the value of username

Returns:
the value of username

isLoggedIn

public boolean isLoggedIn()
Return true if and only if the user is logged is (and the Profile will be written to the userprofile).

Returns:
Return true if logged in

getUserId

public java.lang.Integer getUserId()
Get the value of userId

Returns:
an Integer

setUserId

public void setUserId(java.lang.Integer userId)
Set the userId

Parameters:
userId - an Integer

getPassword

public java.lang.String getPassword()
Get the value of password

Returns:
the value of password

disableSaving

public void disableSaving()
Disable saving until enableSaving() is called. This is called before many templates or queries need to be saved or deleted because each call to ProfileManager.saveProfile() is slow.


enableSaving

public void enableSaving()
Re-enable saving when saveTemplate(), deleteQuery() etc. are called. Also calls ProfileManager.saveProfile() to write this Profile to the database and rebuilds the template description index.


getSavedTemplates

public java.util.Map<java.lang.String,TemplateQuery> getSavedTemplates()
Get the users saved templates

Returns:
saved templates

saveTemplate

public void saveTemplate(java.lang.String name,
                         TemplateQuery template)
Save a template

Parameters:
name - the template name
template - the template

getTemplate

public TemplateQuery getTemplate(java.lang.String name)
get a template

Parameters:
name - the template
Returns:
template

deleteTemplate

public void deleteTemplate(java.lang.String name)
Delete a template

Parameters:
name - the template name

getSavedQueries

public java.util.Map<java.lang.String,SavedQuery> getSavedQueries()
Get the value of savedQueries

Returns:
the value of savedQueries

saveQuery

public void saveQuery(java.lang.String name,
                      SavedQuery query)
Save a query

Parameters:
name - the query name
query - the query

deleteQuery

public void deleteQuery(java.lang.String name)
Delete a query

Parameters:
name - the query name

getHistory

public java.util.Map<java.lang.String,SavedQuery> getHistory()
Get the session query history.

Returns:
map from query name to SavedQuery

saveHistory

public void saveHistory(SavedQuery query)
Save a query to the query history.

Parameters:
query - the SavedQuery to save to the history

deleteHistory

public void deleteHistory(java.lang.String name)
Remove an item from the query history.

Parameters:
name - the of the SavedQuery from the history

renameHistory

public void renameHistory(java.lang.String oldName,
                          java.lang.String newName)
Rename an item in the history.

Parameters:
oldName - the name of the old item
newName - the new name

getSavedBags

public java.util.Map<java.lang.String,InterMineBag> getSavedBags()
Get the value of savedBags

Returns:
the value of savedBags

saveBag

public void saveBag(java.lang.String name,
                    InterMineBag bag)
Stores a new bag in the profile. Note that bags are always present in the user profile database, so this just adds the bag to the in-memory list of this profile.

Parameters:
name - the name of the bag
bag - the InterMineBag object

createBag

public InterMineBag createBag(java.lang.String name,
                              java.lang.String type,
                              java.lang.String description)
                       throws ObjectStoreException
Create a bag and save it to the userprofile database.

Parameters:
name - the bag name
type - the bag type
description - the bag description
Returns:
the new bag
Throws:
ObjectStoreException - if something goes wrong

deleteBag

public void deleteBag(java.lang.String name)
               throws ObjectStoreException
Delete a bag from the user account, if user is logged in also deletes from the userprofile database.

Parameters:
name - the bag name
Throws:
ObjectStoreException - if problems deleting bag

renameBag

public void renameBag(java.lang.String oldName,
                      java.lang.String newName)
               throws ObjectStoreException
Rename an existing bag, throw exceptions when bag doesn't exist of if new name already exists. Moves tags from old bag to new bag.

Parameters:
oldName - the bag to rename
newName - new name for the bag
Throws:
ObjectStoreException - if problems storing

getWebSearchablesByType

public java.util.Map<java.lang.String,? extends WebSearchable> getWebSearchablesByType(java.lang.String type)
Return a WebSearchable Map for the given type.

Parameters:
type - the type (from TagTypes)
Returns:
the Map

getSearchRepository

public SearchRepository getSearchRepository()
Get the SearchRepository for this Profile.

Returns:
the SearchRepository for the user