Fixes to test cases
[jabaws.git] / webservices / compbio / ws / client / Services.java
index 21b8bbc..a0c1f56 100644 (file)
 \r
 package compbio.ws.client;\r
 \r
+import java.net.URL;\r
+\r
+import javax.xml.namespace.QName;\r
+import javax.xml.ws.Service;\r
+\r
+import compbio.data.msa.JABAService;\r
+import compbio.data.msa.MsaWS;\r
+import compbio.data.msa.SequenceAnnotation;\r
+\r
 /**\r
- * List of web services currently supported by JABAWS version 1\r
+ * List of web services currently supported by JABAWS version 2\r
  * \r
  */\r
 public enum Services {\r
-    MafftWS, MuscleWS, ClustalWS, TcoffeeWS, ProbconsWS;\r
+       MafftWS, MuscleWS, ClustalWS, TcoffeeWS, ProbconsWS, AAConWS, JronnWS, DisemblWS, GlobPlotWS;\r
 \r
-    public static Services getService(String servName) {\r
-       servName = servName.trim().toLowerCase();\r
-       if (servName.equalsIgnoreCase(MafftWS.toString())) {\r
-           return MafftWS;\r
+       public static Services getService(String servName) {\r
+               servName = servName.trim().toLowerCase();\r
+               if (servName.equalsIgnoreCase(MafftWS.toString())) {\r
+                       return MafftWS;\r
+               }\r
+               if (servName.equalsIgnoreCase(ClustalWS.toString())) {\r
+                       return ClustalWS;\r
+               }\r
+               if (servName.equalsIgnoreCase(TcoffeeWS.toString())) {\r
+                       return TcoffeeWS;\r
+               }\r
+               if (servName.equalsIgnoreCase(MuscleWS.toString())) {\r
+                       return MuscleWS;\r
+               }\r
+               if (servName.equalsIgnoreCase(ProbconsWS.toString())) {\r
+                       return ProbconsWS;\r
+               }\r
+               if (servName.equalsIgnoreCase(AAConWS.toString())) {\r
+                       return AAConWS;\r
+               }\r
+               if (servName.equalsIgnoreCase(JronnWS.toString())) {\r
+                       return JronnWS;\r
+               }\r
+               if (servName.equalsIgnoreCase(DisemblWS.toString())) {\r
+                       return DisemblWS;\r
+               }\r
+               if (servName.equalsIgnoreCase(GlobPlotWS.toString())) {\r
+                       return GlobPlotWS;\r
+               }\r
+               return null;\r
        }\r
-       if (servName.equalsIgnoreCase(ClustalWS.toString())) {\r
-           return ClustalWS;\r
-       }\r
-       if (servName.equalsIgnoreCase(TcoffeeWS.toString())) {\r
-           return TcoffeeWS;\r
-       }\r
-       if (servName.equalsIgnoreCase(MuscleWS.toString())) {\r
-           return MuscleWS;\r
+\r
+       Service getService(URL url, String sqname) {\r
+               QName qname = new QName(sqname, this.toString());\r
+               return Service.create(url, qname);\r
        }\r
-       if (servName.equalsIgnoreCase(ProbconsWS.toString())) {\r
-           return ProbconsWS;\r
+\r
+       Class<? extends JABAService> getServiceType() {\r
+               switch (this) {\r
+                       // deliberate leaking\r
+                       case AAConWS :\r
+                       case JronnWS :\r
+                       case DisemblWS :\r
+                       case GlobPlotWS :\r
+\r
+                               return SequenceAnnotation.class;\r
+\r
+                               // deliberate leaking\r
+                       case ClustalWS :\r
+                       case MafftWS :\r
+                       case MuscleWS :\r
+                       case ProbconsWS :\r
+                       case TcoffeeWS :\r
+\r
+                               return MsaWS.class;\r
+                       default :\r
+                               throw new RuntimeException("Unrecognised Web Service Type "\r
+                                               + this + " - Should never happened!");\r
+               }\r
        }\r
-       return null;\r
-    }\r
 \r
-    public static Services getService(Class wsImplClass) {\r
-       return getService(wsImplClass.getSimpleName());\r
-    }\r
+       JABAService getInterface(Service service) {\r
+               assert service != null;\r
 \r
+               QName portName = new QName(service.getServiceName().getNamespaceURI(),\r
+                               this.toString() + "Port");\r
+               return service.getPort(portName, this.getServiceType());\r
+       }\r
 }
\ No newline at end of file