{
option = opt;
setLayout(new FlowLayout(FlowLayout.LEFT));
- enabled = new JCheckBox(opt.getName());
+ enabled = new JCheckBox(opt.getLabel());
enabled.setSelected(opt.isRequired());
/*
if (opt.isRequired() && !(opt instanceof JabaOption))
{
finfo = null;
- add(new JLabel(opt.getName()));
+ add(new JLabel(opt.getLabel()));
}
else
{
/**
*
+ * @return display name of this argument
+ */
+ default String getLabel()
+ {
+ return getName();
+ };
+
+ /**
+ *
* @return current value for the argument (may equal the name)
*/
String getValue();
public BooleanOption(String name, String descr, boolean required,
Boolean defVal, Boolean val, URL link)
{
- super(name, descr, required, (defVal != null && defVal ? name : null), (val != null && val ? name : null),
- Arrays.asList(name), link);
+ super(name, descr, required, (defVal != null && defVal ? name : null),
+ (val != null && val ? name : null), Arrays.asList(name), link);
}
+ public BooleanOption(String name, String description, String label,
+ boolean isrequired, Boolean defValue, String reprValue, URL link)
+ {
+ super(name, description, label, isrequired,
+ defValue != null && defValue ? reprValue : null,
+ defValue != null && defValue ? reprValue : null,
+ Arrays.asList(reprValue), link);
+ }
+
+ public BooleanOption(String name, String description, String label,
+ boolean isrequired, Boolean defValue, URL link)
+ {
+ this(name, description, label, isrequired, defValue, String.valueOf(true), link);
+ }
}
{
String name;
+ String label;
+
/*
* current value in string format, or "null" if undefined
*/
public Option(Option opt)
{
name = opt.name;
+ label = opt.label;
value = opt.value;
defvalue = opt.defvalue;
description = opt.description;
{
}
+ public Option(String name, String description, String label, boolean isrequired,
+ String defValue, String val, List<String> possibleVals, URL fdetails)
+ {
+ this(name, description, isrequired, defValue, val, possibleVals, fdetails);
+ this.label = label;
+ }
+
/**
* Constructor including display names for possible values
*
}
@Override
+ public String getLabel()
+ {
+ return label != null ? label : name;
+ }
+
+ @Override
public String getValue()
{
return value == null ? defvalue : value;
import jalview.ws.params.WsParamSetI;
import jalview.ws.uimodel.AlignAnalysisUIText;
-import java.io.ByteArrayInputStream;
import java.io.IOError;
import java.io.IOException;
-import java.io.InputStream;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import uk.ac.dundee.compbio.slivkaclient.FormField;
import uk.ac.dundee.compbio.slivkaclient.RemoteFile;
import uk.ac.dundee.compbio.slivkaclient.SlivkaClient;
-import uk.ac.dundee.compbio.slivkaclient.SlivkaForm;
import uk.ac.dundee.compbio.slivkaclient.SlivkaService;
public class SlivkaAnnotationServiceInstance extends SlivkaWSInstance implements SequenceAnnotationServiceI
@Override
public JobId submitToService(List<SequenceI> seqs, WsParamSetI preset, List<ArgumentI> paramset) throws Throwable
{
- StringBuilder builder = new StringBuilder();
- for (SequenceI seq : seqs)
- {
- builder.append(">").append(seq.getName()).append("\n");
- builder.append(seq.getSequence()).append("\n");
- }
- 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<>(paramset != null ? paramset.size() : 0);
- if (paramset != null)
- {
- for (ArgumentI arg : paramset)
- {
- 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())));
- }
- }
- return new JobId(service.getName(), service.getName(), form.submit());
+ return super.submit(seqs, preset, paramset);
}
@Override
import jalview.ws.params.InvalidArgumentException;
import jalview.ws.params.WsParamSetI;
-import java.io.ByteArrayInputStream;
import java.io.IOError;
import java.io.IOException;
-import java.io.InputStream;
import java.rmi.ServerError;
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;
-import uk.ac.dundee.compbio.slivkaclient.SlivkaForm;
import uk.ac.dundee.compbio.slivkaclient.SlivkaService;
public class SlivkaMsaServiceInstance extends SlivkaWSInstance implements MultipleSequenceAlignmentI
@Override
public JobId align(List<SequenceI> toalign, WsParamSetI parameters, List<ArgumentI> list) throws Throwable
{
- StringBuilder builder = new StringBuilder();
- for (SequenceI seq : toalign)
- {
- builder.append(">").append(seq.getName()).append("\n");
- builder.append(seq.getSequence()).append("\n");
- }
- InputStream stream = new ByteArrayInputStream(builder.toString().getBytes());
- RemoteFile file = client.uploadFile(stream, "input.fasta", "application/fasta");
- SlivkaForm form = service.getForm();
- 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)
- {
- 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());
+ return super.submit(toalign, parameters, list);
}
@Override
SlivkaForm form = service.getForm();
for (FormField field : form.getFields())
{
- ArgumentI arg;
switch (field.getType()) {
case BOOLEAN:
BooleanField boolField = (BooleanField) field;
- arg = new BooleanOption(
- field.getName(), field.getDescription(), field.isRequired(),
- boolField.getDefault(), boolField.getDefault(), null
- );
+ args.add(new BooleanOption(
+ field.getName(), field.getDescription(), field.getLabel(),
+ field.isRequired(), boolField.getDefault(), null
+ ));
break;
case TEXT:
TextField textField = (TextField) field;
- arg = new StringParameter(
+ args.add(new StringParameter(
field.getName(), field.getDescription(), field.isRequired(),
textField.getDefault(), textField.getDefault()
- );
+ ));
break;
case INTEGER:
IntegerField intField = (IntegerField) field;
- arg = new IntegerParameter(
+ args.add(new IntegerParameter(
field.getName(), field.getDescription(), field.isRequired(),
intField.getDefault(), intField.getMin(), intField.getMax()
- );
+ ));
break;
case DECIMAL:
DecimalField doubleField = (DecimalField) field;
- arg = new DoubleParameter(
+ args.add(new DoubleParameter(
field.getName(), field.getDescription(), field.isRequired(),
doubleField.getDefault(), doubleField.getMin(),
doubleField.getMax()
- );
+ ));
break;
case CHOICE:
ChoiceField choiceField = (ChoiceField) field;
List<String> choices = new ArrayList<>(choiceField.getChoices());
- arg = new StringParameter(field.getName(), field.getDescription(),
- field.isRequired(), choiceField.getDefault(), choiceField.getDefault(),
- choices, choices
- );
+ if (field.hasMultipleValues()) {
+ int counter = 0;
+ for (String choice : choices) {
+ args.add(new BooleanOption(
+ String.format("%s$%d", field.getName(), counter++),
+ field.getDescription(), choice, field.isRequired(),
+ choice.equals(choiceField.getDefault()), choice,
+ null
+ ));
+ }
+ }
+ else
+ {
+ args.add(new StringParameter(
+ field.getName(), field.getDescription(),
+ field.isRequired(), choiceField.getDefault(), choiceField.getDefault(),
+ choices, choices
+ ));
+ }
break;
case FILE:
default:
continue;
}
- args.add(arg);
}
}
package jalview.ws.slivkaws;
+import jalview.datamodel.SequenceI;
import jalview.gui.WebserviceInfo;
import jalview.ws.api.JalviewServiceEndpointProviderI;
import jalview.ws.api.JalviewWebServiceI;
+import jalview.ws.api.JobId;
import jalview.ws.api.ServiceWithParameters;
import jalview.ws.gui.WsJob;
+import jalview.ws.params.ArgumentI;
import jalview.ws.params.ParamDatastoreI;
import jalview.ws.params.ParamManager;
+import jalview.ws.params.WsParamSetI;
+import java.io.ByteArrayInputStream;
import java.io.IOError;
import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
import java.util.Set;
+import uk.ac.dundee.compbio.slivkaclient.FieldType;
+import uk.ac.dundee.compbio.slivkaclient.FormField;
import uk.ac.dundee.compbio.slivkaclient.FormValidationException;
import uk.ac.dundee.compbio.slivkaclient.JobState;
import uk.ac.dundee.compbio.slivkaclient.RemoteFile;
import uk.ac.dundee.compbio.slivkaclient.SlivkaClient;
+import uk.ac.dundee.compbio.slivkaclient.SlivkaForm;
import uk.ac.dundee.compbio.slivkaclient.SlivkaService;
import uk.ac.dundee.compbio.slivkaclient.ValidationException;
this.service = service;
}
+ protected final JobId submit(List<SequenceI> sequences,
+ WsParamSetI preset, List<ArgumentI> args) throws Throwable
+ {
+ SlivkaForm form = service.getForm();
+ Optional<FormField> inputField = form.getFields().stream()
+ .filter(f -> f.getType() == FieldType.FILE).findFirst();
+ if (inputField.isPresent())
+ {
+ StringBuilder builder = new StringBuilder();
+ for (SequenceI seq : sequences)
+ {
+ builder.append(">").append(seq.getName()).append("\n")
+ .append(seq.getSequence()).append("\n");
+ }
+ InputStream stream = new ByteArrayInputStream(
+ builder.toString().getBytes());
+ RemoteFile file = client.uploadFile(stream, "input.fa",
+ "application/fasta");
+ form.insert(inputField.get().getName(), file);
+ }
+ if (args != null)
+ {
+ for (ArgumentI arg : args)
+ {
+ 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());
+ }
+
@Override
public final void updateStatus(WsJob job)
{