JAL-3070 rough-and-ready refactor of JABA SequenceAnnotation style services - needs...
[jalview.git] / src / jalview / ws / jws2 / jabaws2 / Jws2Instance.java
index 143bc1c..29f1ed1 100644 (file)
@@ -32,6 +32,7 @@ import jalview.ws.params.ParamDatastoreI;
 import jalview.ws.params.ParamManager;
 
 import java.io.Closeable;
+import java.net.URL;
 
 import javax.swing.JMenu;
 
@@ -47,8 +48,6 @@ public class Jws2Instance extends ServiceWithParameters
 
   public JABAService service;
 
-  public String docUrl;
-
   /**
    * 
    * @param hosturl
@@ -71,11 +70,26 @@ public class Jws2Instance extends ServiceWithParameters
     int p = description.indexOf("MORE INFORMATION:");
     if (p > -1)
     {
-      docUrl = description.substring(description.indexOf("http", p)).trim();
+      String docUrl = description.substring(description.indexOf("http", p))
+              .trim();
       if (docUrl.indexOf('\n') > -1)
       {
         docUrl = docUrl.substring(0, docUrl.indexOf("\n")).trim();
       }
+      if (docUrl.length() > 0)
+      {
+        try
+        {
+          URL url = new URL(docUrl);
+          if (url != null)
+          {
+            setDocumentationUrl(docUrl);
+          }
+        } catch (Exception x)
+        {
+
+        }
+      }
 
     }
   }
@@ -251,18 +265,44 @@ public class Jws2Instance extends ServiceWithParameters
   @Override
   public Object getEndpoint()
   {
-    if (aaui!=null) {
-      // TODO complete
-      return null;
-    } else {
-      if (service instanceof MsaWS<?>)
+    if (service instanceof MsaWS<?>)
+    {
+      if (aaui != null)
+      {
+        throw new Error(
+                "JABAWS MsaWS based instant calculation not implemented.");
+
+      }
+      else
       {
-      return new JabawsMsaInstance(this);
-    } else {
-        // TODO complete
-        // service is for sequence analysis
-        return null;
+        return new JabawsMsaInstance(this);
+      }
+    }
+    else
+    {
+      if (service instanceof compbio.data.msa.SequenceAnnotation)
+      {
+        if (aaui != null)
+        {
+          try
+          {
+            // probably a factory would be nicer but..
+            return aaui.getClient().getConstructor(getClass())
+                    .newInstance(this);
+          } catch (Throwable t)
+          {
+            throw new Error("Implementation Error in web service framework",
+                    t);
+          }
+        }
+        return new AADisorderClient(this);
+      }
+      return null;
     }
   }
-}
+
+  public boolean isInteractiveUpdate()
+  {
+    return aaui != null && aaui.isAA();
+  }
 }