Revision c5e6fc74
Added by Andreas Kohlbecker over 8 years ago
src/main/java/org/bgbm/biovel/drf/checklist/BgbmEditClient.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import org.apache.http.HttpHost; |
13 | 13 |
import org.apache.http.ParseException; |
14 |
import org.bgbm.biovel.drf.rest.ServiceProviderInfo; |
|
14 |
import org.bgbm.biovel.drf.client.ServiceProviderInfo; |
|
15 |
import org.bgbm.biovel.drf.query.RestClient; |
|
15 | 16 |
import org.bgbm.biovel.drf.tnr.msg.Classification; |
16 | 17 |
import org.bgbm.biovel.drf.tnr.msg.NameType; |
17 | 18 |
import org.bgbm.biovel.drf.tnr.msg.Query; |
... | ... | |
29 | 30 |
import org.json.simple.JSONObject; |
30 | 31 |
import org.json.simple.parser.JSONParser; |
31 | 32 |
|
32 |
public class BgbmEditClient extends AggregateChecklistClient { |
|
33 |
public class BgbmEditClient extends AggregateChecklistClient<RestClient> {
|
|
33 | 34 |
|
35 |
/** |
|
36 |
* |
|
37 |
*/ |
|
34 | 38 |
public static final String ID = "bgbm-cdm-server"; |
35 | 39 |
public static final String LABEL = "Name catalogues served by the BGBM CDM Server"; |
36 | 40 |
public static final String DOC_URL = "http://wp5.e-taxonomy.eu/cdmlib/rest-api-name-catalogue.html"; |
37 | 41 |
public static final String COPYRIGHT_URL = "http://wp5.e-taxonomy.eu/cdmlib/license.html"; |
38 | 42 |
private static final String SERVER_PATH_PREFIX = "/"; |
43 |
private static final HttpHost HTTP_HOST = new HttpHost("api.cybertaxonomy.org", 80); // new HttpHost("test.e-taxonomy.eu", 80); |
|
39 | 44 |
|
40 | 45 |
|
41 | 46 |
private final Map<String,Query> taxonIdQueryMap = new HashMap<String,Query>(); |
... | ... | |
57 | 62 |
} |
58 | 63 |
|
59 | 64 |
@Override |
60 |
public HttpHost getHost() { |
|
61 |
return new HttpHost("api.cybertaxonomy.org", 80); |
|
62 |
// return new HttpHost("test.e-taxonomy.eu", 80); |
|
65 |
public void initQueryClient() { |
|
66 |
queryClient = new RestClient(HTTP_HOST); |
|
63 | 67 |
} |
64 | 68 |
|
65 | 69 |
|
... | ... | |
314 | 318 |
Query.Request request = queryList.get(0).getRequest(); |
315 | 319 |
|
316 | 320 |
for (ServiceProviderInfo checklistInfo : getServiceProviderInfo().getSubChecklists()) { |
317 |
URI namesUri = buildUriFromQueryList(queryList, |
|
321 |
URI namesUri = queryClient.buildUriFromQueryList(queryList,
|
|
318 | 322 |
SERVER_PATH_PREFIX + checklistInfo.getId() + "/name_catalogue.json", |
319 | 323 |
"query", |
320 | 324 |
"*", null); |
321 | 325 |
|
322 |
String searchResponseBody = processRESTService(namesUri); |
|
326 |
String searchResponseBody = queryClient.processRESTService(namesUri);
|
|
323 | 327 |
|
324 | 328 |
buildTaxonIdMapsFromCatalogueServiceResponse(queryList, searchResponseBody); |
325 | 329 |
|
326 | 330 |
List<String> taxonIdList = new ArrayList<String>(taxonIdQueryMap.keySet()); |
327 | 331 |
|
328 | 332 |
if(taxonIdList.size() > 0) { |
329 |
URI taxonUri = buildUriFromQueryStringList(taxonIdList, |
|
333 |
URI taxonUri = queryClient.buildUriFromQueryStringList(taxonIdList,
|
|
330 | 334 |
SERVER_PATH_PREFIX + checklistInfo.getId() + "/name_catalogue/taxon.json", |
331 | 335 |
"taxonUuid", |
332 | 336 |
null); |
333 |
String taxonResponseBody = processRESTService(taxonUri); |
|
337 |
String taxonResponseBody = queryClient.processRESTService(taxonUri);
|
|
334 | 338 |
updateQueriesWithResponse(taxonResponseBody, checklistInfo, request); |
335 | 339 |
} |
336 | 340 |
} |
... | ... | |
374 | 378 |
for (ServiceProviderInfo checklistInfo : getServiceProviderInfo().getSubChecklists()) { |
375 | 379 |
// taxon/findByIdentifier.json?identifier=1&includeEntity=1 |
376 | 380 |
if(IdentifierUtils.checkLSID(identifier)){ |
377 |
URI namesUri = buildUriFromQueryList(queryList, |
|
381 |
URI namesUri = queryClient.buildUriFromQueryList(queryList,
|
|
378 | 382 |
SERVER_PATH_PREFIX + checklistInfo.getId() + "/authority/metadata.do", |
379 | 383 |
"lsid", |
380 | 384 |
null, |
381 | 385 |
null ); |
382 | 386 |
|
383 |
String responseBody = processRESTService(namesUri); |
|
387 |
String responseBody = queryClient.processRESTService(namesUri);
|
|
384 | 388 |
addTaxonToTaxonIdMap(queryList, responseBody); |
385 | 389 |
} else { |
386 |
URI namesUri = buildUriFromQueryList(queryList, |
|
390 |
URI namesUri = queryClient.buildUriFromQueryList(queryList,
|
|
387 | 391 |
SERVER_PATH_PREFIX + checklistInfo.getId() + "/taxon/findByIdentifier.json", |
388 | 392 |
"identifier", |
389 | 393 |
null, // like search for identifiers not supported by this client |
390 | 394 |
findByIdentifierParameters ); |
391 | 395 |
|
392 |
String responseBody = processRESTService(namesUri); |
|
396 |
String responseBody = queryClient.processRESTService(namesUri);
|
|
393 | 397 |
addTaxaToTaxonIdMapFromIdentifierServiceResponse(queryList, responseBody); |
394 | 398 |
} |
395 | 399 |
|
396 | 400 |
List<String> taxonIdList = new ArrayList<String>(taxonIdQueryMap.keySet()); |
397 | 401 |
|
398 | 402 |
if(taxonIdList.size() > 0) { |
399 |
URI taxonUri = buildUriFromQueryStringList(taxonIdList, |
|
403 |
URI taxonUri = queryClient.buildUriFromQueryStringList(taxonIdList,
|
|
400 | 404 |
SERVER_PATH_PREFIX + checklistInfo.getId() + "/name_catalogue/taxon.json", |
401 | 405 |
"taxonUuid", |
402 | 406 |
null); |
403 |
String taxonResponseBody = processRESTService(taxonUri); |
|
407 |
String taxonResponseBody = queryClient.processRESTService(taxonUri);
|
|
404 | 408 |
updateQueriesWithResponse(taxonResponseBody, checklistInfo, request); |
405 | 409 |
} |
406 | 410 |
} |
Also available in: Unified diff
separating query protocol implementation from checklist clients