From 7713b430384995e970ec67129c0ce9a9ad2c9855 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 29 Oct 2010 16:11:04 +0000 Subject: [PATCH] refactored so public interfaces take instances of WsParamSetI, and ensured that name of preset is logged in job output (JAL-667) --- src/jalview/ws/jws2/MsaWSClient.java | 11 +++-- src/jalview/ws/jws2/MsaWSThread.java | 85 ++++++++++++++++++++++++++++------ 2 files changed, 77 insertions(+), 19 deletions(-) diff --git a/src/jalview/ws/jws2/MsaWSClient.java b/src/jalview/ws/jws2/MsaWSClient.java index 92f0a3e..8a352bf 100644 --- a/src/jalview/ws/jws2/MsaWSClient.java +++ b/src/jalview/ws/jws2/MsaWSClient.java @@ -50,7 +50,7 @@ public class MsaWSClient extends Jws2Client AlignFrame alignFrame; - private Preset preset; + private WsParamSetI preset; private List paramset; @@ -112,10 +112,11 @@ public class MsaWSClient extends Jws2Client return; } server = sh.service; + this.preset=preset; if (preset != null) { - if (preset instanceof JabaPreset) - { + if (!((preset instanceof JabaPreset) || preset instanceof JabaWsParamSet)) { + /*{ this.preset = ((JabaPreset) preset).p; } else if (preset instanceof JabaWsParamSet) @@ -137,7 +138,7 @@ public class MsaWSClient extends Jws2Client paramset = newargs; } else - { + {*/ throw new Error( "Implementation error: Can only instantiate Jaba parameter sets."); } @@ -167,7 +168,7 @@ public class MsaWSClient extends Jws2Client } else { - this.preset = ((JabaPreset) prset).p; + this.preset = prset; // ((JabaPreset) prset).p; paramset = null; // no user supplied parameters. } } diff --git a/src/jalview/ws/jws2/MsaWSThread.java b/src/jalview/ws/jws2/MsaWSThread.java index 6f06731..bd86bf0 100644 --- a/src/jalview/ws/jws2/MsaWSThread.java +++ b/src/jalview/ws/jws2/MsaWSThread.java @@ -34,6 +34,8 @@ import jalview.gui.*; import jalview.ws.AWsJob; import jalview.ws.WSClientI; import jalview.ws.JobStateSummary; +import jalview.ws.jws2.dm.JabaWsParamSet; +import jalview.ws.params.WsParamSetI; /** *

@@ -69,7 +71,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI { long lastChunk = 0; - Preset preset = null; + WsParamSetI preset = null; List arguments = null; @@ -373,6 +375,67 @@ class MsaWSThread extends AWS2Thread implements WSClientI return alignmentProgram; } + public boolean hasArguments() + { + return (arguments != null && arguments.size() > 0) + || (preset != null && preset instanceof JabaWsParamSet); + } + + public List getJabaArguments() + { + List newargs = new ArrayList(); + if (preset != null && preset instanceof JabaWsParamSet) + { + newargs.addAll(((JabaWsParamSet) preset).getjabaArguments()); + } + if (arguments != null && arguments.size() > 0) + { + newargs.addAll(arguments); + } + return newargs; + } + + /** + * add a progess header to status string containing presets/args used + */ + public void addInitialStatus() + { + if (preset != null) + { + jobProgress.append("Using " + + (preset instanceof JabaPreset ? "Server" : "User") + + "Preset: " + preset.getName()); + if (preset instanceof JabaWsParamSet) + { + for (Argument opt : ((JabaWsParamSet) preset).getjabaArguments()) + { + jobProgress.append(opt.getName() + " " + opt.getDefaultValue() + + "\n"); + } + } + } + if (arguments != null && arguments.size() > 0) + { + jobProgress.append("With custom parameters : \n"); + // merge arguments with preset's own arguments. + for (Argument opt : arguments) + { + jobProgress.append(opt.getName() + " " + opt.getDefaultValue() + + "\n"); + } + } + jobProgress.append("\nJob Output:\n"); + } + + public boolean isPresetJob() + { + return preset != null && preset instanceof JabaPreset; + } + + public Preset getServerPreset() + { + return (isPresetJob()) ? ((JabaPreset) preset).p : null; + } } String alTitle; // name which will be used to form new alignment window. @@ -416,7 +479,7 @@ class MsaWSThread extends AWS2Thread implements WSClientI * @param seqset * Alignment */ - MsaWSThread(MsaWS server2, Preset preset, List paramset, + MsaWSThread(MsaWS server2, WsParamSetI preset, List paramset, String wsUrl, WebserviceInfo wsinfo, jalview.gui.AlignFrame alFrame, String wsname, String title, AlignmentView _msa, boolean subgaps, boolean presorder, @@ -580,21 +643,15 @@ class MsaWSThread extends AWS2Thread implements WSClientI } try { - // TODO: get the parameters (if any) for this job and submit the job - if (j.arguments != null && j.arguments.size() > 0) + j.addInitialStatus(); // list the presets/parameters used for the job in + // status + if (j.isPresetJob()) { - StringBuffer pset = new StringBuffer(); - for (Argument arg : j.arguments) - { - pset.append(arg.getName() + " " + arg.getDefaultValue() + "\n"); - } - j.setStatus("Custom Parameters:\n" + pset.toString() - + "\nJob Output:\n"); - j.setJobId(server.customAlign(j.seqs, j.arguments)); + j.setJobId(server.presetAlign(j.seqs, j.getServerPreset())); } - else if (j.preset != null) + else if (j.hasArguments()) { - j.setJobId(server.presetAlign(j.seqs, j.preset)); + j.setJobId(server.customAlign(j.seqs,j.getJabaArguments())); } else { -- 1.7.10.2