OpenTreeOfLife / taxomachine

taxonomy graphdb
Other
7 stars 4 forks source link

raise exception in doTNRSForNames for unknown contextName #18

Closed mtholder closed 11 years ago

mtholder commented 11 years ago

The "contextName" parameter is optional. It looks to me like it defaults to the "All plants" behavior if the contextName is misspelled. We should probably just return an error in this case.

Note: the name is case-sensitive. I'm not sure if we want to make it case-insensitive, but if we do, the same person who addresses this could then do the case-sensitivity.

chinchliff commented 11 years ago

Ok, both these things have been done.

example (with badly-cased context name):

curl -X POST http://opentree-dev.bio.ku.edu:7476/db/data/ext/TNRS/graphdb/doTNRSForNames -H "Content-Type: Application/json" -d '{"querString":"Poinsettia","contextName":"lAnD PlANtS"}'

should return:

{ "unmatched_names" : [ ], "unambiguous_names" : [ ], "context" : "Land plants", "governing_code" : "ICBN", "matched_names" : [ "Poinsettia" ], "results" : [ { "matches" : [ { "isSynonym" : true, "searchString" : "Poinsettia", "isHomonym" : false, "score" : 1.0, "isPerfectMatch" : false, "matchedNodeId" : 756493, "matchedOttolID" : "756493", "sourceName" : "ottol", "matchedName" : "Euphorbia pulcherrima", "isApprox" : false, "parentName" : "Euphorbia", "nomenCode" : "ICBN", "matchedNameStatus" : "known" } ], "queried_name" : "Poinsettia" } ] }

but:

curl -X POST http://opentree-dev.bio.ku.edu:7476/db/data/ext/TNRS/graphdb/doTNRSForNames -H "Content-Type: Application/json" -d '{"querString":"Poinsettia","contextName":"Spam"}'

should return:

{ "exception" : "ContextNotFoundException", "stacktrace" : [ "opentree.Taxonomy.getContextByName(Taxonomy.java:81)", "opentree.plugins.TNRS.doTNRSForNames(TNRS.java:79)", "java.lang.reflect.Method.invoke(Method.java:597)", "org.neo4j.server.plugins.PluginMethod.invoke(PluginMethod.java:57)", "org.neo4j.server.plugins.PluginManager.invoke(PluginManager.java:168)", "org.neo4j.server.rest.web.ExtensionService.invokeGraphDatabaseExtension(ExtensionService.java:300)", "org.neo4j.server.rest.web.ExtensionService.invokeGraphDatabaseExtension(ExtensionService.java:122)", "java.lang.reflect.Method.invoke(Method.java:597)" ] }

Currently I am just letting the Neo4j plugin interface handle the exception (hence the stacktrace), but the output can be changed to be nicer.