X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2FWSClient.java;h=33aea909e67225d72871fece3875091ba7913984;hb=b3eead416d4a16141910b7dae1eda4eaf2272b6a;hp=4ca0b76f77b8de32e03adae2788e1d9942ffa9c3;hpb=17e77c3f2949a0729322b4a8d907f3f34b6a9914;p=jalview.git diff --git a/src/jalview/ws/WSClient.java b/src/jalview/ws/WSClient.java index 4ca0b76..33aea90 100755 --- a/src/jalview/ws/WSClient.java +++ b/src/jalview/ws/WSClient.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9) - * Copyright (C) 2015 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -20,7 +20,18 @@ */ package jalview.ws; +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; public abstract class WSClient // implements WSMenuEntryProviderI { @@ -56,6 +67,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; @@ -65,13 +81,119 @@ public abstract class WSClient // implements WSMenuEntryProviderI * mappings between abstract interface names and menu entries */ protected java.util.Hashtable ServiceActions; + + /** + * alignFrame associated with this client + */ + protected AlignFrame alignFrame; { ServiceActions = new java.util.Hashtable(); ServiceActions.put("MsaWS", "Multiple Sequence Alignment"); 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(); + WebServiceJobTitle = serv.getActionText(); + WsURL = serv.getHostURL(); + if (!b) + { + return new WebserviceInfo(WebServiceJobTitle, + 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 boolean processParams(ServiceWithParameters sh, + boolean editParams) + { + return processParams(sh, editParams, false); + } + + protected boolean 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")); + } + if (!jobParams.showRunDialog()) + { + return false; // dialog cancelled + } + + 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 true; + } + }