Changeset 5229 for branches/OKBJavaConnector/HLOKBWebClient/src
- Timestamp:
- 01/07/11 00:39:31 (14 years ago)
- Location:
- branches/OKBJavaConnector/HLOKBWebClient/src
- Files:
-
- 7 added
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKBJavaConnector/HLOKBWebClient/src/main/java/at/hl/okb/wsclient/OKBServiceClient.java
r5085 r5229 1 1 package at.hl.okb.wsclient; 2 3 import static at.hl.okb.wsclient.Utilities.createNameFilter; 2 4 3 5 import java.util.ArrayList; … … 5 7 import java.util.List; 6 8 import java.util.Map; 7 import java.util.Set; 9 10 import javax.xml.bind.JAXBElement; 11 import javax.xml.namespace.QName; 12 13 import com.google.common.collect.Iterables; 8 14 9 15 import at.hl.wsclient.okb.Algorithm; … … 15 21 import at.hl.wsclient.okb.IOKBService; 16 22 import at.hl.wsclient.okb.OKBService; 23 import at.hl.wsclient.okb.ObjectFactory; 17 24 import at.hl.wsclient.okb.Platform; 18 25 import at.hl.wsclient.okb.Problem; 19 26 20 27 public class OKBServiceClient { 21 22 28 OKBService srv = null; 29 IOKBService port = null; 23 30 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) { 28 50 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 39 97 } 40 98 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 } 63 105 } 64 106 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 } 90 108 91 109 } -
branches/OKBJavaConnector/HLOKBWebClient/src/test/at/hl/wsclient/okb/OKBClientTest.java
r5084 r5229 12 12 import org.junit.Test; 13 13 14 import at.hl.okb.wsclient.OKBServiceClient; 14 15 import at.hl.okb.wsclient.Exception.OKBWebServiceFailedException; 15 16 … … 20 21 public class OKBClientTest { 21 22 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(); 55 25 @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"); 113 29 } 114 30
Note: See TracChangeset
for help on using the changeset viewer.