1
|
package org.bgbm.biovel.drf.checklist;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
import java.net.URI;
|
5
|
import java.util.ArrayList;
|
6
|
import java.util.EnumSet;
|
7
|
import java.util.List;
|
8
|
import java.util.NoSuchElementException;
|
9
|
|
10
|
import org.apache.jena.rdf.model.Model;
|
11
|
import org.apache.jena.rdf.model.Property;
|
12
|
import org.apache.jena.rdf.model.ResIterator;
|
13
|
import org.apache.jena.rdf.model.Resource;
|
14
|
import org.apache.jena.rdf.model.StmtIterator;
|
15
|
import org.bgbm.biovel.drf.client.ServiceProviderInfo;
|
16
|
import org.bgbm.biovel.drf.query.SparqlClient;
|
17
|
import org.bgbm.biovel.drf.store.TripleStore;
|
18
|
import org.bgbm.biovel.drf.tnr.msg.Classification;
|
19
|
import org.bgbm.biovel.drf.tnr.msg.NameType;
|
20
|
import org.bgbm.biovel.drf.tnr.msg.Query;
|
21
|
import org.bgbm.biovel.drf.tnr.msg.Query.Request;
|
22
|
import org.bgbm.biovel.drf.tnr.msg.Response;
|
23
|
import org.bgbm.biovel.drf.tnr.msg.Source;
|
24
|
import org.bgbm.biovel.drf.tnr.msg.Synonym;
|
25
|
import org.bgbm.biovel.drf.tnr.msg.Taxon;
|
26
|
import org.bgbm.biovel.drf.tnr.msg.TaxonBase;
|
27
|
import org.bgbm.biovel.drf.tnr.msg.TaxonName;
|
28
|
import org.bgbm.biovel.drf.tnr.msg.TnrMsg;
|
29
|
import org.bgbm.biovel.drf.utils.IdentifierUtils;
|
30
|
import org.bgbm.biovel.drf.utils.TnrMsgUtils;
|
31
|
|
32
|
public class EEA_BDC_Client extends AggregateChecklistClient<SparqlClient> {
|
33
|
|
34
|
/**
|
35
|
*
|
36
|
*/
|
37
|
public static final String ID = "eea_bdc";
|
38
|
public static final String LABEL = "European Environment Agency (EEA) Biodiversity data centre (BDC)";
|
39
|
public static final String DOC_URL = "http://semantic.eea.europa.eu/documentation";
|
40
|
public static final String COPYRIGHT_URL = "http://www.eea.europa.eu/legal/eea-data-policy";
|
41
|
private static final String SPARQL_ENDPOINT_URL = "http://semantic.eea.europa.eu/sparql";
|
42
|
private static final String RDF_FILE_URL = "http://localhost/download/species.rdf.gz"; // http://eunis.eea.europa.eu/rdf/species.rdf.gz
|
43
|
private static final boolean USE_REMOTE_SERVICE = true;
|
44
|
private static final boolean REFRESH_TDB = true;
|
45
|
|
46
|
private static final int MAX_PAGING_LIMIT = 50;
|
47
|
|
48
|
public static final EnumSet<SearchMode> SEARCH_MODES = EnumSet.of(
|
49
|
SearchMode.scientificNameExact,
|
50
|
SearchMode.scientificNameLike,
|
51
|
SearchMode.vernacularNameExact,
|
52
|
SearchMode.vernacularNameLike,
|
53
|
SearchMode.findByIdentifier);
|
54
|
|
55
|
public static enum RdfSchema {
|
56
|
|
57
|
/*
|
58
|
* xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
59
|
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
|
60
|
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
|
61
|
xmlns:dcterms="http://purl.org/dc/terms/"
|
62
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
63
|
xmlns:dwc="http://rs.tdwg.org/dwc/terms/"
|
64
|
xmlns:owl="http://www.w3.org/2002/07/owl#"
|
65
|
xmlns="http://eunis.eea.europa.eu/rdf/species-schema.rdf#"
|
66
|
xmlns:sioc="http://rdfs.org/sioc/ns#"
|
67
|
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
|
68
|
xmlns:bibo="http://purl.org/ontology/bibo/"
|
69
|
xmlns:cc="http://creativecommons.org/ns#"
|
70
|
xmlns:foaf="http://xmlns.com/foaf/0.1/"
|
71
|
*/
|
72
|
EUNIS_SPECIES("es","http://eunis.eea.europa.eu/rdf/species-schema.rdf#"),
|
73
|
EUNIS_TAXONOMY("et", "http://eunis.eea.europa.eu/rdf/taxonomies-schema.rdf#"),
|
74
|
DWC("dwc", "http://rs.tdwg.org/dwc/terms/"),
|
75
|
RDF("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"),
|
76
|
RDFS("rdfs", "http://www.w3.org/2000/01/rdf-schema#"),
|
77
|
SKOS_CORE("scos_core", "http://www.w3.org/2004/02/skos/core#");
|
78
|
|
79
|
private String schemaUri;
|
80
|
private String abbreviation;
|
81
|
RdfSchema(String abbreviation, String schemaUri) {
|
82
|
this.abbreviation = abbreviation;
|
83
|
this.schemaUri = schemaUri;
|
84
|
}
|
85
|
|
86
|
public String schemaUri() {
|
87
|
|
88
|
return schemaUri;
|
89
|
}
|
90
|
|
91
|
public String abbreviation() {
|
92
|
|
93
|
return abbreviation;
|
94
|
}
|
95
|
|
96
|
}
|
97
|
|
98
|
public enum SubCheckListId {
|
99
|
|
100
|
eunis, natura_2000;
|
101
|
}
|
102
|
|
103
|
private enum RankLevel{
|
104
|
|
105
|
Kingdom, Phylum, Clazz, Order, Family, Genus;
|
106
|
}
|
107
|
|
108
|
public EEA_BDC_Client() {
|
109
|
|
110
|
super();
|
111
|
}
|
112
|
|
113
|
public EEA_BDC_Client(String checklistInfoJson) throws DRFChecklistException {
|
114
|
|
115
|
super(checklistInfoJson);
|
116
|
}
|
117
|
|
118
|
@Override
|
119
|
public void initQueryClient() {
|
120
|
|
121
|
if(USE_REMOTE_SERVICE) {
|
122
|
// use SPARQL end point
|
123
|
queryClient = new SparqlClient(SPARQL_ENDPOINT_URL);
|
124
|
} else {
|
125
|
TripleStore tripleStore = new TripleStore();
|
126
|
if(REFRESH_TDB) {
|
127
|
// use downloadable rdf
|
128
|
try {
|
129
|
tripleStore.loadIntoStore(RDF_FILE_URL);
|
130
|
} catch (IOException e) {
|
131
|
logger.error("Loading " + RDF_FILE_URL + " into TripleStore failed", e);
|
132
|
}
|
133
|
}
|
134
|
queryClient = new SparqlClient(tripleStore);
|
135
|
|
136
|
}
|
137
|
}
|
138
|
|
139
|
@Override
|
140
|
public ServiceProviderInfo buildServiceProviderInfo() {
|
141
|
|
142
|
ServiceProviderInfo checklistInfo = new ServiceProviderInfo(ID, LABEL, DOC_URL, COPYRIGHT_URL, getSearchModes());
|
143
|
checklistInfo.addSubChecklist(new ServiceProviderInfo(SubCheckListId.eunis.name(), "EUNIS",
|
144
|
"http://www.eea.europa.eu/themes/biodiversity/eunis/eunis-db#tab-metadata",
|
145
|
"http://www.eea.europa.eu/legal/copyright", SEARCH_MODES));
|
146
|
return checklistInfo;
|
147
|
}
|
148
|
|
149
|
|
150
|
/**
|
151
|
* @param queryString
|
152
|
* @throws DRFChecklistException
|
153
|
*/
|
154
|
private void addPrexfixes(StringBuilder queryString) throws DRFChecklistException {
|
155
|
|
156
|
for(RdfSchema schema : RdfSchema.values()) {
|
157
|
queryString.append(String.format("PREFIX %s: <%s>\n", schema.abbreviation(), schema.schemaUri()));
|
158
|
}
|
159
|
}
|
160
|
|
161
|
/**
|
162
|
* @param checklistInfo
|
163
|
* @return
|
164
|
* @throws DRFChecklistException
|
165
|
*/
|
166
|
private StringBuilder prepareQueryString() throws DRFChecklistException {
|
167
|
|
168
|
StringBuilder queryString = new StringBuilder();
|
169
|
addPrexfixes(queryString);
|
170
|
return queryString;
|
171
|
}
|
172
|
|
173
|
private Taxon createTaxon(Model model, Resource taxonR) {
|
174
|
|
175
|
Taxon taxon = new Taxon();
|
176
|
|
177
|
TaxonName taxonName = createTaxonName(taxonR);
|
178
|
|
179
|
// Taxon
|
180
|
taxon.setTaxonName(taxonName);
|
181
|
taxon.setIdentifier(taxonR.getURI());
|
182
|
taxon.setAccordingTo(queryClient.objectAsString(taxonR, RdfSchema.DWC, "nameAccordingToID"));
|
183
|
URI typeUri = queryClient.objectAsURI(taxonR, RdfSchema.RDF, "type");
|
184
|
taxon.setTaxonomicStatus(typeUri.getFragment());
|
185
|
|
186
|
createSources(model, taxonR, taxon);
|
187
|
|
188
|
// classification
|
189
|
Classification c = null;
|
190
|
Resource parentR = queryClient.objectAsResource(taxonR, RdfSchema.EUNIS_SPECIES, "taxonomy");
|
191
|
while (parentR != null) {
|
192
|
|
193
|
String level = queryClient.objectAsString(parentR, RdfSchema.EUNIS_TAXONOMY, "level");
|
194
|
String parentTaxonName = queryClient.objectAsString(parentR, RdfSchema.EUNIS_TAXONOMY, "name");
|
195
|
|
196
|
RankLevel rankLevel = null;
|
197
|
try {
|
198
|
rankLevel = RankLevel.valueOf(level);
|
199
|
} catch (Exception e) {
|
200
|
// IGNORE
|
201
|
}
|
202
|
if(rankLevel != null) {
|
203
|
if(c == null) {
|
204
|
c = new Classification();
|
205
|
}
|
206
|
switch(rankLevel) {
|
207
|
case Clazz:
|
208
|
c.setClazz(parentTaxonName);
|
209
|
break;
|
210
|
case Family:
|
211
|
c.setFamily(parentTaxonName);
|
212
|
break;
|
213
|
case Genus:
|
214
|
c.setGenus(parentTaxonName);
|
215
|
break;
|
216
|
case Kingdom:
|
217
|
c.setKingdom(parentTaxonName);
|
218
|
break;
|
219
|
case Order:
|
220
|
c.setOrder(parentTaxonName);
|
221
|
break;
|
222
|
case Phylum:
|
223
|
c.setPhylum(parentTaxonName);
|
224
|
break;
|
225
|
default:
|
226
|
break;
|
227
|
}
|
228
|
}
|
229
|
Resource lastParentR = parentR;
|
230
|
parentR = queryClient.objectAsResource(parentR, RdfSchema.EUNIS_TAXONOMY, "parent");
|
231
|
if(lastParentR.equals(parentR)) {
|
232
|
// avoid endless looping when data is not correct
|
233
|
break;
|
234
|
}
|
235
|
}
|
236
|
if(c != null) {
|
237
|
taxon.setClassification(c);
|
238
|
}
|
239
|
return taxon;
|
240
|
}
|
241
|
|
242
|
/**
|
243
|
* @param model
|
244
|
* @param taxonR
|
245
|
* @param taxonBase
|
246
|
*/
|
247
|
private void createSources(Model model, Resource taxonR, TaxonBase taxonBase) {
|
248
|
// Sources are source references, re there others like data bases?
|
249
|
for ( StmtIterator refIt = taxonR.listProperties(model.getProperty(RdfSchema.EUNIS_SPECIES.schemaUri, "hasLegalReference")); refIt.hasNext();) {
|
250
|
try {
|
251
|
Source source = new Source();
|
252
|
Resource sourceR = refIt.next().getObject().asResource();
|
253
|
String sourceName = queryClient.objectAsString(sourceR, RdfSchema.RDFS, "source");
|
254
|
source.setName(sourceName);
|
255
|
taxonBase.getSources().add(source);
|
256
|
} catch (NoSuchElementException e) {
|
257
|
logger.debug("No statements for rdf:hasLegalReference" , e);
|
258
|
}
|
259
|
}
|
260
|
}
|
261
|
|
262
|
/**
|
263
|
* @param taxonR
|
264
|
* @return
|
265
|
*/
|
266
|
private TaxonName createTaxonName(Resource taxonR) {
|
267
|
TaxonName taxonName = new TaxonName();
|
268
|
// TaxonName
|
269
|
taxonName.setFullName(queryClient.objectAsString(taxonR, RdfSchema.RDFS, "label"));
|
270
|
// TODO rename CanonicalName to scientificName? compare with dwc:scientificName
|
271
|
taxonName.setCanonicalName(queryClient.objectAsString(taxonR, RdfSchema.EUNIS_SPECIES, "binomialName"));
|
272
|
taxonName.setRank(queryClient.objectAsString(taxonR, RdfSchema.EUNIS_SPECIES, "taxonomicRank"));
|
273
|
return taxonName;
|
274
|
}
|
275
|
|
276
|
|
277
|
|
278
|
|
279
|
private void createSynonyms(Resource taxonR, Response tnrResponse) {
|
280
|
|
281
|
List<Resource> synonymRList = queryForSynonyms(taxonR);
|
282
|
|
283
|
for (Resource synonymR : synonymRList) {
|
284
|
|
285
|
URI typeUri = queryClient.objectAsURI(synonymR, RdfSchema.RDF, "type");
|
286
|
String status = typeUri.getFragment();
|
287
|
|
288
|
|
289
|
if (status != null && status.equals("SpeciesSynonym")) {
|
290
|
|
291
|
Synonym synonym = new Synonym();
|
292
|
|
293
|
TaxonName taxonName = createTaxonName(synonymR);
|
294
|
|
295
|
synonym.setTaxonomicStatus(status);
|
296
|
synonym.setTaxonName(taxonName);
|
297
|
synonym.setAccordingTo(queryClient.objectAsString(synonymR, RdfSchema.DWC, "nameAccordingToID"));
|
298
|
|
299
|
createSources(synonymR.getModel(), synonymR, synonym);
|
300
|
|
301
|
tnrResponse.getSynonym().add(synonym);
|
302
|
}
|
303
|
}
|
304
|
}
|
305
|
|
306
|
/**
|
307
|
* Returns all subjects that are related to the taxonR
|
308
|
* via the es:eunisPrimaryName property.
|
309
|
*
|
310
|
* @param taxonR
|
311
|
* @return
|
312
|
*/
|
313
|
private List<Resource> queryForSynonyms(Resource taxonR) {
|
314
|
|
315
|
List<Resource> synonymRList = null;
|
316
|
|
317
|
try {
|
318
|
StringBuilder queryString = prepareQueryString();
|
319
|
|
320
|
queryString.append("DESCRIBE ?synonym es:eunisPrimaryName <" + taxonR.getURI() + ">");
|
321
|
logger.debug("\n" + queryString.toString());
|
322
|
|
323
|
Model model = queryClient.describe(queryString.toString());
|
324
|
synonymRList = listSynonymResources(model, taxonR);
|
325
|
|
326
|
} catch (DRFChecklistException e) {
|
327
|
logger.error("SPARQL query error in queryForSynonyms()", e);
|
328
|
} finally {
|
329
|
if(synonymRList == null) {
|
330
|
synonymRList = new ArrayList<Resource>(0);
|
331
|
}
|
332
|
}
|
333
|
|
334
|
return synonymRList;
|
335
|
|
336
|
}
|
337
|
|
338
|
/**
|
339
|
* @param model
|
340
|
* @return
|
341
|
*/
|
342
|
private List<Resource> listSynonymResources(Model model, Resource taxonR) {
|
343
|
List<Resource> synonymRList;
|
344
|
Property filterProperty = model.createProperty(RdfSchema.EUNIS_SPECIES.schemaUri, "eunisPrimaryName");
|
345
|
synonymRList = queryClient.listResources(model, filterProperty, null, taxonR);
|
346
|
return synonymRList;
|
347
|
}
|
348
|
|
349
|
@Override
|
350
|
public void resolveScientificNamesExact(TnrMsg tnrMsg) throws DRFChecklistException {
|
351
|
|
352
|
List<Query> queryList = tnrMsg.getQuery();
|
353
|
|
354
|
// selecting one request as representative, only
|
355
|
// the search mode and addSynonmy flag are important
|
356
|
// for the further usage of the request object
|
357
|
|
358
|
for (ServiceProviderInfo checklistInfo : getServiceProviderInfo().getSubChecklists()) {
|
359
|
|
360
|
Query query = singleQueryFrom(tnrMsg);
|
361
|
StringBuilder queryString = prepareQueryString();
|
362
|
|
363
|
String filter;
|
364
|
if(query.getRequest().getSearchMode().equals(SearchMode.scientificNameLike.name())) {
|
365
|
filter = "(regex(?name, \"^" + query.getRequest().getQueryString() + "\"))";
|
366
|
} else {
|
367
|
filter = "(?name = \"" + query.getRequest().getQueryString() + "\")";
|
368
|
}
|
369
|
|
370
|
queryString.append(
|
371
|
"DESCRIBE ?eunisurl \n"
|
372
|
+ "WHERE {\n"
|
373
|
+ " ?eunisurl es:binomialName ?name . \n"
|
374
|
+ " FILTER " + filter + " \n"
|
375
|
+ "} \n"
|
376
|
+ "LIMIT " + MAX_PAGING_LIMIT + " OFFSET 0"
|
377
|
);
|
378
|
|
379
|
logger.debug("\n" + queryString.toString());
|
380
|
|
381
|
Model model = queryClient.describe(queryString.toString());
|
382
|
updateQueriesWithResponse(model, checklistInfo, query);
|
383
|
}
|
384
|
}
|
385
|
|
386
|
@Override
|
387
|
public void resolveScientificNamesLike(TnrMsg tnrMsg) throws DRFChecklistException {
|
388
|
// delegate to resolveScientificNamesExact, since the like search mode
|
389
|
// is handled in buildUriFromQueryList
|
390
|
resolveScientificNamesExact(tnrMsg);
|
391
|
|
392
|
}
|
393
|
|
394
|
@Override
|
395
|
public void resolveVernacularNamesExact(TnrMsg tnrMsg) throws DRFChecklistException {
|
396
|
List<Query> queryList = tnrMsg.getQuery();
|
397
|
|
398
|
// selecting one request as representative, only
|
399
|
// the search mode and addSynonmy flag are important
|
400
|
// for the further usage of the request object
|
401
|
|
402
|
for (ServiceProviderInfo checklistInfo : getServiceProviderInfo().getSubChecklists()) {
|
403
|
|
404
|
Query query = singleQueryFrom(tnrMsg);
|
405
|
StringBuilder queryString = prepareQueryString();
|
406
|
|
407
|
String filter;
|
408
|
if(query.getRequest().getSearchMode().equals(SearchMode.vernacularNameLike.name())) {
|
409
|
filter = "(regex(?name, \"" + query.getRequest().getQueryString() + "\"))";
|
410
|
} else {
|
411
|
// STR returns the lexical form of a literal so this matches literals in any language
|
412
|
filter = "(STR(?name)='" + query.getRequest().getQueryString() + "')";
|
413
|
}
|
414
|
|
415
|
queryString.append(
|
416
|
"DESCRIBE ?eunisurl \n"
|
417
|
+ "WHERE {\n"
|
418
|
+ " ?eunisurl dwc:vernacularName ?name . \n"
|
419
|
+ " FILTER " + filter + " \n"
|
420
|
+ "} \n"
|
421
|
+ "LIMIT " + MAX_PAGING_LIMIT + " OFFSET 0"
|
422
|
);
|
423
|
|
424
|
logger.debug("\n" + queryString.toString());
|
425
|
|
426
|
Model model = queryClient.describe(queryString.toString());
|
427
|
updateQueriesWithResponse(model, checklistInfo, query);
|
428
|
}
|
429
|
|
430
|
}
|
431
|
|
432
|
@Override
|
433
|
public void resolveVernacularNamesLike(TnrMsg tnrMsg) throws DRFChecklistException {
|
434
|
resolveVernacularNamesExact(tnrMsg);
|
435
|
}
|
436
|
|
437
|
@Override
|
438
|
public void findByIdentifier(TnrMsg tnrMsg) throws DRFChecklistException {
|
439
|
for (ServiceProviderInfo checklistInfo : getServiceProviderInfo().getSubChecklists()) {
|
440
|
|
441
|
Query query = singleQueryFrom(tnrMsg);
|
442
|
Resource taxonR = queryClient.getFromUri(query.getRequest().getQueryString());
|
443
|
|
444
|
Response response = tnrResponseFromResource(taxonR.getModel(), taxonR, query.getRequest());
|
445
|
query.getResponse().add(response);
|
446
|
}
|
447
|
}
|
448
|
|
449
|
private void updateQueriesWithResponse(Model model, ServiceProviderInfo ci, Query query)
|
450
|
throws DRFChecklistException {
|
451
|
|
452
|
if (model == null) {
|
453
|
return;
|
454
|
}
|
455
|
|
456
|
ResIterator subjectIt = model.listSubjects();
|
457
|
|
458
|
while (subjectIt.hasNext()) {
|
459
|
Resource subject = subjectIt.next();
|
460
|
Resource taxonR;
|
461
|
StmtIterator exactMatches = subject.listProperties(subject.getModel().getProperty(RdfSchema.SKOS_CORE.schemaUri, "exactMatch"));
|
462
|
if(exactMatches.hasNext()) {
|
463
|
// need to follow the exactMatch uri in this case
|
464
|
taxonR = queryClient.getFromUri(exactMatches.next().getResource().getURI());
|
465
|
} else {
|
466
|
// the subject is already a species
|
467
|
taxonR = subject;
|
468
|
}
|
469
|
|
470
|
Response tnrResponse = tnrResponseFromResource(model, taxonR, query.getRequest());
|
471
|
if(tnrResponse != null) {
|
472
|
query.getResponse().add(tnrResponse);
|
473
|
}
|
474
|
}
|
475
|
}
|
476
|
|
477
|
/**
|
478
|
* @param model
|
479
|
* @param taxonR
|
480
|
* @param request
|
481
|
* @return
|
482
|
*/
|
483
|
private Response tnrResponseFromResource(Model model, Resource taxonR, Request request) {
|
484
|
|
485
|
Response tnrResponse = TnrMsgUtils.tnrResponseFor(getServiceProviderInfo());
|
486
|
|
487
|
SearchMode searchMode = SearchMode.valueOf(request.getSearchMode());
|
488
|
|
489
|
// Check for type to ignore the triple pointing from synonyms to accepted taxonUris
|
490
|
// only complete descriptions of taxa and synonym are relevant.
|
491
|
boolean isCompleteResource = taxonR.hasProperty(taxonR.getModel().getProperty(RdfSchema.RDF.schemaUri, "type"));
|
492
|
if(!isCompleteResource) {
|
493
|
return null;
|
494
|
}
|
495
|
|
496
|
String validName = queryClient.objectAsString(taxonR, RdfSchema.EUNIS_SPECIES, "validName");
|
497
|
boolean isAccepted = validName != null && validName.equals("true^^http://www.w3.org/2001/XMLSchema#boolean");
|
498
|
boolean skipThis = false;
|
499
|
|
500
|
logger.debug("processing " + (isAccepted ? "accepted taxon" : "synonym or other") + " " + taxonR.getURI());
|
501
|
|
502
|
// case when accepted name
|
503
|
if(isAccepted) {
|
504
|
Taxon taxon = createTaxon(model, taxonR);
|
505
|
tnrResponse.setTaxon(taxon);
|
506
|
tnrResponse.setMatchingNameType(NameType.TAXON);
|
507
|
String matchingName = taxon.getTaxonName().getCanonicalName();
|
508
|
tnrResponse.setMatchingNameString(matchingName);
|
509
|
|
510
|
} else {
|
511
|
// case when synonym
|
512
|
Resource synonymR = taxonR;
|
513
|
URI taxonUri = queryClient.objectAsURI(taxonR, RdfSchema.EUNIS_SPECIES, "eunisPrimaryName");
|
514
|
if(taxonUri == null) {
|
515
|
logger.error("no taxon uri found");
|
516
|
}
|
517
|
|
518
|
taxonR = queryClient.getFromUri(taxonUri);
|
519
|
if(taxonR != null) {
|
520
|
Taxon taxon = createTaxon(model, taxonR);
|
521
|
tnrResponse.setTaxon(taxon);
|
522
|
} else {
|
523
|
logger.error("No accepted taxon found for " + synonymR.getURI());
|
524
|
}
|
525
|
tnrResponse.setMatchingNameType(NameType.SYNONYM);
|
526
|
String matchingName = queryClient.objectAsString(synonymR, RdfSchema.EUNIS_SPECIES, "binomialName");
|
527
|
tnrResponse.setMatchingNameString(matchingName);
|
528
|
}
|
529
|
|
530
|
if(!skipThis && request.isAddSynonymy()) {
|
531
|
createSynonyms(taxonR, tnrResponse);
|
532
|
}
|
533
|
logger.debug("processing " + (isAccepted ? "accepted taxon" : "synonym or other") + " " + taxonR.getURI() + " DONE");
|
534
|
|
535
|
return tnrResponse;
|
536
|
}
|
537
|
|
538
|
@Override
|
539
|
public EnumSet<SearchMode> getSearchModes() {
|
540
|
return SEARCH_MODES;
|
541
|
}
|
542
|
|
543
|
@Override
|
544
|
public boolean isSupportedIdentifier(String value) {
|
545
|
return IdentifierUtils.checkURI(value);
|
546
|
}
|
547
|
|
548
|
}
|