JAL-3878 Separate gui elements from operations.
[jalview.git] / src / jalview / ws2 / slivka / SlivkaWSDiscoverer.java
index c0c7502..8534f06 100644 (file)
@@ -22,7 +22,7 @@ public class SlivkaWSDiscoverer implements WebServiceDiscoverer
 
   private static SlivkaWSDiscoverer instance = null;
 
-  private List<WebServiceI> services = List.of();
+  private List<Operation> operations = List.of();
 
   private SlivkaWSDiscoverer()
   {
@@ -96,14 +96,16 @@ public class SlivkaWSDiscoverer implements WebServiceDiscoverer
     }
   }
 
-  public List<WebServiceI> getServices()
+  @Override
+  public List<Operation> getOperations()
   {
-    return Collections.unmodifiableList(services);
+    return Collections.unmodifiableList(operations);
   }
 
+  @Override
   public boolean hasServices()
   {
-    return !isRunning() && services.size() > 0;
+    return !isRunning() && operations.size() > 0;
   }
 
   public boolean isRunning()
@@ -133,16 +135,16 @@ public class SlivkaWSDiscoverer implements WebServiceDiscoverer
               reloadServices();
               return SlivkaWSDiscoverer.this;
             });
-    task.thenRun(() -> fireServicesChanged(getServices()));
+    task.thenRun(() -> fireOperationsChanged(getOperations()));
     discoveryTasks.add(task);
     return task;
   }
 
-  private List<WebServiceI> reloadServices()
+  private List<Operation> reloadServices()
   {
     Cache.log.info("Reloading Slivka services");
-    fireServicesChanged(Collections.emptyList());
-    ArrayList<WebServiceI> allServices = new ArrayList<>();
+    fireOperationsChanged(Collections.emptyList());
+    ArrayList<Operation> allOperations= new ArrayList<>();
     for (String url : getUrls())
     {
       SlivkaClient client = new SlivkaClient(url);
@@ -158,19 +160,20 @@ public class SlivkaWSDiscoverer implements WebServiceDiscoverer
       for (SlivkaService service : services)
       {
         SlivkaWebService instance = new SlivkaWebService(client, service);
+        Operation op = null;
         for (String classifier : service.classifiers)
         {
           String[] path = classifier.split("\\s*::\\s*");
           if (path.length >= 3 && path[0].toLowerCase().equals("operation")
                   && path[1].toLowerCase().equals("analysis"))
           {
-            Operation op = null;
             switch (path[path.length - 1].toLowerCase())
             {
             case "sequence alignment analysis (conservation)":
               AnnotationOperation anop;
               op = anop = new AnnotationOperation(instance,
-                  instance::getAnnotations, instance::getFeaturesFile, "Conservation");
+                  instance::getAnnotations, instance::getFeaturesFile,
+                  "Conservation");
               anop.setAlignmentAnalysis(true);
               anop.setInteractive(true);
               break;
@@ -184,20 +187,18 @@ public class SlivkaWSDiscoverer implements WebServiceDiscoverer
             }
             if (op != null)
             {
-              instance.addOperation(op);
               break;
             }
           }
         }
-        if (instance.operations.size() > 0)
-        {
-          allServices.add(instance);
+        if (op != null) {
+          allOperations.add(op);
         }
       }
     }
-    this.services = allServices;
+    this.operations = allOperations;
     Cache.log.info("Reloading slivka services finished");
-    return allServices;
+    return allOperations;
   }
 
   @Override