Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/28/11 10:03:00 (14 years ago)
Author:
bfarka
Message:

added dokumentation for the service #1441

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OKBJavaConnector/ECJClient/src/com/heuristiclab/okb/ecj/OKBStatistics.java

    r6326 r6327  
    2323 *
    2424 * @author fab
     25 * Implementation of statics which are sending the parameters and results
     26 * to the OKB Serverices
     27 *
    2528 */
    26 public class OKBStatistics extends Statistics{
     29public class OKBStatistics extends Statistics {
    2730
     31    /**
     32     * Plattformname which has to be in already in the service
     33     */
    2834    public static final String ECJ_PLATFORM_NAME = "ECJ";
     35    /**
     36     * Name for parameters in the param file
     37     */
    2938    public static final String OKB_PARAMETER_NAME = "okb.parameter";
     39    /**
     40     * name of the seed paramter in the params file
     41     */
    3042    public static final String OKB_PARAMETER_SEED = "okb.parameter.seed";
     43    /**
     44     * username
     45     */
     46    public static final String OKB_USER = "okb.username";
     47    /**
     48     * password
     49     */
     50    public static final String OKB_PASSWORD = "okb.password";
     51    /**
     52     * current Platform
     53     * */
    3154    private Platform ecjPlatform;
    32    
     55    /**
     56     * current Alogrithm
     57     */
     58    private Algorithm algorithm;
    3359
    34 
     60    /**
     61     * Setup of statistic, username and password are set
     62     *
     63     * platform an algorithm are fetched from the service
     64     * if the platform or algorithm are missing a illegal arugement excption is thorwn
     65     **/
    3566    @Override
    3667    public void setup(EvolutionState state, Parameter base) {
    3768        super.setup(state, base);
    38    
    39        
     69        handler.UserNameHandler.setUser(getUsername(state));
     70        handler.UserNameHandler.setPassword(getPassword(state));
    4071
     72
     73        ecjPlatform = AdministrationServiceUtil.getPlattform(ECJ_PLATFORM_NAME);
     74        algorithm = RunCreationUtil.getAlgorithm(state.evaluator.getClass().getName(), ecjPlatform.getName());
    4175    }
    4276
    43 
    44 
    45     @Override
    46     public void postInitializationStatistics(EvolutionState state) {
    47         super.postInitializationStatistics(state);
    48     }
    49 
     77    /**
     78     * Submitting the results to the service
     79     * @param state
     80     * @param result
     81     */
    5082    @Override
    5183    public void finalStatistics(EvolutionState state, int result) {
    5284        super.finalStatistics(state, result);
    5385
    54        ecjPlatform = AdministrationServiceUtil.getPlattform(ECJ_PLATFORM_NAME);
    55        Algorithm algorithm = RunCreationUtil.getAlgorithm(state.evaluator.getClass().getName(), ecjPlatform.getName());
    56        Map<String, String> parameters = getParametersToSend(state);
    57        ByteArrayOutputStream o = new ByteArrayOutputStream();
    58        new XMLEncoder(o).writeObject(state);
    5986
    60 
    61        
    62         RunCreationUtil.createRun(parameters,result,new String(o.toByteArray()),getSeed(state),algorithm.getId() , ecjPlatform.getId());
     87        Map<String, String> parameters = getParametersToSend(state);
     88        ByteArrayOutputStream o = new ByteArrayOutputStream();
     89        new XMLEncoder(o).writeObject(state);
     90        RunCreationUtil.createRun(parameters, result, new String(o.toByteArray()), getSeed(state), algorithm.getId(), ecjPlatform.getId());
    6391
    6492    }
    6593
    66     private int getSeed(EvolutionState state)
    67     {
     94    /**
     95     * getting the username out of the config
     96     **/
     97    protected final String getUsername(EvolutionState state) {
     98        return state.parameters.getString(new Parameter(OKB_USER), null);
     99    }
     100
     101    /**
     102     * getting the password out of the config
     103     *
     104     */
     105    private String getPassword(EvolutionState state) {
     106        return state.parameters.getString(new Parameter(OKB_PASSWORD), null);
     107    }
     108
     109    /**
     110     * getting the default seed out of the config
     111     * @throws  IllegalArgumentException if the seed is missing
     112     */
     113    private int getSeed(EvolutionState state) {
    68114        int returnValue = 0;
    69         String seedName = state.parameters.getString(new Parameter(OKB_PARAMETER_SEED),null);
    70         if(seedName == null)
     115        String seedName = state.parameters.getString(new Parameter(OKB_PARAMETER_SEED), null);
     116        if (seedName == null) {
    71117            throw new IllegalArgumentException("no seed given!");
     118        }
    72119
    73         returnValue = state.parameters.getInt(new Parameter(seedName),null);
     120        returnValue = state.parameters.getInt(new Parameter(seedName), null);
    74121
    75122        return returnValue;
    76123    }
    77124
    78 
    79     private Map<String, String> getParametersToSend(EvolutionState state)
    80     {
     125    /**
     126     * getting the parameters out of the config
     127     **/
     128    private Map<String, String> getParametersToSend(EvolutionState state) {
    81129        Map<String, String> returnValue = new HashMap<String, String>();
    82         for(String name : state.parameters.getString(new Parameter(OKB_PARAMETER_NAME),null).split(";"))
    83         {
    84             String tmp = state.parameters.getString(new Parameter(name.trim()),null);
    85             if(tmp == null)
     130        for (String name : state.parameters.getString(new Parameter(OKB_PARAMETER_NAME), null).split(";")) {
     131            String tmp = state.parameters.getString(new Parameter(name.trim()), null);
     132            if (tmp == null) {
    86133                returnValue.put(name, name);
    87             else
     134            } else {
    88135                returnValue.put(name, tmp);
    89 
     136            }
    90137        }
    91 
    92138        return returnValue;
    93139    }
    94    
    95    
    96    
    97140}
Note: See TracChangeset for help on using the changeset viewer.