Class 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
    • 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 threads
      java.util.Map<java.lang.String,​java.lang.Integer> getAccessCounter()
      Return the rank associated to the templates
      java.util.Map<java.lang.String,​java.lang.Integer> getKeywordSearches()
      Return the number of search for each keyword
      java.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 templates
      java.lang.Integer getRank​(TemplateManager templateManager, java.lang.String templateName)
      Return the rank associated to a single template
      TemplateTracker getTemplateTracker()
      Return the tracker template
      Tracker getTracker​(java.lang.String trackerName)
      Return the tracker specified in input
      java.util.Map<java.lang.String,​Tracker> getTrackers()
      Return the trackers saved in the TrackerManager
      java.util.Map<java.lang.String,​java.lang.Integer> getUserLogin()
      Return the number of access for each user
      void shutdown()
      Called from ShutdownHook.
      void trackKeywordSearch​(java.lang.String keyword, Profile profile, java.lang.String sessionIdentifier)
      Store into the database the login event
      void trackListCreation​(java.lang.String type, int count, ListBuildMode buildMode, Profile profile, java.lang.String sessionIdentifier)
      Store into the database the list creation
      void trackListExecution​(java.lang.String type, int count, Profile profile, java.lang.String sessionIdentifier)
      Store into the database the list execution
      void trackLogin​(java.lang.String username)
      Store into the database the login event
      void 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 input
      void updateTemplateName​(java.lang.String oldTemplateName, java.lang.String newTemplateName)
      Update the template name value into the database
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • trackers

        protected java.util.Map<java.lang.String,​Tracker> trackers
      • 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 names
        osw - 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 name
        profile - the user profile
        sessionIdentifier - 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 manager
        templateName - 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 name
        newTemplateName - 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 list
        count - the number of items contained
        buildMode - (from identifiers or from the querybuilder page)
        profile - the user profile
        sessionIdentifier - 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 list
        count - the number of items contained
        profile - the user profile
        sessionIdentifier - 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 search
        profile - the user profile
        sessionIdentifier - 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 type
        profile - the user profile
        sessionIdentifier - 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 interface Shutdownable
      • finalize

        public void finalize()
                      throws java.lang.Throwable
        clean up threads
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable - if something goes wrong