JAL-3807 JPred can now successfully submit and track the job.
[jalview.git] / src / jalview / ws / api / ServiceWithParameters.java
index cf82708..d875fd7 100644 (file)
@@ -1,10 +1,20 @@
 package jalview.ws.api;
 
+import jalview.bin.Cache;
+import jalview.gui.AlignFrame;
+import jalview.ws.JPredClient;
+import jalview.ws.jws2.MsaWSClient;
+import jalview.ws.jws2.SequenceAnnotationWSClient;
 import jalview.ws.params.ParamManager;
 
+import javax.swing.JMenu;
+
 public abstract class ServiceWithParameters extends UIinfo
+    implements JalviewServiceEndpointProviderI
 {
 
+  protected jalview.ws.uimodel.AlignAnalysisUIText aaui;
+
   public ServiceWithParameters(String serviceType, String action,
           String name, String description, String hosturl)
   {
@@ -13,4 +23,94 @@ public abstract class ServiceWithParameters extends UIinfo
 
   public abstract void initParamStore(ParamManager userParameterStore);
 
+  public jalview.ws.uimodel.AlignAnalysisUIText getAlignAnalysisUI()
+  {
+    return aaui;
+  }
+
+  public void setAlignAnalysisUI(
+          jalview.ws.uimodel.AlignAnalysisUIText aaui)
+  {
+    this.aaui = aaui;
+  }
+
+  public boolean isInteractiveUpdate()
+  {
+    return aaui != null && aaui.isAA();
+  }
+  // config flags for SeqAnnotationServiceCalcWorker
+
+  public boolean isProteinService()
+  {
+    return aaui == null ? true : aaui.isPr();
+  }
+
+  public boolean isNucleotideService()
+  {
+    return aaui == null ? false : aaui.isNa();
+  }
+
+  public boolean isNeedsAlignedSequences()
+  {
+    return aaui == null ? false : aaui.isNeedsAlignedSeqs();
+  }
+
+  public boolean isAlignmentAnalysis()
+  {
+    return aaui == null ? false : aaui.isAA();
+  }
+
+  public boolean isFilterSymbols()
+  {
+    return aaui != null ? aaui.isFilterSymbols() : true;
+  }
+
+  public int getMinimumInputSequences()
+  {
+    return aaui != null ? aaui.getMinimumSequences() : 1;
+  }
+
+  public String getNameURI()
+  {
+    return "java:" + getName();
+  }
+
+  public String getUri()
+  {
+    // TODO verify that service parameter sets in projects are consistent with
+    // Jalview 2.10.4
+    // this is only valid for Jaba 1.0 - this formula might have to change!
+    return getHostURL()
+            + (getHostURL().lastIndexOf("/") == (getHostURL().length() - 1)
+                    ? ""
+                    : "/")
+            + getName();
+  }
+
+  protected enum ServiceClient
+  {
+    MSAWSCLIENT, SEQUENCEANNOTATIONWSCLIENT, JPREDWSCLIENT;
+  };
+
+  protected ServiceClient style = null;
+
+  public void attachWSMenuEntry(JMenu atpoint, AlignFrame alignFrame)
+  {
+    switch (style)
+    {
+    case MSAWSCLIENT:
+        new MsaWSClient().attachWSMenuEntry(atpoint, this, alignFrame);
+      break;
+    case JPREDWSCLIENT:
+        JPredClient.getMenuEntryProvider(this).attachWSMenuEntry(atpoint, alignFrame);
+        break;
+    case SEQUENCEANNOTATIONWSCLIENT:
+        new SequenceAnnotationWSClient().attachWSMenuEntry(atpoint, this,
+                alignFrame);
+      break;
+    default:
+      Cache.log.warn("Implementation error ? Service " + getName()
+              + " has Unknown service style " + style);
+    }
+  }
 }