Package org.intermine.api.tracker
Class TemplateTracker
- java.lang.Object
-
- org.intermine.api.tracker.AbstractTracker
-
- org.intermine.api.tracker.TemplateTracker
-
- All Implemented Interfaces:
Tracker
public class TemplateTracker extends AbstractTracker
Class for tracking the templates execution by the users. When a user executes a template, a new track is saved into the database and saved into the memory too.- Author:
- dbutano
-
-
Field Summary
-
Fields inherited from class org.intermine.api.tracker.AbstractTracker
trackerLogger, trackQueue, trackTableName
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TemplateTracker(java.util.Queue<Track> trackQueue)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Map<java.lang.String,java.lang.Integer>
getAccessCounter(java.sql.Connection con)
Return the number of executions for each public templatestatic TemplateTracker
getInstance(java.sql.Connection con, java.util.Queue<Track> trackQueue)
Return an instance of the TemplateTrackerjava.util.Map<java.lang.String,java.lang.Double>
getLogarithmMap(java.lang.String userName, java.lang.String sessionId, TemplateManager templateManager)
Return a map containing the logarithm of accesses for each template.java.lang.String
getName()
Return the tracker's nameprotected java.util.Map<java.lang.String,java.lang.Integer>
getRank(TemplateManager templateManager)
Return the rank for each public template.It represents a relationship between the templates executions; a template with rank 1 has been executed more than a template with rank 2.protected java.lang.Integer
getRank(TemplateManager templateManager, java.lang.String templateName)
get rank for a specific templatejava.lang.String
getStatementCreatingTable()
Generate the sql statement to create the table used by the trackerprotected void
trackTemplate(java.lang.String templateName, Profile profile, java.lang.String sessionIdentifier)
Store into the database the template execution by the user or if the user is not logged during a specific http session.protected void
updateTemplateName(java.lang.String oldTemplateName, java.lang.String newTemplateName, java.sql.Connection con)
Update the template name value into the database-
Methods inherited from class org.intermine.api.tracker.AbstractTracker
createTrackerTable, getTrackTableName, releaseResources, setTrackQueue, storeTrack
-
-
-
-
Constructor Detail
-
TemplateTracker
protected TemplateTracker(java.util.Queue<Track> trackQueue)
- Parameters:
trackQueue
- queue
-
-
Method Detail
-
getInstance
public static TemplateTracker getInstance(java.sql.Connection con, java.util.Queue<Track> trackQueue)
Return an instance of the TemplateTracker- Parameters:
con
- connection to the databasetrackQueue
- queue- Returns:
- TemplateTracker the template tracker
-
trackTemplate
protected void trackTemplate(java.lang.String templateName, Profile profile, java.lang.String sessionIdentifier)
Store into the database the template execution by the user or if the user is not logged during a specific http session. Update the cache.- Parameters:
templateName
- the template nameprofile
- the user profilesessionIdentifier
- the session id
-
getAccessCounter
protected java.util.Map<java.lang.String,java.lang.Integer> getAccessCounter(java.sql.Connection con)
Return the number of executions for each public template- Parameters:
con
- db connection- Returns:
- map with key the template name and executions number
-
getRank
protected java.util.Map<java.lang.String,java.lang.Integer> getRank(TemplateManager templateManager)
Return the rank for each public template.It represents a relationship between the templates executions; a template with rank 1 has been executed more than a template with rank 2. The rank is calculated by summing the logarithm of the templates executions launched by the single users, if the user is logged in, or otherwise, by summing the logarithm of the templates executions during the same http session. The function is called only by the super user- Parameters:
templateManager
- the template manager used to retrieve the global templates- Returns:
- map with key the template name and rank
-
getRank
protected java.lang.Integer getRank(TemplateManager templateManager, java.lang.String templateName)
get rank for a specific template- Parameters:
templateManager
- manager of templatestemplateName
- template to test- Returns:
- rank as an integer
-
getLogarithmMap
public java.util.Map<java.lang.String,java.lang.Double> getLogarithmMap(java.lang.String userName, java.lang.String sessionId, TemplateManager templateManager)
Return a map containing the logarithm of accesses for each template. The map is obtained merging the map of logarithm of accesses for single users and the map of logarithm of accesses for the single sessions- Parameters:
userName
- the user namesessionId
- the http session identifiertemplateManager
- the template manager used to retrieve the global templates- Returns:
- map of logarithm of accesses
-
updateTemplateName
protected void updateTemplateName(java.lang.String oldTemplateName, java.lang.String newTemplateName, java.sql.Connection con)
Update the template name value into the database- Parameters:
oldTemplateName
- the old namenewTemplateName
- the new namecon
- the connection
-
getStatementCreatingTable
public java.lang.String getStatementCreatingTable()
Generate the sql statement to create the table used by the tracker- Specified by:
getStatementCreatingTable
in classAbstractTracker
- Returns:
- String sql statement
-
getName
public java.lang.String getName()
Return the tracker's name- Specified by:
getName
in interfaceTracker
- Specified by:
getName
in classAbstractTracker
- Returns:
- String tracker's name
-
-