JAL-3878 Create skeleton for alignment service action
authorMateusz Warowny <mmzwarowny@dundee.ac.uk>
Fri, 18 Feb 2022 16:29:13 +0000 (17:29 +0100)
committerMateusz Warowny <mmzwarowny@dundee.ac.uk>
Fri, 18 Feb 2022 16:29:13 +0000 (17:29 +0100)
src/jalview/ws2/actions/alignment/AlignmentAction.java [new file with mode: 0644]
src/jalview/ws2/actions/alignment/AlignmentProviderI.java [new file with mode: 0644]
src/jalview/ws2/actions/alignment/AlignmentResult.java [new file with mode: 0644]
src/jalview/ws2/client/api/AlignmentWebServiceClientI.java [new file with mode: 0644]

diff --git a/src/jalview/ws2/actions/alignment/AlignmentAction.java b/src/jalview/ws2/actions/alignment/AlignmentAction.java
new file mode 100644 (file)
index 0000000..8c0cd93
--- /dev/null
@@ -0,0 +1,88 @@
+package jalview.ws2.actions.alignment;
+
+import java.util.List;
+import java.util.Objects;
+
+import jalview.viewmodel.AlignmentViewport;
+import jalview.ws.params.ArgumentI;
+import jalview.ws2.actions.BaseAction;
+import jalview.ws2.actions.api.TaskEventListener;
+import jalview.ws2.actions.api.TaskI;
+import jalview.ws2.api.Credentials;
+import jalview.ws2.client.api.AlignmentWebServiceClientI;
+
+/**
+ * Implementation of the {@link BaseAction} that runs alignment services. This
+ * type of action requires {@link AlignmentWebServiceClientI} to retrieve
+ * alignment result from the server.
+ * 
+ * @author mmwarowny
+ *
+ */
+public class AlignmentAction extends BaseAction<AlignmentResult>
+{
+  /**
+   * A builder for AlignemntActions. Adds {@code client} and {@code submitGaps}
+   * parameters to the base builder.
+   * 
+   * @author mmwarowny
+   */
+  public static class Builder extends BaseAction.Builder
+  {
+    protected AlignmentWebServiceClientI client;
+
+    protected boolean submitGaps = false;
+
+    public Builder(AlignmentWebServiceClientI client, String name)
+    {
+      super(name);
+      Objects.requireNonNull(client);
+      this.client = client;
+    }
+
+    public void submitGaps(boolean val)
+    {
+      submitGaps = val;
+    }
+
+    public AlignmentAction build()
+    {
+      return new AlignmentAction(this);
+    }
+  }
+
+  public static Builder newBuilder(AlignmentWebServiceClientI client, String name)
+  {
+    return new Builder(client, name);
+  }
+
+  protected final boolean submitGaps;
+
+  protected final AlignmentWebServiceClientI client;
+
+  public AlignmentAction(Builder builder)
+  {
+    super(builder);
+    submitGaps = builder.submitGaps;
+    client = builder.client;
+  }
+
+  @Override
+  public TaskI<AlignmentResult> perform(AlignmentViewport viewport,
+      List<ArgumentI> args, Credentials credentials,
+      TaskEventListener<AlignmentResult> handler)
+  {
+    
+  }
+
+  /**
+   * Returns if the action is active for the given viewport.
+   * Alignment services are non-interactive, so the action is never active.
+   */
+  @Override
+  public boolean isActive(AlignmentViewport viewport)
+  {
+    return false;
+  }
+
+}
diff --git a/src/jalview/ws2/actions/alignment/AlignmentProviderI.java b/src/jalview/ws2/actions/alignment/AlignmentProviderI.java
new file mode 100644 (file)
index 0000000..caba526
--- /dev/null
@@ -0,0 +1,32 @@
+package jalview.ws2.actions.alignment;
+
+import java.io.IOException;
+
+import jalview.datamodel.AlignmentI;
+
+import jalview.ws2.api.WebServiceJob;
+import jalview.ws2.client.api.AlignmentWebServiceClientI;
+import jalview.ws2.client.api.WebServiceClientI;
+
+/**
+ * An interface for providing alignment results to the alignment services. Web
+ * service clients that want to support alignment actions must implement this
+ * interface in addition to {@link WebServiceClientI}.
+ * 
+ * @author mmwarowny
+ *
+ * @see AlignmentWebServiceClientI
+ */
+public interface AlignmentProviderI
+{
+  /**
+   * Get the alignment result for the job from the server.
+   * 
+   * @param job
+   *          web service job
+   * @return alignment result
+   * @throws IOException
+   *           server communication error
+   */
+  public AlignmentI getAlignemnt(WebServiceJob job) throws IOException;
+}
diff --git a/src/jalview/ws2/actions/alignment/AlignmentResult.java b/src/jalview/ws2/actions/alignment/AlignmentResult.java
new file mode 100644 (file)
index 0000000..d3ed8fc
--- /dev/null
@@ -0,0 +1,6 @@
+package jalview.ws2.actions.alignment;
+
+public class AlignmentResult
+{
+
+}
diff --git a/src/jalview/ws2/client/api/AlignmentWebServiceClientI.java b/src/jalview/ws2/client/api/AlignmentWebServiceClientI.java
new file mode 100644 (file)
index 0000000..b0cb06c
--- /dev/null
@@ -0,0 +1,15 @@
+package jalview.ws2.client.api;
+
+import jalview.ws2.actions.alignment.AlignmentProviderI;
+
+/**
+ * A client interface for alignment services combining {@link WebServiceClientI}
+ * and {@link AlignmentProviderI} functionality into one interface.
+ * Alignment services use this interface to issue queries to the server.  
+ *  
+ * @author mmwarowny
+ */
+public interface AlignmentWebServiceClientI extends WebServiceClientI, AlignmentProviderI
+{
+
+}