| 1 |
|
package jalview.ws.slivkaws; |
| 2 |
|
|
| 3 |
|
import java.io.IOException; |
| 4 |
|
import java.util.ArrayList; |
| 5 |
|
import java.util.Collections; |
| 6 |
|
import java.util.List; |
| 7 |
|
|
| 8 |
|
import jalview.ws.params.ArgumentI; |
| 9 |
|
import jalview.ws.params.WsParamSetI; |
| 10 |
|
import jalview.ws.params.simple.BooleanOption; |
| 11 |
|
import jalview.ws.params.simple.DoubleParameter; |
| 12 |
|
import jalview.ws.params.simple.IntegerParameter; |
| 13 |
|
import jalview.ws.params.simple.StringParameter; |
| 14 |
|
import uk.ac.dundee.compbio.slivkaclient.Parameter; |
| 15 |
|
import uk.ac.dundee.compbio.slivkaclient.SlivkaService; |
| 16 |
|
|
| |
|
| 0% |
Uncovered Elements: 76 (76) |
Complexity: 25 |
Complexity Density: 0.71 |
|
| 17 |
|
public class SlivkaParamSet implements WsParamSetI |
| 18 |
|
{ |
| 19 |
|
private SlivkaService service; |
| 20 |
|
|
| 21 |
|
private List<ArgumentI> args = new ArrayList<>(); |
| 22 |
|
|
| |
|
| 0% |
Uncovered Elements: 60 (60) |
Complexity: 17 |
Complexity Density: 0.61 |
|
| 23 |
0 |
SlivkaParamSet(SlivkaService service)... |
| 24 |
|
{ |
| 25 |
0 |
this.service = service; |
| 26 |
0 |
for (Parameter param : service.getParameters()) |
| 27 |
|
{ |
| 28 |
0 |
Object defaultValue = param.getDefault() instanceof List |
| 29 |
|
? ((List<?>) param.getDefault()).get(0) |
| 30 |
|
: param.getDefault(); |
| 31 |
0 |
if (param instanceof Parameter.FlagParameter) |
| 32 |
|
{ |
| 33 |
0 |
args.add(new BooleanOption(param.getId(), param.getDescription(), |
| 34 |
|
param.getName(), param.isRequired(), (Boolean) defaultValue, null)); |
| 35 |
|
} |
| 36 |
0 |
else if (param instanceof Parameter.TextParameter) |
| 37 |
|
{ |
| 38 |
0 |
args.add(new StringParameter(param.getId(), param.getDescription(), |
| 39 |
|
param.isRequired(), (String) defaultValue, (String) defaultValue)); |
| 40 |
|
} |
| 41 |
0 |
else if (param instanceof Parameter.IntegerParameter) |
| 42 |
|
{ |
| 43 |
0 |
Integer min = ((Parameter.IntegerParameter) param).getMin(); |
| 44 |
0 |
Integer max = ((Parameter.IntegerParameter) param).getMax(); |
| 45 |
0 |
Integer defVal = defaultValue != null |
| 46 |
|
? ((Number) defaultValue).intValue() |
| 47 |
|
: null; |
| 48 |
0 |
args.add(new IntegerParameter(param.getId(), param.getDescription(), |
| 49 |
0 |
param.isRequired(), defVal, (min == null) ? Integer.MIN_VALUE : min, |
| 50 |
0 |
(max == null) ? Integer.MAX_VALUE : max)); |
| 51 |
|
} |
| 52 |
0 |
else if (param instanceof Parameter.DecimalParameter) |
| 53 |
|
{ |
| 54 |
0 |
Double min = ((Parameter.DecimalParameter) param).getMin(); |
| 55 |
0 |
Double max = ((Parameter.DecimalParameter) param).getMax(); |
| 56 |
0 |
Double defVal = defaultValue != null |
| 57 |
|
? ((Number) defaultValue).doubleValue() |
| 58 |
|
: null; |
| 59 |
0 |
args.add(new DoubleParameter(param.getId(), param.getDescription(), |
| 60 |
0 |
param.isRequired(), defVal, (min == null) ? -Double.MAX_VALUE : min, |
| 61 |
0 |
(max == null) ? Double.MAX_VALUE : max)); |
| 62 |
|
} |
| 63 |
0 |
else if (param instanceof Parameter.ChoiceParameter) |
| 64 |
|
{ |
| 65 |
0 |
List<String> choices = ((Parameter.ChoiceParameter) param) |
| 66 |
|
.getChoices(); |
| 67 |
0 |
if (param.isArray()) |
| 68 |
|
{ |
| 69 |
0 |
int i = 0; |
| 70 |
0 |
List<?> selected = param.getDefault() != null |
| 71 |
|
? (List<?>) param.getDefault() |
| 72 |
|
: Collections.EMPTY_LIST; |
| 73 |
0 |
for (String choice : choices) |
| 74 |
|
{ |
| 75 |
0 |
args.add(new BooleanOption( |
| 76 |
|
String.format("%s$%d", param.getId(), i++), |
| 77 |
|
param.getDescription(), choice, param.isRequired(), |
| 78 |
|
selected.contains(choice), choice, null)); |
| 79 |
|
} |
| 80 |
|
} |
| 81 |
|
else |
| 82 |
|
{ |
| 83 |
0 |
args.add(new StringParameter( |
| 84 |
|
param.getId(), param.getDescription(), |
| 85 |
|
param.isRequired(), (String) param.getDefault(), |
| 86 |
|
(String) defaultValue, choices, choices)); |
| 87 |
|
} |
| 88 |
|
} |
| 89 |
0 |
else if (param instanceof Parameter.FileParameter) |
| 90 |
|
{ |
| 91 |
|
|
| 92 |
|
} |
| 93 |
|
else |
| 94 |
|
{ |
| 95 |
0 |
String defaultVal = param.getDefault() != null |
| 96 |
|
? param.getDefault().toString() |
| 97 |
|
: null; |
| 98 |
0 |
args.add(new StringParameter(param.getId(), param.getDescription(), |
| 99 |
|
param.isRequired(), defaultVal, defaultVal)); |
| 100 |
|
} |
| 101 |
|
} |
| 102 |
|
} |
| 103 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 104 |
0 |
@Override... |
| 105 |
|
public String getName() |
| 106 |
|
{ |
| 107 |
0 |
return "Default"; |
| 108 |
|
} |
| 109 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 110 |
0 |
@Override... |
| 111 |
|
public String getDescription() |
| 112 |
|
{ |
| 113 |
0 |
return service.getDescription(); |
| 114 |
|
} |
| 115 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 116 |
0 |
@Override... |
| 117 |
|
public String[] getApplicableUrls() |
| 118 |
|
{ |
| 119 |
0 |
return new String[] { service.getUrl().toString() }; |
| 120 |
|
} |
| 121 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 122 |
0 |
@Override... |
| 123 |
|
public String getSourceFile() |
| 124 |
|
{ |
| 125 |
0 |
return null; |
| 126 |
|
} |
| 127 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 128 |
0 |
@Override... |
| 129 |
|
public void setSourceFile(String newfile) |
| 130 |
|
{ |
| 131 |
|
} |
| 132 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 133 |
0 |
@Override... |
| 134 |
|
public boolean isModifiable() |
| 135 |
|
{ |
| 136 |
0 |
return true; |
| 137 |
|
} |
| 138 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 139 |
0 |
@Override... |
| 140 |
|
public List<ArgumentI> getArguments() |
| 141 |
|
{ |
| 142 |
0 |
return args; |
| 143 |
|
} |
| 144 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 145 |
0 |
@Override... |
| 146 |
|
public void setArguments(List<ArgumentI> args) |
| 147 |
|
{ |
| 148 |
0 |
throw new RuntimeException(); |
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
} |