12 |
12 |
import org.bgbm.biovel.drf.query.TinkerPopClient;
|
13 |
13 |
import org.bgbm.biovel.drf.store.Neo4jStore;
|
14 |
14 |
import org.bgbm.biovel.drf.store.Store;
|
|
15 |
import org.bgbm.biovel.drf.tnr.msg.Classification;
|
15 |
16 |
import org.bgbm.biovel.drf.tnr.msg.NameType;
|
16 |
17 |
import org.bgbm.biovel.drf.tnr.msg.Query;
|
17 |
18 |
import org.bgbm.biovel.drf.tnr.msg.Query.Request;
|
... | ... | |
27 |
28 |
import org.bgbm.biovel.drf.utils.TnrMsgUtils;
|
28 |
29 |
import org.neo4j.graphdb.Relationship;
|
29 |
30 |
|
30 |
|
import com.tinkerpop.blueprints.Direction;
|
31 |
31 |
import com.tinkerpop.blueprints.Graph;
|
32 |
32 |
import com.tinkerpop.blueprints.Vertex;
|
33 |
33 |
import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Vertex;
|
... | ... | |
47 |
47 |
public static final String COPYRIGHT_URL = "http://www.eea.europa.eu/legal/eea-data-policy";
|
48 |
48 |
|
49 |
49 |
private static final String SPECIES_RDF_FILE_URL = "http://localhost/download/species.rdf.gz"; // http://eunis.eea.europa.eu/rdf/species.rdf.gz
|
|
50 |
private static final String TAXONOMY_RDF_FILE_URL = "http://localhost/download/taxonomy.rdf.gz"; // http://eunis.eea.europa.eu/rdf/taxonomy.rdf.gz
|
50 |
51 |
private static final String LEGALREFS_RDF_FILE_URL = "http://localhost/download/legalrefs.rdf.gz"; // http://eunis.eea.europa.eu/rdf/legalrefs.rdf.gz
|
51 |
52 |
private static final String REFERENCES_RDF_FILE_URL = "http://localhost/download/references.rdf.gz"; // http://eunis.eea.europa.eu/rdf/references.rdf.gz
|
|
53 |
|
52 |
54 |
private static final boolean REFRESH_TDB = false;
|
53 |
55 |
|
54 |
56 |
public static final EnumSet<SearchMode> SEARCH_MODES = EnumSet.of(
|
... | ... | |
101 |
103 |
return abbreviation;
|
102 |
104 |
}
|
103 |
105 |
|
104 |
|
public String propertyURI(String name) {
|
|
106 |
public String property(String name) {
|
105 |
107 |
return schemaUri + name;
|
106 |
108 |
}
|
107 |
109 |
|
... | ... | |
148 |
150 |
private void updateStore(Store neo4jStore) {
|
149 |
151 |
try {
|
150 |
152 |
neo4jStore.loadIntoStore(
|
151 |
|
SPECIES_RDF_FILE_URL,
|
152 |
|
LEGALREFS_RDF_FILE_URL,
|
153 |
|
REFERENCES_RDF_FILE_URL
|
|
153 |
// SPECIES_RDF_FILE_URL,
|
|
154 |
TAXONOMY_RDF_FILE_URL
|
|
155 |
// LEGALREFS_RDF_FILE_URL,
|
|
156 |
// REFERENCES_RDF_FILE_URL
|
154 |
157 |
);
|
155 |
158 |
} catch (Exception e) {
|
156 |
159 |
throw new RuntimeException("Loading "
|
157 |
160 |
+ SPECIES_RDF_FILE_URL + ", "
|
|
161 |
+ TAXONOMY_RDF_FILE_URL + ", "
|
158 |
162 |
+ LEGALREFS_RDF_FILE_URL + ", "
|
159 |
163 |
+ REFERENCES_RDF_FILE_URL +
|
160 |
164 |
" into Neo4jStore failed", e);
|
... | ... | |
205 |
209 |
taxon.setTaxonName(taxonName);
|
206 |
210 |
taxon.setIdentifier(v.getId().toString());
|
207 |
211 |
taxon.setAccordingTo(queryClient.relatedVertexValue(v, RdfSchema.DWC, "nameAccordingToID"));
|
208 |
|
URI typeUri = queryClient.relatedVertexURI(v, RdfSchema.RDF, "type");
|
|
212 |
URI typeUri = queryClient.vertexURI(v, RdfSchema.RDF, "type");
|
209 |
213 |
taxon.setTaxonomicStatus(typeUri.getFragment());
|
210 |
214 |
|
211 |
215 |
createSources(v, taxon);
|
212 |
216 |
|
213 |
|
/*
|
214 |
|
|
215 |
217 |
// classification
|
216 |
218 |
Classification c = null;
|
217 |
|
Resource parentR = queryClient.objectAsResource(taxonR, RdfSchema.EUNIS_SPECIES, "taxonomy");
|
218 |
|
while (parentR != null) {
|
|
219 |
Vertex parentV= null;
|
|
220 |
try {
|
|
221 |
parentV = queryClient.relatedVertex(v, RdfSchema.EUNIS_SPECIES, "taxonomy");
|
|
222 |
} catch (Exception e) {
|
|
223 |
logger.error("No taxonomy information for " + v.toString());
|
|
224 |
}
|
219 |
225 |
|
220 |
|
String level = queryClient.objectAsString(parentR, RdfSchema.EUNIS_TAXONOMY, "level");
|
221 |
|
String parentTaxonName = queryClient.objectAsString(parentR, RdfSchema.EUNIS_TAXONOMY, "name");
|
|
226 |
while (parentV != null) {
|
|
227 |
logger.debug("parent taxon: " + parentV.toString());
|
|
228 |
String level = queryClient.relatedVertexValue(parentV, RdfSchema.EUNIS_TAXONOMY, "level");
|
|
229 |
String parentTaxonName = queryClient.relatedVertexValue(parentV, RdfSchema.EUNIS_TAXONOMY, "name");
|
222 |
230 |
|
223 |
231 |
RankLevel rankLevel = null;
|
224 |
232 |
try {
|
... | ... | |
253 |
261 |
break;
|
254 |
262 |
}
|
255 |
263 |
}
|
256 |
|
Resource lastParentR = parentR;
|
257 |
|
parentR = queryClient.objectAsResource(parentR, RdfSchema.EUNIS_TAXONOMY, "parent");
|
258 |
|
if(lastParentR.equals(parentR)) {
|
|
264 |
Vertex lastParentV = parentV;
|
|
265 |
parentV = queryClient.relatedVertex(parentV, RdfSchema.EUNIS_TAXONOMY, "parent");
|
|
266 |
if(lastParentV.equals(parentV)) {
|
259 |
267 |
// avoid endless looping when data is not correct
|
260 |
268 |
break;
|
261 |
269 |
}
|
... | ... | |
263 |
271 |
if(c != null) {
|
264 |
272 |
taxon.setClassification(c);
|
265 |
273 |
}
|
266 |
|
*/
|
267 |
274 |
return taxon;
|
268 |
275 |
}
|
269 |
276 |
|
... | ... | |
280 |
287 |
|
281 |
288 |
try {
|
282 |
289 |
List<Vertex> titleVs = taxonPipe
|
283 |
|
.outE(RdfSchema.EUNIS_SPECIES.propertyURI("hasLegalReference")).inV()
|
284 |
|
.outE(RdfSchema.DCTERMS.propertyURI("source")).inV().dedup()
|
285 |
|
.outE(RdfSchema.DCTERMS.propertyURI("title")).inV()
|
|
290 |
.outE(RdfSchema.EUNIS_SPECIES.property("hasLegalReference")).inV()
|
|
291 |
.outE(RdfSchema.DCTERMS.property("source")).inV().dedup()
|
|
292 |
.outE(RdfSchema.DCTERMS.property("title")).inV()
|
286 |
293 |
.toList();
|
287 |
294 |
for(Vertex tv : titleVs) {
|
288 |
295 |
Source source = new Source();
|
... | ... | |
317 |
324 |
|
318 |
325 |
try {
|
319 |
326 |
List<Vertex> synonymVs = taxonPipe
|
320 |
|
.inE(RdfSchema.EUNIS_SPECIES.propertyURI("eunisPrimaryName")).outV().dedup()
|
|
327 |
.inE(RdfSchema.EUNIS_SPECIES.property("eunisPrimaryName")).outV().dedup()
|
321 |
328 |
.toList();
|
322 |
329 |
for(Vertex synonymV : synonymVs) {
|
323 |
330 |
String typeUri = queryClient.relatedVertexValue(synonymV, RdfSchema.RDF, "type");
|
... | ... | |
379 |
386 |
pipe = new GremlinPipeline<Graph, Vertex>(hitVs);
|
380 |
387 |
|
381 |
388 |
List<Vertex> vertices = new ArrayList<Vertex>();
|
382 |
|
pipe.in(RdfSchema.EUNIS_SPECIES.propertyURI("binomialName")).fill(vertices);
|
|
389 |
pipe.in(RdfSchema.EUNIS_SPECIES.property("binomialName")).fill(vertices);
|
383 |
390 |
|
384 |
391 |
updateQueriesWithResponse(vertices, null, null, checklistInfo, query);
|
385 |
392 |
profiler.end(System.err);
|
... | ... | |
434 |
441 |
List<Vertex> vertices = new ArrayList<Vertex>();
|
435 |
442 |
pipe = new GremlinPipeline<Graph, Vertex>(hitVs);
|
436 |
443 |
Table table = new Table();
|
437 |
|
pipe.as("match").in(RdfSchema.DWC.propertyURI("vernacularName")).as("taxon").table(table).iterate();
|
|
444 |
pipe.as("match").in(RdfSchema.DWC.property("vernacularName")).as("taxon").table(table).iterate();
|
438 |
445 |
|
439 |
446 |
updateQueriesWithResponse(
|
440 |
447 |
table.getColumn("taxon"), table.getColumn("match"),
|
... | ... | |
540 |
547 |
Vertex synonymV = taxonV;
|
541 |
548 |
taxonV = null;
|
542 |
549 |
try {
|
543 |
|
taxonV = synonymV.getEdges(Direction.OUT, RdfSchema.EUNIS_SPECIES.propertyURI("eunisPrimaryName")).iterator().next().getVertex(Direction.IN);
|
|
550 |
taxonV = queryClient.relatedVertex(synonymV, RdfSchema.EUNIS_SPECIES, "eunisPrimaryName");
|
544 |
551 |
} catch(Exception e) {
|
545 |
552 |
logger.error("No accepted taxon found for " + synonymV.toString() + " (" + synonymV.getProperty(GraphSail.VALUE) + ")");
|
546 |
553 |
}
|
gathering classification information implemented with test