JAL-3690 Fixed slivka wsmenu categories.
authorMateusz <mmzwarowny@dundee.ac.uk>
Fri, 15 Jan 2021 18:21:47 +0000 (19:21 +0100)
committerMateusz <mmzwarowny@dundee.ac.uk>
Fri, 22 Jan 2021 14:11:53 +0000 (15:11 +0100)
src/jalview/ws/slivkaws/SlivkaAnnotationServiceInstance.java
src/jalview/ws/slivkaws/SlivkaMsaServiceInstance.java
src/jalview/ws/slivkaws/SlivkaWSDiscoverer.java
src/jalview/ws/slivkaws/SlivkaWSInstance.java

index cc5c1e4..f11eb1c 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
+import compbio.data.msa.Category;
 import uk.ac.dundee.compbio.slivkaclient.RemoteFile;
 import uk.ac.dundee.compbio.slivkaclient.SlivkaClient;
 import uk.ac.dundee.compbio.slivkaclient.SlivkaService;
@@ -29,13 +30,12 @@ import uk.ac.dundee.compbio.slivkaclient.SlivkaService;
 public class SlivkaAnnotationServiceInstance extends SlivkaWSInstance implements SequenceAnnotationServiceI
 {
   public SlivkaAnnotationServiceInstance(SlivkaClient client,
-          SlivkaService service, boolean conservation)
+          SlivkaService service, String category)
   {
-    super(client, service, !conservation ? "Protein sequence analysis"
-        : "Alignment Conservation");
-    if (conservation)
+    super(client, service, category);
+    if (category == Category.CATEGORY_CONSERVATION)
     {
-      setAlignAnalysisUI(new AlignAnalysisUIText(getName(),
+      setAlignAnalysisUI(new AlignAnalysisUIText(category,
               SlivkaAnnotationServiceInstance.class,
               "Slivka.AACons", false, true, true, true, true, 2,
               MessageManager.getString("label.aacon_calculations"),
index a65e93e..9a33b04 100644 (file)
@@ -16,14 +16,15 @@ import java.io.IOException;
 import java.rmi.ServerError;
 import java.util.List;
 
+import compbio.data.msa.Category;
 import uk.ac.dundee.compbio.slivkaclient.RemoteFile;
 import uk.ac.dundee.compbio.slivkaclient.SlivkaClient;
 import uk.ac.dundee.compbio.slivkaclient.SlivkaService;
 
 public class SlivkaMsaServiceInstance extends SlivkaWSInstance implements MultipleSequenceAlignmentI
 {
-  SlivkaMsaServiceInstance(SlivkaClient client, SlivkaService service) {
-    super(client, service, "Sequence Alignment");
+  SlivkaMsaServiceInstance(SlivkaClient client, SlivkaService service, String category) {
+    super(client, service, category);
     style = ServiceClient.MSAWSCLIENT;
   }
 
index cd296c6..e849f97 100644 (file)
@@ -17,6 +17,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
+
+import compbio.data.msa.Category;
 import uk.ac.dundee.compbio.slivkaclient.SlivkaClient;
 import uk.ac.dundee.compbio.slivkaclient.SlivkaService;
 
@@ -65,7 +67,9 @@ public class SlivkaWSDiscoverer implements WSDiscovererI
     }
   }
 
-  private final ExecutorService executor = Executors.newSingleThreadExecutor();
+  private final ExecutorService executor = Executors
+          .newSingleThreadExecutor();
+
   private Vector<Future<?>> discoveryTasks = new Vector<>();
 
   public CompletableFuture<WSDiscovererI> startDiscoverer()
@@ -87,48 +91,57 @@ public class SlivkaWSDiscoverer implements WSDiscovererI
 
     for (String url : getServiceUrls())
     {
-      Cache.log.info(url);
-      SlivkaClient client;
-      client = new SlivkaClient(url);
+      SlivkaClient client = new SlivkaClient(url);
+
+      List<SlivkaService> services;
       try
       {
-        for (SlivkaService service : client.getServices())
+        services = client.getServices();
+      } catch (IOException e)
+      {
+        e.printStackTrace();
+        continue;
+      }
+      for (SlivkaService service : services)
+      {
+        SlivkaWSInstance newInstance = null;
+        for (String classifier : service.classifiers)
         {
-          SlivkaWSInstance newinstance = 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"))
           {
-            if (classifier.contains("Multiple sequence alignment"))
-            {
-              newinstance = new SlivkaMsaServiceInstance(client, service);
-            }
-            if (classifier.contains("Protein sequence analysis")
-                && newinstance == null)
+            switch (path[path.length - 1].toLowerCase())
             {
-              newinstance = new SlivkaAnnotationServiceInstance(client,
-                  service, false);
-            }
-            if (classifier
-                .contains("Sequence alignment analysis (conservation)"))
-            {
-              newinstance = new SlivkaAnnotationServiceInstance(client,
-                  service, true);
+            case "sequence alignment analysis (conservation)":
+              newInstance = new SlivkaAnnotationServiceInstance(client,
+                      service, Category.CATEGORY_CONSERVATION);
+              break;
+            case "protein sequence analysis":
+              newInstance = new SlivkaAnnotationServiceInstance(client,
+                      service, Category.CATEGORY_DISORDER);
+              break;
+            case "protein secondary structure prediction":
+              newInstance = new SlivkaAnnotationServiceInstance(client,
+                      service, "Secondary Structure Prediction");
+              break;
+            case "multiple sequence alignment":
+              newInstance = new SlivkaMsaServiceInstance(client, service,
+                      Category.CATEGORY_ALIGNMENT);
+              break;
             }
           }
-          if (newinstance != null)
-          {
-            instances.add(newinstance);
-          }
+          if (newInstance != null)
+            break;
         }
-      } catch (IOException e)
-      {
-        e.printStackTrace();
-        continue;
+        if (newInstance != null)
+          instances.add(newInstance);
       }
     }
 
     services = instances;
-    notifyServiceListeners(instances);
     Cache.log.info("Slivka services reloading finished");
+    notifyServiceListeners(instances);
     return instances;
   }
 
@@ -178,11 +191,11 @@ public class SlivkaWSDiscoverer implements WSDiscovererI
       } catch (MalformedURLException e)
       {
         Cache.log.warn("Problem whilst trying to make a URL from '"
-            + ((url != null) ? url : "<null>") + "'");
+                + ((url != null) ? url : "<null>") + "'");
         Cache.log.warn(
-            "This was probably due to a malformed comma separated list"
-                + " in the " + SLIVKA_HOST_URLS
-                + " entry of $(HOME)/.jalview_properties)");
+                "This was probably due to a malformed comma separated list"
+                        + " in the " + SLIVKA_HOST_URLS
+                        + " entry of $(HOME)/.jalview_properties)");
         Cache.log.debug("Exception was ", e);
       }
     }
index 978d775..54039ce 100644 (file)
@@ -64,7 +64,7 @@ public abstract class SlivkaWSInstance extends ServiceWithParameters
 
   public SlivkaWSInstance(SlivkaClient client, SlivkaService service, String action)
   {
-    super(service.getName(), action, service.getLabel(), "Slivka", client.getUrl().toString());
+    super(action, action, service.getLabel(), "Slivka", client.getUrl().toString());
     this.client = client;
     this.service = service;
   }