Changeset 485
- Timestamp:
- 01/23/11 23:27:01 (2 years ago)
- Location:
- raptor-web/trunk
- Files:
-
- 2 added
- 7 edited
-
pom.xml (modified) (1 diff)
-
src/main/java/uk/ac/cardiff/raptorweb/model/CachedStartStatistics.java (added)
-
src/main/java/uk/ac/cardiff/raptorweb/model/StartModel.java (modified) (4 diffs)
-
src/main/java/uk/ac/cardiff/raptorweb/model/StartStatistics.java (added)
-
src/main/java/uk/ac/cardiff/raptorweb/service/impl/StartServiceImpl.java (modified) (9 diffs)
-
src/main/resources/log4j.properties (modified) (1 diff)
-
src/main/webapp/WEB-INF/config/web-setup.xml (modified) (1 diff)
-
src/main/webapp/WEB-INF/flows/reports/startReport.jspx (modified) (5 diffs)
-
src/main/webapp/WEB-INF/web.xml (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
raptor-web/trunk/pom.xml
r476 r485 512 512 </exclusions> 513 513 </dependency> 514 515 <!-- Quartz --> 516 517 <dependency> 518 <groupId>org.quartz-scheduler</groupId> 519 <artifactId>quartz</artifactId> 520 <version>1.8.0</version> 521 <exclusions> 522 <exclusion> 523 <artifactId>slf4j-api</artifactId> 524 <groupId>org.slf4j</groupId> 525 </exclusion> 526 </exclusions> 527 </dependency> 514 528 515 529 <!-- spring security --> -
raptor-web/trunk/src/main/java/uk/ac/cardiff/raptorweb/model/StartModel.java
r484 r485 8 8 import java.text.DecimalFormatSymbols; 9 9 10 import org.joda.time.DateTime; 10 11 import org.slf4j.Logger; 11 12 import org.slf4j.LoggerFactory; … … 22 23 23 24 static Logger log = LoggerFactory.getLogger(StartModel.class); 24 25 private double numberOfAuthenticationsPer; 26 private double numberOfUniqueAuthenticationsPer; 27 private RaptorTableChartModel topFiveResouces; 28 private RaptorTableChartModel bottomFiveResouces; 29 private RaptorGraphModel headlineGraph; 25 30 26 private Capabilities attachedMUACapabilities; 27 28 private StartStatistics startStatistics; 29 31 30 private TimeRange statsRangeSelector; 32 31 33 /* only updated on the UI, hence sensible default*/34 32 public enum TimeRange{TODAY,LASTWEEK,LASTMONTH,LASTYEAR} 35 33 … … 38 36 } 39 37 40 public void setNumberOfAuthenticationsPer(double numberOfAuthenticationsPer) {41 this.numberOfAuthenticationsPer = numberOfAuthenticationsPer;42 }43 44 public double getNumberOfAuthenticationsPer() {45 return numberOfAuthenticationsPer;46 }47 48 public String getNumberOfAuthenticationsPerFormatted(){49 return formatDoubleWithCommas(numberOfAuthenticationsPer);50 }51 52 private String formatDoubleWithCommas(double number){53 DecimalFormat df = new DecimalFormat();54 DecimalFormatSymbols dfs = new DecimalFormatSymbols();55 dfs.setGroupingSeparator(',');56 df.setDecimalFormatSymbols(dfs);57 String formattedNumber = df.format((int)number);58 return formattedNumber;59 }60 61 public void setNumberOfUniqueAuthenticationsPer(double numberOfUniqueAuthenticationsPer) {62 this.numberOfUniqueAuthenticationsPer = numberOfUniqueAuthenticationsPer;63 }64 65 public double getNumberOfUniqueAuthenticationsPer() {66 return numberOfUniqueAuthenticationsPer;67 }68 69 public String getNumberOfUniqueAuthenticationsPerFormatted() {70 return formatDoubleWithCommas(numberOfUniqueAuthenticationsPer);71 }72 73 public void setTopFiveResouces(RaptorTableChartModel topFiveResouces) {74 this.topFiveResouces = topFiveResouces;75 }76 77 public RaptorTableChartModel getTopFiveResouces() {78 return topFiveResouces;79 }80 81 public void setBottomFiveResouces(RaptorTableChartModel bottomFiveResouces) {82 this.bottomFiveResouces = bottomFiveResouces;83 }84 85 public RaptorTableChartModel getBottomFiveResouces() {86 return bottomFiveResouces;87 }88 89 public void setHeadlineGraph(RaptorGraphModel headlineGraph) {90 this.headlineGraph = headlineGraph;91 }92 93 public RaptorGraphModel getHeadlineGraph() {94 log.debug("getting headline graph");95 return headlineGraph;96 }97 38 98 39 public void setAttachedMUACapabilities(Capabilities attachedMUACapabilities) { … … 113 54 } 114 55 56 public void setStartStatistics(StartStatistics startStatistics) { 57 this.startStatistics = startStatistics; 58 } 59 60 public StartStatistics getStartStatistics() { 61 return startStatistics; 62 } 63 115 64 116 65 -
raptor-web/trunk/src/main/java/uk/ac/cardiff/raptorweb/service/impl/StartServiceImpl.java
r484 r485 17 17 import uk.ac.cardiff.raptorweb.engine.ChartProcessor; 18 18 import uk.ac.cardiff.raptorweb.engine.RaptorWebEngine; 19 import uk.ac.cardiff.raptorweb.model.CachedStartStatistics; 19 20 import uk.ac.cardiff.raptorweb.model.RaptorGraphModel; 20 21 import uk.ac.cardiff.raptorweb.model.RaptorTableChartModel; 21 22 import uk.ac.cardiff.raptorweb.model.StartModel; 23 import uk.ac.cardiff.raptorweb.model.StartStatistics; 22 24 import uk.ac.cardiff.raptorweb.model.WebSession; 23 25 import uk.ac.cardiff.raptorweb.model.StartModel.TimeRange; … … 33 35 34 36 private RaptorWebEngine webEngine; 35 36 /** 37 * Adds the following statistical information from the attached MUA: 1. Number of authentications per <RANGE> 38 */ 37 38 /* holds the statistics for the front page gathered from the background worker thread */ 39 private CachedStartStatistics cachedStartModelToday; 40 private CachedStartStatistics cachedStartModelLastWeek; 41 private CachedStartStatistics cachedStartModelLastMonth; 42 private CachedStartStatistics cachedStartModelLastYear; 43 44 public void generateStatisticsBackground(){ 45 log.info("Generating background statistics for the start page, using {}",this); 46 CurrentTimeRange currentTimeRange = getTimeRanges(); 47 if (cachedStartModelToday==null) 48 cachedStartModelToday= new CachedStartStatistics(); 49 if (cachedStartModelLastWeek==null) 50 cachedStartModelLastWeek= new CachedStartStatistics(); 51 if (cachedStartModelLastMonth==null) 52 cachedStartModelLastMonth= new CachedStartStatistics(); 53 if (cachedStartModelLastYear==null) 54 cachedStartModelLastYear= new CachedStartStatistics(); 55 56 log.debug("Background start page worker getting today"); 57 generateStatistics(cachedStartModelToday.getCached(),currentTimeRange.currentTime,currentTimeRange.startToday); 58 log.debug("Background start page worker getting last week"); 59 generateStatistics(cachedStartModelLastWeek.getCached(),currentTimeRange.currentTime,currentTimeRange.startWeek); 60 log.debug("Background start page worker getting last month"); 61 generateStatistics(cachedStartModelLastMonth.getCached(),currentTimeRange.currentTime,currentTimeRange.startMonth); 62 log.debug("Background start page worker getting last year"); 63 generateStatistics(cachedStartModelLastYear.getCached(),currentTimeRange.currentTime,currentTimeRange.startYear); 64 65 log.info("Generating background statistics for the start page...done"); 66 } 67 39 68 @Override 40 public void generateStatistics(WebSession websession) { 41 StartModel startmodel = websession.getStartmodel(); 69 public void generateStatistics(WebSession websession){ 70 log.debug("Getting start statistics for {} from {}",websession.getStartmodel().getStatsRangeSelector(),this); 71 72 if (websession.getStartmodel().getStatsRangeSelector()==StartModel.TimeRange.LASTMONTH) 73 websession.getStartmodel().setStartStatistics(cachedStartModelLastMonth.getCached()); 74 if (websession.getStartmodel().getStatsRangeSelector()==StartModel.TimeRange.LASTWEEK) 75 websession.getStartmodel().setStartStatistics(cachedStartModelLastWeek.getCached()); 76 if (websession.getStartmodel().getStatsRangeSelector()==StartModel.TimeRange.TODAY) 77 websession.getStartmodel().setStartStatistics(cachedStartModelToday.getCached()); 78 if (websession.getStartmodel().getStatsRangeSelector()==StartModel.TimeRange.LASTYEAR) 79 websession.getStartmodel().setStartStatistics(cachedStartModelLastYear.getCached()); 80 81 //so we could output the name of the attached MUA 82 Capabilities capabilities = getAttachedCapabilities(); 83 if (capabilities!=null){ 84 websession.getStartmodel().setAttachedMUACapabilities(capabilities); 85 86 } 87 } 88 89 private CurrentTimeRange getTimeRanges(){ 42 90 long currentTimeInMS = System.currentTimeMillis(); 43 91 //decide dates to use … … 54 102 //log.debug("One Year Previous {}",oneYearPrevious); 55 103 DateTime oneWeekPrevious = currentDateTime.minusWeeks(1); 56 DateTime chosenStartTime = null; 57 if (startmodel.getStatsRangeSelector()==StartModel.TimeRange.LASTMONTH) 58 chosenStartTime = oneMonthPrevious; 59 if (startmodel.getStatsRangeSelector()==StartModel.TimeRange.LASTWEEK) 60 chosenStartTime = oneWeekPrevious; 61 if (startmodel.getStatsRangeSelector()==StartModel.TimeRange.TODAY) 62 chosenStartTime = today; 63 if (startmodel.getStatsRangeSelector()==StartModel.TimeRange.LASTYEAR) 64 chosenStartTime = oneYearPrevious; 65 66 // get all the stats 104 105 CurrentTimeRange currentRange = new CurrentTimeRange(); 106 currentRange.startMonth=oneMonthPrevious; 107 currentRange.startToday=today; 108 currentRange.startWeek=oneWeekPrevious; 109 currentRange.startYear=oneYearPrevious; 110 currentRange.currentTime = currentDateTime; 111 return currentRange; 112 113 } 114 115 116 /** 117 * Adds the following statistical information from the attached MUA: 118 * 1. Number of authentications per <RANGE> 119 * 2. 120 */ 121 private void generateStatistics(StartStatistics startstats, DateTime currentDateTime, DateTime chosenStartTime) { 122 67 123 List<StatisticalUnitInformation> statisticalUnits = getStatisticalUnits(); 68 124 log.debug("Found {} statistics", statisticalUnits.size()); … … 102 158 if (table.getRows().size() == 1) { 103 159 if (table.getRows().get(0).getValue() instanceof Double) { 104 start model.setNumberOfAuthenticationsPer(((Double) table.getRows().get(0).getValue()));160 startstats.setNumberOfAuthenticationsPer(((Double) table.getRows().get(0).getValue())); 105 161 } 106 162 } 107 163 } 108 164 else{ 109 start model.setNumberOfAuthenticationsPer(0);165 startstats.setNumberOfAuthenticationsPer(0); 110 166 } 111 167 } … … 121 177 log.debug("Number of rows: {}",table.getRows().size()); 122 178 if (table.getRows() != null) { 123 start model.setNumberOfUniqueAuthenticationsPer(table.getRows().size());179 startstats.setNumberOfUniqueAuthenticationsPer(table.getRows().size()); 124 180 } 125 181 } 126 182 } 127 183 else{ 128 start model.setNumberOfUniqueAuthenticationsPer(0);184 startstats.setNumberOfUniqueAuthenticationsPer(0); 129 185 } 130 186 … … 137 193 if (topFiveResourcesModel!=null){ 138 194 RaptorTableChartModel table = ChartProcessor.constructRaptorTableChartModel(topFiveResourcesModel); 139 start model.setTopFiveResouces(table);195 startstats.setTopFiveResouces(table); 140 196 } 141 197 else 142 start model.setTopFiveResouces(null);198 startstats.setTopFiveResouces(null); 143 199 } 144 200 … … 149 205 if (bottomFiveResourcesModel!=null){ 150 206 RaptorTableChartModel table = ChartProcessor.constructRaptorTableChartModel(bottomFiveResourcesModel); 151 start model.setBottomFiveResouces(table);207 startstats.setBottomFiveResouces(table); 152 208 } 153 209 else 154 start model.setBottomFiveResouces(null);210 startstats.setBottomFiveResouces(null); 155 211 156 212 } … … 167 223 graph.getGroupLabels().set(i,new String("")); 168 224 } 169 start model.setHeadlineGraph(graph);225 startstats.setHeadlineGraph(graph); 170 226 } 171 227 else 172 startmodel.setHeadlineGraph(null); 173 } 174 175 Capabilities capabilities = getAttachedCapabilities(); 176 if (capabilities!=null){ 177 startmodel.setAttachedMUACapabilities(capabilities); 178 179 } 228 startstats.setHeadlineGraph(null); 229 } 230 231 180 232 181 233 } … … 195 247 public Capabilities getAttachedCapabilities() { 196 248 return webEngine.getAttachedCapabilities(); 197 }249 } 198 250 199 251 200 252 } 253 254 /* Temporary storage for constantly updated start times */ 255 class CurrentTimeRange{ 256 public DateTime currentTime; 257 public DateTime startToday; 258 public DateTime startWeek; 259 public DateTime startMonth; 260 public DateTime startYear; 261 262 } -
raptor-web/trunk/src/main/resources/log4j.properties
r476 r485 9 9 #log4j.logger.org.springframework = DEBUG, stdout 10 10 log4j.logger.uk.ac = DEBUG, stdout 11 log4j.logger.org.quartz=DEBUG,stdout 11 12 #log4j.logger.org.springframework.security=DEBUG, stdout -
raptor-web/trunk/src/main/webapp/WEB-INF/config/web-setup.xml
r475 r485 64 64 65 65 66 <!-- Set up the start page background stats generator --> 67 <bean id="statsSchedular" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> 68 <property name="triggers"> 69 <list> 70 <ref local="SystemStatsQuickTrigger"/> 71 </list> 72 </property> 73 </bean> 74 75 <bean id="SystemStatsQuickTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean"> 76 <property name="jobDetail"> 77 <ref local="SystemStatsJobDetail" /> 78 </property> 79 <property name="startDelay" value="5000"/> 80 <property name="repeatInterval" value="300000"/> 81 </bean> 66 82 83 <bean id="SystemStatsJobDetail" 84 class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> 85 <property name="targetObject"> 86 <ref bean="startService" /> 87 </property> 88 <property name="targetMethod"> 89 <value>generateStatisticsBackground</value> 90 </property> 91 <property name="concurrent"> 92 <value>false</value> 93 </property> 94 </bean> 67 95 68 96 -
raptor-web/trunk/src/main/webapp/WEB-INF/flows/reports/startReport.jspx
r484 r485 51 51 <tr:spacer height="10px" /> 52 52 <tr:chart id="chart" verticalMajorSections="15" 53 value="#{flowScope.websession.startmodel. headlineGraph}"54 rendered="#{not empty flowScope.websession.startmodel. headlineGraph}"53 value="#{flowScope.websession.startmodel.startStatistics.headlineGraph}" 54 rendered="#{not empty flowScope.websession.startmodel.startStatistics.headlineGraph}" 55 55 inlineStyle="width:100%; height:270px; border-style: hidden;" 56 56 type="stackedArea" width="98%" animationDuration="400" … … 71 71 <tr:spacer height="7px" /> 72 72 <tr:outputText 73 value="#{flowScope.websession.startmodel. numberOfAuthenticationsPerFormatted}"73 value="#{flowScope.websession.startmodel.startStatistics.numberOfAuthenticationsPerFormatted}" 74 74 partialTriggers=":quickStatsRangeSelector" 75 75 inlineStyle="font-size:270%;font-weight: bold" /> … … 79 79 <tr:spacer height="7px" /> 80 80 <tr:outputText 81 value="#{flowScope.websession.startmodel. numberOfUniqueAuthenticationsPerFormatted}"81 value="#{flowScope.websession.startmodel.startStatistics.numberOfUniqueAuthenticationsPerFormatted}" 82 82 inlineStyle="font-size:270%;font-weight: bold" /> 83 83 </tr:panelFormLayout> … … 85 85 <tr:spacer width="30px" /> 86 86 87 <tr:table value="#{flowScope.websession.startmodel. topFiveResouces.rows}"87 <tr:table value="#{flowScope.websession.startmodel.startStatistics.topFiveResouces.rows}" 88 88 bandingInterval="2" banding="row" var="row" width="100%" 89 rendered="#{not empty flowScope.websession.startmodel. topFiveResouces}">89 rendered="#{not empty flowScope.websession.startmodel.startStatistics.topFiveResouces}"> 90 90 <f:facet name="header"> 91 91 <tr:outputText value="Top 5 eResources" /> … … 108 108 <tr:spacer width="15px" /> 109 109 110 <tr:table value="#{flowScope.websession.startmodel. bottomFiveResouces.rows}"110 <tr:table value="#{flowScope.websession.startmodel.startStatistics.bottomFiveResouces.rows}" 111 111 bandingInterval="2" banding="row" var="row" width="100%" 112 rendered="#{not empty flowScope.websession.startmodel. bottomFiveResouces}">112 rendered="#{not empty flowScope.websession.startmodel.startStatistics.bottomFiveResouces}"> 113 113 <f:facet name="header"> 114 114 <tr:outputText value="Bottom 5 eResources" /> -
raptor-web/trunk/src/main/webapp/WEB-INF/web.xml
r475 r485 14 14 version="2.4"> 15 15 16 <description>Template Jsf Trinidad SWF Alephsa</description> 17 <!-- - Location of the XML file that defines the root application context 18 - Applied by ContextLoaderListener. All standard beans are included in the 19 raptor-servlet, security is seperated into the security.xml file --> 16 <description>RaptorWeb</description> 17 18 19 <!-- - defines setup that can be accessed by the entire servlet, not just spring 20 hence why security is defined here --> 20 21 <context-param> 21 22 <param-name>contextConfigLocation</param-name> 22 23 <param-value> 23 /WEB-INF/config/raptorweb-servlet.xml 24 /WEB-INF/config/security.xml 25 </param-value> 24 /WEB-INF/config/security.xml 25 </param-value> 26 26 </context-param> 27 27 … … 176 176 </listener> 177 177 178 <!-- Spring web flow servlet --> 178 <!-- Spring web flow servlet, defines config specific to the current 179 application instance --> 179 180 <servlet> 180 181 <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> 181 182 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 182 <init-param>183 <init-param> 183 184 <param-name>contextConfigLocation</param-name> 184 <param-value>/WEB-INF/config/raptorweb-servlet.xml</param-value> 185 <param-value>/WEB-INF/config/raptorweb-servlet.xml 186 </param-value> 185 187 </init-param> 186 188 <load-on-startup>1</load-on-startup>
Note: See TracChangeset
for help on using the changeset viewer.
