Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 16:11:35 GMT
  2. Package jalview.ws.slivkaws

File SlivkaParamSet.java

 

Coverage histogram

../../../img/srcFileCovDistChart0.png
60% of files have more coverage

Code metrics

32
35
9
1
151
136
25
0.71
3.89
9
2.78

Classes

Class Line # Actions
SlivkaParamSet 17 35 25
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

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   
 
17    public class SlivkaParamSet implements WsParamSetI
18    {
19    private SlivkaService service;
20   
21    private List<ArgumentI> args = new ArrayList<>();
22   
 
23  0 toggle 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    // skip: files are provided from sequences
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   
 
104  0 toggle @Override
105    public String getName()
106    {
107  0 return "Default";
108    }
109   
 
110  0 toggle @Override
111    public String getDescription()
112    {
113  0 return service.getDescription();
114    }
115   
 
116  0 toggle @Override
117    public String[] getApplicableUrls()
118    {
119  0 return new String[] { service.getUrl().toString() };
120    }
121   
 
122  0 toggle @Override
123    public String getSourceFile()
124    {
125  0 return null;
126    }
127   
 
128  0 toggle @Override
129    public void setSourceFile(String newfile)
130    {
131    }
132   
 
133  0 toggle @Override
134    public boolean isModifiable()
135    {
136  0 return true;
137    }
138   
 
139  0 toggle @Override
140    public List<ArgumentI> getArguments()
141    {
142  0 return args;
143    }
144   
 
145  0 toggle @Override
146    public void setArguments(List<ArgumentI> args)
147    {
148  0 throw new RuntimeException();
149    }
150   
151    }