-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return API v2 responses in Turtle and RDF/XML #851
Conversation
- Use JSON-LD content type for JSON-LD responses.
- Simplify R2R ontology test code. - Make it easier to regenerate expected response files.
- Add datatypes where needed in responses in the simple schema.
Example of a book resource in the simple schema in Turtle, with a @prefix knora-api: <http://api.knora.org/ontology/knora-api/simple/v2#> .
@prefix incunabula: <http://0.0.0.0:3333/ontology/0803/incunabula/simple/v2#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<http://rdfh.ch/2a6221216701> a incunabula:book;
incunabula:book_comment "Katalogaufnahme anhand ISTC und v.d.Haegen";
incunabula:citation "Borm 1751", "C 3833", "FairMur(G) 283", "Goff M165", "IBP 3556",
"Klebs 651.2", "Schr 4799", "Schramm XXI p. 9 & 26", "Van der Haegen I: 9,14";
incunabula:location "Basel UB, Sign: Aleph D III 13:1";
incunabula:note "Besitzervermerke: Kartause, H. Zscheckenbürlin", "Holzschnitte nicht koloriert",
"Rubr. mit Init. J zu Beginn", "Zusammengebunden mit: Die zehen Gebote ; Was und wie man beten soll und Auslegung des hlg. Pater nosters / Hans von Warmont. Strassburg, 1516",
"deutsch von Otto von Diemeringen";
incunabula:physical_desc "Extent: 1 Bd.; Dimensions: f°";
incunabula:pubdate "JULIAN:1481 CE"^^knora-api:Date;
incunabula:publisher "Bernhard Richel";
incunabula:publoc "Basel";
incunabula:title "Itinerarius", "Reise ins Heilige Land", "Reysen und wanderschafften durch das Gelobte Land";
incunabula:url "http://aleph.unibas.ch/F/?local_base=DSV01&con_lng=GER&func=find-b&find_code=SYS&request=002610320";
rdfs:label "Reise ins Heilige Land" . |
@benjamingeer I managed to create the test data, but now some tests have to be fixed. I cannot do it before Wednesday. Could you have a look at it? I think it is just the tests that search for things that now have a different result since I added another thing. |
- Rename RouteUtilV2.runJsonRoute -> runRdfRoute.
…oid returning it to browsers.
- Add tests for requesting lists in Turtle and RDF/XML. - Update sample resource responses in resourcesResponses.ts.
@benjamingeer I fixed a general problem with the test function in PR #862 but I think some of those should be applied immediately: webapi/src/test/scala/org/knora/webapi/e2e/v2/ResponseCheckerR2RV2.scala: two additional asserts webapi/src/test/scala/org/knora/webapi/responders/v2/ResourcesResponseCheckerV2.scala three additional asserts Shall I add them to this PR? |
Yes please. |
done in 6274fb8 this is just what is absolutely needed, more will come with my PR |
or probably I decide to make an own PR just for that to be faster |
This PR allows all API v2 responses to be returned in Turtle and RDF/XML as well as in JSON-LD, using HTTP content negotation.
@graph
in JSON-LD) as per hasClasses and hasProperties produce nonsensical Turtle #854 (requires change in SALSAH 2).@graph
in JSON-LD as per hasClasses and hasProperties produce nonsensical Turtle #854 (requires change in SALSAH 2).I was going to support returning API responses as HTML, but it would be a lot of work, and it doesn't seem worth it, since that's already being done in SALSAH 2.
The conversion from JSON-LD to other formats is done by writing the JSON-LD to a string, then parsing and reformatting it using RDF4J Rio (in
RouteUtilV2.formatResponse
). I tried converting our JSON-LD data structure directly to a Rio model, but the code to do this turned out to be rather complex, so I decided not to. And a test withab
shows that, even with the extra formatting and parsing, there is no noticeable difference in performance between formats.The necessary changes to SALSAH 2 are in dhlab-basel/Salsah#252.
Resolves #609.
Resolves #854.
Resolves #857.
Resolves #855.
Resolves #853.
Resolves #863.
Resolves #865.