From: jprocter Date: Thu, 3 Nov 2011 18:13:26 +0000 (+0000) Subject: (JAL-976) refactored common code for JABAWS v2 service clients X-Git-Tag: Jalview_2_9~564^2~3 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c9df7697dacf668e97290c57d4d117ac8cc40bc8;p=jalview.git (JAL-976) refactored common code for JABAWS v2 service clients --- diff --git a/src/jalview/ws/jws2/Jws2Client.java b/src/jalview/ws/jws2/Jws2Client.java index 184e514..e6b4cf5 100644 --- a/src/jalview/ws/jws2/Jws2Client.java +++ b/src/jalview/ws/jws2/Jws2Client.java @@ -17,31 +17,120 @@ */ package jalview.ws.jws2; +import java.util.List; + import javax.swing.JMenu; +import compbio.metadata.Argument; + import jalview.gui.AlignFrame; +import jalview.gui.Desktop; import jalview.gui.WebserviceInfo; -import jalview.ws.jws2.Jws2Discoverer.Jws2Instance; +import jalview.gui.WsJobParameters; +import jalview.ws.jws2.dm.JabaWsParamSet; +import jalview.ws.jws2.jabaws2.Jws2Instance; +import jalview.ws.params.WsParamSetI; /** - * provides metadata for a jws2 service instance - resolves names, etc. + * provides metadata for a jabaws2 service instance - resolves names, etc. * * @author JimP * */ public abstract class Jws2Client extends jalview.ws.WSClient { + protected AlignFrame alignFrame; + + protected WsParamSetI preset; + + protected List paramset; + + public Jws2Client(AlignFrame _alignFrame, + WsParamSetI preset, List arguments) + { + alignFrame = _alignFrame; + this.preset = preset; + if (preset != null) + { + if (!((preset instanceof JabaPreset) || preset instanceof JabaWsParamSet)) + { + /* + * { this.preset = ((JabaPreset) preset).p; } else if (preset instanceof + * JabaWsParamSet) { List newargs = new ArrayList(); + * JabaWsParamSet pset = ((JabaWsParamSet) preset); for (Option opt : + * pset.getjabaArguments()) { newargs.add(opt); } if (arguments != null + * && arguments.size() > 0) { // merge arguments with preset's own + * arguments. for (Argument opt : arguments) { newargs.add(opt); } } + * paramset = newargs; } else { + */ + throw new Error( + "Implementation error: Can only instantiate Jaba parameter sets."); + } + } + else + { + // just provided with a bunch of arguments + this.paramset = arguments; + } + } + + boolean processParams(Jws2Instance sh, boolean editParams) + { + return processParams(sh, editParams, false); + } + protected boolean processParams(Jws2Instance sh, boolean editParams, + boolean adjustingExisting) + { + + if (editParams) + { + if (sh.paramStore == null) + { + sh.paramStore = new JabaParamStore(sh, + Desktop.getUserParameterStore()); + } + WsJobParameters jobParams = new WsJobParameters(sh, preset); + if (adjustingExisting) + { + jobParams.setName("Adjusting parameters for existing Calculation"); + } + if (!jobParams.showRunDialog()) + { + return false; + } + WsParamSetI prset = jobParams.getPreset(); + if (prset == null) + { + paramset = JabaParamStore.getJabafromJwsArgs(jobParams + .getJobParams()); + } + else + { + this.preset = prset; // ((JabaPreset) prset).p; + paramset = null; // no user supplied parameters. + } + } + return true; + + } + + public Jws2Client() + { + // anonymous constructor - used for headless method calls only + } + protected WebserviceInfo setWebService(Jws2Instance serv, boolean b) { // serviceHandle = serv; - String serviceInstance = serv.service.getClass().getName(); + String serviceInstance = serv.action; // serv.service.getClass().getName(); WebServiceName = serv.serviceType; WebServiceJobTitle = serv.getActionText(); WsURL = serv.hosturl; if (!b) { return new WebserviceInfo(WebServiceJobTitle, WebServiceJobTitle - + " using service hosted at " + serv.hosturl); + + " using service hosted at " + serv.hosturl + "\n" + + (serv.description != null ? serv.description : "")); } return null; } diff --git a/src/jalview/ws/jws2/MsaWSClient.java b/src/jalview/ws/jws2/MsaWSClient.java index 950073f..66ef9a6 100644 --- a/src/jalview/ws/jws2/MsaWSClient.java +++ b/src/jalview/ws/jws2/MsaWSClient.java @@ -31,8 +31,8 @@ import compbio.metadata.Argument; import compbio.metadata.Option; import compbio.metadata.Preset; import compbio.metadata.PresetManager; -import jalview.ws.jws2.Jws2Discoverer.Jws2Instance; import jalview.ws.jws2.dm.JabaWsParamSet; +import jalview.ws.jws2.jabaws2.Jws2Instance; import jalview.ws.params.WsParamSetI; /** @@ -48,13 +48,7 @@ public class MsaWSClient extends Jws2Client */ MsaWS server; - AlignFrame alignFrame; - - private WsParamSetI preset; - - private List paramset; - - public MsaWSClient(Jws2Discoverer.Jws2Instance sh, String altitle, + public MsaWSClient(Jws2Instance sh, String altitle, jalview.datamodel.AlignmentView msa, boolean submitGaps, boolean preserveOrder, Alignment seqdataset, AlignFrame _alignFrame) @@ -64,7 +58,7 @@ public class MsaWSClient extends Jws2Client // TODO Auto-generated constructor stub } - public MsaWSClient(Jws2Discoverer.Jws2Instance sh, WsParamSetI preset, + public MsaWSClient(Jws2Instance sh, WsParamSetI preset, String altitle, jalview.datamodel.AlignmentView msa, boolean submitGaps, boolean preserveOrder, Alignment seqdataset, AlignFrame _alignFrame) @@ -90,14 +84,18 @@ public class MsaWSClient extends Jws2Client * DOCUMENT ME! */ - public MsaWSClient(Jws2Discoverer.Jws2Instance sh, WsParamSetI preset, + public MsaWSClient(Jws2Instance sh, WsParamSetI preset, List arguments, boolean editParams, String altitle, jalview.datamodel.AlignmentView msa, boolean submitGaps, boolean preserveOrder, Alignment seqdataset, AlignFrame _alignFrame) { - super(); - alignFrame = _alignFrame; + super(_alignFrame, preset, arguments); + if (!processParams(sh, editParams)) + { + return; + } + if (!(sh.service instanceof MsaWS)) { // redundant at mo - but may change @@ -111,68 +109,7 @@ public class MsaWSClient extends Jws2Client return; } - server = sh.service; - this.preset=preset; - if (preset != null) - { - if (!((preset instanceof JabaPreset) || preset instanceof JabaWsParamSet)) { - /*{ - this.preset = ((JabaPreset) preset).p; - } - else if (preset instanceof JabaWsParamSet) - { - List newargs = new ArrayList(); - JabaWsParamSet pset = ((JabaWsParamSet) preset); - for (Option opt : pset.getjabaArguments()) - { - newargs.add(opt); - } - if (arguments != null && arguments.size() > 0) - { - // merge arguments with preset's own arguments. - for (Argument opt : arguments) - { - newargs.add(opt); - } - } - paramset = newargs; - } - else - {*/ - throw new Error( - "Implementation error: Can only instantiate Jaba parameter sets."); - } - } - else - { - // just provided with a bunch of arguments - this.paramset = arguments; - } - if (editParams) - { - if (sh.paramStore == null) - { - sh.paramStore = new JabaParamStore(sh, - Desktop.getUserParameterStore()); - } - WsJobParameters jobParams = new WsJobParameters(sh, preset); - if (!jobParams.showRunDialog()) - { - return; - } - WsParamSetI prset = jobParams.getPreset(); - if (prset == null) - { - paramset = JabaParamStore.getJabafromJwsArgs(jobParams - .getJobParams()); - } - else - { - this.preset = prset; // ((JabaPreset) prset).p; - paramset = null; // no user supplied parameters. - } - } - + server = (MsaWS) sh.service; if ((wsInfo = setWebService(sh, false)) == null) { JOptionPane.showMessageDialog(Desktop.desktop, @@ -254,6 +191,7 @@ public class MsaWSClient extends Jws2Client return (WebServiceName.indexOf("lustal") > -1); // cheat! } + public void attachWSMenuEntry(JMenu rmsawsmenu, final Jws2Instance service, final AlignFrame alignFrame) {