JAL-3066 hack to instantiate the correct client according to slivka service annotatio...
authorJim Procter <jprocter@issues.jalview.org>
Mon, 7 Oct 2019 08:06:16 +0000 (09:06 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Mon, 7 Oct 2019 08:06:16 +0000 (09:06 +0100)
src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java

index 7720b11..f8ac60f 100644 (file)
@@ -44,30 +44,48 @@ public class SlivkaWSDiscoverer implements Runnable, WSMenuEntryProviderI
     return instance;
   }
 
+  /**
+   * TODO: tests needed for logic for determining type of each discovered
+   * service. Then reimplement this routine !
+   * 
+   * @return (MSA instances, one AAUI type instance, and the remaining all
+   *         sequence analysis instances taking 1 sequence only)
+   */
   List<ServiceWithParameters> getServiceInstances()
   {
     List<ServiceWithParameters> instances = new ArrayList<>();
     for (SlivkaService service : services)
     {
+      ServiceWithParameters newinstance = null;
       for (String classifier : service.classifiers)
       {
         if (classifier.contains("Multiple sequence alignment"))
         {
-          instances
-                  .add(new SlivkaMsaServiceInstance(slivkaClient, service));
+          // MSA services always overwrite
+          newinstance = new SlivkaMsaServiceInstance(slivkaClient, service);
         }
-        else if (classifier.contains("Protein sequence analysis"))
+        if (classifier.contains("Protein sequence analysis"))
         {
-          instances.add(new SlivkaAnnotationServiceInstance(slivkaClient,
-                  service, false));
-        }
-        else if (classifier
+          if (newinstance == null)
+            {
+              newinstance = (new SlivkaAnnotationServiceInstance(
+                      slivkaClient,
+
+                      service, false));
+            }
+          }
+
+        if (classifier
                 .contains("Sequence alignment analysis (conservation)"))
         {
-          instances.add(new SlivkaAnnotationServiceInstance(slivkaClient,
-                  service, true));
+          // always overwrite other instances
+          newinstance = new SlivkaAnnotationServiceInstance(slivkaClient,
+                  service, true);
         }
-
+      }
+      if (newinstance != null)
+      {
+        instances.add(newinstance);
       }
     }
     return instances;