1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.urls; |
22 |
|
|
23 |
|
import static jalview.util.UrlConstants.SEP; |
24 |
|
|
25 |
|
import jalview.urls.api.UrlProviderI; |
26 |
|
|
27 |
|
import java.util.ArrayList; |
28 |
|
import java.util.List; |
29 |
|
import java.util.Vector; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@author |
36 |
|
@version |
37 |
|
|
|
|
| 86.1% |
Uncovered Elements: 14 (101) |
Complexity: 24 |
Complexity Density: 0.36 |
|
38 |
|
public class UrlProvider implements UrlProviderI |
39 |
|
{ |
40 |
|
|
41 |
|
private List<UrlProviderI> providers; |
42 |
|
|
43 |
|
|
44 |
|
private UrlProviderI customProvider; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@param |
50 |
|
|
51 |
|
@param |
52 |
|
|
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
54 |
37 |
public UrlProvider(String defaultUrlString,... |
55 |
|
List<UrlProviderI> allProviders) |
56 |
|
{ |
57 |
37 |
providers = allProviders; |
58 |
|
|
59 |
37 |
customProvider = findCustomProvider(); |
60 |
|
|
61 |
|
|
62 |
37 |
if (!contains(defaultUrlString)) |
63 |
|
{ |
64 |
|
|
65 |
|
|
66 |
4 |
choosePrimaryUrl(); |
67 |
|
} |
68 |
|
else |
69 |
|
{ |
70 |
33 |
setPrimaryUrl(defaultUrlString); |
71 |
|
} |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
77 |
37 |
private UrlProviderI findCustomProvider()... |
78 |
|
{ |
79 |
37 |
for (UrlProviderI p : providers) |
80 |
|
{ |
81 |
74 |
if (p instanceof CustomUrlProvider) |
82 |
|
{ |
83 |
37 |
return p; |
84 |
|
} |
85 |
|
} |
86 |
|
|
87 |
0 |
jalview.bin.Console.outPrintln( |
88 |
|
"Error initialising UrlProvider - no custom url provider"); |
89 |
0 |
return null; |
90 |
|
} |
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
92 |
36 |
@Override... |
93 |
|
public boolean setPrimaryUrl(String id) |
94 |
|
{ |
95 |
36 |
boolean outcome = false; |
96 |
36 |
for (UrlProviderI p : providers) |
97 |
|
{ |
98 |
72 |
if (p.setPrimaryUrl(id)) |
99 |
|
{ |
100 |
35 |
outcome = true; |
101 |
|
} |
102 |
|
} |
103 |
36 |
if (!outcome) |
104 |
|
{ |
105 |
1 |
throw new IllegalArgumentException(); |
106 |
|
} |
107 |
35 |
return outcome; |
108 |
|
} |
109 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
110 |
37 |
@Override... |
111 |
|
public boolean contains(String id) |
112 |
|
{ |
113 |
37 |
boolean outcome = false; |
114 |
37 |
for (UrlProviderI p : providers) |
115 |
|
{ |
116 |
74 |
if (p.contains(id)) |
117 |
|
{ |
118 |
33 |
outcome = true; |
119 |
|
} |
120 |
|
} |
121 |
37 |
return outcome; |
122 |
|
} |
123 |
|
|
|
|
| 92.3% |
Uncovered Elements: 1 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
124 |
3 |
@Override... |
125 |
|
public String writeUrlsAsString(boolean selected) |
126 |
|
{ |
127 |
3 |
String result = ""; |
128 |
3 |
for (UrlProviderI p : providers) |
129 |
|
{ |
130 |
6 |
String next = p.writeUrlsAsString(selected); |
131 |
6 |
if (!next.isEmpty()) |
132 |
|
{ |
133 |
5 |
result += next; |
134 |
5 |
result += SEP; |
135 |
|
} |
136 |
|
} |
137 |
|
|
138 |
3 |
if (!result.isEmpty()) |
139 |
|
{ |
140 |
3 |
result = result.substring(0, result.length() - 1); |
141 |
|
} |
142 |
3 |
return result; |
143 |
|
} |
144 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
145 |
102 |
@Override... |
146 |
|
public Vector<String> getLinksForMenu() |
147 |
|
{ |
148 |
102 |
Vector<String> fullLinks = new Vector<String>(); |
149 |
102 |
for (UrlProviderI p : providers) |
150 |
|
{ |
151 |
204 |
List<String> links = p.getLinksForMenu(); |
152 |
204 |
if (links != null) |
153 |
|
{ |
154 |
|
|
155 |
|
|
156 |
204 |
fullLinks.addAll(links); |
157 |
|
} |
158 |
|
} |
159 |
102 |
return fullLinks; |
160 |
|
} |
161 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
162 |
21 |
@Override... |
163 |
|
public List<UrlLinkDisplay> getLinksForTable() |
164 |
|
{ |
165 |
21 |
ArrayList<UrlLinkDisplay> displayLinks = new ArrayList<UrlLinkDisplay>(); |
166 |
21 |
for (UrlProviderI p : providers) |
167 |
|
{ |
168 |
42 |
displayLinks.addAll(p.getLinksForTable()); |
169 |
|
} |
170 |
21 |
return displayLinks; |
171 |
|
} |
172 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
173 |
9 |
@Override... |
174 |
|
public void setUrlData(List<UrlLinkDisplay> links) |
175 |
|
{ |
176 |
9 |
for (UrlProviderI p : providers) |
177 |
|
{ |
178 |
18 |
p.setUrlData(links); |
179 |
|
} |
180 |
|
} |
181 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
182 |
3 |
@Override... |
183 |
|
public String getPrimaryUrl(String seqid) |
184 |
|
{ |
185 |
3 |
String link = null; |
186 |
3 |
for (UrlProviderI p : providers) |
187 |
|
{ |
188 |
6 |
if (p.getPrimaryUrl(seqid) == null) |
189 |
|
{ |
190 |
3 |
continue; |
191 |
|
} |
192 |
|
else |
193 |
|
{ |
194 |
3 |
link = p.getPrimaryUrl(seqid); |
195 |
3 |
break; |
196 |
|
} |
197 |
|
} |
198 |
3 |
return link; |
199 |
|
} |
200 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
201 |
4 |
@Override... |
202 |
|
public String getPrimaryUrlId() |
203 |
|
{ |
204 |
4 |
String id = null; |
205 |
4 |
for (UrlProviderI p : providers) |
206 |
|
{ |
207 |
7 |
if (p.getPrimaryUrlId() == null) |
208 |
|
{ |
209 |
3 |
continue; |
210 |
|
} |
211 |
|
else |
212 |
|
{ |
213 |
4 |
id = p.getPrimaryUrlId(); |
214 |
4 |
break; |
215 |
|
} |
216 |
|
} |
217 |
4 |
return id; |
218 |
|
} |
219 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
220 |
0 |
@Override... |
221 |
|
public String getPrimaryTarget(String seqid) |
222 |
|
{ |
223 |
0 |
String target = null; |
224 |
0 |
for (UrlProviderI p : providers) |
225 |
|
{ |
226 |
0 |
if (p.getPrimaryTarget(seqid) == null) |
227 |
|
{ |
228 |
0 |
continue; |
229 |
|
} |
230 |
|
else |
231 |
|
{ |
232 |
0 |
target = p.getPrimaryTarget(seqid); |
233 |
0 |
break; |
234 |
|
} |
235 |
|
} |
236 |
0 |
return target; |
237 |
|
} |
238 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
239 |
4 |
@Override... |
240 |
|
public String choosePrimaryUrl() |
241 |
|
{ |
242 |
|
|
243 |
4 |
return customProvider.choosePrimaryUrl(); |
244 |
|
} |
245 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
246 |
20 |
@Override... |
247 |
|
public boolean isUserEntry(String id) |
248 |
|
{ |
249 |
20 |
return customProvider.isUserEntry(id); |
250 |
|
} |
251 |
|
} |