Changeset 1175
- Timestamp:
- 10/26/11 23:01:07 (19 months ago)
- Location:
- raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua
- Files:
-
- 2 deleted
- 24 edited
- 1 moved
-
engine/CapabilitiesConstructor.java (modified) (3 diffs)
-
engine/MUAEngine.java (modified) (2 diffs)
-
engine/classification/SaveAndApplyResourceClassificationTask.java (modified) (1 diff)
-
engine/statistics/BaseStatistic.java (moved) (moved from raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/Statistic.java) (9 diffs)
-
engine/statistics/ContextAwareStatisticRegistry.java (modified) (6 diffs)
-
engine/statistics/DefaultStatisticProcessorRegistry.java (modified) (1 diff)
-
engine/statistics/SQLFilterConstructor.java (modified) (2 diffs)
-
engine/statistics/StatisticHandler.java (modified) (5 diffs)
-
engine/statistics/StatisticRegistry.java (modified) (3 diffs)
-
engine/statistics/StatisticalUnitException.java (modified) (1 diff)
-
engine/statistics/StatisticsPreProcessor.java (deleted)
-
engine/statistics/functions/CountEntry.java (modified) (1 diff)
-
engine/statistics/functions/CountEntryPerInterval.java (modified) (1 diff)
-
engine/statistics/functions/GroupBy.java (modified) (1 diff)
-
engine/statistics/functions/GroupByCountDistinct.java (modified) (1 diff)
-
engine/statistics/functions/GroupByFrequency.java (modified) (1 diff)
-
engine/statistics/helper/ObservationComparator.java (modified) (2 diffs)
-
engine/statistics/helper/StringGroupComparator.java (modified) (2 diffs)
-
engine/statistics/processor/NumberFormatterPostProcessor.java (modified) (1 diff)
-
engine/statistics/processor/PostprocessorException.java (modified) (1 diff)
-
engine/statistics/processor/SamlMetadataNameFormatter.java (modified) (1 diff)
-
engine/statistics/records/Bucket.java (modified) (1 diff)
-
engine/statistics/records/GraphEntry.java (modified) (1 diff)
-
engine/statistics/records/Group.java (modified) (1 diff)
-
engine/statistics/records/Observation.java (modified) (1 diff)
-
engine/statistics/records/ObservationSeries.java (modified) (1 diff)
-
model (deleted)
Legend:
- Unmodified
- Added
- Removed
-
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/CapabilitiesConstructor.java
r1097 r1175 40 40 import uk.ac.cardiff.raptor.runtimeutils.ReflectionHelper; 41 41 import uk.ac.cardiff.raptor.store.StorageEngine; 42 import uk.ac.cardiff.raptormua.engine.statistics. Statistic;42 import uk.ac.cardiff.raptormua.engine.statistics.BaseStatistic; 43 43 import uk.ac.cardiff.raptormua.engine.statistics.StatisticHandler; 44 44 import uk.ac.cardiff.raptormua.engine.statistics.StatisticPostProcessor; … … 93 93 capabilities = new Capabilities(); 94 94 95 List< Statistic> su = statisticsHandler.getStatisticalUnits();95 List<BaseStatistic> su = statisticsHandler.getStatisticalUnits(); 96 96 97 97 capabilities.setMetadata(metadata); … … 128 128 129 129 ArrayList<StatisticalUnitInformation> stats = new ArrayList(); 130 for ( Statistic entry : su) {130 for (BaseStatistic entry : su) { 131 131 log.debug("Setting statistical unit information as: " + entry.getStatisticParameters().getUnitName()); 132 132 StatisticalUnitInformation information = new StatisticalUnitInformation(); -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/MUAEngine.java
r1174 r1175 48 48 import uk.ac.cardiff.raptormua.engine.classification.ResourceClassificationBackgroundService; 49 49 import uk.ac.cardiff.raptormua.engine.statistics.StatisticHandler; 50 import uk.ac.cardiff.raptormua.model.Users;51 50 import uk.ac.cardiff.raptormua.upload.BatchFile; 52 51 … … 68 67 */ 69 68 private EventReleaseClient eventReleaseClient; 70 71 // TODO implement user level control on the MUA?72 /** Support for user classification on the MUA. */73 private Users users;74 69 75 70 /** The Storage Engine that handles all storage transactions. */ -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/classification/SaveAndApplyResourceClassificationTask.java
r1174 r1175 39 39 private final Logger log = LoggerFactory.getLogger(SaveAndApplyResourceClassificationTask.class); 40 40 41 /** The e ntry handler used to store entries (e.g. events)*/41 /** The event handler used to access events */ 42 42 private EventHandler entryHandler; 43 43 -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/BaseStatistic.java
r1103 r1175 35 35 import uk.ac.cardiff.raptor.store.EventHandler; 36 36 import uk.ac.cardiff.raptormua.engine.statistics.processor.PostprocessorException; 37 import uk.ac.cardiff.raptormua.engine.statistics.processor.PreprocessorException;38 37 import uk.ac.cardiff.raptormua.engine.statistics.records.Bucket; 39 38 import uk.ac.cardiff.raptormua.engine.statistics.records.Group; … … 44 43 * @author philsmart Holds a statistics unit or one statistics operation on one piece of data 45 44 */ 46 public abstract class Statistic {45 public abstract class BaseStatistic { 47 46 48 47 /** Class logger */ 49 private final Logger log = LoggerFactory.getLogger( Statistic.class);50 51 /** 52 * The <code>E ntryHandler</code> that allows access to all <code>Event</code>s this statistic works off.48 private final Logger log = LoggerFactory.getLogger(BaseStatistic.class); 49 50 /** 51 * The <code>EventHandler</code> that allows access to all <code>Event</code>s this statistic works off. 53 52 */ 54 53 private EventHandler entryHandler; 55 54 56 /** The parameters used to configure this statistic */55 /** The parameters used to configure this statistic. */ 57 56 protected StatisticParameters statisticParameters; 58 57 59 /** add a preprocessing module to the statistical method */ 60 private StatisticsPreProcessor preprocessor; 61 62 /** add a postprocessing module to the statistical method */ 58 /** A list of postprocessing modules. */ 63 59 private List<StatisticPostProcessor> postprocessor; 64 60 … … 72 68 * Default constructor. 73 69 */ 74 public Statistic() {70 public BaseStatistic() { 75 71 setObservationSeries(new ArrayList<ObservationSeries>()); 76 72 } … … 96 92 97 93 public void setEntryHandler(EventHandler entryHandler) { 98 if (preprocessor != null)99 try {100 log.info("Invoking statistical preprocessor " + preprocessor.getClass());101 preprocessor.preProcess(entryHandler);102 } catch (PreprocessorException e) {103 log.error("Could not preprocess entries " + preprocessor.getClass());104 }105 94 this.entryHandler = entryHandler; 106 95 } … … 175 164 } 176 165 // Buckets are time series, and so are already sorted chronologically. 177 178 166 for (int i = 0; i < observationSeries.size(); i++) { 179 167 buckets = (Bucket[]) observationSeries.get(i).getObservations(); … … 211 199 /** 212 200 * <p> 213 * pre processing effects the entries that go into the statistical unit post processing effects the observations 214 * that result form the statistical unit 201 * Send the results of performing the statistic to the post processors. 215 202 * </p> 216 203 */ … … 221 208 Arrays.toString(getPostprocessor().toArray(new StatisticPostProcessor[0]))); 222 209 for (StatisticPostProcessor post : postprocessor) { 223 // perform the same post process on each observationseries224 210 for (ObservationSeries obsSeries : getObservationSeries()) { 225 211 obsSeries.setObservations(post.process(obsSeries.getObservations())); … … 230 216 } 231 217 } catch (PostprocessorException e) { 232 log.error("Could not post process entries, using " +getPostprocessor().getClass());218 log.error("Could not post process entries, using {}", getPostprocessor().getClass()); 233 219 } 234 220 } … … 252 238 } 253 239 254 public void setPreprocessor(StatisticsPreProcessor preprocessor) {255 this.preprocessor = preprocessor;256 }257 258 public StatisticsPreProcessor getPreprocessor() {259 return preprocessor;260 }261 262 240 public List<StatisticPostProcessor> getPostprocessor() { 263 241 return postprocessor; -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/ContextAwareStatisticRegistry.java
r1097 r1175 44 44 45 45 /** 46 * List of {@link uk.ac.cardiff.raptormua.engine.statistics. Statistic}s that have been registered with this handler46 * List of {@link uk.ac.cardiff.raptormua.engine.statistics.BaseStatistic}s that have been registered with this handler 47 47 */ 48 private List< Statistic> statisticalUnits;48 private List<BaseStatistic> statisticalUnits; 49 49 50 50 /** Used to automatically add statistics from the application context iff automaticallyFindStatsiticsToLoad = true */ … … 63 63 64 64 public void updateStatisticalUnit(StatisticalUnitInformation statisticalUnitInformation) { 65 Statistic toUpdate = null;66 for ( Statistic statistic : statisticalUnits) {65 BaseStatistic toUpdate = null; 66 for (BaseStatistic statistic : statisticalUnits) { 67 67 if (statistic.getStatisticParameters().getUnitName() 68 68 .equals(statisticalUnitInformation.getStatisticParameters().getUnitName())) … … 75 75 } 76 76 77 public Statistic getStatistic(String statisticName) {78 for ( Statistic statistic : statisticalUnits) {77 public BaseStatistic getStatistic(String statisticName) { 78 for (BaseStatistic statistic : statisticalUnits) { 79 79 if (statistic.getStatisticParameters().getUnitName().equals(statisticName)) { 80 80 log.debug("Found statistic [{}] from statistic registry", statistic.getStatisticParameters() … … 92 92 * @param statisticalUnitInformation - the statistical unit information to used update the <code>statistic</code> 93 93 */ 94 private void performUpdate( Statistic statistic, StatisticalUnitInformation statisticalUnitInformation) {94 private void performUpdate(BaseStatistic statistic, StatisticalUnitInformation statisticalUnitInformation) { 95 95 statistic.setStatisticParameters(statisticalUnitInformation.getStatisticParameters()); 96 96 // now deal with the post processors … … 123 123 * <code>setStatisticalUnitsFromApplicationContext</code> method 124 124 */ 125 public void setStatisticalUnits(List< Statistic> statisticalUnits) {126 for ( Statistic stat : statisticalUnits) {125 public void setStatisticalUnits(List<BaseStatistic> statisticalUnits) { 126 for (BaseStatistic stat : statisticalUnits) { 127 127 log.info("Registering statistic [{}], role {}", stat.getStatisticParameters().getUnitName(), stat 128 128 .getStatisticParameters().getType()); … … 133 133 134 134 public void setStatisticalUnitsFromApplicationContext() { 135 statisticalUnits = new ArrayList< Statistic>();136 Map<String, ?> allStatisticBeans = applicationContext.getBeansOfType( Statistic.class);135 statisticalUnits = new ArrayList<BaseStatistic>(); 136 Map<String, ?> allStatisticBeans = applicationContext.getBeansOfType(BaseStatistic.class); 137 137 for (Map.Entry<String, ?> entry : allStatisticBeans.entrySet()) { 138 log.debug("Registering statistic [{}], role {}", (( Statistic) entry.getValue()).getStatisticParameters()139 .getUnitName(), (( Statistic) entry.getValue()).getStatisticParameters().getType());140 statisticalUnits.add(( Statistic) entry.getValue());138 log.debug("Registering statistic [{}], role {}", ((BaseStatistic) entry.getValue()).getStatisticParameters() 139 .getUnitName(), ((BaseStatistic) entry.getValue()).getStatisticParameters().getType()); 140 statisticalUnits.add((BaseStatistic) entry.getValue()); 141 141 } 142 142 } 143 143 144 public List< Statistic> getStatisticalUnits() {144 public List<BaseStatistic> getStatisticalUnits() { 145 145 return statisticalUnits; 146 146 } -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/DefaultStatisticProcessorRegistry.java
r1097 r1175 21 21 import uk.ac.cardiff.model.wsmodel.ProcessorInformation; 22 22 23 //TODO NEW and not finished. 23 24 public class DefaultStatisticProcessorRegistry implements StatisticProcessorRegistry { 24 25 -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/SQLFilterConstructor.java
r787 r1175 14 14 * limitations under the License. 15 15 */ 16 16 17 package uk.ac.cardiff.raptormua.engine.statistics; 17 18 … … 21 22 22 23 /** 23 * This is a experimental and not very well implemented engine for constructing24 * SQL filters (principaly where), for useby the statistics engine.25 * 24 * This is a experimental and not very well implemented engine for constructing SQL filters (principaly where), for use 25 * by the statistics engine. 26 * 26 27 * @author philsmart 27 * 28 * 28 29 */ 29 30 public class SQLFilterConstructor { 30 31 31 private SQLFilter sqlFilter;32 private SQLFilter sqlFilter; 32 33 33 public SQLFilterConstructor(SQLFilter sqlFilter){34 this.sqlFilter = sqlFilter;34 public SQLFilterConstructor(SQLFilter sqlFilter) { 35 this.sqlFilter = sqlFilter; 35 36 36 }37 } 37 38 38 /** 39 * Perform the conversion of the <code>SQLFilter</code> into a string that 40 * can be inserted into an SQL expression. 41 * 42 * @return 43 */ 44 public String convertFilterToString(){ 39 /** 40 * Perform the conversion of the <code>SQLFilter</code> into a string that can be inserted into an SQL expression. 41 * 42 * @return 43 */ 44 public String convertFilterToString() { 45 45 46 if (sqlFilter instanceof SQLWhere){47 return buildWhere((SQLWhere)sqlFilter);48 }46 if (sqlFilter instanceof SQLWhere) { 47 return buildWhere((SQLWhere) sqlFilter); 48 } 49 49 50 return null;50 return null; 51 51 52 }52 } 53 53 54 private String buildWhere(SQLWhere sqlWhere){55 StringBuilder sql = new StringBuilder();54 private String buildWhere(SQLWhere sqlWhere) { 55 StringBuilder sql = new StringBuilder(); 56 56 57 CompOp comparisonOperator = sqlWhere.getBooleanExpression().getBooleanTerm().getBooleanFactor().getBooleanTest().getBooleanPrimary().getPredicate().getComparisonPredicate().getCompOp(); 58 String fieldName = sqlWhere.getBooleanExpression().getBooleanTerm().getBooleanFactor().getBooleanTest().getBooleanPrimary().getPredicate().getComparisonPredicate().getFieldName(); 59 String value = sqlWhere.getBooleanExpression().getBooleanTerm().getBooleanFactor().getBooleanTest().getBooleanPrimary().getPredicate().getComparisonPredicate().getValue(); 57 CompOp comparisonOperator = 58 sqlWhere.getBooleanExpression().getBooleanTerm().getBooleanFactor().getBooleanTest() 59 .getBooleanPrimary().getPredicate().getComparisonPredicate().getCompOp(); 60 String fieldName = 61 sqlWhere.getBooleanExpression().getBooleanTerm().getBooleanFactor().getBooleanTest() 62 .getBooleanPrimary().getPredicate().getComparisonPredicate().getFieldName(); 63 String value = 64 sqlWhere.getBooleanExpression().getBooleanTerm().getBooleanFactor().getBooleanTest() 65 .getBooleanPrimary().getPredicate().getComparisonPredicate().getValue(); 60 66 61 sql.append(fieldName); 62 if (comparisonOperator==CompOp.EQUAL)sql.append("="); 63 if (comparisonOperator==CompOp.NOT_EQUAL)sql.append("!="); 64 sql.append("'"+value+"'"); 67 sql.append(fieldName); 68 if (comparisonOperator == CompOp.EQUAL) 69 sql.append("="); 70 if (comparisonOperator == CompOp.NOT_EQUAL) 71 sql.append("!="); 72 sql.append("'" + value + "'"); 65 73 66 if (sql.length()==0)return null; 74 if (sql.length() == 0) 75 return null; 67 76 68 return sql.toString();77 return sql.toString(); 69 78 70 71 } 72 73 79 } 74 80 75 81 } -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/StatisticHandler.java
r1082 r1175 52 52 public AggregatorGraphModel performStatistic(String statisticName) { 53 53 if (statisticRegistry != null) { 54 Statistic statistic = statisticRegistry.getStatistic(statisticName);54 BaseStatistic statistic = statisticRegistry.getStatistic(statisticName); 55 55 if (statistic != null) { 56 56 return performStatiticalPipeline(statistic); … … 62 62 } 63 63 64 private AggregatorGraphModel performStatiticalPipeline( Statistic statistic) {64 private AggregatorGraphModel performStatiticalPipeline(BaseStatistic statistic) { 65 65 statistic.setEntryHandler(getEventHandler()); 66 66 Boolean success = invoke(statistic); … … 92 92 * @param statistic 93 93 */ 94 private Boolean invoke( Statistic statistic) {94 private Boolean invoke(BaseStatistic statistic) { 95 95 if (getEventHandler() != null) 96 96 log.debug("Invoking statistic [{}], working off {} events", statistic.getStatisticParameters() … … 133 133 } 134 134 135 public List< Statistic> getStatisticalUnits() {135 public List<BaseStatistic> getStatisticalUnits() { 136 136 return statisticRegistry.getStatisticalUnits(); 137 137 } … … 158 158 */ 159 159 @Deprecated 160 public void setStatisticalUnits(List< Statistic> statisticalUnits) {160 public void setStatisticalUnits(List<BaseStatistic> statisticalUnits) { 161 161 if (statisticRegistry == null) { 162 162 statisticRegistry = new ContextAwareStatisticRegistry(); -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/StatisticRegistry.java
r1097 r1175 36 36 * @return 37 37 */ 38 public Statistic getStatistic(String statisticName);38 public BaseStatistic getStatistic(String statisticName); 39 39 40 40 /** … … 43 43 * @param statisticalUnits - the <code>Statistic</code>s to register 44 44 */ 45 public void setStatisticalUnits(List< Statistic> statisticalUnits);45 public void setStatisticalUnits(List<BaseStatistic> statisticalUnits); 46 46 47 47 /** … … 50 50 * @return a <code>List</code> of currently registered statistics 51 51 */ 52 public List< Statistic> getStatisticalUnits();52 public List<BaseStatistic> getStatisticalUnits(); 53 53 54 54 } -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/StatisticalUnitException.java
r1020 r1175 14 14 * limitations under the License. 15 15 */ 16 16 17 package uk.ac.cardiff.raptormua.engine.statistics; 17 18 18 public class StatisticalUnitException extends Exception {19 public class StatisticalUnitException extends Exception { 19 20 20 /** 21 * 22 */ 23 private static final long serialVersionUID = -4614661463043866258L; 24 25 public StatisticalUnitException (String message){ 26 super(message); 27 } 28 29 public StatisticalUnitException (String message, Exception wrappedException){ 30 super(message, wrappedException); 31 } 21 /** 22 * Generated serial UID. 23 */ 24 private static final long serialVersionUID = -4614661463043866258L; 32 25 26 /** Constructor. */ 27 public StatisticalUnitException() { 28 super(); 29 } 30 31 /** 32 * Constructor. 33 * 34 * @param message exception message 35 */ 36 public StatisticalUnitException(final String message) { 37 super(message); 38 } 39 40 /** 41 * Constructor. 42 * 43 * @param wrappedException exception to be wrapped by this one 44 */ 45 public StatisticalUnitException(final Exception wrappedException) { 46 super(wrappedException); 47 } 48 49 /** 50 * Constructor. 51 * 52 * @param message exception message 53 * @param wrappedException exception to be wrapped by this one 54 */ 55 public StatisticalUnitException(final String message, final Exception wrappedException) { 56 super(message, wrappedException); 57 } 33 58 34 59 } -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/functions/CountEntry.java
r1082 r1175 25 25 import uk.ac.cardiff.model.wsmodel.MethodParameter; 26 26 import uk.ac.cardiff.model.wsmodel.StatisticParameters; 27 import uk.ac.cardiff.raptormua.engine.statistics. Statistic;27 import uk.ac.cardiff.raptormua.engine.statistics.BaseStatistic; 28 28 import uk.ac.cardiff.raptormua.engine.statistics.StatisticalUnitException; 29 29 import uk.ac.cardiff.raptormua.engine.statistics.records.Bucket; 30 30 import uk.ac.cardiff.raptormua.engine.statistics.records.ObservationSeries; 31 31 32 public class CountEntry extends Statistic{32 public class CountEntry extends BaseStatistic{ 33 33 34 34 /** Class logger */ -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/functions/CountEntryPerInterval.java
r1082 r1175 26 26 import uk.ac.cardiff.model.wsmodel.StatisticParameters; 27 27 import uk.ac.cardiff.model.wsmodel.MethodParameter.ParameterType; 28 import uk.ac.cardiff.raptormua.engine.statistics. Statistic;28 import uk.ac.cardiff.raptormua.engine.statistics.BaseStatistic; 29 29 import uk.ac.cardiff.raptormua.engine.statistics.StatisticalUnitException; 30 30 import uk.ac.cardiff.raptormua.engine.statistics.records.Bucket; 31 31 import uk.ac.cardiff.raptormua.engine.statistics.records.ObservationSeries; 32 32 33 public class CountEntryPerInterval extends Statistic{33 public class CountEntryPerInterval extends BaseStatistic{ 34 34 35 35 static Logger log = LoggerFactory.getLogger(CountEntryPerInterval.class); -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/functions/GroupBy.java
r1082 r1175 27 27 import uk.ac.cardiff.model.wsmodel.MethodParameter.ParameterType; 28 28 import uk.ac.cardiff.raptor.runtimeutils.ReflectionHelper; 29 import uk.ac.cardiff.raptormua.engine.statistics. Statistic;29 import uk.ac.cardiff.raptormua.engine.statistics.BaseStatistic; 30 30 import uk.ac.cardiff.raptormua.engine.statistics.StatisticalUnitException; 31 31 import uk.ac.cardiff.raptormua.engine.statistics.records.Group; 32 32 import uk.ac.cardiff.raptormua.engine.statistics.records.ObservationSeries; 33 33 34 public class GroupBy extends Statistic{34 public class GroupBy extends BaseStatistic{ 35 35 36 36 /** Class logger */ -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/functions/GroupByCountDistinct.java
r1082 r1175 28 28 import uk.ac.cardiff.raptor.runtimeutils.ReflectionException; 29 29 import uk.ac.cardiff.raptor.runtimeutils.ReflectionHelper; 30 import uk.ac.cardiff.raptormua.engine.statistics. Statistic;30 import uk.ac.cardiff.raptormua.engine.statistics.BaseStatistic; 31 31 import uk.ac.cardiff.raptormua.engine.statistics.StatisticalUnitException; 32 32 import uk.ac.cardiff.raptormua.engine.statistics.records.Group; 33 33 import uk.ac.cardiff.raptormua.engine.statistics.records.ObservationSeries; 34 34 35 public class GroupByCountDistinct extends Statistic {35 public class GroupByCountDistinct extends BaseStatistic { 36 36 37 37 /** Class logger */ -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/functions/GroupByFrequency.java
r1082 r1175 27 27 import uk.ac.cardiff.model.wsmodel.MethodParameter.ParameterType; 28 28 import uk.ac.cardiff.raptor.runtimeutils.ReflectionHelper; 29 import uk.ac.cardiff.raptormua.engine.statistics. Statistic;29 import uk.ac.cardiff.raptormua.engine.statistics.BaseStatistic; 30 30 import uk.ac.cardiff.raptormua.engine.statistics.StatisticalUnitException; 31 31 import uk.ac.cardiff.raptormua.engine.statistics.records.Group; 32 32 import uk.ac.cardiff.raptormua.engine.statistics.records.ObservationSeries; 33 33 34 public class GroupByFrequency extends Statistic {34 public class GroupByFrequency extends BaseStatistic { 35 35 36 36 /** Class logger */ -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/helper/ObservationComparator.java
r807 r1175 17 17 * 18 18 */ 19 19 20 package uk.ac.cardiff.raptormua.engine.statistics.helper; 20 21 … … 24 25 25 26 /** 27 * The Class ObservationComparator. 28 * 26 29 * @author philsmart 27 *28 30 */ 29 public class ObservationComparator implements Comparator<Observation> {31 public class ObservationComparator implements Comparator<Observation> { 30 32 33 /** Whether the observations should be sorted in ascending order. Sorted in descending order otherwise. */ 31 34 private boolean asc; 32 35 33 public ObservationComparator(boolean asc){ 34 this.asc = asc; 36 /** 37 * Instantiates a new observation comparator. 38 * 39 * @param asc the asc 40 */ 41 public ObservationComparator(boolean asc) { 42 this.asc = asc; 35 43 } 36 44 45 /* 46 * (non-Javadoc) 47 * 48 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) 49 */ 37 50 public int compare(Observation arg0, Observation arg1) { 38 if (asc)39 return (int)(arg0.getValue() - arg1.getValue()); //if =0 same, < 0 smaller, >0 bigger40 else41 return (int)(arg1.getValue() - arg0.getValue());51 if (asc) 52 return (int) (arg0.getValue() - arg1.getValue()); // if =0 same, < 0 smaller, >0 bigger 53 else 54 return (int) (arg1.getValue() - arg0.getValue()); 42 55 } 43 56 -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/helper/StringGroupComparator.java
r807 r1175 17 17 * 18 18 */ 19 19 20 package uk.ac.cardiff.raptormua.engine.statistics.helper; 20 21 … … 25 26 import org.slf4j.LoggerFactory; 26 27 27 import uk.ac.cardiff.raptormua.engine.statistics.Statistic;28 28 import uk.ac.cardiff.raptormua.engine.statistics.records.Group; 29 import uk.ac.cardiff.raptormua.engine.statistics.records.Observation;30 29 31 30 /** 31 * The Class StringGroupComparator. 32 * 32 33 * @author philsmart 33 *34 34 */ 35 public class StringGroupComparator implements Comparator<Group>{ 36 37 /** Class logger */ 38 private final Logger log = LoggerFactory.getLogger(StringGroupComparator.class); 35 public class StringGroupComparator implements Comparator<Group> { 39 36 37 /** Class logger. */ 38 private final Logger log = LoggerFactory.getLogger(StringGroupComparator.class); 39 40 /** The asc. */ 40 41 private boolean asc; 41 42 42 public StringGroupComparator(boolean asc){ 43 this.asc = asc; 43 /** 44 * Instantiates a new string group comparator. 45 * 46 * @param asc the asc 47 */ 48 public StringGroupComparator(boolean asc) { 49 this.asc = asc; 44 50 } 45 51 52 /* 53 * (non-Javadoc) 54 * 55 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) 56 */ 46 57 public int compare(Group arg0, Group arg1) { 47 Collator c = Collator.getInstance();48 return c.compare(arg0.getGroupName(),arg1.getGroupName());58 Collator c = Collator.getInstance(); 59 return c.compare(arg0.getGroupName(), arg1.getGroupName()); 49 60 } 50 61 -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/processor/NumberFormatterPostProcessor.java
r1083 r1175 34 34 */ 35 35 public class NumberFormatterPostProcessor implements StatisticPostProcessor { 36 36 // TODO Not implemented... 37 37 /** class logger */ 38 38 private static final Logger log = LoggerFactory.getLogger(NumberFormatterPostProcessor.class); -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/processor/PostprocessorException.java
r1020 r1175 14 14 * limitations under the License. 15 15 */ 16 16 17 package uk.ac.cardiff.raptormua.engine.statistics.processor; 17 18 18 public class PostprocessorException extends Exception {19 public class PostprocessorException extends Exception { 19 20 20 /**21 * 22 */23 private static final long serialVersionUID = -4614661463043866256L;21 /** 22 * Generated serial UID 23 */ 24 private static final long serialVersionUID = -4614661463043866256L; 24 25 25 public PostprocessorException (String message){ 26 super(message); 27 } 26 /** Constructor. */ 27 public PostprocessorException() { 28 super(); 29 } 28 30 31 /** 32 * Constructor. 33 * 34 * @param message exception message 35 */ 36 public PostprocessorException(final String message) { 37 super(message); 38 } 39 40 /** 41 * Constructor. 42 * 43 * @param wrappedException exception to be wrapped by this one 44 */ 45 public PostprocessorException(final Exception wrappedException) { 46 super(wrappedException); 47 } 48 49 /** 50 * Constructor. 51 * 52 * @param message exception message 53 * @param wrappedException exception to be wrapped by this one 54 */ 55 public PostprocessorException(final String message, final Exception wrappedException) { 56 super(message, wrappedException); 57 } 29 58 30 59 } -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/processor/SamlMetadataNameFormatter.java
r1083 r1175 55 55 private final Logger log = LoggerFactory.getLogger(SamlMetadataNameFormatter.class); 56 56 57 /* *this is not a proper URI at the moment, just a UNC path */57 /* this is not a proper URI at the moment, just a UNC path */ 58 58 private String SAMLMetadataURI; 59 59 -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/records/Bucket.java
r363 r1175 14 14 * limitations under the License. 15 15 */ 16 16 17 package uk.ac.cardiff.raptormua.engine.statistics.records; 17 18 18 19 import org.joda.time.DateTime; 19 20 20 public class Bucket extends Observation{ 21 /** 22 * The Class Bucket. 23 */ 24 public class Bucket extends Observation { 21 25 22 private DateTime start; 23 private DateTime end;26 /** The start date and time. */ 27 private DateTime start; 24 28 29 /** The end date and time. */ 30 private DateTime end; 25 31 32 /** 33 * Checks if is inside. 34 * 35 * @param eventTime the event time 36 * @return true, if is inside 37 */ 38 public boolean isInside(DateTime eventTime) { 39 /* semantics here are; if equal to or after start but before end return true */ 40 if ((eventTime.isEqual(start) && eventTime.isBefore(end)) 41 || (eventTime.isAfter(start) && eventTime.isBefore(end))) 42 return true; 43 return false; 44 } 26 45 27 public boolean isInside(DateTime eventTime){ 28 /* semantics here are; if equal to or after start but before end return true*/ 29 if ((eventTime.isEqual(start) && eventTime.isBefore(end)) || (eventTime.isAfter(start) && eventTime.isBefore(end))) return true; 30 return false; 31 } 46 /** 47 * Increment. 48 */ 49 public void increment() { 50 value++; 51 } 32 52 33 public void increment(){ 34 value++; 35 } 53 /** 54 * Sets the start. 55 * 56 * @param start the start to set 57 */ 58 public void setStart(DateTime start) { 59 this.start = start; 60 } 36 61 37 /** 38 * @param start the start to set 39 */ 40 public void setStart(DateTime start) { 41 this.start = start; 42 } 43 /** 44 * @return the start 45 */ 46 public DateTime getStart() { 47 return start; 48 } 49 /** 50 * @param end the end to set 51 */ 52 public void setEnd(DateTime end) { 53 this.end = end; 54 } 55 /** 56 * @return the end 57 */ 58 public DateTime getEnd() { 59 return end; 60 } 62 /** 63 * Gets the start. 64 * 65 * @return the start 66 */ 67 public DateTime getStart() { 68 return start; 69 } 61 70 71 /** 72 * Sets the end. 73 * 74 * @param end the end to set 75 */ 76 public void setEnd(DateTime end) { 77 this.end = end; 78 } 79 80 /** 81 * Gets the end. 82 * 83 * @return the end 84 */ 85 public DateTime getEnd() { 86 return end; 87 } 62 88 63 89 } -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/records/GraphEntry.java
r363 r1175 17 17 * 18 18 */ 19 19 20 package uk.ac.cardiff.raptormua.engine.statistics.records; 20 21 21 22 /** 22 * @author philsmart 23 * this is a generic category, data class to send as a result of a statistical operation for display, may need subclassing 24 * in the future e.g. for line charts etc that require more values - This format should be compatible with primeface 25 * graphing components. 23 * @author philsmart this is a generic category, data class to send as a result of a statistical operation for display, 24 * may need subclassing in the future e.g. for line charts etc that require more values - This format should be 25 * compatible with view graphing components. 26 26 */ 27 27 public class GraphEntry { 28 /* the label that is to be displayed for the data entry e.g. a time interval, or a server hostname */ 29 private String categoryLabel; 30 /* the actual value of the data entry e.g. frequency, mean etc. */ 31 private double value; 28 /** the label that is to be displayed for the data entry e.g. a time interval, or a server hostname */ 29 private String categoryLabel; 32 30 31 /** the actual value of the data entry e.g. frequency, mean etc. */ 32 private double value; 33 33 34 public void setCategoryLabel(String categoryLabel) { 35 this.categoryLabel = categoryLabel; 36 } 37 public String getCategoryLabel() { 38 return categoryLabel; 39 } 40 public void setValue(double value) { 41 this.value = value; 42 } 43 public double getValue() { 44 return value; 45 } 34 public void setCategoryLabel(String categoryLabel) { 35 this.categoryLabel = categoryLabel; 36 } 37 38 public String getCategoryLabel() { 39 return categoryLabel; 40 } 41 42 public void setValue(double value) { 43 this.value = value; 44 } 45 46 public double getValue() { 47 return value; 48 } 46 49 47 50 } -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/records/Group.java
r363 r1175 17 17 * 18 18 */ 19 19 20 package uk.ac.cardiff.raptormua.engine.statistics.records; 20 21 21 22 /** 23 * The Class Group. 24 * 22 25 * @author philsmart 23 *24 26 */ 25 public class Group extends Observation {27 public class Group extends Observation { 26 28 27 private String groupName; 29 /** The group name. */ 30 private String groupName; 28 31 32 /** 33 * Sets the group name. 34 * 35 * @param groupName the new group name 36 */ 37 public void setGroupName(String groupName) { 38 this.groupName = groupName; 39 } 29 40 30 public void setGroupName(String groupName) { 31 this.groupName = groupName; 32 } 33 public String getGroupName() { 34 return groupName; 35 } 36 public void increment() { 37 value++; 41 /** 42 * Gets the group name. 43 * 44 * @return the group name 45 */ 46 public String getGroupName() { 47 return groupName; 48 } 38 49 39 } 50 /** 51 * Increment. 52 */ 53 public void increment() { 54 value++; 55 56 } 40 57 41 58 } -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/records/Observation.java
r363 r1175 17 17 * 18 18 */ 19 19 20 package uk.ac.cardiff.raptormua.engine.statistics.records; 20 21 21 22 /** 23 * The Class Observation. 24 * 22 25 * @author philsmart 23 *24 26 */ 25 27 public class Observation { 26 28 27 protected double value; 29 /** The value. */ 30 protected double value; 28 31 29 public void setValue(double value) { 30 this.value = value; 31 } 32 /** 33 * Sets the value. 34 * 35 * @param value the new value 36 */ 37 public void setValue(double value) { 38 this.value = value; 39 } 32 40 33 public double getValue() { 34 return value; 35 } 41 /** 42 * Gets the value. 43 * 44 * @return the value 45 */ 46 public double getValue() { 47 return value; 48 } 36 49 37 50 } -
raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/records/ObservationSeries.java
r1082 r1175 14 14 * limitations under the License. 15 15 */ 16 16 17 package uk.ac.cardiff.raptormua.engine.statistics.records; 17 18 19 /** 20 * The Class ObservationSeries. 21 */ 22 public class ObservationSeries { 18 23 19 public class ObservationSeries { 20 21 private String seriesName; 22 23 /* 24 * each statistical method produces objects (observations) which are stored in this array variable ready for postprocessing or construction of an 25 * <code>AggregatorGraphModel</code> 24 /** The series name. */ 25 private String seriesName; 26 27 /** 28 * Each statistical method produces objects (observations) which are stored in this array variable ready for 29 * postprocessing or construction of an <code>AggregatorGraphModel</code>. 26 30 */ 27 31 private Observation[] observations; 28 32 29 public void setSeriesName(String seriesName) { 30 this.seriesName = seriesName; 31 } 33 /** 34 * Sets the series name. 35 * 36 * @param seriesName the new series name 37 */ 38 public void setSeriesName(String seriesName) { 39 this.seriesName = seriesName; 40 } 32 41 33 public String getSeriesName() { 34 return seriesName; 35 } 42 /** 43 * Gets the series name. 44 * 45 * @return the series name 46 */ 47 public String getSeriesName() { 48 return seriesName; 49 } 36 50 37 public void setObservations(Observation[] observations) { 38 this.observations = observations; 39 } 51 /** 52 * Sets the observations. 53 * 54 * @param observations the new observations 55 */ 56 public void setObservations(Observation[] observations) { 57 this.observations = observations; 58 } 40 59 41 public Observation[] getObservations() { 42 return observations; 43 } 60 /** 61 * Gets the observations. 62 * 63 * @return the observations 64 */ 65 public Observation[] getObservations() { 66 return observations; 67 } 44 68 45 69 }
Note: See TracChangeset
for help on using the changeset viewer.
