| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
package jalview.fts.service.uniprot; |
| 23 |
|
|
| 24 |
|
import jalview.bin.ApplicationSingletonProvider; |
| 25 |
|
import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI; |
| 26 |
|
import java.lang.invoke.MethodHandles; |
| 27 |
|
import java.net.MalformedURLException; |
| 28 |
|
import java.net.URL; |
| 29 |
|
|
| 30 |
|
import java.util.ArrayList; |
| 31 |
|
import java.util.Collection; |
| 32 |
|
import java.util.List; |
| 33 |
|
import java.util.Objects; |
| 34 |
|
|
| 35 |
|
import javax.ws.rs.core.MediaType; |
| 36 |
|
|
| 37 |
|
import com.sun.jersey.api.client.Client; |
| 38 |
|
import com.sun.jersey.api.client.ClientResponse; |
| 39 |
|
import com.sun.jersey.api.client.WebResource; |
| 40 |
|
import com.sun.jersey.api.client.config.DefaultClientConfig; |
| 41 |
|
|
| 42 |
|
import jalview.bin.Cache; |
| 43 |
|
import jalview.bin.Console; |
| 44 |
|
import jalview.fts.api.FTSData; |
| 45 |
|
import jalview.fts.api.FTSDataColumnI; |
| 46 |
|
import jalview.fts.api.FTSRestClientI; |
| 47 |
|
import jalview.fts.core.FTSRestClient; |
| 48 |
|
import jalview.fts.core.FTSRestRequest; |
| 49 |
|
import jalview.fts.core.FTSRestResponse; |
| 50 |
|
import jalview.util.ChannelProperties; |
| 51 |
|
import jalview.util.MessageManager; |
| 52 |
|
import jalview.util.Platform; |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| |
|
| 0% |
Uncovered Elements: 225 (225) |
Complexity: 73 |
Complexity Density: 0.53 |
|
| 79 |
|
public class UniProtFTSRestClient extends FTSRestClient |
| 80 |
|
implements ApplicationSingletonI,FTSRestClientI |
| 81 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 82 |
0 |
public static UniProtFTSRestClient getInstance()... |
| 83 |
|
{ |
| 84 |
0 |
return ApplicationSingletonProvider |
| 85 |
|
.getInstance(UniProtFTSRestClient.class); |
| 86 |
|
} |
| 87 |
|
private static final String DEFAULT_UNIPROT_DOMAIN = "https://rest.uniprot.org"; |
| 88 |
|
|
| 89 |
|
private static final String USER_AGENT = ChannelProperties |
| 90 |
|
.getProperty("app_name", "Jalview") + " " |
| 91 |
|
+ Cache.getDefault("VERSION", "Unknown") + " " |
| 92 |
|
+ UniProtFTSRestClient.class.toString() + " help@jalview.org"; |
| 93 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 94 |
0 |
static... |
| 95 |
|
{ |
| 96 |
0 |
Platform.addJ2SDirectDatabaseCall(DEFAULT_UNIPROT_DOMAIN); |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
|
| 100 |
|
public final String uniprotSearchEndpoint; |
| 101 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 102 |
0 |
private UniProtFTSRestClient()... |
| 103 |
|
{ |
| 104 |
0 |
super(); |
| 105 |
0 |
this.clearCursors(); |
| 106 |
0 |
uniprotSearchEndpoint = Cache.getDefault("UNIPROT_2022_DOMAIN", |
| 107 |
|
DEFAULT_UNIPROT_DOMAIN) + "/uniprotkb/search"; |
| 108 |
|
} |
| 109 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 110 |
0 |
@SuppressWarnings("unchecked")... |
| 111 |
|
@Override |
| 112 |
|
public FTSRestResponse executeRequest(FTSRestRequest uniprotRestRequest) |
| 113 |
|
throws Exception |
| 114 |
|
{ |
| 115 |
0 |
return executeRequest(uniprotRestRequest, null); |
| 116 |
|
} |
| 117 |
|
|
| |
|
| 0% |
Uncovered Elements: 84 (84) |
Complexity: 20 |
Complexity Density: 0.37 |
|
| 118 |
0 |
public FTSRestResponse executeRequest(FTSRestRequest uniprotRestRequest,... |
| 119 |
|
String cursor) throws Exception |
| 120 |
|
{ |
| 121 |
0 |
try |
| 122 |
|
{ |
| 123 |
0 |
String wantedFields = getDataColumnsFieldsAsCommaDelimitedString( |
| 124 |
|
uniprotRestRequest.getWantedFields()); |
| 125 |
0 |
int responseSize = (uniprotRestRequest.getResponseSize() == 0) |
| 126 |
|
? getDefaultResponsePageSize() |
| 127 |
|
: uniprotRestRequest.getResponseSize(); |
| 128 |
|
|
| 129 |
0 |
int offSet = uniprotRestRequest.getOffSet(); |
| 130 |
0 |
String query; |
| 131 |
0 |
if (isAdvancedQuery(uniprotRestRequest.getSearchTerm())) |
| 132 |
|
{ |
| 133 |
0 |
query = uniprotRestRequest.getSearchTerm(); |
| 134 |
|
} |
| 135 |
|
else |
| 136 |
|
{ |
| 137 |
0 |
query = uniprotRestRequest.getFieldToSearchBy().equalsIgnoreCase( |
| 138 |
|
"Search All") ? uniprotRestRequest.getSearchTerm() |
| 139 |
|
|
| 140 |
|
|
| 141 |
|
: uniprotRestRequest.getFieldToSearchBy() + ":" |
| 142 |
|
+ uniprotRestRequest.getSearchTerm(); |
| 143 |
|
} |
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
0 |
Client client; |
| 149 |
0 |
Class<ClientResponse> clientResponseClass; |
| 150 |
0 |
if (Platform.isJS()) |
| 151 |
|
{ |
| 152 |
|
|
| 153 |
0 |
client = (Client) (Object) new jalview.javascript.web.Client(); |
| 154 |
0 |
clientResponseClass = (Class<ClientResponse>) (Object) jalview.javascript.web.ClientResponse.class; |
| 155 |
|
} |
| 156 |
|
else |
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
|
| 162 |
|
{ |
| 163 |
|
|
| 164 |
0 |
client = Client.create(new DefaultClientConfig()); |
| 165 |
0 |
clientResponseClass = ClientResponse.class; |
| 166 |
|
} |
| 167 |
|
|
| 168 |
0 |
WebResource webResource = null; |
| 169 |
0 |
webResource = client.resource(uniprotSearchEndpoint) |
| 170 |
|
.queryParam("format", "tsv") |
| 171 |
|
.queryParam("fields", wantedFields) |
| 172 |
|
.queryParam("size", String.valueOf(responseSize)) |
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| 176 |
|
.queryParam("query", query); |
| 177 |
0 |
if (offSet != 0 && cursor != null && cursor.length() > 0) |
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
| 181 |
|
{ |
| 182 |
0 |
webResource = webResource.queryParam("cursor", cursor); |
| 183 |
|
} |
| 184 |
0 |
Console.debug( |
| 185 |
|
"Uniprot FTS Request: " + webResource.getURI().toString()); |
| 186 |
|
|
| 187 |
0 |
WebResource.Builder wrBuilder = webResource |
| 188 |
|
.accept(MediaType.TEXT_PLAIN); |
| 189 |
0 |
if (!Platform.isJS()) |
| 190 |
|
|
| 191 |
|
|
| 192 |
|
|
| 193 |
|
|
| 194 |
|
|
| 195 |
|
{ |
| 196 |
0 |
wrBuilder.header("User-Agent", USER_AGENT); |
| 197 |
|
} |
| 198 |
0 |
ClientResponse clientResponse = wrBuilder.get(clientResponseClass); |
| 199 |
|
|
| 200 |
0 |
if (!Platform.isJS()) |
| 201 |
|
|
| 202 |
|
|
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
|
{ |
| 207 |
0 |
if (clientResponse.getHeaders().containsKey("Link")) |
| 208 |
|
{ |
| 209 |
|
|
| 210 |
0 |
String linkHeader = clientResponse.getHeaders().get("Link") |
| 211 |
|
.get(0); |
| 212 |
0 |
if (linkHeader.indexOf("<") > -1) |
| 213 |
|
{ |
| 214 |
0 |
String temp = linkHeader.substring(linkHeader.indexOf("<") + 1); |
| 215 |
0 |
if (temp.indexOf(">") > -1) |
| 216 |
|
{ |
| 217 |
0 |
String nextUrl = temp.substring(0, temp.indexOf(">")); |
| 218 |
|
|
| 219 |
0 |
String nextCursor = getQueryParam("cursor", nextUrl); |
| 220 |
0 |
setCursor(cursorPage + 1, nextCursor); |
| 221 |
|
} |
| 222 |
|
} |
| 223 |
|
} |
| 224 |
|
} |
| 225 |
0 |
String uniProtTabDelimittedResponseString = clientResponse |
| 226 |
|
.getEntity(String.class); |
| 227 |
|
|
| 228 |
|
|
| 229 |
|
|
| 230 |
|
|
| 231 |
0 |
if (clientResponse.getStatus() != 200) |
| 232 |
|
{ |
| 233 |
0 |
String errorMessage = getMessageByHTTPStatusCode( |
| 234 |
|
clientResponse.getStatus(), "Uniprot"); |
| 235 |
0 |
throw new Exception(errorMessage); |
| 236 |
|
|
| 237 |
|
} |
| 238 |
0 |
int xTotalResults = 0; |
| 239 |
0 |
if (Platform.isJS()) |
| 240 |
|
{ |
| 241 |
0 |
xTotalResults = 1; |
| 242 |
|
} |
| 243 |
|
else |
| 244 |
|
{ |
| 245 |
|
|
| 246 |
|
|
| 247 |
|
|
| 248 |
0 |
List<String> resultsHeaders = clientResponse.getHeaders() |
| 249 |
|
.get("X-Total-Results"); |
| 250 |
0 |
if (resultsHeaders != null && resultsHeaders.size() >= 1) |
| 251 |
|
{ |
| 252 |
0 |
xTotalResults = Integer.valueOf(resultsHeaders.get(0)); |
| 253 |
|
} |
| 254 |
|
} |
| 255 |
0 |
clientResponse = null; |
| 256 |
0 |
client = null; |
| 257 |
0 |
return parseUniprotResponse(uniProtTabDelimittedResponseString, |
| 258 |
|
uniprotRestRequest, xTotalResults); |
| 259 |
|
} catch (Exception e) |
| 260 |
|
{ |
| 261 |
0 |
Console.warn("Problem with the query: " + e.getMessage()); |
| 262 |
0 |
Console.debug("Exception stacktrace:", e); |
| 263 |
0 |
String exceptionMsg = e.getMessage(); |
| 264 |
0 |
if (exceptionMsg.contains("SocketException")) |
| 265 |
|
{ |
| 266 |
|
|
| 267 |
0 |
throw new Exception(MessageManager.getString( |
| 268 |
|
"exception.unable_to_detect_internet_connection")); |
| 269 |
|
} |
| 270 |
0 |
else if (exceptionMsg.contains("UnknownHostException")) |
| 271 |
|
{ |
| 272 |
|
|
| 273 |
0 |
throw new Exception(MessageManager.formatMessage( |
| 274 |
|
"exception.fts_server_unreachable", "Uniprot")); |
| 275 |
|
} |
| 276 |
|
else |
| 277 |
|
{ |
| 278 |
0 |
throw e; |
| 279 |
|
} |
| 280 |
|
} |
| 281 |
|
} |
| 282 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 9 |
Complexity Density: 3 |
|
| 283 |
0 |
public boolean isAdvancedQuery(String query)... |
| 284 |
|
{ |
| 285 |
0 |
if (query.contains(" AND ") || query.contains(" OR ") |
| 286 |
|
|| query.contains(" NOT ") || query.contains(" ! ") |
| 287 |
|
|| query.contains(" || ") || query.contains(" && ") |
| 288 |
|
|| query.contains(":") || query.contains("-")) |
| 289 |
|
{ |
| 290 |
0 |
return true; |
| 291 |
|
} |
| 292 |
0 |
return false; |
| 293 |
|
} |
| 294 |
|
|
| |
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 6 |
Complexity Density: 0.35 |
|
| 295 |
0 |
public FTSRestResponse parseUniprotResponse(... |
| 296 |
|
String uniProtTabDelimittedResponseString, |
| 297 |
|
FTSRestRequest uniprotRestRequest, int xTotalResults) |
| 298 |
|
{ |
| 299 |
0 |
FTSRestResponse searchResult = new FTSRestResponse(); |
| 300 |
0 |
List<FTSData> result = null; |
| 301 |
0 |
if (uniProtTabDelimittedResponseString == null |
| 302 |
|
|| uniProtTabDelimittedResponseString.trim().isEmpty()) |
| 303 |
|
{ |
| 304 |
0 |
searchResult.setNumberOfItemsFound(0); |
| 305 |
0 |
return searchResult; |
| 306 |
|
} |
| 307 |
0 |
String[] foundDataRow = uniProtTabDelimittedResponseString.split("\n"); |
| 308 |
0 |
if (foundDataRow != null && foundDataRow.length > 0) |
| 309 |
|
{ |
| 310 |
0 |
result = new ArrayList<>(); |
| 311 |
0 |
boolean firstRow = true; |
| 312 |
0 |
for (String dataRow : foundDataRow) |
| 313 |
|
{ |
| 314 |
|
|
| 315 |
|
|
| 316 |
0 |
if (firstRow) |
| 317 |
|
{ |
| 318 |
0 |
firstRow = false; |
| 319 |
0 |
continue; |
| 320 |
|
} |
| 321 |
|
|
| 322 |
0 |
result.add(getFTSData(dataRow, uniprotRestRequest)); |
| 323 |
|
} |
| 324 |
0 |
searchResult.setNumberOfItemsFound(xTotalResults); |
| 325 |
0 |
searchResult.setSearchSummary(result); |
| 326 |
|
} |
| 327 |
0 |
return searchResult; |
| 328 |
|
} |
| 329 |
|
|
| 330 |
|
|
| 331 |
|
|
| 332 |
|
|
| 333 |
|
|
| 334 |
|
|
| 335 |
|
|
| 336 |
|
|
| 337 |
|
|
| 338 |
|
|
| 339 |
|
|
| 340 |
|
|
| 341 |
|
|
| 342 |
|
|
| 343 |
|
|
| 344 |
|
|
| 345 |
|
|
| 346 |
|
|
| 347 |
|
|
| 348 |
|
|
| 349 |
|
|
| 350 |
|
|
| 351 |
|
|
| 352 |
|
|
| 353 |
|
|
| 354 |
|
|
| 355 |
|
|
| 356 |
|
|
| 357 |
|
|
| 358 |
|
|
| 359 |
|
|
| 360 |
|
|
| 361 |
|
|
| 362 |
|
|
| 363 |
|
|
| |
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 8 |
Complexity Density: 0.38 |
|
| 364 |
0 |
public static FTSData getFTSData(String tabDelimittedDataStr,... |
| 365 |
|
FTSRestRequest request) |
| 366 |
|
{ |
| 367 |
0 |
String primaryKey = null; |
| 368 |
|
|
| 369 |
0 |
Object[] summaryRowData; |
| 370 |
|
|
| 371 |
0 |
Collection<FTSDataColumnI> diplayFields = request.getWantedFields(); |
| 372 |
0 |
int colCounter = 0; |
| 373 |
0 |
summaryRowData = new Object[diplayFields.size()]; |
| 374 |
0 |
String[] columns = tabDelimittedDataStr.split("\t"); |
| 375 |
0 |
for (FTSDataColumnI field : diplayFields) |
| 376 |
|
{ |
| 377 |
0 |
try |
| 378 |
|
{ |
| 379 |
0 |
String fieldData = columns[colCounter]; |
| 380 |
0 |
if (field.isPrimaryKeyColumn()) |
| 381 |
|
{ |
| 382 |
0 |
primaryKey = fieldData; |
| 383 |
0 |
summaryRowData[colCounter++] = primaryKey; |
| 384 |
|
} |
| 385 |
0 |
else if (fieldData == null || fieldData.isEmpty()) |
| 386 |
|
{ |
| 387 |
0 |
summaryRowData[colCounter++] = null; |
| 388 |
|
} |
| 389 |
|
else |
| 390 |
|
{ |
| 391 |
0 |
try |
| 392 |
|
{ |
| 393 |
0 |
summaryRowData[colCounter++] = (field.getDataType() |
| 394 |
|
.getDataTypeClass() == Integer.class) |
| 395 |
|
? Integer.valueOf(fieldData.replace(",", "")) |
| 396 |
0 |
: (field.getDataType() |
| 397 |
|
.getDataTypeClass() == Double.class) |
| 398 |
|
? Double.valueOf(fieldData) |
| 399 |
|
: fieldData; |
| 400 |
|
} catch (Exception e) |
| 401 |
|
{ |
| 402 |
0 |
e.printStackTrace(); |
| 403 |
0 |
jalview.bin.Console.outPrintln("offending value:" + fieldData); |
| 404 |
|
} |
| 405 |
|
} |
| 406 |
|
} catch (Exception e) |
| 407 |
|
{ |
| 408 |
|
|
| 409 |
|
} |
| 410 |
|
} |
| 411 |
|
|
| 412 |
0 |
final String primaryKey1 = primaryKey; |
| 413 |
|
|
| 414 |
0 |
final Object[] summaryRowData1 = summaryRowData; |
| 415 |
0 |
return new FTSData() |
| 416 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 417 |
0 |
@Override... |
| 418 |
|
public Object[] getSummaryData() |
| 419 |
|
{ |
| 420 |
0 |
return summaryRowData1; |
| 421 |
|
} |
| 422 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 423 |
0 |
@Override... |
| 424 |
|
public Object getPrimaryKey() |
| 425 |
|
{ |
| 426 |
0 |
return primaryKey1; |
| 427 |
|
} |
| 428 |
|
|
| 429 |
|
|
| 430 |
|
|
| 431 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 432 |
0 |
@Override... |
| 433 |
|
public String toString() |
| 434 |
|
{ |
| 435 |
0 |
StringBuilder summaryFieldValues = new StringBuilder(); |
| 436 |
0 |
for (Object summaryField : summaryRowData1) |
| 437 |
|
{ |
| 438 |
0 |
summaryFieldValues.append( |
| 439 |
0 |
summaryField == null ? " " : summaryField.toString()) |
| 440 |
|
.append("\t"); |
| 441 |
|
} |
| 442 |
0 |
return summaryFieldValues.toString(); |
| 443 |
|
} |
| 444 |
|
|
| 445 |
|
|
| 446 |
|
|
| 447 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 448 |
0 |
@Override... |
| 449 |
|
public int hashCode() |
| 450 |
|
{ |
| 451 |
0 |
return Objects.hash(primaryKey1, this.toString()); |
| 452 |
|
} |
| 453 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 454 |
0 |
@Override... |
| 455 |
|
public boolean equals(Object that) |
| 456 |
|
{ |
| 457 |
0 |
return this.toString().equals(that.toString()); |
| 458 |
|
} |
| 459 |
|
}; |
| 460 |
|
} |
| 461 |
|
|
| 462 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 463 |
0 |
@Override... |
| 464 |
|
public String getColumnDataConfigFileName() |
| 465 |
|
{ |
| 466 |
0 |
return "/fts/uniprot_data_columns-2022.txt"; |
| 467 |
|
} |
| 468 |
|
|
| 469 |
|
|
| 470 |
|
|
| 471 |
|
|
| 472 |
|
private ArrayList<String> cursors; |
| 473 |
|
|
| 474 |
|
private int cursorPage = 0; |
| 475 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 476 |
0 |
protected int getCursorPage()... |
| 477 |
|
{ |
| 478 |
0 |
return cursorPage; |
| 479 |
|
} |
| 480 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 481 |
0 |
protected void setCursorPage(int i)... |
| 482 |
|
{ |
| 483 |
0 |
cursorPage = i; |
| 484 |
|
} |
| 485 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 486 |
0 |
protected void setPrevCursorPage()... |
| 487 |
|
{ |
| 488 |
0 |
if (cursorPage > 0) |
| 489 |
0 |
cursorPage--; |
| 490 |
|
} |
| 491 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 492 |
0 |
protected void setNextCursorPage()... |
| 493 |
|
{ |
| 494 |
0 |
cursorPage++; |
| 495 |
|
} |
| 496 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 497 |
0 |
protected void clearCursors()... |
| 498 |
|
{ |
| 499 |
0 |
cursors = new ArrayList(10); |
| 500 |
|
} |
| 501 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 502 |
0 |
protected String getCursor(int i)... |
| 503 |
|
{ |
| 504 |
0 |
return cursors.get(i); |
| 505 |
|
} |
| 506 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 507 |
0 |
protected String getNextCursor()... |
| 508 |
|
{ |
| 509 |
0 |
if (cursors.size() < cursorPage + 2) |
| 510 |
0 |
return null; |
| 511 |
0 |
return cursors.get(cursorPage + 1); |
| 512 |
|
} |
| 513 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 514 |
0 |
protected String getPrevCursor()... |
| 515 |
|
{ |
| 516 |
0 |
if (cursorPage == 0) |
| 517 |
0 |
return null; |
| 518 |
0 |
return cursors.get(cursorPage - 1); |
| 519 |
|
} |
| 520 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 521 |
0 |
protected void setCursor(int i, String c)... |
| 522 |
|
{ |
| 523 |
0 |
cursors.ensureCapacity(i + 1); |
| 524 |
0 |
while (cursors.size() <= i) |
| 525 |
|
{ |
| 526 |
0 |
cursors.add(null); |
| 527 |
|
} |
| 528 |
0 |
cursors.set(i, c); |
| 529 |
0 |
Console.debug( |
| 530 |
|
"Set UniprotFRSRestClient cursors[" + i + "] to '" + c + "'"); |
| 531 |
|
|
| 532 |
|
} |
| 533 |
|
|
| |
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 6 |
Complexity Density: 0.55 |
|
| 534 |
0 |
public static String getQueryParam(String param, String u)... |
| 535 |
|
{ |
| 536 |
0 |
if (param == null || u == null) |
| 537 |
0 |
return null; |
| 538 |
0 |
try |
| 539 |
|
{ |
| 540 |
0 |
URL url = new URL(u); |
| 541 |
0 |
String[] kevs = url.getQuery().split("&"); |
| 542 |
0 |
for (int j = 0; j < kevs.length; j++) |
| 543 |
|
{ |
| 544 |
0 |
String[] kev = kevs[j].split("=", 2); |
| 545 |
0 |
if (param.equals(kev[0])) |
| 546 |
|
{ |
| 547 |
0 |
return kev[1]; |
| 548 |
|
} |
| 549 |
|
} |
| 550 |
|
} catch (MalformedURLException e) |
| 551 |
|
{ |
| 552 |
0 |
Console.warn("Could not obtain next page 'cursor' value from 'u"); |
| 553 |
|
} |
| 554 |
0 |
return null; |
| 555 |
|
} |
| 556 |
|
} |