Package org.intermine.api.tracker
Class TrackerDelegate
- java.lang.Object
-
- org.intermine.api.tracker.TrackerDelegate
-
- All Implemented Interfaces:
Shutdownable
public class TrackerDelegate extends java.lang.Object implements Shutdownable
Intermediate class which decouples the tracker components from the code that uses them.- Author:
- dbutano
-
-
Field Summary
Fields Modifier and Type Field Description protected java.sql.Connection
connection
protected ObjectStoreWriter
osw
protected java.lang.Thread
trackerLoggerThread
protected java.util.Map<java.lang.String,Tracker>
trackers
-
Constructor Summary
Constructors Constructor Description TrackerDelegate(java.lang.String[] trackerClassNames, ObjectStoreWriter osw)
Create the tracker manager managing the trackers specified in input
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Release the db connection when done.void
finalize()
clean up threadsjava.util.Map<java.lang.String,java.lang.Integer>
getAccessCounter()
Return the rank associated to the templatesjava.util.Map<java.lang.String,java.lang.Integer>
getKeywordSearches()
Return the number of search for each keywordjava.util.List<ListTrack>
getListOperations()
Return the operations done for each list (execution or creation)java.util.Map<java.lang.String,java.lang.Integer>
getRank(TemplateManager templateManager)
Return the rank associated to the templatesjava.lang.Integer
getRank(TemplateManager templateManager, java.lang.String templateName)
Return the rank associated to a single templateTemplateTracker
getTemplateTracker()
Return the tracker templateTracker
getTracker(java.lang.String trackerName)
Return the tracker specified in inputjava.util.Map<java.lang.String,Tracker>
getTrackers()
Return the trackers saved in the TrackerManagerjava.util.Map<java.lang.String,java.lang.Integer>
getUserLogin()
Return the number of access for each uservoid
shutdown()
Called from ShutdownHook.void
trackKeywordSearch(java.lang.String keyword, Profile profile, java.lang.String sessionIdentifier)
Store into the database the login eventvoid
trackListCreation(java.lang.String type, int count, ListBuildMode buildMode, Profile profile, java.lang.String sessionIdentifier)
Store into the database the list creationvoid
trackListExecution(java.lang.String type, int count, Profile profile, java.lang.String sessionIdentifier)
Store into the database the list executionvoid
trackLogin(java.lang.String username)
Store into the database the login eventvoid
trackQuery(java.lang.String type, Profile profile, java.lang.String sessionIdentifier)
Store into the database the execution of a query (saved or temporary)void
trackTemplate(java.lang.String templateName, Profile profile, java.lang.String sessionIdentifier)
Store into the database the template execution by the user specified in inputvoid
updateTemplateName(java.lang.String oldTemplateName, java.lang.String newTemplateName)
Update the template name value into the database
-
-
-
Field Detail
-
trackers
protected java.util.Map<java.lang.String,Tracker> trackers
-
osw
protected ObjectStoreWriter osw
-
connection
protected final java.sql.Connection connection
-
trackerLoggerThread
protected java.lang.Thread trackerLoggerThread
-
-
Constructor Detail
-
TrackerDelegate
public TrackerDelegate(java.lang.String[] trackerClassNames, ObjectStoreWriter osw)
Create the tracker manager managing the trackers specified in input- Parameters:
trackerClassNames
- the tracker namesosw
- the object store witer used to retrieve the connections
-
-
Method Detail
-
getTrackers
public java.util.Map<java.lang.String,Tracker> getTrackers()
Return the trackers saved in the TrackerManager- Returns:
- map containing names and trackers
-
getTemplateTracker
public TemplateTracker getTemplateTracker()
Return the tracker template- Returns:
- map containing names and trackers
-
getTracker
public Tracker getTracker(java.lang.String trackerName)
Return the tracker specified in input- Parameters:
trackerName
- the name of the tracker- Returns:
- Tracker the tracker
-
trackTemplate
public void trackTemplate(java.lang.String templateName, Profile profile, java.lang.String sessionIdentifier)
Store into the database the template execution by the user specified in input- Parameters:
templateName
- the template nameprofile
- the user profilesessionIdentifier
- the session id
-
getAccessCounter
public java.util.Map<java.lang.String,java.lang.Integer> getAccessCounter()
Return the rank associated to the templates- Returns:
- map with key the template name and value the rank associated
-
getRank
public java.util.Map<java.lang.String,java.lang.Integer> getRank(TemplateManager templateManager)
Return the rank associated to the templates- Parameters:
templateManager
- the template manager- Returns:
- map with key the template name and value the rank associated
-
getRank
public java.lang.Integer getRank(TemplateManager templateManager, java.lang.String templateName)
Return the rank associated to a single template- Parameters:
templateManager
- the template managertemplateName
- the template to get the rank for- Returns:
- rank of specified template
-
updateTemplateName
public void updateTemplateName(java.lang.String oldTemplateName, java.lang.String newTemplateName)
Update the template name value into the database- Parameters:
oldTemplateName
- the old namenewTemplateName
- the new name
-
trackListCreation
public void trackListCreation(java.lang.String type, int count, ListBuildMode buildMode, Profile profile, java.lang.String sessionIdentifier)
Store into the database the list creation- Parameters:
type
- the type of the listcount
- the number of items containedbuildMode
- (from identifiers or from the querybuilder page)profile
- the user profilesessionIdentifier
- the session id
-
trackListExecution
public void trackListExecution(java.lang.String type, int count, Profile profile, java.lang.String sessionIdentifier)
Store into the database the list execution- Parameters:
type
- the type of the listcount
- the number of items containedprofile
- the user profilesessionIdentifier
- the session id
-
getListOperations
public java.util.List<ListTrack> getListOperations()
Return the operations done for each list (execution or creation)- Returns:
- the list of ListTrack
-
trackLogin
public void trackLogin(java.lang.String username)
Store into the database the login event- Parameters:
username
- the name of the user logged
-
getUserLogin
public java.util.Map<java.lang.String,java.lang.Integer> getUserLogin()
Return the number of access for each user- Returns:
- map with key the user name and access number
-
trackKeywordSearch
public void trackKeywordSearch(java.lang.String keyword, Profile profile, java.lang.String sessionIdentifier)
Store into the database the login event- Parameters:
keyword
- the keywords used for the searchprofile
- the user profilesessionIdentifier
- the session id
-
getKeywordSearches
public java.util.Map<java.lang.String,java.lang.Integer> getKeywordSearches()
Return the number of search for each keyword- Returns:
- map with key the keyword and the number of searches for that keyword
-
trackQuery
public void trackQuery(java.lang.String type, Profile profile, java.lang.String sessionIdentifier)
Store into the database the execution of a query (saved or temporary)- Parameters:
type
- the root typeprofile
- the user profilesessionIdentifier
- the session id
-
close
public void close()
Release the db connection when done. Once this connection is released, it will be sent back to the connection pool and reassigned to someone else. So we need to be careful to not close a connection someone else is using!
-
shutdown
public void shutdown()
Called from ShutdownHook.- Specified by:
shutdown
in interfaceShutdownable
-
finalize
public void finalize() throws java.lang.Throwable
clean up threads- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
- if something goes wrong
-
-