Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5248


Ignore:
Timestamp:
01/08/11 13:40:09 (13 years ago)
Author:
mholper
Message:

modified Interface #1218

File:
1 edited

Legend:

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

    r5242 r5248  
    33import static at.hl.okb.wsclient.Utilities.createNameFilter;
    44
     5import java.util.HashMap;
    56import java.util.Iterator;
     7import java.util.Map;
    68
     9import at.hl.okb.ECJDataTypeEnum;
    710import at.hl.wsclient.okb.Algorithm;
    811import at.hl.wsclient.okb.AlgorithmClass;
     12import at.hl.wsclient.okb.AlgorithmData;
     13import at.hl.wsclient.okb.AlgorithmParameter;
     14import at.hl.wsclient.okb.ArrayOfAlgorithmParameter;
    915import at.hl.wsclient.okb.IOKBService;
    1016import at.hl.wsclient.okb.NamedOKBItem;
     
    1824
    1925public class OKBServiceClient {
    20     OKBService srv = null;
    21     IOKBService port = null;
    22     ObjectFactory factory = new ObjectFactory();
     26  OKBService srv = null;
     27  IOKBService port = null;
     28  ObjectFactory factory = new ObjectFactory();
    2329
    24     public OKBServiceClient() {
    25   this.srv = new OKBService();
    26   this.port = srv.getWSHttpBindingIOKBService1();
    27     }
     30  public OKBServiceClient() {
     31    this.srv = new OKBService();
     32    this.port = srv.getWSHttpBindingIOKBService1();
     33  }
    2834
    29     public Long getPlatformId(String platformName) {
    30   Platform returnValue = Iterables.find(
    31     port.getPlatforms().getPlatform(),
    32     createNameFilter(platformName), null);
     35  public Long getPlatformId(String platformName) {
     36    Platform returnValue = Iterables.find(
     37        port.getPlatforms().getPlatform(),
     38        createNameFilter(platformName), null);
    3339
    34   return returnValue.getId();
    35     }
     40    return returnValue.getId();
     41  }
     42 
     43  public Long getProblemId(String problemName) {
     44    Problem returnValue = Iterables.find(
     45        port.getProblems().getProblem(),
     46        createNameFilter(problemName), null);
    3647
    37     public Long getProblemClassId(String problemClass) {
    38   ProblemClass returnValue = Iterables.find(port.getProblemClasses()
    39     .getProblemClass(), createNameFilter(problemClass), null);
     48    return returnValue.getId();
     49  }
    4050
    41   return returnValue.getId();
     51  public Long getProblemClassId(String problemClass) {
     52    ProblemClass returnValue = Iterables.find(port.getProblemClasses()
     53        .getProblemClass(), createNameFilter(problemClass), null);
    4254
    43     }
     55    return returnValue.getId();
    4456
    45     public Long getAlgorithmClassId(String algorithmClassName) {
    46   AlgorithmClass returnValue = Iterables.find(port.getAlgorithmClasses()
    47     .getAlgorithmClass(), createNameFilter(algorithmClassName),
    48     null);
     57  }
    4958
    50   return returnValue.getId();
     59  public Long getAlgorithmClassId(String algorithmClassName) {
     60    AlgorithmClass returnValue = Iterables.find(port.getAlgorithmClasses()
     61        .getAlgorithmClass(), createNameFilter(algorithmClassName),
     62        null);
    5163
    52     }
     64    return returnValue.getId();
    5365
    54     public Long getProblem(String problemName, Long problemClassId,
    55       Long platformId) {
    56   Problem problem = null;
    57   Iterator<Problem> it = port.getProblems().getProblem().iterator();
     66  }
     67
     68  public Long getProblem(String problemName, Long problemClassId,
     69      Long platformId) {
     70    Problem problem = null;
     71    Iterator<Problem> it = port.getProblems().getProblem().iterator();
     72
     73    while (it.hasNext() && problem == null) {
     74      Problem tmpProblem = it.next();
     75      if (platformId.equals(tmpProblem.getPlatformId())
     76          && problemName.equals(tmpProblem.getName().getValue())
     77          && problemClassId.equals(tmpProblem.getProblemClassId())) {
     78
     79        problem = tmpProblem;
     80      }
     81    }
     82    return problem.getId();
     83  }
     84
     85  public Long getAlgorithmId(String algorithmName, /*Long algorithmClassId,*/
     86      Long platformId) {
     87    Algorithm algorithm = null;
     88   
     89    Iterator<Algorithm> it = port.getAlgorithms().getAlgorithm().iterator();
     90
     91    while (it.hasNext() && algorithm == null) {
     92      Algorithm tmpAlgo = it.next();
     93      if (platformId.equals(tmpAlgo.getPlatformId())
     94          && algorithmName.equals(tmpAlgo.getName().getValue())
     95          //&& algorithmClassId.equals(tmpAlgo.getAlgorithmClassId())
     96          ) {
     97        algorithm = tmpAlgo;
     98      }
     99    }
     100   
     101    return algorithm != null ?algorithm.getId() : null;
     102     
     103  }
    58104 
    59   while (it.hasNext() && problem == null) {
    60       Problem tmpProblem = it.next();
    61       if (platformId.equals(tmpProblem.getPlatformId())
    62         && problemName.equals(tmpProblem.getName().getValue())
    63         && problemClassId.equals(tmpProblem.getProblemClassId())) {
    64    
    65    
    66    
    67     problem = tmpProblem;
    68       }
     105//  public Map<String, ECJDataTypeEnum> getAlgorithParameter(Long  algorithmId) {
     106//    Map<String, AlgorithmParameter> returnMap = new HashMap<String, AlgorithmParameter>();
     107//   
     108//    AlgorithmData algoData = port.getAlgorithmData(algorithmId);
     109// 
     110//    ArrayOfAlgorithmParameter algoParamList = port.getAlgorithmParameters(algorithmId);
     111//   
     112//    for (AlgorithmParameter algoParam:algoParamList.getAlgorithmParameter()) {
     113//      mapOKBDataTypetoECJDataTypeEnum()
     114//      port.getDataType(algoParam.getDataTypeId()).getName().getValue()) {
     115//     
     116//      }
     117//      returnMap.put(algoParam.getName().getValue(), port.getDataType(algoParam.getDataTypeId()).getName().getValue());
     118//    }
     119//   
     120//    return returnMap;
     121//  }
     122
     123  private <T extends NamedOKBItem> T createNamedOKBItem(Class<T> clazz,
     124      String name) {
     125    try {
     126      T instance = clazz.newInstance();
     127      instance.setName(factory.createNamedOKBItemName(name));
     128      return instance;
     129    } catch (IllegalAccessException ex) {
     130      throw new IllegalArgumentException(ex);
     131    } catch (InstantiationException ex) {
     132      throw new IllegalArgumentException(ex);
     133    }
    69134  }
    70   return problem.getId();
    71     }
    72 
    73    
    74     public Long getAlgorithm(String algorithmName, Long algorithmClassId,
    75       Long platformId) {
    76   Algorithm algorithm = null;
    77   Iterator<Algorithm> it = port.getAlgorithms().getAlgorithm().iterator();
    78  
    79   while (it.hasNext() && algorithm == null) {
    80       Algorithm tmpAlgo = it.next();
    81       if (platformId.equals(tmpAlgo.getPlatformId())
    82         && algorithmName.equals(tmpAlgo.getName().getValue())
    83         && algorithmClassId.equals(tmpAlgo.getAlgorithmClassId())) {
    84     algorithm = tmpAlgo;
    85       }
    86   }
    87   return algorithm.getId();
    88     }
    89 
    90    
    91     private <T extends NamedOKBItem> T createNamedOKBItem(Class<T> clazz,
    92       String name) {
    93   try {
    94       T instance = clazz.newInstance();
    95       instance.setName(factory.createNamedOKBItemName(name));
    96       return instance;
    97   } catch (IllegalAccessException ex) {
    98       throw new IllegalArgumentException(ex);
    99   } catch (InstantiationException ex) {
    100       throw new IllegalArgumentException(ex);
    101   }
    102     }
    103135
    104136}
Note: See TracChangeset for help on using the changeset viewer.