Changeset 5248
- Timestamp:
- 01/08/11 13:40:09 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKBJavaConnector/HLOKBWebClient/src/main/java/at/hl/okb/wsclient/OKBServiceClient.java
r5242 r5248 3 3 import static at.hl.okb.wsclient.Utilities.createNameFilter; 4 4 5 import java.util.HashMap; 5 6 import java.util.Iterator; 7 import java.util.Map; 6 8 9 import at.hl.okb.ECJDataTypeEnum; 7 10 import at.hl.wsclient.okb.Algorithm; 8 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; 9 15 import at.hl.wsclient.okb.IOKBService; 10 16 import at.hl.wsclient.okb.NamedOKBItem; … … 18 24 19 25 public class OKBServiceClient { 20 21 22 26 OKBService srv = null; 27 IOKBService port = null; 28 ObjectFactory factory = new ObjectFactory(); 23 29 24 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 } 28 34 29 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); 33 39 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); 36 47 37 public Long getProblemClassId(String problemClass) { 38 ProblemClass returnValue = Iterables.find(port.getProblemClasses() 39 .getProblemClass(), createNameFilter(problemClass), null); 48 return returnValue.getId(); 49 } 40 50 41 return returnValue.getId(); 51 public Long getProblemClassId(String problemClass) { 52 ProblemClass returnValue = Iterables.find(port.getProblemClasses() 53 .getProblemClass(), createNameFilter(problemClass), null); 42 54 43 } 55 return returnValue.getId(); 44 56 45 public Long getAlgorithmClassId(String algorithmClassName) { 46 AlgorithmClass returnValue = Iterables.find(port.getAlgorithmClasses() 47 .getAlgorithmClass(), createNameFilter(algorithmClassName), 48 null); 57 } 49 58 50 return returnValue.getId(); 59 public Long getAlgorithmClassId(String algorithmClassName) { 60 AlgorithmClass returnValue = Iterables.find(port.getAlgorithmClasses() 61 .getAlgorithmClass(), createNameFilter(algorithmClassName), 62 null); 51 63 52 } 64 return returnValue.getId(); 53 65 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 } 58 104 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 } 69 134 } 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 }103 135 104 136 }
Note: See TracChangeset
for help on using the changeset viewer.