Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/19/11 09:37:18 (14 years ago)
Author:
mholper
Message:

first Unit-Test build against new AdministrationService #1441

Location:
branches/OKBJavaConnector/src/main/java/com/heuristiclab/okb
Files:
84 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/OKBJavaConnector/src/main/java/com/heuristiclab/okb/impl/ECJ19ConnectorImpl.java

    r5673 r5761  
    1010import com.heuristiclab.okb.ECJConnectorState;
    1111
    12 import at.hl.okb.IECJConnector;
    13 import at.hl.okb.wsclient.OKBServiceClient;
     12//import at.hl.okb.IECJConnector;
     13//import at.hl.okb.wsclient.OKBServiceClient;
    1414
    1515/**
     
    1717 *
    1818 */
    19 public class ECJ19ConnectorImpl implements IECJConnector {
     19public class ECJ19ConnectorImpl { //implements IECJConnector {
    2020
    21   private OKBServiceClient okbClient = null;
    22 
    23   /**
    24    *
    25    */
    26   public ECJ19ConnectorImpl() {
    27     this.okbClient = new OKBServiceClient();
    28   }
    29  
    30 
    31   @Override
    32   public ECJConnectorState initialize(String algorithmName, String platformName, String problemName) throws Exception {
    33 
    34     Long platformId = okbClient.getPlatformId(platformName);
    35     if (platformId == null)
    36       throw new Exception("Platform " + platformName + " not found!");
    37 
    38     Long algorithmId = okbClient.getAlgorithmId(algorithmName, platformId);
    39     if (algorithmId == null)
    40       throw new Exception("Algorithm " + algorithmName + " for Platform " + platformName + " not found!");
    41 
    42     Long problemId = okbClient.getProblemId(problemName);
    43     if (problemId == null)
    44       throw new Exception("Proble " + problemName + " not found!");
    45    
    46     return new ECJConnectorState(platformId,algorithmId,problemId);
    47   }
    48 
    49   @Override
    50   public void result(ECJConnectorState state, List<Object> resultList, Map<String, Object> algoParams, Map<String, Object> problemParams,
    51       Object paramFile) throws Exception {
    52     // TODO Auto-generated method stub
    53    
    54     Set<String> missingAlgoParamSet = algoParams.keySet();
    55     missingAlgoParamSet.removeAll(okbClient.getAlgorithmParameterMap(state.getAlgorithmId()).keySet());
    56    
    57     //fehlende Param Anlegen
    58     if (missingAlgoParamSet.size()>0)
    59       okbClient.createMissingAlgoParams(state.getAlgorithmId(), missingAlgoParamSet);   
    60    
    61     Set<String> missingProblemParamSet = problemParams.keySet();
    62     missingProblemParamSet.removeAll(okbClient.getProblemParameterMap(state.getProblemId()).keySet());   
    63 
    64     //create Experiment if algoparams not exists in HL and problemparams not exits (in HL)
    65     //create missing Params in Algo and Problem (if not exits for experiment)
    66     //create Datatype if missing
    67    
    68   }
     21//  private OKBServiceClient okbClient = null;
     22//
     23//  /**
     24//   *
     25//   */
     26//  public ECJ19ConnectorImpl() {
     27//    this.okbClient = new OKBServiceClient();
     28//  }
     29// 
     30//
     31//  @Override
     32//  public ECJConnectorState initialize(String algorithmName, String platformName, String problemName) throws Exception {
     33//
     34//    Long platformId = okbClient.getPlatformId(platformName);
     35//    if (platformId == null)
     36//      throw new Exception("Platform " + platformName + " not found!");
     37//
     38//    Long algorithmId = okbClient.getAlgorithmId(algorithmName, platformId);
     39//    if (algorithmId == null)
     40//      throw new Exception("Algorithm " + algorithmName + " for Platform " + platformName + " not found!");
     41//
     42//    Long problemId = okbClient.getProblemId(problemName);
     43//    if (problemId == null)
     44//      throw new Exception("Proble " + problemName + " not found!");
     45//   
     46//    return new ECJConnectorState(platformId,algorithmId,problemId);
     47//  }
     48//
     49//  @Override
     50//  public void result(ECJConnectorState state, List<Object> resultList, Map<String, Object> algoParams, Map<String, Object> problemParams,
     51//      Object paramFile) throws Exception {
     52//    // TODO Auto-generated method stub
     53//   
     54//    Set<String> missingAlgoParamSet = algoParams.keySet();
     55//    missingAlgoParamSet.removeAll(okbClient.getAlgorithmParameterMap(state.getAlgorithmId()).keySet());
     56//   
     57//    //fehlende Param Anlegen
     58//    if (missingAlgoParamSet.size()>0)
     59//      okbClient.createMissingAlgoParams(state.getAlgorithmId(), missingAlgoParamSet);   
     60//   
     61//    Set<String> missingProblemParamSet = problemParams.keySet();
     62//    missingProblemParamSet.removeAll(okbClient.getProblemParameterMap(state.getProblemId()).keySet());   
     63//
     64//    //create Experiment if algoparams not exists in HL and problemparams not exits (in HL)
     65//    //create missing Params in Algo and Problem (if not exits for experiment)
     66//    //create Datatype if missing
     67//   
     68//  }
    6969}
  • branches/OKBJavaConnector/src/main/java/com/heuristiclab/okb/wsclient/OKBServiceClient.java

    r5673 r5761  
    11package com.heuristiclab.okb.wsclient;
    22
    3 import static at.hl.okb.wsclient.Utilities.createNameFilter;
     3//import static at.hl.okb.wsclient.Utilities.createNameFilter;
    44
    55import java.util.HashMap;
     
    88import java.util.Set;
    99
    10 import at.hl.wsclient.okb.Algorithm;
    11 import at.hl.wsclient.okb.AlgorithmClass;
    12 import at.hl.wsclient.okb.AlgorithmData;
    13 import at.hl.wsclient.okb.AlgorithmParameter;
    14 import at.hl.wsclient.okb.ArrayOfAlgorithmParameter;
    15 import at.hl.wsclient.okb.ArrayOfProblemParameter;
    16 import at.hl.wsclient.okb.IOKBService;
    17 import at.hl.wsclient.okb.NamedOKBItem;
    18 import at.hl.wsclient.okb.OKBService;
    19 import at.hl.wsclient.okb.ObjectFactory;
    20 import at.hl.wsclient.okb.Platform;
    21 import at.hl.wsclient.okb.Problem;
    22 import at.hl.wsclient.okb.ProblemClass;
    23 import at.hl.wsclient.okb.ProblemData;
    24 import at.hl.wsclient.okb.ProblemParameter;
     10//import at.hl.wsclient.okb.Algorithm;
     11//import at.hl.wsclient.okb.AlgorithmClass;
     12//import at.hl.wsclient.okb.AlgorithmData;
     13//import at.hl.wsclient.okb.AlgorithmParameter;
     14//import at.hl.wsclient.okb.ArrayOfAlgorithmParameter;
     15//import at.hl.wsclient.okb.ArrayOfProblemParameter;
     16//import at.hl.wsclient.okb.IOKBService;
     17//import at.hl.wsclient.okb.NamedOKBItem;
     18//import at.hl.wsclient.okb.OKBService;
     19//import at.hl.wsclient.okb.ObjectFactory;
     20//import at.hl.wsclient.okb.Platform;
     21//import at.hl.wsclient.okb.Problem;
     22//import at.hl.wsclient.okb.ProblemClass;
     23//import at.hl.wsclient.okb.ProblemData;
     24//import at.hl.wsclient.okb.ProblemParameter;
    2525
    2626import com.google.common.collect.Iterables;
    2727
    2828public class OKBServiceClient {
    29   OKBService srv = null;
    30   IOKBService port = null;
    31   ObjectFactory factory = new ObjectFactory();
    3229
    33   public OKBServiceClient() {
    34     this.srv = new OKBService();
    35     this.port = srv.getWSHttpBindingIOKBService1();
    36   }
    37 
    38   public Long getPlatformId(String platformName) {
    39     Platform returnValue = Iterables.find(
    40         port.getPlatforms().getPlatform(),
    41         createNameFilter(platformName), null);
    42 
    43     return returnValue != null ? returnValue.getId() : null;
    44   }
    45 
    46   public Long getProblemId(String problemName) {
    47     Problem returnValue = Iterables.find(port.getProblems().getProblem(),
    48         createNameFilter(problemName), null);
    49 
    50     return returnValue != null ? returnValue.getId() : null;
    51   }
    52 
    53   public Long getProblemClassId(String problemClass) {
    54     ProblemClass returnValue = Iterables.find(port.getProblemClasses()
    55         .getProblemClass(), createNameFilter(problemClass), null);
    56 
    57     return returnValue != null ? returnValue.getId() : null;
    58 
    59   }
    60 
    61   public Long getAlgorithmClassId(String algorithmClassName) {
    62     AlgorithmClass returnValue = Iterables.find(port.getAlgorithmClasses()
    63         .getAlgorithmClass(), createNameFilter(algorithmClassName),
    64         null);
    65 
    66     return returnValue != null ? returnValue.getId() : null;
    67 
    68   }
    69 
    70   public Long getProblem(String problemName, Long problemClassId,
    71       Long platformId) {
    72     Problem problem = null;
    73     Iterator<Problem> it = port.getProblems().getProblem().iterator();
    74 
    75     while (it.hasNext() && problem == null) {
    76       Problem tmpProblem = it.next();
    77       if (platformId.equals(tmpProblem.getPlatformId())
    78           && problemName.equals(tmpProblem.getName().getValue())
    79           && problemClassId.equals(tmpProblem.getProblemClassId())) {
    80 
    81         problem = tmpProblem;
    82       }
    83     }
    84     return problem != null ? problem.getId() : null;
    85   }
    86 
    87   public Long getAlgorithmId(String algorithmName, /* Long algorithmClassId, */
    88   Long platformId) {
    89     Algorithm algorithm = null;
    90 
    91     Iterator<Algorithm> it = port.getAlgorithms().getAlgorithm().iterator();
    92 
    93     while (it.hasNext() && algorithm == null) {
    94       Algorithm tmpAlgo = it.next();
    95       if (platformId.equals(tmpAlgo.getPlatformId())
    96           && algorithmName.equals(tmpAlgo.getName().getValue())
    97       // && algorithmClassId.equals(tmpAlgo.getAlgorithmClassId())
    98       ) {
    99         algorithm = tmpAlgo;
    100       }
    101     }
    102 
    103     return algorithm != null ? algorithm.getId() : null;
    104 
    105   }
    106 
    107   public Map<String, Object> getAlgorithmParameterMap(Long algorithmId) {
    108     Map<String, Object> returnMap = new HashMap<String, Object>();
    109 
    110     ArrayOfAlgorithmParameter algoParamList = port
    111         .getAlgorithmParameters(algorithmId);
    112 
    113     for (AlgorithmParameter algoParam : algoParamList
    114         .getAlgorithmParameter()) {
    115       returnMap.put(algoParam.getName().getValue(), null);
    116     }
    117 
    118     return returnMap;
    119   }
    120  
    121   public Map<String, Object> getProblemParameterMap(Long ProblemId) {
    122     Map<String, Object> returnMap = new HashMap<String, Object>();
    123 
    124     ArrayOfProblemParameter algoParamList = port
    125         .getProblemParameters(ProblemId);
    126 
    127     for (ProblemParameter algoParam : algoParamList
    128         .getProblemParameter()) {
    129       returnMap.put(algoParam.getName().getValue(), null);
    130     }
    131 
    132     return returnMap;
    133   }
    134  
    135 
    136 
    137   private <T extends NamedOKBItem> T createNamedOKBItem(Class<T> clazz,
    138       String name) {
    139     try {
    140       T instance = clazz.newInstance();
    141       instance.setName(factory.createNamedOKBItemName(name));
    142       return instance;
    143     } catch (IllegalAccessException ex) {
    144       throw new IllegalArgumentException(ex);
    145     } catch (InstantiationException ex) {
    146       throw new IllegalArgumentException(ex);
    147     }
    148   }
    149 
    150   public Boolean areAlgoParamsEqual() {
    151     Boolean retval = false;
    152 
    153     return retval;
    154   }
    155 
    156   public void createMissingAlgoParams(Long algorithmId,
    157       Set<String> missingParamNames) {
    158 
    159     //falls Werte auch verglichen werdne sollen
    160     //Map<String, Object> ecjAlgoParams
    161     //Set<String> missingParamNames = ecjAlgoParams.keySet();
    162     for (String paramname : missingParamNames) {
    163       AlgorithmParameter newAlgoParam = new AlgorithmParameter();
    164       newAlgoParam.setAlgorithmId(algorithmId);
    165       newAlgoParam.setDataTypeId(null);// TODO insert DatatypeId if not
    166                         // exists (mapping first);
    167       newAlgoParam.setDescription(factory
    168           .createNamedOKBItemDescription("created from ECJ"));
    169       newAlgoParam.setName(factory
    170           .createNamedOKBItemName(paramname));
    171       port.addAlgorithmParameter(newAlgoParam);
    172     }
    173   }
    174  
    175   public void createMissingProblemParams(Long ProblemId,
    176       Set<String> missingParamNames) {
    177 
    178     //falls Werte auch verglichen werdne sollen
    179     //Map<String, Object> ecjProblemParams
    180     //Set<String> missingParamNames = ecjProblemParams.keySet();
    181     for (String paramname : missingParamNames) {
    182       ProblemParameter newProblemParam = new ProblemParameter();
    183       newProblemParam.setProblemId(ProblemId);
    184       newProblemParam.setDataTypeId(null);// TODO insert DatatypeId if not
    185                         // exists (mapping first);
    186       newProblemParam.setDescription(factory
    187           .createNamedOKBItemDescription("created from ECJ"));
    188       newProblemParam.setName(factory
    189           .createNamedOKBItemName(paramname));
    190       port.addProblemParameter(newProblemParam);
    191     }
    192   }
    19330}
     31//  OKBService srv = null;
     32//  IOKBService port = null;
     33//  ObjectFactory factory = new ObjectFactory();
     34//
     35//  public OKBServiceClient() {
     36//    this.srv = new OKBService();
     37//    this.port = srv.getWSHttpBindingIOKBService1();
     38//  }
     39//
     40//  public Long getPlatformId(String platformName) {
     41//    Platform returnValue = Iterables.find(
     42//        port.getPlatforms().getPlatform(),
     43//        createNameFilter(platformName), null);
     44//
     45//    return returnValue != null ? returnValue.getId() : null;
     46//  }
     47//
     48//  public Long getProblemId(String problemName) {
     49//    Problem returnValue = Iterables.find(port.getProblems().getProblem(),
     50//        createNameFilter(problemName), null);
     51//
     52//    return returnValue != null ? returnValue.getId() : null;
     53//  }
     54//
     55//  public Long getProblemClassId(String problemClass) {
     56//    ProblemClass returnValue = Iterables.find(port.getProblemClasses()
     57//        .getProblemClass(), createNameFilter(problemClass), null);
     58//
     59//    return returnValue != null ? returnValue.getId() : null;
     60//
     61//  }
     62//
     63//  public Long getAlgorithmClassId(String algorithmClassName) {
     64//    AlgorithmClass returnValue = Iterables.find(port.getAlgorithmClasses()
     65//        .getAlgorithmClass(), createNameFilter(algorithmClassName),
     66//        null);
     67//
     68//    return returnValue != null ? returnValue.getId() : null;
     69//
     70//  }
     71//
     72//  public Long getProblem(String problemName, Long problemClassId,
     73//      Long platformId) {
     74//    Problem problem = null;
     75//    Iterator<Problem> it = port.getProblems().getProblem().iterator();
     76//
     77//    while (it.hasNext() && problem == null) {
     78//      Problem tmpProblem = it.next();
     79//      if (platformId.equals(tmpProblem.getPlatformId())
     80//          && problemName.equals(tmpProblem.getName().getValue())
     81//          && problemClassId.equals(tmpProblem.getProblemClassId())) {
     82//
     83//        problem = tmpProblem;
     84//      }
     85//    }
     86//    return problem != null ? problem.getId() : null;
     87//  }
     88//
     89//  public Long getAlgorithmId(String algorithmName, /* Long algorithmClassId, */
     90//  Long platformId) {
     91//    Algorithm algorithm = null;
     92//
     93//    Iterator<Algorithm> it = port.getAlgorithms().getAlgorithm().iterator();
     94//
     95//    while (it.hasNext() && algorithm == null) {
     96//      Algorithm tmpAlgo = it.next();
     97//      if (platformId.equals(tmpAlgo.getPlatformId())
     98//          && algorithmName.equals(tmpAlgo.getName().getValue())
     99//      // && algorithmClassId.equals(tmpAlgo.getAlgorithmClassId())
     100//      ) {
     101//        algorithm = tmpAlgo;
     102//      }
     103//    }
     104//
     105//    return algorithm != null ? algorithm.getId() : null;
     106//
     107//  }
     108//
     109//  public Map<String, Object> getAlgorithmParameterMap(Long algorithmId) {
     110//    Map<String, Object> returnMap = new HashMap<String, Object>();
     111//
     112//    ArrayOfAlgorithmParameter algoParamList = port
     113//        .getAlgorithmParameters(algorithmId);
     114//
     115//    for (AlgorithmParameter algoParam : algoParamList
     116//        .getAlgorithmParameter()) {
     117//      returnMap.put(algoParam.getName().getValue(), null);
     118//    }
     119//
     120//    return returnMap;
     121//  }
     122// 
     123//  public Map<String, Object> getProblemParameterMap(Long ProblemId) {
     124//    Map<String, Object> returnMap = new HashMap<String, Object>();
     125//
     126//    ArrayOfProblemParameter algoParamList = port
     127//        .getProblemParameters(ProblemId);
     128//
     129//    for (ProblemParameter algoParam : algoParamList
     130//        .getProblemParameter()) {
     131//      returnMap.put(algoParam.getName().getValue(), null);
     132//    }
     133//
     134//    return returnMap;
     135//  }
     136// 
     137//
     138//
     139//  private <T extends NamedOKBItem> T createNamedOKBItem(Class<T> clazz,
     140//      String name) {
     141//    try {
     142//      T instance = clazz.newInstance();
     143//      instance.setName(factory.createNamedOKBItemName(name));
     144//      return instance;
     145//    } catch (IllegalAccessException ex) {
     146//      throw new IllegalArgumentException(ex);
     147//    } catch (InstantiationException ex) {
     148//      throw new IllegalArgumentException(ex);
     149//    }
     150//  }
     151//
     152//  public Boolean areAlgoParamsEqual() {
     153//    Boolean retval = false;
     154//
     155//    return retval;
     156//  }
     157//
     158//  public void createMissingAlgoParams(Long algorithmId,
     159//      Set<String> missingParamNames) {
     160//
     161//    //falls Werte auch verglichen werdne sollen
     162//    //Map<String, Object> ecjAlgoParams
     163//    //Set<String> missingParamNames = ecjAlgoParams.keySet();
     164//    for (String paramname : missingParamNames) {
     165//      AlgorithmParameter newAlgoParam = new AlgorithmParameter();
     166//      newAlgoParam.setAlgorithmId(algorithmId);
     167//      newAlgoParam.setDataTypeId(null);// TODO insert DatatypeId if not
     168//                        // exists (mapping first);
     169//      newAlgoParam.setDescription(factory
     170//          .createNamedOKBItemDescription("created from ECJ"));
     171//      newAlgoParam.setName(factory
     172//          .createNamedOKBItemName(paramname));
     173//      port.addAlgorithmParameter(newAlgoParam);
     174//    }
     175//  }
     176// 
     177//  public void createMissingProblemParams(Long ProblemId,
     178//      Set<String> missingParamNames) {
     179//
     180//    //falls Werte auch verglichen werdne sollen
     181//    //Map<String, Object> ecjProblemParams
     182//    //Set<String> missingParamNames = ecjProblemParams.keySet();
     183//    for (String paramname : missingParamNames) {
     184//      ProblemParameter newProblemParam = new ProblemParameter();
     185//      newProblemParam.setProblemId(ProblemId);
     186//      newProblemParam.setDataTypeId(null);// TODO insert DatatypeId if not
     187//                        // exists (mapping first);
     188//      newProblemParam.setDescription(factory
     189//          .createNamedOKBItemDescription("created from ECJ"));
     190//      newProblemParam.setName(factory
     191//          .createNamedOKBItemName(paramname));
     192//      port.addProblemParameter(newProblemParam);
     193//    }
     194//  }
     195//}
  • branches/OKBJavaConnector/src/main/java/com/heuristiclab/okb/wsclient/Utilities.java

    r5673 r5761  
    11package com.heuristiclab.okb.wsclient;
    22
    3 import at.hl.wsclient.okb.NamedOKBItem;
    4 import at.hl.wsclient.okb.Problem;
     3//import at.hl.wsclient.okb.NamedOKBItem;
     4//import at.hl.wsclient.okb.Problem;
    55
    66import com.google.common.base.Predicate;
     
    88class Utilities {
    99 
    10   private static class NameFilter implements Predicate<NamedOKBItem>
    11   {
    12     private final String name;
    13    
    14     public NameFilter(String name)
    15     {
    16       this.name = name;
    17     }
    18    
    19     @Override
    20     public boolean apply(NamedOKBItem arg0) {
    21       return arg0.getName().getValue().equals(name);   
    22     }
    23   }
    24  
    25  
    26   private static class ProblemFilter implements Predicate<Problem>
    27   {
    28       private final String problemName;
    29       private final String problemClass;
    30      
    31       public ProblemFilter(String problemName, String problemClass)
    32       {
    33     this.problemClass = problemClass;
    34     this.problemName = problemName;
    35       }
     10//  private static class NameFilter implements Predicate<NamedOKBItem>
     11//  {
     12//    private final String name;
     13//   
     14//    public NameFilter(String name)
     15//    {
     16//      this.name = name;
     17//    }
     18//   
     19//    @Override
     20//    public boolean apply(NamedOKBItem arg0) {
     21//      return arg0.getName().getValue().equals(name);   
     22//    }
     23//  }
     24// 
     25// 
     26//  private static class ProblemFilter implements Predicate<Problem>
     27//  {
     28//      private final String problemName;
     29//      private final String problemClass;
     30//     
     31//      public ProblemFilter(String problemName, String problemClass)
     32//      {
     33//    this.problemClass = problemClass;
     34//    this.problemName = problemName;
     35//      }
     36//
     37//      @Override
     38//      public boolean apply(Problem input) {
     39//    // TODO Auto-generated method stub
     40//    return false;
     41//      }
     42//  }
     43// 
     44// 
     45//  public static Predicate<NamedOKBItem> createNameFilter(String name)
     46//  {
     47//    return new NameFilter(name);
     48//  }
     49// 
     50//  private Utilities()
     51//  {
     52//   
     53//  }
    3654
    37       @Override
    38       public boolean apply(Problem input) {
    39     // TODO Auto-generated method stub
    40     return false;
    41       }
    42   }
    43  
    44  
    45   public static Predicate<NamedOKBItem> createNameFilter(String name)
    46   {
    47     return new NameFilter(name);
    48   }
    49  
    50   private Utilities()
    51   {
    52    
    53   }
    54  
    55  
    5655}
  • branches/OKBJavaConnector/src/main/java/com/heuristiclab/okb/wsclient/handler/TrustStoreCallbackHandler.java

    r5673 r5761  
    3131                //String keystoreURL = "C:\\Users\\HolperM\\.netbeans\\6.9\\config\\GF3\\domain1\\config\\keystoreHL.jks";
    3232                //FIXME
    33                 is = this.getClass().getClassLoader().getResourceAsStream("HLOKB_KeystoreLocalhost.jks");
     33                is = this.getClass().getClassLoader().getResourceAsStream("okbkeystore.jks");
    3434                //is = new FileInputStream(keystoreURL);//keystoreURL);
    3535                //keyStore.load(is, "changeit".toCharArray());
    36                 keyStore.load(is, "mh2404".toCharArray());
     36                keyStore.load(is, "okb123".toCharArray());
    3737            } catch (IOException ex) {
    3838                Logger.getLogger(TrustStoreCallbackHandler.class.getName()).log(Level.SEVERE, null, ex);
Note: See TracChangeset for help on using the changeset viewer.