Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5229


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

restructure of service project #1218

Location:
branches/OKBJavaConnector/HLOKBWebClient
Files:
7 added
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • branches/OKBJavaConnector/HLOKBWebClient/.classpath

    r5084 r5229  
    22<classpath>
    33  <classpathentry kind="src" output="target/classes" path="src/main/java"/>
    4   <classpathentry kind="src" path="generated/jax-ws"/>
     4  <classpathentry kind="src" output="target/classes" path="target/jaxws/wsimport/java"/>
    55  <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
     6  <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
    67  <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
    78  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
  • branches/OKBJavaConnector/HLOKBWebClient/.project

    r4955 r5229  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<projectDescription>
    3   <name>HLOKBWSClient</name>
    4   <comment></comment>
     3  <name>connector</name>
     4  <comment>contains a java client for HeuristicLab OKB WCF-Service. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
    55  <projects>
    66  </projects>
     
    2121    <nature>org.eclipse.jdt.core.javanature</nature>
    2222  </natures>
    23   <linkedResources>
    24     <link>
    25       <name>jax-ws</name>
    26       <type>2</type>
    27       <location>C:/Users/HolperM/workspace/HLOKBWSClient/generated/jax-ws</location>
    28     </link>
    29   </linkedResources>
    3023</projectDescription>
  • branches/OKBJavaConnector/HLOKBWebClient/pom.xml

    r5084 r5229  
    5757            <configuration>
    5858              <packageName>at.hl.wsclient.okb</packageName>
    59               <sourceDestDir>${basedir}/generated/jax-ws</sourceDestDir>
     59             
    6060              <wsdlLocation>http://localhost:8732/Design_Time_Addresses/OKB-3.3/OKBService?wsdl</wsdlLocation>
    6161              <wsdlDirectory>${basedir}/src/main/resources</wsdlDirectory>
     
    6464              </wsdlFiles><!-- <wsdlUrls> <wsdlUrl>http://localhost:8732/Design_Time_Addresses/OKB-3.3/OKBService?wsdl</wsdlUrl>
    6565                </wsdlUrls> -->
    66               <xnocompile>true</xnocompile>
    6766              <extension>true</extension>
    68               <verbose>true</verbose>
    6967              <!-- <bindingDirectory>/bindings</bindingDirectory> -->
    7068            </configuration>
     
    9593      <version>2.1-b17</version>
    9694    </dependency>
    97 
     95    <dependency>
     96      <groupId>com.google.guava</groupId>
     97      <artifactId>guava</artifactId>
     98      <version>r07</version>
     99    </dependency>
    98100    <dependency>
    99101      <groupId>org.glassfish.metro</groupId>
  • 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}
  • branches/OKBJavaConnector/HLOKBWebClient/src/test/at/hl/wsclient/okb/OKBClientTest.java

    r5084 r5229  
    1212import org.junit.Test;
    1313
     14import at.hl.okb.wsclient.OKBServiceClient;
    1415import at.hl.okb.wsclient.Exception.OKBWebServiceFailedException;
    1516
     
    2021public class OKBClientTest {
    2122 
    22   OKBService srv = null;
    23   IOKBService port = null; 
    24 
    25   /**
    26    * @throws java.lang.Exception
    27    */
    28   @BeforeClass
    29   public static void setUpBeforeClass() throws Exception {
    30   }
    31 
    32   /**
    33    * @throws java.lang.Exception
    34    */
    35   @AfterClass
    36   public static void tearDownAfterClass() throws Exception {
    37   }
    38 
    39   /**
    40    * @throws java.lang.Exception
    41    */
    42   @Before
    43   public void setUp() throws Exception {
    44     this.srv = new OKBService();
    45     this.port = srv.getWSHttpBindingIOKBService1();
    46   }
    47 
    48   /**
    49    * @throws java.lang.Exception
    50    */
    51   @After
    52   public void tearDown() throws Exception {
    53   }
    54  
     23   
     24      OKBServiceClient client = new OKBServiceClient();
    5525  @Test
    56   public void AddAlgorithmTest() throws Exception  {
    57    
    58         ObjectFactory fac = new ObjectFactory();
    59         AddAlgorithm addA = fac.createAddAlgorithm();
    60         addA.setDto(fac.createAddAlgorithmDto(fac.createAlgorithm()));
    61         Long retval = 0L;
    62 
    63         Algorithm a = fac.createAlgorithm();
    64         a.setAlgorithmClassId(1L);
    65         a.setDescription(fac.createNamedOKBItemDescription("a new Algo"));
    66         a.setId(2L);
    67         a.setName(fac.createNamedOKBItemName("Algorithm Name 6"));
    68         a.setPlatformId(1L);
    69         try {
    70         retval = port.addAlgorithm(a);
    71         } catch (Exception e) {
    72           throw new OKBWebServiceFailedException(e.getMessage());
    73         }
    74         assertTrue("Algortihm wasn't added", retval>0);
    75   }
    76  
    77   @Test
    78   public void GetAlgorithms() {
    79    
    80     ArrayOfAlgorithm algos = port.getAlgorithms();
    81    
    82     for (Algorithm algo:algos.getAlgorithm()) {
    83       System.out.println("algo ClassId:="+algo.getAlgorithmClassId());
    84       System.out.println("algo Id:="+algo.getId());
    85       System.out.println("algo PlattformId:="+algo.getPlatformId());
    86       System.out.println("algo Class:="+algo.getClass());
    87       System.out.println("algo Description:="+algo.getDescription().getValue());
    88       System.out.println("algo Name:="+algo.getName().getValue());
    89     }
    90     assertTrue("No Algorithms found!", algos.getAlgorithm().size()>0);
    91   }
    92  
    93   @Test
    94   public void GetDataTypes() {
    95    
    96     ArrayOfDataType dataTypes = port.getDataTypes();
    97    
    98     for (DataType dataType:dataTypes.getDataType()) {
    99       System.out.println("algo Id:="+dataType.getId());
    100       System.out.println("algo platformId:="+dataType.getPlatformId());
    101       System.out.println("algo Name:="+dataType.getName());
    102       System.out.println("algo Class:="+dataType.getClass());
    103       System.out.println("algo SQLName:="+dataType.getSqlName().getValue());
    104     }
    105     assertTrue("No dataTypes found!", dataTypes.getDataType().size()>0);
    106   }
    107  
    108  
    109  
    110   @Test
    111   public void GetIds(){
    112    
     26      public void testGetPlatform()
     27  {
     28      client.getPlatformId("ECJ");
    11329  }
    11430
Note: See TracChangeset for help on using the changeset viewer.