An attempt to automatically make binaries executables - not successful but the code...
[jabaws.git] / webservices / compbio / ws / client / Services.java
index f18eadf..893117f 100644 (file)
@@ -1,6 +1,6 @@
-/* Copyright (c) 2009 Peter Troshin\r
+/* Copyright (c) 2011 Peter Troshin\r
  *  \r
- *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0     \r
+ *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0     \r
  * \r
  *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
  *  Apache License version 2 as published by the Apache Software Foundation\r
@@ -19,6 +19,7 @@
 package compbio.ws.client;\r
 \r
 import java.net.URL;\r
+import java.util.Set;\r
 \r
 import javax.xml.namespace.QName;\r
 import javax.xml.ws.Service;\r
@@ -32,27 +33,18 @@ import compbio.data.msa.SequenceAnnotation;
  * \r
  */\r
 public enum Services {\r
-       MafftWS, MuscleWS, ClustalWS, TcoffeeWS, ProbconsWS, AAConWS;\r
+       /*\r
+        * Make sure this class has NO references to runners or engines as it is a\r
+        * part of minimal client package. Such things should go into ServicesUtil\r
+        */\r
+       MafftWS, MuscleWS, ClustalWS, ClustalOWS, TcoffeeWS, ProbconsWS, AAConWS, JronnWS, DisemblWS, GlobPlotWS, IUPredWS;\r
 \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
+               for (Services service : Services.values()) {\r
+                       if (service.toString().equalsIgnoreCase(servName)) {\r
+                               return service;\r
+                       }\r
                }\r
                return null;\r
        }\r
@@ -62,29 +54,49 @@ public enum Services {
                return Service.create(url, qname);\r
        }\r
 \r
-       JABAService getInterface(Service service) {\r
-               assert service != null;\r
-\r
-               QName portName = new QName(service.getServiceName().getNamespaceURI(),\r
-                               this.toString() + "Port");\r
+       public static String toString(Set<Services> services) {\r
+               if (services == null || services.isEmpty()) {\r
+                       return "";\r
+               }\r
+               String value = "";\r
+               String delim = ", ";\r
+               for (Services serv : services) {\r
+                       value += serv.toString() + delim;\r
+               }\r
+               value = value.substring(0, value.length() - delim.length());\r
+               return value;\r
+       }\r
 \r
+       Class<? extends JABAService> getServiceType() {\r
                switch (this) {\r
+                       // deliberate leaking\r
                        case AAConWS :\r
-                               return service.getPort(portName, SequenceAnnotation.class);\r
+                       case JronnWS :\r
+                       case DisemblWS :\r
+                       case GlobPlotWS :\r
+                       case IUPredWS :\r
+                               return SequenceAnnotation.class;\r
 \r
                                // deliberate leaking\r
                        case ClustalWS :\r
+                       case ClustalOWS :\r
                        case MafftWS :\r
                        case MuscleWS :\r
                        case ProbconsWS :\r
                        case TcoffeeWS :\r
-                               // TODO remove\r
-                               System.out.println("Qname from serv: " + portName);\r
-\r
-                               return service.getPort(portName, MsaWS.class);\r
 \r
+                               return MsaWS.class;\r
                        default :\r
-                               throw new RuntimeException("Should never happened!");\r
+                               throw new RuntimeException("Unrecognised Web Service Type "\r
+                                               + this + " - Should never happened!");\r
                }\r
        }\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