Changeset 698


Ignore:
Timestamp:
04/25/11 22:54:13 (8 years ago)
Author:
philsmart
Message:
 
Location:
raptor-web/trunk/src/main
Files:
6 added
1 deleted
6 edited
2 moved

Legend:

Unmodified
Added
Removed
  • raptor-web/trunk/src/main/java/uk/ac/cardiff/raptorweb/engine/ChartProcessor.java

    r621 r698  
    6262 */ 
    6363public class ChartProcessor { 
    64     static Logger log = LoggerFactory.getLogger(ChartProcessor.class); 
     64     
     65    /** Class logger */ 
     66    private final Logger log = LoggerFactory.getLogger(ChartProcessor.class); 
    6567 
    6668    /* the location of the directory within the application that reports are saved to */ 
     
    436438        tableModel.constructTableForView(); 
    437439 
    438         // log.debug("Raptor Table model constructed, with {} rows",tableModel.getRowList().size()); 
     440        log.debug("Raptor Table model constructed, with {} rows",tableModel.getRowList().size()); 
    439441 
    440442        return tableModel; 
  • raptor-web/trunk/src/main/java/uk/ac/cardiff/raptorweb/engine/RaptorWebEngine.java

    r659 r698  
    103103     * @return List of statistical units, as <code>StatisticalUnitInformation</code> 
    104104     */ 
    105     public List getStatisticalUnits() { 
     105    public List<StatisticalUnitInformation> getStatisticalUnits() { 
    106106        /* get the statistical methods from the currently attached MUA */ 
    107107        if (currentlyAttachedCapabilities!=null && currentlyAttachedCapabilities.isError()==false){ 
     
    128128 
    129129        //return an empty list so as not confuse the view. 
    130         return new ArrayList(); 
     130        return new ArrayList<StatisticalUnitInformation>(); 
    131131    } 
    132132 
  • raptor-web/trunk/src/main/java/uk/ac/cardiff/raptorweb/model/StartStatistics.java

    r538 r698  
    1212public class StartStatistics implements Serializable{ 
    1313 
    14     static Logger log = LoggerFactory.getLogger(StartStatistics.class); 
     14    /** Generates serial UID*/ 
     15    private static final long serialVersionUID = 5877084192204850929L; 
     16 
     17    /** Class logger */ 
     18    private final Logger log = LoggerFactory.getLogger(StartStatistics.class); 
    1519 
    1620    private double numberOfAuthenticationsPer; 
    1721    private double numberOfUniqueAuthenticationsPer; 
    1822    private RaptorTableChartModel topFiveResouces; 
    19     private RaptorTableChartModel bottomFiveResouces; 
    2023    private RaptorJFreeChartModel headlineGraph; 
    2124    private RaptorTableChartModel topFiveUniqueUsersPerSP; 
     25     
     26    public enum StartStatisticType{ 
     27        /** Number of authentications */ 
     28        NO_AUTHS, 
     29        /** Number of unique authentications */ 
     30        NO_UNIQUE_AUTHS, 
     31        /** Top Five resources by no. of authentications*/ 
     32        TOP_FIVE, 
     33        /** The number of authentications over a given time period*/ 
     34        HEADLINE_GRAPH, 
     35        /** Top five resouces by no. of unique users */ 
     36        TOP_FIVE_UNIQUE         
     37    } 
    2238 
    2339    /* the time at which these values were computed */ 
     
    2642    public StartStatistics(){ 
    2743        topFiveResouces=null; 
    28         bottomFiveResouces=null; 
    2944    } 
    3045 
     
    7085    } 
    7186 
    72     public void setBottomFiveResouces(RaptorTableChartModel bottomFiveResouces) { 
    73         this.bottomFiveResouces = bottomFiveResouces; 
    74     } 
    75  
    76     public RaptorTableChartModel getBottomFiveResouces() { 
    77         return bottomFiveResouces; 
    78     } 
    79  
    8087    public void setHeadlineGraph(RaptorJFreeChartModel headlineGraph) { 
    8188        this.headlineGraph = headlineGraph; 
  • raptor-web/trunk/src/main/java/uk/ac/cardiff/raptorweb/model/dashboard/AbstractDashboardStatistic.java

    r693 r698  
    1 package uk.ac.cardiff.raptorweb.model; 
     1package uk.ac.cardiff.raptorweb.model.dashboard; 
    22 
    33import org.joda.time.DateTime; 
     
    55import org.slf4j.LoggerFactory; 
    66 
    7 public class DashboardStatistic { 
     7import uk.ac.cardiff.model.report.AggregatorGraphModel; 
     8import uk.ac.cardiff.model.wsmodel.StatisticParameters; 
     9import uk.ac.cardiff.model.wsmodel.StatisticalUnitInformation; 
     10import uk.ac.cardiff.raptorweb.engine.ChartProcessor; 
     11import uk.ac.cardiff.raptorweb.model.StartStatistics; 
     12 
     13public abstract class AbstractDashboardStatistic { 
    814     
    915    /** Class logger */ 
    10     private final Logger log = LoggerFactory.getLogger(DashboardStatistic.class); 
     16    private final Logger log = LoggerFactory.getLogger(AbstractDashboardStatistic.class); 
    1117     
    1218    /** The name of ths statistical unit in the MUA that is invoked*/ 
     
    1420     
    1521    /** Whether the statistic is to be computed */ 
    16     private boolean enabled; 
     22    private boolean enabled;     
    1723     
     24    /** The type of event this statistic should work over. For example, SHIBBOLETH_AUTHENTICATION*/ 
     25    private StatisticParameters.EventType eventType; 
    1826     
    19     /** The type of event this statistic should work over. For example shibboleth or ezproxy*/ 
    20     private StartModel.EventType eventType; 
     27    /** The chart processor which converts Aggregator Charts into RaptorWeb charts for outputting */ 
     28    protected ChartProcessor chartProcessor; 
     29     
     30    /** Stores which dashboard statistic this should be applied to */ 
     31    private StartStatistics.StartStatisticType dashboardStatisticType; 
     32     
    2133 
     34    /** 
     35     * Process the <code>model</code> passed as a parameter, and return the result 
     36     *  
     37     * @param model 
     38     * @return 
     39     * @throws DashboardStatisticException 
     40     */ 
     41    public abstract Object processStatistic(AggregatorGraphModel model,StatisticalUnitInformation statisticalUnitInformation) throws DashboardStatisticException; 
     42     
     43    public Object getProcessedStatistic(AggregatorGraphModel model, StatisticalUnitInformation statisticalUnitInformation) throws DashboardStatisticException{ 
     44        if (model==null){ 
     45            throw new DashboardStatisticException("Input graph model was null"); 
     46        } 
     47        return processStatistic(model,statisticalUnitInformation); 
     48    } 
    2249 
    2350    public void setStatisticalUnitName(String statisticalUnitName) { 
     
    3764    } 
    3865 
    39     public void setEventType(StartModel.EventType eventType) { 
     66    public void setEventType(StatisticParameters.EventType eventType) { 
    4067        this.eventType = eventType; 
    4168    } 
    4269 
    43     public StartModel.EventType getEventType() { 
     70    public StatisticParameters.EventType getEventType() { 
    4471        return eventType; 
    4572    } 
    4673 
     74    public void setChartProcessor(ChartProcessor chartProcessor) { 
     75        this.chartProcessor = chartProcessor; 
     76    } 
     77 
     78    public ChartProcessor getChartProcessor() { 
     79        return chartProcessor; 
     80    } 
     81 
     82    public void setDashboardStatisticType(StartStatistics.StartStatisticType dashboardStatisticType) { 
     83        this.dashboardStatisticType = dashboardStatisticType; 
     84    } 
     85 
     86    public StartStatistics.StartStatisticType getDashboardStatisticType() { 
     87        return dashboardStatisticType; 
     88    } 
     89 
    4790} 
  • raptor-web/trunk/src/main/java/uk/ac/cardiff/raptorweb/service/impl/StartServiceImpl.java

    r693 r698  
    1515import uk.ac.cardiff.model.wsmodel.StatisticParameters; 
    1616import uk.ac.cardiff.model.wsmodel.StatisticalUnitInformation; 
    17 import uk.ac.cardiff.raptorweb.engine.ChartProcessor; 
    1817import uk.ac.cardiff.raptorweb.engine.RaptorWebEngine; 
    1918import uk.ac.cardiff.raptorweb.model.CachedStartStatistics; 
    2019import uk.ac.cardiff.raptorweb.model.ChartOptions.ChartType; 
    2120import uk.ac.cardiff.raptorweb.model.ChartOptions.GraphPresentation; 
    22 import uk.ac.cardiff.raptorweb.model.DashboardStatistic; 
    2321import uk.ac.cardiff.raptorweb.model.RaptorGraphModel; 
    2422import uk.ac.cardiff.raptorweb.model.RaptorJFreeChartModel; 
     
    2826import uk.ac.cardiff.raptorweb.model.WebSession; 
    2927import uk.ac.cardiff.raptorweb.model.StartModel.TimeRange; 
     28import uk.ac.cardiff.raptorweb.model.dashboard.AbstractDashboardStatistic; 
     29import uk.ac.cardiff.raptorweb.model.dashboard.DashboardStatisticException; 
    3030import uk.ac.cardiff.raptorweb.service.StartService; 
    3131 
    3232/** 
    3333 * @author philsmart 
    34  * 
     34 *  
    3535 */ 
    3636public class StartServiceImpl implements StartService { 
    37     //TODO start or dashboard stats should not be hard coded 
    38      
     37    // TODO start or dashboard stats should not be hard coded 
     38 
    3939    /** Class Logger */ 
    4040    private final Logger log = LoggerFactory.getLogger(StartServiceImpl.class); 
    4141 
    42     /** The engine that is delegated to for all common internal functions of RaptorWeb*/ 
     42    /** The engine that is delegated to for all common internal functions of RaptorWeb */ 
    4343    private RaptorWebEngine webEngine; 
    44      
    45     private List<DashboardStatistic> dashboardStatistics; 
    46      
     44 
     45    /** A <code>List</code> of all the dashboard statistics to compute */ 
     46    private List<AbstractDashboardStatistic> dashboardStatistics; 
    4747 
    4848    /** holds the statistics for the front page gathered from the background worker thread */ 
     
    5151    private CachedStartStatistics cachedStartModelLastMonthShib; 
    5252    private CachedStartStatistics cachedStartModelLastYearShib; 
    53      
     53 
    5454    private CachedStartStatistics cachedStartModelTodayEzproxy; 
    5555    private CachedStartStatistics cachedStartModelLastWeekEzproxy; 
     
    5757    private CachedStartStatistics cachedStartModelLastYearEzproxy; 
    5858 
    59     /** The chart processor which converts Aggregator Charts into RaptorWeb charts for outputting */ 
    60     private ChartProcessor chartProcessor; 
    61  
    6259    public StartServiceImpl() { 
    63         cachedStartModelTodayShib = new CachedStartStatistics(); 
    64         cachedStartModelLastWeekShib = new CachedStartStatistics(); 
    65         cachedStartModelLastMonthShib = new CachedStartStatistics(); 
    66         cachedStartModelLastYearShib = new CachedStartStatistics(); 
    67          
    68         cachedStartModelTodayEzproxy = new CachedStartStatistics(); 
    69         cachedStartModelLastWeekEzproxy = new CachedStartStatistics(); 
    70         cachedStartModelLastMonthEzproxy = new CachedStartStatistics(); 
    71         cachedStartModelLastYearEzproxy = new CachedStartStatistics(); 
     60        cachedStartModelTodayShib = new CachedStartStatistics(); 
     61        cachedStartModelLastWeekShib = new CachedStartStatistics(); 
     62        cachedStartModelLastMonthShib = new CachedStartStatistics(); 
     63        cachedStartModelLastYearShib = new CachedStartStatistics(); 
     64 
     65        cachedStartModelTodayEzproxy = new CachedStartStatistics(); 
     66        cachedStartModelLastWeekEzproxy = new CachedStartStatistics(); 
     67        cachedStartModelLastMonthEzproxy = new CachedStartStatistics(); 
     68        cachedStartModelLastYearEzproxy = new CachedStartStatistics(); 
    7269    } 
    7370 
    7471    public void generateStatisticsBackground() { 
    75         log.info("Generating background statistics for the start page, using {}", this); 
    76         CurrentTimeRange currentTimeRange = getTimeRanges(); 
    77  
    78         StatisticParameters.EventType shibEventType = StatisticParameters.EventType.SHIBBOLETH_AUTHENTICATION; 
    79         StatisticParameters.EventType ezproxyEventType = StatisticParameters.EventType.EZPROXY_AUTHENTICATION; 
    80          
    81         log.debug("Background start page worker getting today"); 
    82         generateStatistics(cachedStartModelTodayShib.getCached(), currentTimeRange.currentTime, currentTimeRange.startToday,shibEventType); 
    83         generateStatistics(cachedStartModelTodayEzproxy.getCached(), currentTimeRange.currentTime, currentTimeRange.startToday,ezproxyEventType); 
    84         log.debug("Background start page worker getting last week"); 
    85         generateStatistics(cachedStartModelLastWeekShib.getCached(), currentTimeRange.currentTime, currentTimeRange.startWeek,shibEventType); 
    86         generateStatistics(cachedStartModelLastWeekEzproxy.getCached(), currentTimeRange.currentTime, currentTimeRange.startWeek,ezproxyEventType); 
    87         log.debug("Background start page worker getting last month"); 
    88         generateStatistics(cachedStartModelLastMonthShib.getCached(), currentTimeRange.currentTime, currentTimeRange.startMonth,shibEventType); 
    89         generateStatistics(cachedStartModelLastMonthEzproxy.getCached(), currentTimeRange.currentTime, currentTimeRange.startMonth,ezproxyEventType); 
    90         log.debug("Background start page worker getting last year"); 
    91         generateStatistics(cachedStartModelLastYearShib.getCached(), currentTimeRange.currentTime, currentTimeRange.startYear,shibEventType); 
    92         generateStatistics(cachedStartModelLastYearEzproxy.getCached(), currentTimeRange.currentTime, currentTimeRange.startYear,ezproxyEventType); 
    93  
    94         log.info("Generating background statistics for the start page...done"); 
     72        log.info("Generating background statistics for the start page, using {}", this); 
     73        CurrentTimeRange currentTimeRange = getTimeRanges(); 
     74 
     75        StatisticParameters.EventType shibEventType = StatisticParameters.EventType.SHIBBOLETH_AUTHENTICATION; 
     76        StatisticParameters.EventType ezproxyEventType = StatisticParameters.EventType.EZPROXY_AUTHENTICATION; 
     77 
     78        log.debug("Background start page worker getting today"); 
     79        generateStatistics(cachedStartModelTodayShib.getCached(), currentTimeRange.currentTime, currentTimeRange.startToday, shibEventType); 
     80        generateStatistics(cachedStartModelTodayEzproxy.getCached(), currentTimeRange.currentTime, currentTimeRange.startToday, ezproxyEventType); 
     81        log.debug("Background start page worker getting last week"); 
     82        generateStatistics(cachedStartModelLastWeekShib.getCached(), currentTimeRange.currentTime, currentTimeRange.startWeek, shibEventType); 
     83        generateStatistics(cachedStartModelLastWeekEzproxy.getCached(), currentTimeRange.currentTime, currentTimeRange.startWeek, ezproxyEventType); 
     84        log.debug("Background start page worker getting last month"); 
     85        generateStatistics(cachedStartModelLastMonthShib.getCached(), currentTimeRange.currentTime, currentTimeRange.startMonth, shibEventType); 
     86        generateStatistics(cachedStartModelLastMonthEzproxy.getCached(), currentTimeRange.currentTime, currentTimeRange.startMonth, ezproxyEventType); 
     87        log.debug("Background start page worker getting last year"); 
     88        generateStatistics(cachedStartModelLastYearShib.getCached(), currentTimeRange.currentTime, currentTimeRange.startYear, shibEventType); 
     89        generateStatistics(cachedStartModelLastYearEzproxy.getCached(), currentTimeRange.currentTime, currentTimeRange.startYear, ezproxyEventType); 
     90 
     91        log.info("Generating background statistics for the start page...done"); 
    9592    } 
    9693 
    9794    @Override 
    9895    public void generateStatistics(WebSession websession) { 
    99         log.debug("Getting start statistics for {} from {}", websession.getStartmodel().getStatsRangeSelector(), this); 
    100  
    101         if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.LASTMONTH &&  
    102                 websession.getStartmodel().getEventType() == StartModel.EventType.SHIBBOLETH_AUTHENTICATION) 
    103             websession.getStartmodel().setStartStatistics(cachedStartModelLastMonthShib.getCached()); 
    104         if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.LASTWEEK &&  
    105                 websession.getStartmodel().getEventType() == StartModel.EventType.SHIBBOLETH_AUTHENTICATION) 
    106             websession.getStartmodel().setStartStatistics(cachedStartModelLastWeekShib.getCached()); 
    107         if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.TODAY &&  
    108                 websession.getStartmodel().getEventType() == StartModel.EventType.SHIBBOLETH_AUTHENTICATION) 
    109             websession.getStartmodel().setStartStatistics(cachedStartModelTodayShib.getCached()); 
    110         if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.LASTYEAR &&  
    111                 websession.getStartmodel().getEventType() == StartModel.EventType.SHIBBOLETH_AUTHENTICATION) 
    112             websession.getStartmodel().setStartStatistics(cachedStartModelLastYearShib.getCached()); 
    113          
    114         if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.LASTMONTH &&  
    115                 websession.getStartmodel().getEventType() == StartModel.EventType.EZPROXY_AUTHENTICATION) 
     96        log.debug("Getting start statistics for {} from {}", websession.getStartmodel().getStatsRangeSelector(), this); 
     97 
     98        if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.LASTMONTH && websession.getStartmodel().getEventType() == StartModel.EventType.SHIBBOLETH_AUTHENTICATION) 
     99            websession.getStartmodel().setStartStatistics(cachedStartModelLastMonthShib.getCached()); 
     100        if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.LASTWEEK && websession.getStartmodel().getEventType() == StartModel.EventType.SHIBBOLETH_AUTHENTICATION) 
     101            websession.getStartmodel().setStartStatistics(cachedStartModelLastWeekShib.getCached()); 
     102        if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.TODAY && websession.getStartmodel().getEventType() == StartModel.EventType.SHIBBOLETH_AUTHENTICATION) 
     103            websession.getStartmodel().setStartStatistics(cachedStartModelTodayShib.getCached()); 
     104        if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.LASTYEAR && websession.getStartmodel().getEventType() == StartModel.EventType.SHIBBOLETH_AUTHENTICATION) 
     105            websession.getStartmodel().setStartStatistics(cachedStartModelLastYearShib.getCached()); 
     106 
     107        if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.LASTMONTH && websession.getStartmodel().getEventType() == StartModel.EventType.EZPROXY_AUTHENTICATION) 
    116108            websession.getStartmodel().setStartStatistics(cachedStartModelLastMonthEzproxy.getCached()); 
    117         if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.LASTWEEK &&  
    118                 websession.getStartmodel().getEventType() == StartModel.EventType.EZPROXY_AUTHENTICATION) 
     109        if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.LASTWEEK && websession.getStartmodel().getEventType() == StartModel.EventType.EZPROXY_AUTHENTICATION) 
    119110            websession.getStartmodel().setStartStatistics(cachedStartModelLastWeekEzproxy.getCached()); 
    120         if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.TODAY &&  
    121                 websession.getStartmodel().getEventType() == StartModel.EventType.EZPROXY_AUTHENTICATION) 
     111        if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.TODAY && websession.getStartmodel().getEventType() == StartModel.EventType.EZPROXY_AUTHENTICATION) 
    122112            websession.getStartmodel().setStartStatistics(cachedStartModelTodayEzproxy.getCached()); 
    123         if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.LASTYEAR &&  
    124                 websession.getStartmodel().getEventType() == StartModel.EventType.EZPROXY_AUTHENTICATION) 
     113        if (websession.getStartmodel().getStatsRangeSelector() == StartModel.TimeRange.LASTYEAR && websession.getStartmodel().getEventType() == StartModel.EventType.EZPROXY_AUTHENTICATION) 
    125114            websession.getStartmodel().setStartStatistics(cachedStartModelLastYearEzproxy.getCached()); 
    126115 
    127         // so we could output the name of the attached MUA 
    128         Capabilities capabilities = getAttachedCapabilities(); 
    129         if (capabilities != null) { 
    130             websession.getStartmodel().setAttachedMUACapabilities(capabilities); 
    131  
    132         } 
     116        // so we could output the name of the attached MUA 
     117        Capabilities capabilities = getAttachedCapabilities(); 
     118        if (capabilities != null) { 
     119            websession.getStartmodel().setAttachedMUACapabilities(capabilities); 
     120 
     121        } 
    133122    } 
    134123 
    135124    private CurrentTimeRange getTimeRanges() { 
    136         long currentTimeInMS = System.currentTimeMillis(); 
    137         DateTime currentDateTime = new DateTime(currentTimeInMS); 
    138         DateTime today = new DateTime(currentTimeInMS); 
    139         today = today.minusHours(today.getHourOfDay()); 
    140         today = today.minusMinutes(today.getMinuteOfHour()); 
    141         today = today.minusSeconds(today.getSecondOfMinute()); 
    142         DateTime oneMonthPrevious = currentDateTime.minusMonths(1); 
    143         DateTime oneYearPrevious = currentDateTime.minusYears(1); 
    144         DateTime oneWeekPrevious = currentDateTime.minusWeeks(1); 
    145  
    146         CurrentTimeRange currentRange = new CurrentTimeRange(); 
    147         currentRange.startMonth = oneMonthPrevious; 
    148         currentRange.startToday = today; 
    149         currentRange.startWeek = oneWeekPrevious; 
    150         currentRange.startYear = oneYearPrevious; 
    151         currentRange.currentTime = currentDateTime; 
    152  
    153         log.debug("Start Page, TODAY [start:{}] [end:{}]", today, currentDateTime); 
    154         log.debug("Start Page, LASTWEEK [start:{}] [end:{}]", oneWeekPrevious, currentDateTime); 
    155         log.debug("Start Page, LASTMONTH [start:{}] [end:{}]", oneMonthPrevious, currentDateTime); 
    156         log.debug("Start Page, LASTYEAR [start:{}] [end:{}]", oneYearPrevious, currentDateTime); 
    157  
    158         return currentRange; 
     125        long currentTimeInMS = System.currentTimeMillis(); 
     126        DateTime currentDateTime = new DateTime(currentTimeInMS); 
     127        DateTime today = new DateTime(currentTimeInMS); 
     128        today = today.minusHours(today.getHourOfDay()); 
     129        today = today.minusMinutes(today.getMinuteOfHour()); 
     130        today = today.minusSeconds(today.getSecondOfMinute()); 
     131        DateTime oneMonthPrevious = currentDateTime.minusMonths(1); 
     132        DateTime oneYearPrevious = currentDateTime.minusYears(1); 
     133        DateTime oneWeekPrevious = currentDateTime.minusWeeks(1); 
     134 
     135        CurrentTimeRange currentRange = new CurrentTimeRange(); 
     136        currentRange.startMonth = oneMonthPrevious; 
     137        currentRange.startToday = today; 
     138        currentRange.startWeek = oneWeekPrevious; 
     139        currentRange.startYear = oneYearPrevious; 
     140        currentRange.currentTime = currentDateTime; 
     141 
     142        log.debug("Start Page, TODAY [start:{}] [end:{}]", today, currentDateTime); 
     143        log.debug("Start Page, LASTWEEK [start:{}] [end:{}]", oneWeekPrevious, currentDateTime); 
     144        log.debug("Start Page, LASTMONTH [start:{}] [end:{}]", oneMonthPrevious, currentDateTime); 
     145        log.debug("Start Page, LASTYEAR [start:{}] [end:{}]", oneYearPrevious, currentDateTime); 
     146 
     147        return currentRange; 
    159148 
    160149    } 
     
    165154    private void generateStatistics(StartStatistics startstats, DateTime currentDateTime, DateTime chosenStartTime, StatisticParameters.EventType eventType) { 
    166155 
    167         List<StatisticalUnitInformation> statisticalUnits = getStatisticalUnits(); 
    168         log.debug("Found {} statistics", statisticalUnits.size()); 
    169         // check for statistical units named numberOfAuthenticationsPer, numberOfUnqiueUsersPer, hence the MUA must support this 
    170         StatisticalUnitInformation numberOfAuthenticationsPerUnitInformation = null; 
    171         StatisticalUnitInformation numberOfUniqueUsersPerUnitInformation = null; 
    172         StatisticalUnitInformation topFiveResources = null; 
    173         StatisticalUnitInformation bottomFiveResources = null; 
    174         StatisticalUnitInformation numberOfAuthenticationsPerIntervalNumber = null; 
    175         StatisticalUnitInformation numberOfUniqueAuthenticationsPerSP =null; 
    176         for (StatisticalUnitInformation unit : statisticalUnits) { 
    177             if (unit.getStatisticParameters().getType() == StatisticParameters.StatisticType.SYSTEM) { 
    178                 if (unit.getStatisticParameters().getUnitName().equals("numberOfAuthenticationsPer")) 
    179                     numberOfAuthenticationsPerUnitInformation = unit; 
    180                 if (unit.getStatisticParameters().getUnitName().equals("numberOfUnqiueUsersPer")) 
    181                     numberOfUniqueUsersPerUnitInformation = unit; 
    182                 if (unit.getStatisticParameters().getUnitName().equals("top5Resources")) 
    183                     topFiveResources = unit; 
    184                 if (unit.getStatisticParameters().getUnitName().equals("bottom5Resources")) 
    185                     bottomFiveResources = unit; 
    186                 if (unit.getStatisticParameters().getUnitName().equals("numberOfAuthenticationsPerIntervalNumber")) 
    187                     numberOfAuthenticationsPerIntervalNumber = unit; 
    188                 if (unit.getStatisticParameters().getUnitName().equals("numberOfUniqueAuthenticationsPerSP")) 
    189                     numberOfUniqueAuthenticationsPerSP = unit; 
    190             } 
    191         } 
    192         log.debug("Using statistic {} to find number of authentications per", numberOfAuthenticationsPerUnitInformation); 
    193         log.debug("Using statistic {} to find number of unique users per", numberOfUniqueUsersPerUnitInformation); 
    194         log.debug("Using statistic {} to find number top five resources", topFiveResources); 
    195         log.debug("Using statistic {} to find number bottom five resources", topFiveResources); 
    196         log.debug("Using statistic {} to find number of authentication in 12 intervals", numberOfAuthenticationsPerIntervalNumber); 
    197         log.debug("Using statistic {} to find number of unique authentication per service provider", numberOfUniqueAuthenticationsPerSP); 
    198  
    199         AggregatorGraphModel numberOfAuthentications = null; 
    200         if (numberOfAuthenticationsPerUnitInformation != null) { 
    201             numberOfAuthenticationsPerUnitInformation.getStatisticParameters().setEndTime(currentDateTime); 
    202             numberOfAuthenticationsPerUnitInformation.getStatisticParameters().setStartTime(chosenStartTime); 
    203             numberOfAuthenticationsPerUnitInformation.getStatisticParameters().setEventType(eventType); 
    204             numberOfAuthentications = webEngine.updateAndInvokeStatisticalUnit(numberOfAuthenticationsPerUnitInformation); 
    205         } 
    206  
    207         AggregatorGraphModel numberOfUniqueUsers = null; 
    208         if (numberOfUniqueUsersPerUnitInformation != null) { 
    209             numberOfUniqueUsersPerUnitInformation.getStatisticParameters().setEndTime(currentDateTime); 
    210             numberOfUniqueUsersPerUnitInformation.getStatisticParameters().setStartTime(chosenStartTime); 
    211             numberOfUniqueUsersPerUnitInformation.getStatisticParameters().setEventType(eventType); 
    212             numberOfUniqueUsers = webEngine.updateAndInvokeStatisticalUnit(numberOfUniqueUsersPerUnitInformation); 
    213  
    214         } 
    215  
    216         AggregatorGraphModel topFiveResourcesModel = null; 
    217         if (topFiveResources != null) { 
    218             topFiveResources.getStatisticParameters().setEndTime(currentDateTime); 
    219             topFiveResources.getStatisticParameters().setStartTime(chosenStartTime); 
    220             topFiveResources.getStatisticParameters().setEventType(eventType); 
    221             topFiveResourcesModel = webEngine.updateAndInvokeStatisticalUnit(topFiveResources); 
    222         } 
    223  
    224  
    225         AggregatorGraphModel numberOfAuthenticationsPerIntervalNumberModel = null; 
    226         if (numberOfAuthenticationsPerIntervalNumber != null) { 
    227             numberOfAuthenticationsPerIntervalNumber.getStatisticParameters().setEndTime(currentDateTime); 
    228             numberOfAuthenticationsPerIntervalNumber.getStatisticParameters().setStartTime(chosenStartTime); 
    229             numberOfAuthenticationsPerIntervalNumber.getStatisticParameters().setEventType(eventType); 
    230             numberOfAuthenticationsPerIntervalNumberModel = webEngine.updateAndInvokeStatisticalUnit(numberOfAuthenticationsPerIntervalNumber); 
    231         } 
    232  
    233         AggregatorGraphModel uniqueAuthsPerSPModel =null; 
    234         if (numberOfUniqueAuthenticationsPerSP !=null){ 
    235             numberOfUniqueAuthenticationsPerSP.getStatisticParameters().setEndTime(currentDateTime); 
    236             numberOfUniqueAuthenticationsPerSP.getStatisticParameters().setStartTime(chosenStartTime); 
    237             numberOfUniqueAuthenticationsPerSP.getStatisticParameters().setEventType(eventType); 
    238             uniqueAuthsPerSPModel = webEngine.updateAndInvokeStatisticalUnit(numberOfUniqueAuthenticationsPerSP); 
    239         } 
    240  
    241         // Now set the statistics values ------ 
    242  
    243         if (numberOfAuthentications != null && numberOfUniqueUsers != null && topFiveResourcesModel != null && numberOfAuthenticationsPerIntervalNumberModel != null && uniqueAuthsPerSPModel!=null) { 
    244             if (numberOfAuthentications != null) { 
    245                 RaptorTableChartModel table = getChartProcessor().constructRaptorTableChartModel(numberOfAuthentications); 
    246                 //should only have one series, and one row 
    247                 if (table.getTableSeries().size()==1){ 
    248                         if (table.getTableSeries().get(0).getRows().size() == 1) { 
    249                             if (table.getTableSeries().get(0).getRows().get(0).getValue() instanceof Double) { 
    250                                 startstats.setNumberOfAuthenticationsPer(((Double) table.getTableSeries().get(0).getRows().get(0).getValue())); 
    251                             } 
    252                         } 
    253                 } 
    254             } 
    255  
    256             if (numberOfUniqueUsers != null) { 
    257                 if (numberOfUniqueUsers != null) { 
    258                     RaptorTableChartModel table = getChartProcessor().constructRaptorTableChartModel(numberOfUniqueUsers); 
    259                     // there should only be one series, and each result shows one distinct value, so number of results show number of distinct values 
    260                     if (table.getTableSeries().size()==1){ 
    261                             if (table.getTableSeries().get(0).getRows() != null) { 
    262                                 startstats.setNumberOfUniqueAuthenticationsPer(table.getTableSeries().get(0).getRows().size()); 
    263                             } 
    264                     } 
    265                 } 
    266             } 
    267  
    268             if (topFiveResourcesModel != null) { 
    269                 RaptorTableChartModel table = getChartProcessor().constructRaptorTableChartModel(topFiveResourcesModel); 
    270                 startstats.setTopFiveResouces(table); 
    271             } 
    272  
    273             if (numberOfAuthenticationsPerIntervalNumberModel != null) { 
    274                 RaptorJFreeChartModel jfreeChart = getChartProcessor().constructJFreeGraph(GraphPresentation.FRONT,ChartType.AREA,numberOfAuthenticationsPerIntervalNumberModel,1270,350,(chosenStartTime.toString("ddMMyyyHH-mm")+"-"+currentDateTime.toString("ddMMyyyHH-mm"))); 
    275                 startstats.setHeadlineGraph(jfreeChart); 
    276             } 
    277             if (uniqueAuthsPerSPModel != null) { 
    278                 RaptorTableChartModel table = getChartProcessor().constructRaptorTableChartModel(uniqueAuthsPerSPModel); 
    279                 startstats.setTopFiveUniqueUsersPerSP(table); 
    280             } 
    281  
    282             // set update time on the stats 
    283             startstats.setAccurateOf(new DateTime(System.currentTimeMillis())); 
    284         } else { 
    285             log.warn("Did not fetch all statistics for dates {} and {}", chosenStartTime, currentDateTime); 
    286         } 
    287  
    288     } 
    289  
    290     private List getStatisticalUnits() { 
    291         return webEngine.getStatisticalUnits(); 
     156        List<StatisticalUnitInformation> statisticalUnits = getStatisticalUnits(); 
     157        log.info("Dashboard statistics are to be computed from a possible {} MUA statistics", statisticalUnits.size()); 
     158 
     159        int computed=0; 
     160        int toCompute =0; 
     161        for (AbstractDashboardStatistic dashboardStatistic : dashboardStatistics) { 
     162            if (dashboardStatistic.isEnabled() && dashboardStatistic.getEventType()==eventType) { 
     163                toCompute++; 
     164                for (StatisticalUnitInformation unit : statisticalUnits) { 
     165                    if (unit.getStatisticParameters().getType() == StatisticParameters.StatisticType.SYSTEM) { 
     166                        if (unit.getStatisticParameters().getUnitName().equals(dashboardStatistic.getStatisticalUnitName())) { 
     167                            unit.getStatisticParameters().setEndTime(currentDateTime); 
     168                            unit.getStatisticParameters().setStartTime(chosenStartTime); 
     169                            unit.getStatisticParameters().setEventType(dashboardStatistic.getEventType()); 
     170                            log.debug("Invoking statistic {} for the dasboard page",unit.getStatisticParameters().getUnitName()); 
     171                            AggregatorGraphModel model = webEngine.updateAndInvokeStatisticalUnit(unit); 
     172                            try { 
     173                                Object result = dashboardStatistic.getProcessedStatistic(model,unit); 
     174                                cacheStatistic(startstats, result, dashboardStatistic.getDashboardStatisticType()); 
     175                                computed++; 
     176                            } catch (DashboardStatisticException e) { 
     177                                log.warn("Dashboard statistic failed to process statistic, {}", e.getMessage()); 
     178                            } catch (ClassCastException e) { 
     179                                log.error("Unable to set cached statistic {}", e.getMessage()); 
     180                            } 
     181                        } 
     182                    } 
     183 
     184                } 
     185            } 
     186        } 
     187        log.info("{} out of a possible {} dashboard statistics computed",computed,toCompute); 
     188        startstats.setAccurateOf(new DateTime(System.currentTimeMillis())); 
     189 
     190    } 
     191 
     192    private void cacheStatistic(StartStatistics startstats, Object result, StartStatistics.StartStatisticType statisticType) throws ClassCastException  { 
     193        log.debug("Setting cached start statistic, for type {}",statisticType); 
     194         
     195        if (statisticType==null){ 
     196            log.error("StatisticType not set for this statistic"); 
     197            return; 
     198        } 
     199         
     200        switch (statisticType) { 
     201            case NO_AUTHS: 
     202                startstats.setNumberOfAuthenticationsPer(((Double) result).doubleValue()); 
     203                break; 
     204 
     205            case NO_UNIQUE_AUTHS: 
     206                startstats.setNumberOfUniqueAuthenticationsPer(((Double) result).doubleValue()); 
     207                break; 
     208 
     209            case TOP_FIVE: 
     210                startstats.setTopFiveResouces((RaptorTableChartModel) result); 
     211                break; 
     212 
     213            case HEADLINE_GRAPH: 
     214                startstats.setHeadlineGraph((RaptorJFreeChartModel) result); 
     215                break; 
     216 
     217            case TOP_FIVE_UNIQUE: 
     218                startstats.setTopFiveUniqueUsersPerSP((RaptorTableChartModel) result); 
     219                break; 
     220            default: 
     221                log.error("Statistic could not be cached, probably the wrong statisticType set"); 
     222        } 
     223 
     224    } 
     225 
     226    private List<StatisticalUnitInformation> getStatisticalUnits() { 
     227        return webEngine.getStatisticalUnits(); 
    292228    } 
    293229 
    294230    public void setWebEngine(RaptorWebEngine webEngine) { 
    295         this.webEngine = webEngine; 
     231        this.webEngine = webEngine; 
    296232    } 
    297233 
    298234    public RaptorWebEngine getWebEngine() { 
    299         return webEngine; 
     235        return webEngine; 
    300236    } 
    301237 
    302238    public Capabilities getAttachedCapabilities() { 
    303         return webEngine.getAttachedCapabilities(); 
    304     } 
    305  
    306     public void setChartProcessor(ChartProcessor chartProcessor) { 
    307         this.chartProcessor = chartProcessor; 
    308     } 
    309  
    310     public ChartProcessor getChartProcessor() { 
    311         return chartProcessor; 
    312     } 
    313  
    314     public void setDashboardStatistics(List<DashboardStatistic> dashboardStatistics) { 
     239        return webEngine.getAttachedCapabilities(); 
     240    } 
     241 
     242    public void setDashboardStatistics(List<AbstractDashboardStatistic> dashboardStatistics) { 
    315243        this.dashboardStatistics = dashboardStatistics; 
    316244    } 
    317245 
    318     public List<DashboardStatistic> getDashboardStatistics() { 
     246    public List<AbstractDashboardStatistic> getDashboardStatistics() { 
    319247        return dashboardStatistics; 
    320248    } 
  • raptor-web/trunk/src/main/webapp/WEB-INF/config/dashboard-statistics.xml

    r693 r698  
    99 
    1010    <util:list id="dashboardStatisticsList"> 
    11         <bean id="shibNoAuthentications" class="uk.ac.cardiff.raptorweb.model.DashboardStatistic"> 
     11        <bean id="shibNoAuthentications" class="uk.ac.cardiff.raptorweb.model.dashboard.UniqueChartDashboardStatistic"> 
     12            <property name="chartProcessor"><ref bean="chartProcessor"/></property> 
     13            <property name="dashboardStatisticType"><value>NO_AUTHS</value></property> 
    1214            <property name="statisticalUnitName"> 
    1315                <value>numberOfAuthenticationsPer</value> 
     
    2022            </property> 
    2123        </bean> 
    22         <bean id="shibNoUniqueUsers" class="uk.ac.cardiff.raptorweb.model.DashboardStatistic"> 
     24        <bean id="shibNoUniqueUsers" class="uk.ac.cardiff.raptorweb.model.dashboard.NoRowsChartDashboardStatistic"> 
     25            <property name="chartProcessor"><ref bean="chartProcessor"/></property> 
     26            <property name="dashboardStatisticType"><value>NO_UNIQUE_AUTHS</value></property> 
    2327            <property name="statisticalUnitName"> 
    2428                <value>numberOfUnqiueUsersPer</value> 
     
    3135            </property> 
    3236        </bean> 
    33         <bean id="shibTop5Resources" class="uk.ac.cardiff.raptorweb.model.DashboardStatistic"> 
     37        <bean id="shibTop5Resources" class="uk.ac.cardiff.raptorweb.model.dashboard.DefaultChartDashboardStatistic"> 
     38            <property name="chartProcessor"><ref bean="chartProcessor"/></property> 
     39            <property name="dashboardStatisticType"><value>TOP_FIVE</value></property> 
    3440            <property name="statisticalUnitName"> 
    3541                <value>top5Resources</value> 
     
    4248            </property> 
    4349        </bean> 
    44         <bean id="shibBottom5Resources" class="uk.ac.cardiff.raptorweb.model.DashboardStatistic"> 
    45             <property name="statisticalUnitName"> 
    46                 <value>bottom5Resources</value> 
    47             </property> 
    48             <property name="enabled"> 
    49                 <value>true</value> 
    50             </property> 
    51             <property name="eventType"> 
    52                 <value>SHIBBOLETH_AUTHENTICATION</value> 
    53             </property> 
    54         </bean> 
    55         <bean id="shibNoAuthenticationsOverInterval" class="uk.ac.cardiff.raptorweb.model.DashboardStatistic"> 
     50        <bean id="shibNoAuthenticationsOverInterval" class="uk.ac.cardiff.raptorweb.model.dashboard.DefaultGraphDashboardStatistic"> 
     51            <property name="chartProcessor"><ref bean="chartProcessor"/></property> 
     52            <property name="dashboardStatisticType"><value>HEADLINE_GRAPH</value></property> 
    5653            <property name="statisticalUnitName"> 
    5754                <value>numberOfAuthenticationsPerIntervalNumber</value> 
     
    6461            </property> 
    6562        </bean> 
    66         <bean id="shibNoUniqueAuthenticationsPerServiceProvider" class="uk.ac.cardiff.raptorweb.model.DashboardStatistic"> 
     63        <bean id="shibTop5NoUniqueAuthenticationsPerServiceProvider" class="uk.ac.cardiff.raptorweb.model.dashboard.DefaultChartDashboardStatistic"> 
     64            <property name="chartProcessor"><ref bean="chartProcessor"/></property> 
     65            <property name="dashboardStatisticType"><value>TOP_FIVE_UNIQUE</value></property> 
    6766            <property name="statisticalUnitName"> 
    6867                <value>numberOfUniqueAuthenticationsPerSP</value> 
     
    7574            </property> 
    7675        </bean> 
     76         
     77         
     78         
     79         
     80         
     81        <bean id="ezproxyNoAuthentications" class="uk.ac.cardiff.raptorweb.model.dashboard.UniqueChartDashboardStatistic"> 
     82            <property name="chartProcessor"><ref bean="chartProcessor"/></property> 
     83            <property name="dashboardStatisticType"><value>NO_AUTHS</value></property> 
     84            <property name="statisticalUnitName"> 
     85                <value>numberOfAuthenticationsPer</value> 
     86            </property> 
     87            <property name="enabled"> 
     88                <value>true</value> 
     89            </property> 
     90            <property name="eventType"> 
     91                <value>EZPROXY_AUTHENTICATION</value> 
     92            </property> 
     93        </bean> 
     94        <bean id="ezproxyNoUniqueUsers" class="uk.ac.cardiff.raptorweb.model.dashboard.NoRowsChartDashboardStatistic"> 
     95            <property name="chartProcessor"><ref bean="chartProcessor"/></property> 
     96            <property name="dashboardStatisticType"><value>NO_UNIQUE_AUTHS</value></property> 
     97            <property name="statisticalUnitName"> 
     98                <value>numberOfUnqiueUsersPer</value> 
     99            </property> 
     100            <property name="enabled"> 
     101                <value>true</value> 
     102            </property> 
     103            <property name="eventType"> 
     104                <value>EZPROXY_AUTHENTICATION</value> 
     105            </property> 
     106        </bean> 
     107        <bean id="ezproxyTop5Resources" class="uk.ac.cardiff.raptorweb.model.dashboard.DefaultChartDashboardStatistic"> 
     108            <property name="chartProcessor"><ref bean="chartProcessor"/></property> 
     109            <property name="dashboardStatisticType"><value>TOP_FIVE</value></property> 
     110            <property name="statisticalUnitName"> 
     111                <value>top5Resources</value> 
     112            </property> 
     113            <property name="enabled"> 
     114                <value>true</value> 
     115            </property> 
     116            <property name="eventType"> 
     117                <value>EZPROXY_AUTHENTICATION</value> 
     118            </property> 
     119        </bean> 
     120        <bean id="ezproxyNoAuthenticationsOverInterval" class="uk.ac.cardiff.raptorweb.model.dashboard.DefaultGraphDashboardStatistic"> 
     121            <property name="chartProcessor"><ref bean="chartProcessor"/></property> 
     122            <property name="dashboardStatisticType"><value>HEADLINE_GRAPH</value></property> 
     123            <property name="statisticalUnitName"> 
     124                <value>numberOfAuthenticationsPerIntervalNumber</value> 
     125            </property> 
     126            <property name="enabled"> 
     127                <value>true</value> 
     128            </property> 
     129            <property name="eventType"> 
     130                <value>EZPROXY_AUTHENTICATION</value> 
     131            </property> 
     132        </bean> 
     133        <bean id="ezproxyTop5NoUniqueAuthenticationsPerServiceProvider" class="uk.ac.cardiff.raptorweb.model.dashboard.DefaultChartDashboardStatistic"> 
     134            <property name="chartProcessor"><ref bean="chartProcessor"/></property> 
     135            <property name="dashboardStatisticType"><value>TOP_FIVE_UNIQUE</value></property> 
     136            <property name="statisticalUnitName"> 
     137                <value>numberOfUniqueAuthenticationsPerSP</value> 
     138            </property> 
     139            <property name="enabled"> 
     140                <value>true</value> 
     141            </property> 
     142            <property name="eventType"> 
     143                <value>EZPROXY_AUTHENTICATION</value> 
     144            </property> 
     145        </bean> 
    77146    </util:list> 
    78147 
  • raptor-web/trunk/src/main/webapp/WEB-INF/config/web-setup.xml

    r693 r698  
    5555        <bean id="startService" class="uk.ac.cardiff.raptorweb.service.impl.StartServiceImpl"> 
    5656                <property name="webEngine"><ref bean="webEngine"/></property> 
    57                 <property name="chartProcessor"><ref bean="chartProcessor"/></property> 
    5857        <property name="dashboardStatistics" ref="dashboardStatisticsList"/> 
    5958        </bean> 
     
    9897                <property name="triggers"> 
    9998                        <list> 
    100                           <ref local="SystemStatsQuickTrigger"/> 
     99                        <!--  <ref local="SystemStatsQuickTrigger"/>--> 
    101100                        </list> 
    102101                </property> 
Note: See TracChangeset for help on using the changeset viewer.