com.atlassian.jira.project.statistics
Class StatisticsManagerImpl

java.lang.Object
  |
  +--com.atlassian.jira.project.statistics.StatisticsManagerImpl
All Implemented Interfaces:
StatisticsManager

public class StatisticsManagerImpl
extends java.lang.Object
implements StatisticsManager

This class manages the Statistics of a project. From this class Statistics are loaded, retrieved, updated etc.


Field Summary
 
Fields inherited from interface com.atlassian.jira.project.statistics.StatisticsManager
CREATE_EVENT, DELETE_EVENT, MOVE_EVENT, UPDATE_EVENT
 
Constructor Summary
StatisticsManagerImpl()
          Construct a StatisticsManager with the default configuration file.
StatisticsManagerImpl(java.lang.String configFile)
          Construct a StatisticsManager with a given configuration file.
 
Method Summary
 java.util.Map getAllStatistics()
          Returns a Map containing the Statistics for all projects that have had their statistics loaded.
 StatisticCollection getStatistics(org.ofbiz.core.entity.GenericValue securityLevel, StatisticType statisticType, org.ofbiz.core.entity.GenericValue project)
          Get the StatisticCollection for this StatisticType, security level and project.
 StatisticCollection getStatistics(com.opensymphony.module.user.User user, StatisticType statisticType, org.ofbiz.core.entity.GenericValue project)
          Returns a StatisticCollection object visible for a particular User based on StatisticType and project.
 long getTotalStatistics(StatisticType statisticType, java.lang.String key, org.ofbiz.core.entity.GenericValue project)
          Get the total statistical value for this StatisticType, key and project.
 java.util.Map getTypes()
          Returns a Map containing all the StatisticType objects that have been loaded
 long getUsersTotalStatistics(com.opensymphony.module.user.User user, StatisticType statisticType, java.lang.String key, org.ofbiz.core.entity.GenericValue project)
          Get the total statistical value for this StatisticType, key and project for all issues that the user can see given their issue security levels.
 void loadStatisticsForAllProjects()
          Load all the statistics for every project into this StatisticsManagerImpl.
 ProjectStatistics refreshProjectStatistics(org.ofbiz.core.entity.GenericValue project)
          Refresh the Statistics for a given project
 java.lang.String toString()
           
 void updateStatistics(StatisticsUpdateEvent event)
          Updates the Statistics based on an issue and its changegroup.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StatisticsManagerImpl

public StatisticsManagerImpl()
Construct a StatisticsManager with the default configuration file.


StatisticsManagerImpl

public StatisticsManagerImpl(java.lang.String configFile)
Construct a StatisticsManager with a given configuration file.

Method Detail

loadStatisticsForAllProjects

public void loadStatisticsForAllProjects()
Load all the statistics for every project into this StatisticsManagerImpl.

If you want to pre-cache all statistics, call this method straight after constructing a StatisticsManager.

Alternatively if you want to lazy load statistics, don't call loadStatisticsForAllProjects() and the first time statistics for a particular project are accessed, they will be loaded.

Specified by:
loadStatisticsForAllProjects in interface StatisticsManager

getStatistics

public StatisticCollection getStatistics(org.ofbiz.core.entity.GenericValue securityLevel,
                                         StatisticType statisticType,
                                         org.ofbiz.core.entity.GenericValue project)
Get the StatisticCollection for this StatisticType, security level and project.

First the ProjectStatistics will be retrieved for this project and from this the StatisticCollection for this security level and StatisticType will be returned

Specified by:
getStatistics in interface StatisticsManager

getTypes

public java.util.Map getTypes()
Returns a Map containing all the StatisticType objects that have been loaded

Specified by:
getTypes in interface StatisticsManager

getAllStatistics

public java.util.Map getAllStatistics()
Returns a Map containing the Statistics for all projects that have had their statistics loaded.

If loadStatisticsForAllProjects() has been called then this map will contain the Statistics for all Projects.

Specified by:
getAllStatistics in interface StatisticsManager

getStatistics

public StatisticCollection getStatistics(com.opensymphony.module.user.User user,
                                         StatisticType statisticType,
                                         org.ofbiz.core.entity.GenericValue project)
Returns a StatisticCollection object visible for a particular User based on StatisticType and project.

It firstly gets the StatisticCollection for no security level for this StatisticType and project

It then gets all the Security Levels that the User has access to. It loops through these levels and gets the StatisticCollection for this level, StatisticType and project.

It merges each StatisticCollection to get one single StatisticCollection object and this is returned

Specified by:
getStatistics in interface StatisticsManager

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

refreshProjectStatistics

public ProjectStatistics refreshProjectStatistics(org.ofbiz.core.entity.GenericValue project)
Refresh the Statistics for a given project

The ProjectStatistics object for the given project is removed from the Project Statistics Map and then they are recalculated and added again

Specified by:
refreshProjectStatistics in interface StatisticsManager

updateStatistics

public void updateStatistics(StatisticsUpdateEvent event)
                      throws org.ofbiz.core.entity.GenericEntityException
Updates the Statistics based on an issue and its changegroup.

This method gets the ProjectStatistics object based on the project of the issue passed in. UpdateStatistics is then called on this object

Specified by:
updateStatistics in interface StatisticsManager
org.ofbiz.core.entity.GenericEntityException
See Also:
ProjectStatistics.updateStatistics(com.atlassian.jira.project.statistics.StatisticsUpdateEvent)

getTotalStatistics

public long getTotalStatistics(StatisticType statisticType,
                               java.lang.String key,
                               org.ofbiz.core.entity.GenericValue project)
Get the total statistical value for this StatisticType, key and project. For example the Statistics for OpenByAssignee for "joe" in Project X

The ProjectStatistics object for this project is retrieved. For each SecurityStatistic in this ProjectStatistics, the StatisticCollection object for this StatisticType is retrieved. The value of the Statistic object with this key is taken from the StatisticCollection and added to the total.

Specified by:
getTotalStatistics in interface StatisticsManager

getUsersTotalStatistics

public long getUsersTotalStatistics(com.opensymphony.module.user.User user,
                                    StatisticType statisticType,
                                    java.lang.String key,
                                    org.ofbiz.core.entity.GenericValue project)
                             throws java.lang.Exception
Get the total statistical value for this StatisticType, key and project for all issues that the user can see given their issue security levels. For example the Statistics for OpenByAssignee for "joe" in Project X that the user can see

The ProjectStatistics object for this project is retrieved. For each SecurityStatistic in this ProjectStatistics, if the security level is one that the user has access to then , the StatisticCollection object for this StatisticType is retrieved. The value of the Statistic object with this key is taken from the StatisticCollection and added to the total.

Specified by:
getUsersTotalStatistics in interface StatisticsManager
java.lang.Exception


Copyright © 2002-2003 Atlassian. All Rights Reserved.