From: Mateusz Warowny Date: Wed, 9 Oct 2019 15:40:19 +0000 (+0100) Subject: JAL-3066 Read parameters directly from args list allowing for multiple values. X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=48d4e0739a95ee0016ec8a753758561339a86e11;p=jalview.git JAL-3066 Read parameters directly from args list allowing for multiple values. --- diff --git a/j11lib/slivka-client.jar b/j11lib/slivka-client.jar index 28a92da..1725efb 100644 Binary files a/j11lib/slivka-client.jar and b/j11lib/slivka-client.jar differ diff --git a/src/jalview/ws/slivkaws/SlivkaMsaServiceInstance.java b/src/jalview/ws/slivkaws/SlivkaMsaServiceInstance.java index db1577e..f09ba16 100644 --- a/src/jalview/ws/slivkaws/SlivkaMsaServiceInstance.java +++ b/src/jalview/ws/slivkaws/SlivkaMsaServiceInstance.java @@ -16,9 +16,10 @@ import java.io.IOError; import java.io.IOException; import java.io.InputStream; import java.rmi.ServerError; -import java.util.HashMap; import java.util.List; +import java.util.Optional; +import uk.ac.dundee.compbio.slivkaclient.FieldType; import uk.ac.dundee.compbio.slivkaclient.FormField; import uk.ac.dundee.compbio.slivkaclient.RemoteFile; import uk.ac.dundee.compbio.slivkaclient.SlivkaClient; @@ -44,26 +45,25 @@ public class SlivkaMsaServiceInstance extends SlivkaWSInstance implements Multip InputStream stream = new ByteArrayInputStream(builder.toString().getBytes()); RemoteFile file = client.uploadFile(stream, "input.fasta", "application/fasta"); SlivkaForm form = service.getForm(); - HashMap values = new HashMap<>(list != null ? list.size() : 0); + Optional inputField = form.getFields().stream() + .filter(f -> f.getType() == FieldType.FILE).findFirst(); + if (inputField.isPresent()) + { + form.insert(inputField.get().getName(), file); + } if (list != null) { for (ArgumentI arg : list) { - values.put(arg.getName(), arg.getValue()); - } - } - for (FormField field : form.getFields()) - { - switch (field.getType()) { - case FILE: - form.insert(field.getName(), file); - break; - case BOOLEAN: - String value = values.get(field.getName()); - form.insert(field.getName(), (value != null && !value.isBlank()) ? true : false); - break; - default: - form.insert(field.getName(), field.valueOf(values.get(field.getName()))); + FormField field = form.getField(arg.getName()); + if (field.getType() == FieldType.BOOLEAN) + { + form.insert(arg.getName(), (arg.getValue() != null && !arg.getValue().isBlank()) ? true : false); + } + else + { + form.insert(arg.getName(), field.valueOf(arg.getValue())); + } } } return new JobId(service.getName(), service.getName(), form.submit());