X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2FWSClient.java;h=a68f3f387cca8fcb13cde170ed1e43646d22c4a7;hb=eb349b848556f0d8537755d5d869366479364d45;hp=68bd4b07ba85a615a195d6a0d5d90f810c0d2c17;hpb=9a68d6293a1d0ded59716fa34826fb4af793c330;p=jalview.git diff --git a/src/jalview/ws/WSClient.java b/src/jalview/ws/WSClient.java index 68bd4b0..a68f3f3 100755 --- a/src/jalview/ws/WSClient.java +++ b/src/jalview/ws/WSClient.java @@ -20,9 +20,21 @@ */ package jalview.ws; +import jalview.bin.Cache; import jalview.gui.AlignFrame; +import jalview.gui.Desktop; import jalview.gui.WebserviceInfo; +import jalview.gui.WsJobParameters; +import jalview.util.MessageManager; +import jalview.ws.api.ServiceWithParameters; import jalview.ws.api.UIinfo; +import jalview.ws.params.ArgumentI; +import jalview.ws.params.ParamDatastoreI; +import jalview.ws.params.WsParamSetI; + +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; public abstract class WSClient // implements WSMenuEntryProviderI { @@ -58,6 +70,11 @@ public abstract class WSClient // implements WSMenuEntryProviderI protected WebserviceInfo wsInfo; /** + * the root object for the service client + */ + protected UIinfo serviceHandle; + + /** * total number of jobs managed by this web service client instance. */ int jobsRunning = 0; @@ -78,10 +95,37 @@ public abstract class WSClient // implements WSMenuEntryProviderI ServiceActions.put("SecStrPred", "Secondary Structure Prediction"); }; + /** + * The preset for the job executed by this client (may be null) + */ + protected WsParamSetI preset; + + /** + * The parameters for the job executed by this client (may be null) + */ + protected List paramset; + public WSClient() { } + /** + * base constructor for a web service with parameters. Extending classes + * should implement this constructor with additional logic to verify that + * preset and arguments are compatible with the service being configured. + * + * @param _alignFrame + * @param preset + * @param arguments + */ + public WSClient(AlignFrame _alignFrame, WsParamSetI preset, + List arguments) + { + alignFrame = _alignFrame; + this.preset = preset; + this.paramset = arguments; + } + protected WebserviceInfo setWebService(UIinfo serv, boolean b) { WebServiceName = serv.getName(); @@ -90,13 +134,71 @@ public abstract class WSClient // implements WSMenuEntryProviderI if (!b) { return new WebserviceInfo(WebServiceJobTitle, - WebServiceJobTitle + " using service hosted at " - + WsURL + "\n" - + (serv.getDescription() != null - ? serv.getDescription() - : ""), - false); + WebServiceJobTitle + " using service hosted at " + + WsURL + "\n" + + (serv.getDescription() != null + ? serv.getDescription() + : ""), + false); } return null; } + + /** + * called to open a parameter editing dialog for parameterised services + * + * @param sh + * @param editParams + * @return + */ + protected CompletionStage processParams(ServiceWithParameters sh, + boolean editParams) + { + return processParams(sh, editParams, false); + } + + protected CompletionStage processParams(ServiceWithParameters sh, + boolean editParams, boolean adjustingExisting) + { + + if (editParams) + { + // always do this + sh.initParamStore(Desktop.getUserParameterStore()); + + WsJobParameters jobParams = (preset == null && paramset != null + && paramset.size() > 0) + ? new WsJobParameters((ParamDatastoreI) null, sh, + (WsParamSetI) null, paramset) + : new WsJobParameters((ParamDatastoreI) null, sh, + preset, (List) null); + if (adjustingExisting) + { + jobParams.setName(MessageManager + .getString("label.adjusting_parameters_for_calculation")); + } + var stage = jobParams.showRunDialog(); + return stage.thenApply((startJob) -> { + if (startJob) + { + WsParamSetI prset = jobParams.getPreset(); + if (prset == null) + { + paramset = jobParams.isServiceDefaults() ? null + : jobParams.getJobParams(); + this.preset = null; + } + else + { + this.preset = prset; // ((JabaPreset) prset).p; + paramset = null; // no user supplied parameters. + } + } + return startJob; + }); + + } + return CompletableFuture.completedFuture(true); + } + }