| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.fts.service.pdb; |
| 22 |
|
|
| 23 |
|
import java.io.File; |
| 24 |
|
import java.io.FileInputStream; |
| 25 |
|
import java.io.FileReader; |
| 26 |
|
import java.net.URI; |
| 27 |
|
import java.nio.CharBuffer; |
| 28 |
|
import java.util.ArrayList; |
| 29 |
|
import java.util.Collection; |
| 30 |
|
import java.util.Iterator; |
| 31 |
|
import java.util.List; |
| 32 |
|
import java.util.Map; |
| 33 |
|
import java.util.Objects; |
| 34 |
|
|
| 35 |
|
import javax.ws.rs.core.MediaType; |
| 36 |
|
|
| 37 |
|
import org.json.simple.parser.ParseException; |
| 38 |
|
|
| 39 |
|
import com.sun.jersey.api.client.Client; |
| 40 |
|
import com.sun.jersey.api.client.ClientResponse; |
| 41 |
|
import com.sun.jersey.api.client.WebResource; |
| 42 |
|
import com.sun.jersey.api.client.config.DefaultClientConfig; |
| 43 |
|
|
| 44 |
|
import jalview.datamodel.SequenceI; |
| 45 |
|
import jalview.fts.api.FTSData; |
| 46 |
|
import jalview.fts.api.FTSDataColumnI; |
| 47 |
|
import jalview.fts.api.FTSRestClientI; |
| 48 |
|
import jalview.fts.api.StructureFTSRestClientI; |
| 49 |
|
import jalview.fts.core.FTSDataColumnPreferences; |
| 50 |
|
import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource; |
| 51 |
|
import jalview.fts.core.FTSRestClient; |
| 52 |
|
import jalview.fts.core.FTSRestRequest; |
| 53 |
|
import jalview.fts.core.FTSRestResponse; |
| 54 |
|
import jalview.fts.service.alphafold.AlphafoldRestClient; |
| 55 |
|
import jalview.util.JSONUtils; |
| 56 |
|
import jalview.util.MessageManager; |
| 57 |
|
import jalview.util.Platform; |
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
@author |
| 63 |
|
|
| |
|
| 65.1% |
Uncovered Elements: 80 (229) |
Complexity: 60 |
Complexity Density: 0.4 |
|
| 64 |
|
public class PDBFTSRestClient extends FTSRestClient |
| 65 |
|
implements StructureFTSRestClientI |
| 66 |
|
{ |
| 67 |
|
|
| 68 |
|
private static FTSRestClientI instance = null; |
| 69 |
|
|
| 70 |
|
public static final String PDB_SEARCH_ENDPOINT = "https://www.ebi.ac.uk/pdbe/search/pdb/select?"; |
| 71 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 72 |
5 |
protected PDBFTSRestClient()... |
| 73 |
|
{ |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
@param |
| 80 |
|
|
| 81 |
|
@return |
| 82 |
|
@throws |
| 83 |
|
|
| |
|
| 66% |
Uncovered Elements: 32 (94) |
Complexity: 24 |
Complexity Density: 0.41 |
|
| 84 |
34 |
@SuppressWarnings({ "unused", "unchecked" })... |
| 85 |
|
@Override |
| 86 |
|
public FTSRestResponse executeRequest(FTSRestRequest pdbRestRequest) |
| 87 |
|
throws Exception |
| 88 |
|
{ |
| 89 |
34 |
try |
| 90 |
|
{ |
| 91 |
34 |
String wantedFields = getDataColumnsFieldsAsCommaDelimitedString( |
| 92 |
|
pdbRestRequest.getWantedFields()); |
| 93 |
34 |
int responseSize = (pdbRestRequest.getResponseSize() == 0) |
| 94 |
|
? getDefaultResponsePageSize() |
| 95 |
|
: pdbRestRequest.getResponseSize(); |
| 96 |
34 |
int offSet = pdbRestRequest.getOffSet(); |
| 97 |
34 |
String sortParam = null; |
| 98 |
34 |
if (pdbRestRequest.getFieldToSortBy() == null |
| 99 |
|
|| pdbRestRequest.getFieldToSortBy().trim().isEmpty()) |
| 100 |
|
{ |
| 101 |
32 |
sortParam = ""; |
| 102 |
|
} |
| 103 |
|
else |
| 104 |
|
{ |
| 105 |
2 |
if (pdbRestRequest.getFieldToSortBy() |
| 106 |
|
.equalsIgnoreCase("Resolution")) |
| 107 |
|
{ |
| 108 |
0 |
sortParam = pdbRestRequest.getFieldToSortBy() |
| 109 |
0 |
+ (pdbRestRequest.isAscending() ? " asc" : " desc"); |
| 110 |
|
} |
| 111 |
|
else |
| 112 |
|
{ |
| 113 |
2 |
sortParam = pdbRestRequest.getFieldToSortBy() |
| 114 |
2 |
+ (pdbRestRequest.isAscending() ? " desc" : " asc"); |
| 115 |
|
} |
| 116 |
|
} |
| 117 |
|
|
| 118 |
34 |
String facetPivot = (pdbRestRequest.getFacetPivot() == null |
| 119 |
|
|| pdbRestRequest.getFacetPivot().isEmpty()) ? "" |
| 120 |
|
: pdbRestRequest.getFacetPivot(); |
| 121 |
34 |
String facetPivotMinCount = String |
| 122 |
|
.valueOf(pdbRestRequest.getFacetPivotMinCount()); |
| 123 |
|
|
| 124 |
34 |
String query = pdbRestRequest.getFieldToSearchBy() |
| 125 |
|
+ pdbRestRequest.getSearchTerm() |
| 126 |
34 |
+ (pdbRestRequest.isAllowEmptySeq() ? "" |
| 127 |
|
: " AND molecule_sequence:['' TO *]") |
| 128 |
34 |
+ (pdbRestRequest.isAllowUnpublishedEntries() ? "" |
| 129 |
|
: " AND status:REL"); |
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
34 |
Client client; |
| 137 |
34 |
Class<ClientResponse> clientResponseClass; |
| 138 |
34 |
if (Platform.isJS()) |
| 139 |
|
{ |
| 140 |
|
|
| 141 |
0 |
client = (Client) (Object) new jalview.javascript.web.Client(); |
| 142 |
0 |
clientResponseClass = (Class<ClientResponse>) (Object) jalview.javascript.web.ClientResponse.class; |
| 143 |
|
} |
| 144 |
|
else |
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
|
{ |
| 151 |
34 |
client = Client.create(new DefaultClientConfig()); |
| 152 |
34 |
clientResponseClass = ClientResponse.class; |
| 153 |
|
} |
| 154 |
|
|
| 155 |
34 |
WebResource webResource; |
| 156 |
34 |
if (pdbRestRequest.isFacet()) |
| 157 |
|
{ |
| 158 |
0 |
webResource = client.resource(PDB_SEARCH_ENDPOINT) |
| 159 |
|
.queryParam("wt", "json").queryParam("fl", wantedFields) |
| 160 |
|
.queryParam("rows", String.valueOf(responseSize)) |
| 161 |
|
.queryParam("q", query) |
| 162 |
|
.queryParam("start", String.valueOf(offSet)) |
| 163 |
|
.queryParam("sort", sortParam).queryParam("facet", "true") |
| 164 |
|
.queryParam("facet.pivot", facetPivot) |
| 165 |
|
.queryParam("facet.pivot.mincount", facetPivotMinCount); |
| 166 |
|
} |
| 167 |
|
else |
| 168 |
|
{ |
| 169 |
34 |
webResource = client.resource(PDB_SEARCH_ENDPOINT) |
| 170 |
|
.queryParam("wt", "json").queryParam("fl", wantedFields) |
| 171 |
|
.queryParam("rows", String.valueOf(responseSize)) |
| 172 |
|
.queryParam("start", String.valueOf(offSet)) |
| 173 |
|
.queryParam("q", query).queryParam("sort", sortParam); |
| 174 |
|
} |
| 175 |
|
|
| 176 |
34 |
URI uri = webResource.getURI(); |
| 177 |
|
|
| 178 |
34 |
jalview.bin.Console.outPrintln(uri); |
| 179 |
34 |
ClientResponse clientResponse = null; |
| 180 |
34 |
int responseStatus = -1; |
| 181 |
|
|
| 182 |
|
|
| 183 |
34 |
Map<String, Object> jsonObj = null; |
| 184 |
34 |
String responseString = null; |
| 185 |
|
|
| 186 |
34 |
jalview.bin.Console |
| 187 |
|
.outPrintln("query >>>>>>> " + pdbRestRequest.toString()); |
| 188 |
|
|
| 189 |
34 |
if (!isMocked()) |
| 190 |
|
{ |
| 191 |
|
|
| 192 |
0 |
clientResponse = webResource.accept(MediaType.APPLICATION_JSON) |
| 193 |
|
.get(clientResponseClass); |
| 194 |
0 |
responseStatus = clientResponse.getStatus(); |
| 195 |
|
} |
| 196 |
|
else |
| 197 |
|
{ |
| 198 |
|
|
| 199 |
34 |
if (mockQueries.containsKey(uri.toString())) |
| 200 |
|
{ |
| 201 |
32 |
responseStatus = 200; |
| 202 |
|
} |
| 203 |
|
else |
| 204 |
|
{ |
| 205 |
|
|
| 206 |
2 |
responseStatus = 400; |
| 207 |
|
} |
| 208 |
|
} |
| 209 |
|
|
| 210 |
|
|
| 211 |
34 |
switch (responseStatus) |
| 212 |
|
{ |
| 213 |
32 |
case 200: |
| 214 |
|
|
| 215 |
32 |
if (isMocked()) |
| 216 |
|
{ |
| 217 |
32 |
responseString = mockQueries.get(uri.toString()); |
| 218 |
|
} |
| 219 |
|
else |
| 220 |
|
{ |
| 221 |
0 |
if (Platform.isJS()) |
| 222 |
|
{ |
| 223 |
0 |
jsonObj = clientResponse.getEntity(Map.class); |
| 224 |
|
} |
| 225 |
|
else |
| 226 |
|
{ |
| 227 |
0 |
responseString = clientResponse.getEntity(String.class); |
| 228 |
|
} |
| 229 |
|
} |
| 230 |
32 |
break; |
| 231 |
2 |
case 400: |
| 232 |
2 |
throw new Exception(isMocked() ? "400 response (Mocked)" |
| 233 |
|
: parseJsonExceptionString(responseString)); |
| 234 |
0 |
default: |
| 235 |
0 |
throw new Exception( |
| 236 |
|
getMessageByHTTPStatusCode(responseStatus, "PDB")); |
| 237 |
|
} |
| 238 |
|
|
| 239 |
|
|
| 240 |
32 |
return parsePDBJsonResponse(responseString, jsonObj, pdbRestRequest); |
| 241 |
|
} catch (Exception e) |
| 242 |
|
{ |
| 243 |
2 |
if (e.getMessage() == null) |
| 244 |
|
{ |
| 245 |
0 |
throw (e); |
| 246 |
|
} |
| 247 |
2 |
String exceptionMsg = e.getMessage(); |
| 248 |
2 |
if (exceptionMsg.contains("SocketException")) |
| 249 |
|
{ |
| 250 |
|
|
| 251 |
0 |
throw new Exception(MessageManager.getString( |
| 252 |
|
"exception.unable_to_detect_internet_connection")); |
| 253 |
|
} |
| 254 |
2 |
else if (exceptionMsg.contains("UnknownHostException")) |
| 255 |
|
{ |
| 256 |
|
|
| 257 |
0 |
throw new Exception(MessageManager.formatMessage( |
| 258 |
|
"exception.fts_server_unreachable", "PDB Solr")); |
| 259 |
|
} |
| 260 |
|
else |
| 261 |
|
{ |
| 262 |
2 |
throw e; |
| 263 |
|
} |
| 264 |
|
} |
| 265 |
|
} |
| 266 |
|
|
| 267 |
|
|
| 268 |
|
|
| 269 |
|
|
| 270 |
|
@param |
| 271 |
|
|
| 272 |
|
@return |
| 273 |
|
|
| |
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 2 |
Complexity Density: 0.12 |
|
| 274 |
0 |
@SuppressWarnings("unchecked")... |
| 275 |
|
public static String parseJsonExceptionString(String jsonErrorResponse) |
| 276 |
|
{ |
| 277 |
0 |
StringBuilder errorMessage = new StringBuilder( |
| 278 |
|
"\n============= PDB Rest Client RunTime error =============\n"); |
| 279 |
|
|
| 280 |
|
|
| 281 |
|
|
| 282 |
|
|
| 283 |
|
|
| 284 |
|
|
| 285 |
|
|
| 286 |
|
|
| 287 |
|
|
| 288 |
|
|
| 289 |
|
|
| 290 |
|
|
| 291 |
|
|
| 292 |
|
|
| 293 |
|
|
| 294 |
|
|
| 295 |
|
|
| 296 |
|
|
| 297 |
|
|
| 298 |
|
|
| 299 |
|
|
| 300 |
0 |
try |
| 301 |
|
{ |
| 302 |
0 |
Map<String, Object> jsonObj = (Map<String, Object>) JSONUtils |
| 303 |
|
.parse(jsonErrorResponse); |
| 304 |
0 |
Map<String, Object> errorResponse = (Map<String, Object>) jsonObj |
| 305 |
|
.get("error"); |
| 306 |
|
|
| 307 |
0 |
Map<String, Object> responseHeader = (Map<String, Object>) jsonObj |
| 308 |
|
.get("responseHeader"); |
| 309 |
0 |
Map<String, Object> paramsObj = (Map<String, Object>) responseHeader |
| 310 |
|
.get("params"); |
| 311 |
0 |
String status = responseHeader.get("status").toString(); |
| 312 |
0 |
String message = errorResponse.get("msg").toString(); |
| 313 |
0 |
String query = paramsObj.get("q").toString(); |
| 314 |
0 |
String fl = paramsObj.get("fl").toString(); |
| 315 |
|
|
| 316 |
0 |
errorMessage.append("Status: ").append(status).append("\n"); |
| 317 |
0 |
errorMessage.append("Message: ").append(message).append("\n"); |
| 318 |
0 |
errorMessage.append("query: ").append(query).append("\n"); |
| 319 |
0 |
errorMessage.append("fl: ").append(fl).append("\n"); |
| 320 |
|
|
| 321 |
|
} catch (ParseException e) |
| 322 |
|
{ |
| 323 |
0 |
e.printStackTrace(); |
| 324 |
|
} |
| 325 |
0 |
return errorMessage.toString(); |
| 326 |
|
} |
| 327 |
|
|
| 328 |
|
|
| 329 |
|
|
| 330 |
|
|
| 331 |
|
|
| 332 |
|
|
| 333 |
|
@param |
| 334 |
|
|
| 335 |
|
@param |
| 336 |
|
|
| 337 |
|
|
| 338 |
|
@return |
| 339 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 340 |
0 |
public static FTSRestResponse parsePDBJsonResponse(... |
| 341 |
|
String pdbJsonResponseString, FTSRestRequest pdbRestRequest) |
| 342 |
|
{ |
| 343 |
0 |
return parsePDBJsonResponse(pdbJsonResponseString, |
| 344 |
|
(Map<String, Object>) null, pdbRestRequest); |
| 345 |
|
} |
| 346 |
|
|
| |
|
| 88% |
Uncovered Elements: 3 (25) |
Complexity: 5 |
Complexity Density: 0.26 |
|
| 347 |
32 |
@SuppressWarnings("unchecked")... |
| 348 |
|
public static FTSRestResponse parsePDBJsonResponse( |
| 349 |
|
String pdbJsonResponseString, Map<String, Object> jsonObj, |
| 350 |
|
FTSRestRequest pdbRestRequest) |
| 351 |
|
{ |
| 352 |
32 |
FTSRestResponse searchResult = new FTSRestResponse(); |
| 353 |
32 |
List<FTSData> result = null; |
| 354 |
32 |
try |
| 355 |
|
{ |
| 356 |
32 |
if (jsonObj == null) |
| 357 |
|
{ |
| 358 |
32 |
jsonObj = (Map<String, Object>) JSONUtils |
| 359 |
|
.parse(pdbJsonResponseString); |
| 360 |
|
} |
| 361 |
32 |
Map<String, Object> pdbResponse = (Map<String, Object>) jsonObj |
| 362 |
|
.get("response"); |
| 363 |
32 |
String queryTime = ((Map<String, Object>) jsonObj |
| 364 |
|
.get("responseHeader")).get("QTime").toString(); |
| 365 |
32 |
int numFound = Integer |
| 366 |
|
.valueOf(pdbResponse.get("numFound").toString()); |
| 367 |
32 |
List<Object> docs = (List<Object>) pdbResponse.get("docs"); |
| 368 |
|
|
| 369 |
32 |
result = new ArrayList<FTSData>(); |
| 370 |
32 |
if (numFound > 0) |
| 371 |
|
{ |
| 372 |
|
|
| 373 |
8278 |
for (Iterator<Object> docIter = docs.iterator(); docIter.hasNext();) |
| 374 |
|
{ |
| 375 |
8246 |
Map<String, Object> doc = (Map<String, Object>) docIter.next(); |
| 376 |
8246 |
result.add(getFTSData(doc, pdbRestRequest)); |
| 377 |
|
} |
| 378 |
|
} |
| 379 |
|
|
| 380 |
|
|
| 381 |
32 |
searchResult.setNumberOfItemsFound(numFound); |
| 382 |
32 |
searchResult.setResponseTime(queryTime); |
| 383 |
32 |
searchResult.setSearchSummary(result); |
| 384 |
|
|
| 385 |
|
} catch (ParseException e) |
| 386 |
|
{ |
| 387 |
0 |
e.printStackTrace(); |
| 388 |
|
} |
| 389 |
32 |
return searchResult; |
| 390 |
|
} |
| 391 |
|
|
| |
|
| 79.5% |
Uncovered Elements: 8 (39) |
Complexity: 10 |
Complexity Density: 0.4 |
|
| 392 |
8246 |
public static FTSData getFTSData(Map<String, Object> pdbJsonDoc,... |
| 393 |
|
FTSRestRequest request) |
| 394 |
|
{ |
| 395 |
|
|
| 396 |
8246 |
String primaryKey = null; |
| 397 |
|
|
| 398 |
8246 |
Object[] summaryRowData; |
| 399 |
|
|
| 400 |
8246 |
SequenceI associatedSequence; |
| 401 |
|
|
| 402 |
8246 |
Collection<FTSDataColumnI> diplayFields = request.getWantedFields(); |
| 403 |
8246 |
SequenceI associatedSeq = request.getAssociatedSequence(); |
| 404 |
8246 |
int colCounter = 0; |
| 405 |
8246 |
summaryRowData = new Object[(associatedSeq != null) |
| 406 |
|
? diplayFields.size() + 1 |
| 407 |
|
: diplayFields.size()]; |
| 408 |
8246 |
if (associatedSeq != null) |
| 409 |
|
{ |
| 410 |
0 |
associatedSequence = associatedSeq; |
| 411 |
0 |
summaryRowData[0] = associatedSequence; |
| 412 |
0 |
colCounter = 1; |
| 413 |
|
} |
| 414 |
|
|
| 415 |
8246 |
for (FTSDataColumnI field : diplayFields) |
| 416 |
|
{ |
| 417 |
|
|
| 418 |
32984 |
String fieldData = (pdbJsonDoc.get(field.getCode()) == null) ? "" |
| 419 |
|
: pdbJsonDoc.get(field.getCode()).toString(); |
| 420 |
|
|
| 421 |
32984 |
if (field.isPrimaryKeyColumn()) |
| 422 |
|
{ |
| 423 |
8246 |
primaryKey = fieldData; |
| 424 |
8246 |
summaryRowData[colCounter++] = primaryKey; |
| 425 |
|
} |
| 426 |
24738 |
else if (fieldData == null || fieldData.isEmpty()) |
| 427 |
|
{ |
| 428 |
480 |
summaryRowData[colCounter++] = null; |
| 429 |
|
} |
| 430 |
|
else |
| 431 |
|
{ |
| 432 |
24258 |
try |
| 433 |
|
{ |
| 434 |
24258 |
summaryRowData[colCounter++] = (field.getDataType() |
| 435 |
|
.getDataTypeClass() == Integer.class) |
| 436 |
|
? Integer.valueOf(fieldData) |
| 437 |
24258 |
: (field.getDataType() |
| 438 |
|
.getDataTypeClass() == Double.class) |
| 439 |
|
? Double.valueOf(fieldData) |
| 440 |
|
: sanitiseData(fieldData); |
| 441 |
|
} catch (Exception e) |
| 442 |
|
{ |
| 443 |
0 |
e.printStackTrace(); |
| 444 |
0 |
jalview.bin.Console.outPrintln("offending value:" + fieldData); |
| 445 |
|
} |
| 446 |
|
} |
| 447 |
|
} |
| 448 |
|
|
| 449 |
8246 |
final String primaryKey1 = primaryKey; |
| 450 |
|
|
| 451 |
8246 |
final Object[] summaryRowData1 = summaryRowData; |
| 452 |
8246 |
return new FTSData() |
| 453 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 454 |
11201663 |
@Override... |
| 455 |
|
public Object[] getSummaryData() |
| 456 |
|
{ |
| 457 |
11201663 |
return summaryRowData1; |
| 458 |
|
} |
| 459 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 460 |
0 |
@Override... |
| 461 |
|
public Object getPrimaryKey() |
| 462 |
|
{ |
| 463 |
0 |
return primaryKey1; |
| 464 |
|
} |
| 465 |
|
|
| 466 |
|
|
| 467 |
|
|
| 468 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 469 |
0 |
@Override... |
| 470 |
|
public String toString() |
| 471 |
|
{ |
| 472 |
0 |
StringBuilder summaryFieldValues = new StringBuilder(); |
| 473 |
0 |
for (Object summaryField : summaryRowData1) |
| 474 |
|
{ |
| 475 |
0 |
summaryFieldValues.append( |
| 476 |
0 |
summaryField == null ? " " : summaryField.toString()) |
| 477 |
|
.append("\t"); |
| 478 |
|
} |
| 479 |
0 |
return summaryFieldValues.toString(); |
| 480 |
|
} |
| 481 |
|
|
| 482 |
|
|
| 483 |
|
|
| 484 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 485 |
0 |
@Override... |
| 486 |
|
public int hashCode() |
| 487 |
|
{ |
| 488 |
0 |
return Objects.hash(primaryKey1, this.toString()); |
| 489 |
|
} |
| 490 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 491 |
0 |
@Override... |
| 492 |
|
public boolean equals(Object that) |
| 493 |
|
{ |
| 494 |
0 |
return this.toString().equals(that.toString()); |
| 495 |
|
} |
| 496 |
|
}; |
| 497 |
|
} |
| 498 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 499 |
16492 |
private static String sanitiseData(String data)... |
| 500 |
|
{ |
| 501 |
16492 |
String cleanData = data.replaceAll("\\[\"", "").replaceAll("\\]\"", "") |
| 502 |
|
.replaceAll("\\[", "").replaceAll("\\]", "") |
| 503 |
|
.replaceAll("\",\"", ", ").replaceAll("\"", ""); |
| 504 |
16492 |
return cleanData; |
| 505 |
|
} |
| 506 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 507 |
5 |
@Override... |
| 508 |
|
public String getColumnDataConfigFileName() |
| 509 |
|
{ |
| 510 |
5 |
return "/fts/pdb_data_columns.txt"; |
| 511 |
|
} |
| 512 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 513 |
197 |
public static FTSRestClientI getInstance()... |
| 514 |
|
{ |
| 515 |
197 |
if (instance == null) |
| 516 |
|
{ |
| 517 |
5 |
instance = new PDBFTSRestClient(); |
| 518 |
|
} |
| 519 |
197 |
return instance; |
| 520 |
|
} |
| 521 |
|
|
| 522 |
|
private Collection<FTSDataColumnI> allDefaultDisplayedStructureDataColumns; |
| 523 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 524 |
85 |
@Override... |
| 525 |
|
public Collection<FTSDataColumnI> getAllDefaultDisplayedStructureDataColumns() |
| 526 |
|
{ |
| 527 |
85 |
if (allDefaultDisplayedStructureDataColumns == null |
| 528 |
|
|| allDefaultDisplayedStructureDataColumns.isEmpty()) |
| 529 |
|
{ |
| 530 |
5 |
allDefaultDisplayedStructureDataColumns = new ArrayList<>(); |
| 531 |
5 |
allDefaultDisplayedStructureDataColumns |
| 532 |
|
.addAll(super.getAllDefaultDisplayedFTSDataColumns()); |
| 533 |
|
} |
| 534 |
85 |
return allDefaultDisplayedStructureDataColumns; |
| 535 |
|
} |
| 536 |
|
|
| |
|
| 64.3% |
Uncovered Elements: 5 (14) |
Complexity: 4 |
Complexity Density: 0.29 |
|
| 537 |
86 |
@Override... |
| 538 |
|
public String[] getPreferencesColumnsFor(PreferenceSource source) |
| 539 |
|
{ |
| 540 |
86 |
String[] columnNames = null; |
| 541 |
86 |
switch (source) |
| 542 |
|
{ |
| 543 |
1 |
case SEARCH_SUMMARY: |
| 544 |
1 |
columnNames = new String[] { "", "Display", "Group" }; |
| 545 |
1 |
break; |
| 546 |
85 |
case STRUCTURE_CHOOSER: |
| 547 |
85 |
columnNames = new String[] { "", "Display", "Group" }; |
| 548 |
85 |
break; |
| 549 |
0 |
case PREFERENCES: |
| 550 |
0 |
columnNames = new String[] { "PDB Field", "Show in search summary", |
| 551 |
|
"Show in structure summary" }; |
| 552 |
0 |
break; |
| 553 |
0 |
default: |
| 554 |
0 |
break; |
| 555 |
|
} |
| 556 |
86 |
return columnNames; |
| 557 |
|
} |
| 558 |
|
} |