From: kjvdheide Date: Thu, 1 Feb 2018 16:07:49 +0000 (+0000) Subject: JAL-2890 added validation for parameters X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2472794b6481408a9d9b079a7f821591bbd02e4c;p=jalview.git JAL-2890 added validation for parameters --- diff --git a/src/jalview/ext/cipres/TreeJob.java b/src/jalview/ext/cipres/TreeJob.java index 1a0b550..52ebbc0 100644 --- a/src/jalview/ext/cipres/TreeJob.java +++ b/src/jalview/ext/cipres/TreeJob.java @@ -5,7 +5,10 @@ import java.util.HashMap; import java.util.Map; import org.ngbw.directclient.CiApplication; +import org.ngbw.directclient.CiCipresException; import org.ngbw.directclient.CiClient; +import org.ngbw.restdatatypes.ErrorData; +import org.ngbw.restdatatypes.ParamError; public class TreeJob { @@ -38,10 +41,13 @@ public class TreeJob inputParams.put("infile_", alignmentFilePath); } + + /** * Specifies a parameter about the input data for a CIPRES job with its value, * for example the "infile_" parameter for the MSA file to calculate a tree - * from with file path as value. + * from with file path as value. Note that different tools support different + * input parameters. * * @param parameter * @param value @@ -99,6 +105,34 @@ public class TreeJob metadata.clear(); } + /** + * Sends this job with all given parameters to the given Cipres tool but + * doesn't actually run the job. This is a lightweight way to validate that + * the given parameters are correct for a specified tool. + */ + public void validateJobParams(String toolName) + { + try + { + cipresClient.validateJob(toolName, vParams, inputParams, metadata); + } catch (CiCipresException ce) + { + ErrorData ed = ce.getErrorData(); + System.out.println( + "Cipres error while trying to validate parameters, code=" + + ed.code + ", message=" + + ed.displayMessage + ); + if (ed.code == ErrorData.FORM_VALIDATION) + { + for (ParamError pe : ed.paramError) + { + System.out.println(pe.param + ": " + pe.error); + } + } + } + + } }