From 7b9f93ca2c7f5e5d9347f00be309522f76e3e778 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Fri, 18 Feb 2022 17:29:13 +0100 Subject: [PATCH] JAL-3878 Create skeleton for alignment service action --- .../ws2/actions/alignment/AlignmentAction.java | 88 ++++++++++++++++++++ .../ws2/actions/alignment/AlignmentProviderI.java | 32 +++++++ .../ws2/actions/alignment/AlignmentResult.java | 6 ++ .../ws2/client/api/AlignmentWebServiceClientI.java | 15 ++++ 4 files changed, 141 insertions(+) create mode 100644 src/jalview/ws2/actions/alignment/AlignmentAction.java create mode 100644 src/jalview/ws2/actions/alignment/AlignmentProviderI.java create mode 100644 src/jalview/ws2/actions/alignment/AlignmentResult.java create mode 100644 src/jalview/ws2/client/api/AlignmentWebServiceClientI.java diff --git a/src/jalview/ws2/actions/alignment/AlignmentAction.java b/src/jalview/ws2/actions/alignment/AlignmentAction.java new file mode 100644 index 0000000..8c0cd93 --- /dev/null +++ b/src/jalview/ws2/actions/alignment/AlignmentAction.java @@ -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 +{ + /** + * 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 perform(AlignmentViewport viewport, + List args, Credentials credentials, + TaskEventListener 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 index 0000000..caba526 --- /dev/null +++ b/src/jalview/ws2/actions/alignment/AlignmentProviderI.java @@ -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 index 0000000..d3ed8fc --- /dev/null +++ b/src/jalview/ws2/actions/alignment/AlignmentResult.java @@ -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 index 0000000..b0cb06c --- /dev/null +++ b/src/jalview/ws2/client/api/AlignmentWebServiceClientI.java @@ -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 +{ + +} -- 1.7.10.2