+ protected final JobId submit(List<SequenceI> sequences,
+ WsParamSetI preset, List<ArgumentI> args) throws Throwable
+ {
+ SlivkaForm form = service.getForm();
+ for (FormField field : form.getFields())
+ {
+ if (field.getType() == FieldType.FILE)
+ {
+ FormatAdapter fa = new FormatAdapter();
+ fa.setNewlineString("\r\n");
+ FileField fileField = (FileField) field;
+ FileFormat format;
+ switch (fileField.getMediaType())
+ {
+ case "application/pfam":
+ format = FileFormat.Pfam;
+ break;
+ case "application/stockholm":
+ format = FileFormat.Stockholm;
+ break;
+ default:
+ case "application/fasta":
+ format = FileFormat.Fasta;
+ break;
+ }
+ InputStream stream = new ByteArrayInputStream(
+ fa.formatSequences(format, sequences.toArray(new SequenceI[0]))
+ .getBytes());
+ RemoteFile rf = client.uploadFile(stream, "input",
+ fileField.getMediaType());
+ form.insert(field.getName(), rf);
+ }
+ }
+ if (args != null)
+ {
+ for (ArgumentI arg : args)
+ {
+ // multiple choice field names are name$number to avoid duplications
+ // the number is stripped here
+ String fieldName = arg.getName().split("\\$", 2)[0];
+ FormField field = form.getField(fieldName);
+ if (field.getType() == FieldType.BOOLEAN)
+ {
+ form.insert(fieldName,
+ (arg.getValue() != null && !arg.getValue().isBlank())
+ ? true
+ : false);
+ }
+ else
+ {
+ form.insert(fieldName, field.valueOf(arg.getValue()));
+ }
+ }
+ }
+ return new JobId(service.getName(), service.getName(), form.submit());
+ }
+