Changeset 1083


Ignore:
Timestamp:
08/30/11 19:56:46 (9 years ago)
Author:
philsmart
Message:

before v0.2.0

Location:
raptor-mua/trunk/src/main
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • raptor-mua/trunk/src/main/config/statistical-units.xml

    r1082 r1083  
    341341 
    342342        <import resource="statistical-units-system.xml"/> 
     343    <!-- <import resource="statistical-processors.xml"/> --> 
    343344 
    344345 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/CapabilitiesConstructor.java

    r1082 r1083  
    22 *  
    33 */ 
     4 
    45package uk.ac.cardiff.raptormua.engine; 
    56 
     
    3334 *  
    3435 */ 
    35 public class CapabilitiesConstructor implements ApplicationContextAware{ 
     36public class CapabilitiesConstructor implements ApplicationContextAware { 
    3637 
    3738    /** Class logger. */ 
     
    5253    private Set<String> excludeFieldNames; 
    5354 
    54     /** Springs application context*/ 
    55         private ApplicationContext applicationContext; 
     55    /** Springs application context */ 
     56    private ApplicationContext applicationContext; 
    5657 
    5758    /** 
    5859     * @return 
    5960     */ 
    60     public Capabilities constructCapabilities(StatisticHandler statisticsHandler, StorageEngine storageEngine, ServiceMetadata metadata) { 
     61    public Capabilities constructCapabilities(StatisticHandler statisticsHandler, StorageEngine storageEngine, 
     62            ServiceMetadata metadata) { 
    6163        log.info("Capabilities Constructor Called"); 
    6264        long startTime = System.currentTimeMillis(); 
     
    6668        checkCacheValidity(); 
    6769 
    68         if (cacheEnabled && cachedCapabilities!=null) { 
    69             log.info("Capabilities retrieved from cache, cache will timeout in {} milliseconds",cacheTimeoutMs-(System.currentTimeMillis()-cacheResetTimeMs)); 
     70        if (cacheEnabled && cachedCapabilities != null) { 
     71            log.info("Capabilities retrieved from cache, cache will timeout in {} milliseconds", cacheTimeoutMs 
     72                    - (System.currentTimeMillis() - cacheResetTimeMs)); 
    7073            capabilities = cachedCapabilities; 
    7174        } 
     
    8588            capabilities.setNumberOfAuthenticationsStored(storageEngine.getEntryHandler().getNumberOfEvents()); 
    8689            List<Suggestion> possiblePostProcessors = findPostProcessors(); 
    87             log.debug("Has set {} possible post processor suggestion values",possiblePostProcessors.size()); 
     90            log.trace("Has set {} possible post processor suggestion values", possiblePostProcessors.size()); 
    8891            suggestionValues.setPossiblePostProcessors(possiblePostProcessors); 
    8992 
     
    103106 
    104107            // set resource metadata 
    105             List<ResourceMetadata> resourceMetadata = (List<ResourceMetadata>) storageEngine.getEntryHandler().query("from ResourceMetadata"); 
     108            List<ResourceMetadata> resourceMetadata = 
     109                    (List<ResourceMetadata>) storageEngine.getEntryHandler().query("from ResourceMetadata"); 
    106110            log.debug("Setting {} resource metadata", resourceMetadata.size()); 
    107             Collections.sort(resourceMetadata,new ResourceMetadataComparator()); 
     111            Collections.sort(resourceMetadata, new ResourceMetadataComparator()); 
    108112            capabilities.setResourceMetadata(resourceMetadata); 
    109113 
     
    119123                if (entry.getPostprocessor() != null) { 
    120124                    for (StatisticPostProcessor postprocessor : entry.getPostprocessor()) { 
    121                         ProcessorInformation processorInformation = new ProcessorInformation(); 
    122                         processorInformation.setBeanName(postprocessor.getClass().getSimpleName()); 
     125                        ProcessorInformation processorInformation = new ProcessorInformation(); 
     126                        processorInformation.setBeanName(postprocessor.getClass().getSimpleName()); 
    123127                        postprocessors.add(processorInformation); 
    124128                    } 
     
    128132            } 
    129133            capabilities.setStatisticalServices(stats); 
    130              
     134 
    131135            if (cacheEnabled) { 
    132136                cachedCapabilities = capabilities; 
     
    135139        } 
    136140        long endTime = System.currentTimeMillis(); 
    137         log.info("Constructed MUA Capabilities for [{}] in {}s", capabilities.getMetadata().getEntityId(),((endTime-startTime)/1000)); 
     141        log.info("Constructed MUA Capabilities for [{}] in {}s", capabilities.getMetadata().getEntityId(), 
     142                ((endTime - startTime) / 1000)); 
    138143 
    139144        return capabilities; 
    140145    } 
    141      
    142     private List<Suggestion> findPostProcessors(){ 
    143         String[] postProcessors = applicationContext.getBeanNamesForType(StatisticPostProcessor.class); 
    144         ArrayList<Suggestion> postProcessorSuggestions = new ArrayList<Suggestion>(); 
    145         for (String processor : postProcessors){ 
    146                 Suggestion suggestion = new Suggestion(); 
    147                 suggestion.setBase("postprocessor"); 
    148                 suggestion.setValue(processor); 
    149                 postProcessorSuggestions.add(suggestion); 
    150                 log.trace("Postprocessor, {}",processor); 
    151         } 
    152         return postProcessorSuggestions; 
    153          
     146 
     147    private List<Suggestion> findPostProcessors() { 
     148        String[] postProcessors = applicationContext.getBeanNamesForType(StatisticPostProcessor.class); 
     149        ArrayList<Suggestion> postProcessorSuggestions = new ArrayList<Suggestion>(); 
     150        for (String processor : postProcessors) { 
     151            Suggestion suggestion = new Suggestion(); 
     152            suggestion.setBase("postprocessor"); 
     153            suggestion.setValue(processor); 
     154            postProcessorSuggestions.add(suggestion); 
     155            log.trace("Postprocessor, {}", processor); 
     156        } 
     157        return postProcessorSuggestions; 
     158 
    154159    } 
    155160 
     
    167172 
    168173    /** 
    169      * Sets whether the cache is enabled, and sets a default timeout of 30 minutes 
    170      * in case one is not specified in the XML 
     174     * Sets whether the cache is enabled, and sets a default timeout of 30 minutes in case one is not specified in the 
     175     * XML 
    171176     *  
    172      * @param cacheEnabled 
    173      *            the cacheEnabled to set 
     177     * @param cacheEnabled the cacheEnabled to set 
    174178     */ 
    175179    public void setCacheEnabled(boolean cacheEnabled) { 
    176180        this.cacheEnabled = cacheEnabled; 
    177         cacheTimeoutMs=1800000; 
     181        cacheTimeoutMs = 1800000; 
    178182    } 
    179183 
     
    186190 
    187191    /** 
    188      * @param cacheTimeoutMs 
    189      *            the cacheTimeoutMs to set 
     192     * @param cacheTimeoutMs the cacheTimeoutMs to set 
    190193     */ 
    191194    public void setCacheTimeoutMs(long cacheTimeoutMs) { 
     
    201204 
    202205    /** 
    203      * @param excludeFieldNames 
    204      *            the excludeFieldNames to set 
     206     * @param excludeFieldNames the excludeFieldNames to set 
    205207     */ 
    206208    public void setExcludeFieldNames(Set<String> excludeFieldNames) { 
     
    215217    } 
    216218 
    217         public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 
    218                 this.applicationContext = applicationContext; 
    219                  
    220         } 
     219    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 
     220        this.applicationContext = applicationContext; 
     221 
     222    } 
    221223 
    222224} 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/ContextAwareStatisticRegistry.java

    r1082 r1083  
    8080        statistic.setStatisticParameters(statisticalUnitInformation.getStatisticParameters()); 
    8181        // now deal with the post processors 
    82         List<StatisticPostProcessor> postProcessors = 
    83                 initialisePostProcessors(statisticalUnitInformation.getPostprocessors()); 
    84         statistic.setPostprocessor(postProcessors); 
     82        // List<StatisticPostProcessor> postProcessors = 
     83        // initialisePostProcessors(statisticalUnitInformation.getPostprocessors()); 
     84        // statistic.setPostprocessor(postProcessors); 
    8585    } 
    8686 
     
    9292    private List<StatisticPostProcessor> initialisePostProcessors(List<ProcessorInformation> postProcessorsInformation) { 
    9393        // TODO could be factory method, need to acquire the bean implementation now. 
     94        StatisticProcessorFactory factory = new StatisticProcessorFactory(); 
    9495        List<StatisticPostProcessor> postprocessors = null; 
     96 
     97        for (ProcessorInformation information : postProcessorsInformation) { 
     98            postprocessors.add(factory.getPostProcessor(information.getClassName())); 
     99        } 
    95100 
    96101        return postprocessors; 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/Statistic.java

    r1082 r1083  
    223223                    // perform the same post process on each observationseries 
    224224                    for (ObservationSeries obsSeries : getObservationSeries()) { 
    225                         obsSeries.setObservations(post.postProcess(obsSeries.getObservations())); 
     225                        obsSeries.setObservations(post.process(obsSeries.getObservations())); 
    226226                    } 
    227227                } 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/StatisticPostProcessor.java

    r1082 r1083  
    3232public interface StatisticPostProcessor { 
    3333 
    34         public Observation[] postProcess(Observation[] observations) throws PostprocessorException; 
     34        public Observation[] process(Observation[] observations) throws PostprocessorException; 
    3535} 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/StatisticProcessorFactory.java

    r1082 r1083  
    11 
    22package uk.ac.cardiff.raptormua.engine.statistics; 
     3 
     4import org.slf4j.Logger; 
     5import org.slf4j.LoggerFactory; 
    36 
    47/** 
     
    1013public class StatisticProcessorFactory { 
    1114 
     15    /** class logger */ 
     16    private final Logger log = LoggerFactory.getLogger(StatisticProcessorFactory.class); 
     17 
     18    /** the default package name for processors */ 
     19    private static final String DEFAULT_PROCESSOR_PACKAGE = "uk.ac.cardiff.raptormua.engine.statistics.processor."; 
     20 
     21    public StatisticPostProcessor getPostProcessor(String processorName) { 
     22        StatisticPostProcessor processor = null; 
     23        Object processorClass; 
     24        try { 
     25            processorClass = Class.forName(DEFAULT_PROCESSOR_PACKAGE + processorName); 
     26            if (processorClass instanceof StatisticPostProcessor) { 
     27                processor = (StatisticPostProcessor) processorClass; 
     28                log.debug("Processor factory has constructor [{}]", processor); 
     29                return processor; 
     30            } 
     31        } catch (ClassNotFoundException e) { 
     32            log.error("Unable to create new statistical processor", e); 
     33        } 
     34 
     35        return processor; 
     36    } 
     37 
    1238} 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/processor/CutRowsPostProcessor.java

    r1082 r1083  
    4747     * (non-Javadoc) 
    4848     *  
    49      * @see uk.ac.cardiff.raptormua.engine.statistics.StatisticPostProcessor#postProcess(uk.ac.cardiff.raptormua.engine.statistics.records.Observation[]) 
     49     * @see uk.ac.cardiff.raptormua.engine.statistics.StatisticPostProcessor#process(uk.ac.cardiff.raptormua.engine.statistics.records.Observation[]) 
    5050     */ 
    5151 
    52     public Observation[] postProcess(Observation[] observations) throws PostprocessorException { 
     52    public Observation[] process(Observation[] observations) throws PostprocessorException { 
    5353        log.debug("{} post processor called, entries into postprocessor: {}", this.getClass(), observations.length); 
    5454        int rowsToKeep = (observations.length < numberOfRowsToKeep) ? observations.length : numberOfRowsToKeep; 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/processor/NumberFormatterPostProcessor.java

    r1082 r1083  
    3535public class NumberFormatterPostProcessor implements StatisticPostProcessor { 
    3636 
    37     /* class logger */ 
    38     static Logger log = LoggerFactory.getLogger(NumberFormatterPostProcessor.class); 
     37    /** class logger */ 
     38    private static final Logger log = LoggerFactory.getLogger(NumberFormatterPostProcessor.class); 
    3939 
    40     /* 
    41      * <p> performs all actions directly ('live') on the input object, and passes that back as a reference to conform 
    42      * with the <code>StatisticsPostProcessor</code> interface </p> 
     40    /** 
     41     * <p> 
     42     * performs all actions directly ('live') on the input object, and passes that back as a reference to conform with 
     43     * the <code>StatisticsPostProcessor</code> interface 
     44     * </p> 
    4345     *  
    4446     * (non-Javadoc) 
    4547     *  
    46      * @see 
    47      * uk.ac.cardiff.raptormua.engine.statistics.StatisticsPostProcessor#postProcess(uk.ac.cardiff.raptormua.engine. 
    48      * statistics.records.Observation[]) 
     48     * @see uk.ac.cardiff.raptormua.engine.statistics.StatisticsPostProcessor#postProcess(uk.ac.cardiff.raptormua.engine. 
     49     *      statistics.records.Observation[]) 
    4950     */ 
    50     public Observation[] postProcess(Observation[] observations) throws PostprocessorException { 
     51    public Observation[] process(Observation[] observations) throws PostprocessorException { 
    5152        log.debug("{} post processor called, entries into postprocessor: {}", this.getClass(), observations.length); 
    5253        for (Observation obs : observations) { 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/processor/PercentagePostProcessor.java

    r1082 r1083  
    4343     * (non-Javadoc) 
    4444     *  
    45      * @see uk.ac.cardiff.raptormua.engine.statistics.StatisticPostProcessor#postProcess(uk.ac.cardiff.raptormua.engine.statistics.records.Observation[]) 
     45     * @see uk.ac.cardiff.raptormua.engine.statistics.StatisticPostProcessor#process(uk.ac.cardiff.raptormua.engine.statistics.records.Observation[]) 
    4646     */ 
    47     public Observation[] postProcess(Observation[] observations) throws PostprocessorException { 
     47    public Observation[] process(Observation[] observations) throws PostprocessorException { 
    4848        log.debug("{} post processor called, entries into postprocessor: {}", this.getClass(), observations.length); 
    4949        // find total value (sum) 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/processor/RowSortPostProcessor.java

    r1082 r1083  
    5252     * (non-Javadoc) 
    5353     *  
    54      * @see uk.ac.cardiff.raptormua.engine.statistics.StatisticPostProcessor#postProcess(uk.ac.cardiff.raptormua.engine.statistics.records.Observation[]) 
     54     * @see uk.ac.cardiff.raptormua.engine.statistics.StatisticPostProcessor#process(uk.ac.cardiff.raptormua.engine.statistics.records.Observation[]) 
    5555     */ 
    56     public Observation[] postProcess(Observation[] observations) throws PostprocessorException { 
     56    public Observation[] process(Observation[] observations) throws PostprocessorException { 
    5757        log.debug("{} post processor called, entries into postprocessor: {}", this.getClass(), observations.length); 
    5858        Arrays.sort(observations, new ObservationComparator(ascending)); 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/processor/SamlMetadataNameFormatter.java

    r1082 r1083  
    8484    } 
    8585 
    86     public Observation[] postProcess(Observation[] observations) throws PostprocessorException { 
     86    public Observation[] process(Observation[] observations) throws PostprocessorException { 
    8787        log.debug("{} post processor called, entries into postprocessor: {}", this.getClass(), observations.length); 
    8888        for (Observation obs : observations) { 
  • raptor-mua/trunk/src/main/java/uk/ac/cardiff/raptormua/engine/statistics/processor/SortGroupsAlphabeticallyPostProcessor.java

    r1082 r1083  
    5353     * (non-Javadoc) 
    5454     *  
    55      * @see uk.ac.cardiff.raptormua.engine.statistics.StatisticPostProcessor#postProcess(uk.ac.cardiff.raptormua.engine.statistics.records.Observation[]) 
     55     * @see uk.ac.cardiff.raptormua.engine.statistics.StatisticPostProcessor#process(uk.ac.cardiff.raptormua.engine.statistics.records.Observation[]) 
    5656     */ 
    57     public Observation[] postProcess(Observation[] observations) throws PostprocessorException { 
     57    public Observation[] process(Observation[] observations) throws PostprocessorException { 
    5858        log.debug("{} post processor called, entries into postprocessor: {}", this.getClass(), observations.length); 
    5959        if (observations instanceof Group[]) { 
Note: See TracChangeset for help on using the changeset viewer.