Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/07/11 00:39:31 (14 years ago)
Author:
bfarka
Message:

restructure of service project #1218

Location:
branches/OKBJavaConnector/HLOKBWebClient/src/main/java/at/hl/okb/wsclient
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OKBJavaConnector/HLOKBWebClient/src/main/java/at/hl/okb/wsclient/OKBServiceClient.java

    r5085 r5229  
    11package at.hl.okb.wsclient;
     2
     3import static at.hl.okb.wsclient.Utilities.createNameFilter;
    24
    35import java.util.ArrayList;
     
    57import java.util.List;
    68import java.util.Map;
    7 import java.util.Set;
     9
     10import javax.xml.bind.JAXBElement;
     11import javax.xml.namespace.QName;
     12
     13import com.google.common.collect.Iterables;
    814
    915import at.hl.wsclient.okb.Algorithm;
     
    1521import at.hl.wsclient.okb.IOKBService;
    1622import at.hl.wsclient.okb.OKBService;
     23import at.hl.wsclient.okb.ObjectFactory;
    1724import at.hl.wsclient.okb.Platform;
    1825import at.hl.wsclient.okb.Problem;
    1926
    2027public class OKBServiceClient {
    21   OKBService srv = null;
    22   IOKBService port = null;
     28    OKBService srv = null;
     29    IOKBService port = null;
    2330
    24   public OKBServiceClient() {
    25     this.srv = new OKBService();
    26     this.port = srv.getWSHttpBindingIOKBService1();
    27   } 
     31    public OKBServiceClient() {
     32  this.srv = new OKBService();
     33  this.port = srv.getWSHttpBindingIOKBService();
     34    }
     35
     36    public Long getPlatformId(String platformName) {
     37  Platform returnValue = Iterables.find(
     38    port.getPlatforms().getPlatform(),
     39    createNameFilter(platformName));
     40  if (returnValue == null)
     41      createPlatform(platformName);
     42
     43  returnValue = Iterables.find(port.getPlatforms().getPlatform(),
     44    createNameFilter(platformName));
     45  return returnValue.getId();
     46
     47    }
     48
     49    private void createPlatform(String name) {
    2850 
    29   public Long getPlatformId(String platformName) {
    30     Long platformId = null;
    31    
    32     ArrayOfPlatform allPlatforms = port.getPlatforms();
    33     for (Platform platform:allPlatforms.getPlatform()) {
    34       if (platform.getName().getValue()==platformName) {
    35         platformId = platform.getId();
    36       }
    37     }
    38     return platformId;
     51  ObjectFactory factory = new ObjectFactory();
     52  Platform platform = factory.createPlatform();
     53 
     54  platform.setName(factory.createNamedOKBItemName(name));
     55  port.addPlatform(platform);
     56    }
     57
     58    public Long getAlgorithmId(String algorithmName) {
     59  Long algorithmId = null;
     60
     61  ArrayOfAlgorithm allAlgorithms = port.getAlgorithms();
     62  for (Algorithm algo : allAlgorithms.getAlgorithm()) {
     63      if (algo.getName().getValue() == algorithmName) {
     64    algorithmId = algo.getId();
     65      }
     66  }
     67  return algorithmId;
     68    }
     69
     70    public Long getProblemId(String problemName) {
     71  Long problemId = null;
     72
     73  ArrayOfProblem allProblems = port.getProblems();
     74  for (Problem problem : allProblems.getProblem()) {
     75      if (problem.getName().getValue() == problemName) {
     76    problemId = problem.getId();
     77      }
     78  }
     79  return problemId;
     80    }
     81
     82    public void checkAlgoParamsExists(Long algorithmId,
     83      Map<String, Object> ecjAlgoParams) {
     84
     85  List<String> missingParams = new ArrayList<String>();
     86
     87  ArrayOfAlgorithmParameter hlAlgoParams = port
     88    .getAlgorithmParameters(algorithmId);
     89  Map<String, Object> hlAlgoParamMap = new HashMap<String, Object>();
     90
     91  for (AlgorithmParameter algoParam : hlAlgoParams
     92    .getAlgorithmParameter()) {
     93      hlAlgoParamMap.put(algoParam.getName().getValue(), null); // value
     94                      // hangs
     95                      // on
     96                      // Experiments
    3997  }
    4098
    41   public Long getAlgorithmId(String algorithmName) {
    42     Long algorithmId = null;
    43    
    44     ArrayOfAlgorithm allAlgorithms = port.getAlgorithms();
    45     for (Algorithm algo:allAlgorithms.getAlgorithm()) {
    46       if (algo.getName().getValue()==algorithmName) {
    47         algorithmId = algo.getId();
    48       }
    49     }
    50     return algorithmId;
    51   }
    52  
    53   public Long getProblemId(String problemName) {
    54     Long problemId = null;
    55    
    56     ArrayOfProblem allProblems = port.getProblems();
    57     for (Problem problem:allProblems.getProblem()) {
    58       if (problem.getName().getValue()==problemName) {
    59         problemId = problem.getId();
    60       }
    61     }
    62     return problemId;
     99  String[] ecjparamNames = (String[]) ecjAlgoParams.keySet().toArray();
     100
     101  for (int i = 0; i < ecjparamNames.length; i++) {
     102      if (!hlAlgoParamMap.containsKey(ecjparamNames[i])) {
     103    missingParams.add(new String(ecjparamNames[i]));
     104      }
    63105  }
    64106
    65   public void checkAlgoParamsExists(Long algorithmId,
    66       Map<String, Object> ecjAlgoParams) {
    67    
    68     List<String> missingParams = new ArrayList<String>();
    69    
    70     ArrayOfAlgorithmParameter hlAlgoParams = port.getAlgorithmParameters(algorithmId);
    71     Map<String, Object> hlAlgoParamMap = new HashMap<String, Object>();
    72    
    73     for (AlgorithmParameter algoParam:hlAlgoParams.getAlgorithmParameter()) {
    74       hlAlgoParamMap.put(algoParam.getName().getValue(), null); //value hangs on Experiments
    75     }
    76    
    77    
    78     String[] ecjparamNames = (String[]) ecjAlgoParams.keySet().toArray();
    79    
    80     for (int i=0;i<ecjparamNames.length;i++) {
    81       if (!hlAlgoParamMap.containsKey(ecjparamNames[i])) {
    82         missingParams.add(new String(ecjparamNames[i]));
    83       }
    84     }
    85    
    86    
    87   }
    88 
    89 
     107    }
    90108
    91109}
Note: See TracChangeset for help on using the changeset viewer.