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;
InputStream stream = new ByteArrayInputStream(builder.toString().getBytes());
RemoteFile file = client.uploadFile(stream, "input.fasta", "application/fasta");
SlivkaForm form = service.getForm();
- HashMap<String, String> values = new HashMap<>(list != null ? list.size() : 0);
+ Optional<FormField> 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());