From 00ad4f2b9a8484da4cb9bbfb4308da6e70b9e47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Thu, 18 Jun 2020 16:04:02 +0200 Subject: [PATCH 01/20] test: New generated test data --- scripts/v2-test-data-config.json | 4 ++ .../admin/projects/get-projects-response.json | 2 +- ...l-ontology-metadata-response-expanded.json | 2 +- .../all-ontology-metadata-response.json | 18 +++++---- ...es-project-anything-response-expanded.json | 1 + ...-ontologies-project-anything-response.json | 38 +++++++++++++++++++ 6 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 test/data/api/v2/ontologies/get-ontologies-project-anything-response-expanded.json create mode 100644 test/data/api/v2/ontologies/get-ontologies-project-anything-response.json diff --git a/scripts/v2-test-data-config.json b/scripts/v2-test-data-config.json index 6b5cc7a55..eec74b5db 100644 --- a/scripts/v2-test-data-config.json +++ b/scripts/v2-test-data-config.json @@ -20,6 +20,10 @@ "source": "/v2/ontologies/incunabula-ontology.json", "destination": "./test/data/api/v2/ontologies/incunabula-ontology.json" }, + { + "source": "/v2/ontologies/get-ontologies-project-anything-response.json", + "destination": "./test/data/api/v2/ontologies/get-ontologies-project-anything-response.json" + }, { "source": "/v2/resources/testding.json", "destination": "./test/data/api/v2/resources/testding.json" diff --git a/test/data/api/admin/projects/get-projects-response.json b/test/data/api/admin/projects/get-projects-response.json index b839c649e..53bd65a11 100644 --- a/test/data/api/admin/projects/get-projects-response.json +++ b/test/data/api/admin/projects/get-projects-response.json @@ -1 +1 @@ -{"projects":[{"description":[{"value":"Anything Project"}],"id":"http://rdfh.ch/projects/0001","keywords":["arbitrary test data","things"],"logo":null,"longname":"Anything Project","ontologies":["http://www.knora.org/ontology/0001/anything","http://www.knora.org/ontology/0001/minimal","http://www.knora.org/ontology/0001/something"],"selfjoin":false,"shortcode":"0001","shortname":"anything","status":true},{"description":[{"value":"A demo project of a collection of images","language":"en"}],"id":"http://rdfh.ch/projects/00FF","keywords":["collection","images"],"logo":null,"longname":"Image Collection Demo","ontologies":["http://www.knora.org/ontology/00FF/images"],"selfjoin":false,"shortcode":"00FF","shortname":"images","status":true},{"description":[{"value":"

Das interdisziplinäre Forschungsprojekt \"Die Bilderfolgen der Basler Frühdrucke: Spätmittelalterliche Didaxe als Bild-Text-Lektüre\" verbindet eine umfassende kunstwissenschaftliche Analyse der Bezüge zwischen den Bildern und Texten in den illustrierten Basler Inkunabeln mit der Digitalisierung der Bestände der Universitätsbibliothek und der Entwicklung einer elektronischen Edition in der Form einer neuartigen Web-0.2-Applikation.\n

\n

Das Projekt wird durchgeführt vom Kunsthistorischen Seminar der Universität Basel (Prof. B. Schellewald) und dem Digital Humanities Lab der Universität Basel (PD Dr. L. Rosenthaler).\n

\n

\nDas Kernstück der digitalen Edition besteht aus rund zwanzig reich bebilderten Frühdrucken aus vier verschiedenen Basler Offizinen. Viele davon sind bereits vor 1500 in mehreren Ausgaben erschienen, einige fast gleichzeitig auf Deutsch und Lateinisch. Es handelt sich um eine ausserordentlich vielfältige Produktion; neben dem Heilsspiegel finden sich ein Roman, die Melusine, die Reisebeschreibungen des Jean de Mandeville, einige Gebets- und Erbauungsbüchlein, theologische Schriften, Fastenpredigten, die Leben der Heiligen Fridolin und Meinrad, das berühmte Narrenschiff sowie die Exempelsammlung des Ritters vom Thurn.\n

\nDie Internetpublikation macht das digitalisierte Korpus dieser Frühdrucke durch die Möglichkeiten nichtlinearer Verknüpfung und Kommentierung der Bilder und Texte, für die wissenschaftliche Edition sowie für die Erforschung der Bilder und Texte nutzbar machen. Auch können bereits bestehende und entstehende Online-Editionen damit verknüpft werden , wodurch die Nutzung von Datenbanken anderer Institutionen im Hinblick auf unser Corpus optimiert wird.\n

"}],"id":"http://rdfh.ch/projects/0803","keywords":["Basel","Basler Frühdrucke","Bilderfolgen","Contectualisation of images","Inkunabel","Kunsthistorisches Seminar Universität Basel","Late Middle Ages","Letterpress Printing","Narrenschiff","Sebastian Brant","Wiegendrucke","early print","incunabula","ship of fools"],"logo":"incunabula_logo.png","longname":"Bilderfolgen Basler Frühdrucke","ontologies":["http://www.knora.org/ontology/0803/incunabula"],"selfjoin":false,"shortcode":"0803","shortname":"incunabula","status":true},{"description":[{"value":"Dokubib"}],"id":"http://rdfh.ch/projects/0804","keywords":[],"logo":null,"longname":"Dokubib","ontologies":["http://www.knora.org/ontology/0804/dokubib"],"selfjoin":false,"shortcode":"0804","shortname":"dokubib","status":false},{"description":[{"value":"Historisch-kritische Edition des Gesamtschaffens von Anton Webern."}],"id":"http://rdfh.ch/projects/08AE","keywords":[],"logo":null,"longname":"Anton Webern Gesamtausgabe","ontologies":["http://www.knora.org/ontology/08AE/webern"],"selfjoin":false,"shortcode":"08AE","shortname":"webern","status":true},{"description":[{"value":"Bernoulli-Euler Online"}],"id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF","keywords":[],"logo":null,"longname":"Bernoulli-Euler Online","ontologies":["http://www.knora.org/ontology/0801/leibniz","http://www.knora.org/ontology/0801/biblio","http://www.knora.org/ontology/0801/newton","http://www.knora.org/ontology/0801/beol"],"selfjoin":false,"shortcode":"0801","shortname":"beol","status":true},{"description":[{"value":"Knora Shared Ontologies Project","language":"en"}],"id":"http://www.knora.org/ontology/knora-admin#DefaultSharedOntologiesProject","keywords":[],"logo":null,"longname":"Knora Default Shared Ontologies Project","ontologies":[],"selfjoin":false,"shortcode":"0000","shortname":"DefaultSharedOntologiesProject","status":true},{"description":[{"value":"Knora System Project","language":"en"}],"id":"http://www.knora.org/ontology/knora-admin#SystemProject","keywords":[],"logo":null,"longname":"Knora System Project","ontologies":["http://www.knora.org/ontology/standoff","http://www.knora.org/ontology/knora-base","http://www.knora.org/ontology/knora-admin","http://www.knora.org/ontology/salsah-gui"],"selfjoin":false,"shortcode":"FFFF","shortname":"SystemProject","status":true}]} \ No newline at end of file +{"projects":[{"description":[{"value":"Anything Project"}],"id":"http://rdfh.ch/projects/0001","keywords":["arbitrary test data","things"],"logo":null,"longname":"Anything Project","ontologies":["http://www.knora.org/ontology/0001/anything","http://www.knora.org/ontology/0001/minimal","http://www.knora.org/ontology/0001/something"],"selfjoin":false,"shortcode":"0001","shortname":"anything","status":true},{"description":[{"value":"A demo project of a collection of images","language":"en"}],"id":"http://rdfh.ch/projects/00FF","keywords":["collection","images"],"logo":null,"longname":"Image Collection Demo","ontologies":["http://www.knora.org/ontology/00FF/images","http://www.knora.org/ontology/00FF/foo"],"selfjoin":false,"shortcode":"00FF","shortname":"images","status":true},{"description":[{"value":"

Das interdisziplinäre Forschungsprojekt \"Die Bilderfolgen der Basler Frühdrucke: Spätmittelalterliche Didaxe als Bild-Text-Lektüre\" verbindet eine umfassende kunstwissenschaftliche Analyse der Bezüge zwischen den Bildern und Texten in den illustrierten Basler Inkunabeln mit der Digitalisierung der Bestände der Universitätsbibliothek und der Entwicklung einer elektronischen Edition in der Form einer neuartigen Web-0.2-Applikation.\n

\n

Das Projekt wird durchgeführt vom Kunsthistorischen Seminar der Universität Basel (Prof. B. Schellewald) und dem Digital Humanities Lab der Universität Basel (PD Dr. L. Rosenthaler).\n

\n

\nDas Kernstück der digitalen Edition besteht aus rund zwanzig reich bebilderten Frühdrucken aus vier verschiedenen Basler Offizinen. Viele davon sind bereits vor 1500 in mehreren Ausgaben erschienen, einige fast gleichzeitig auf Deutsch und Lateinisch. Es handelt sich um eine ausserordentlich vielfältige Produktion; neben dem Heilsspiegel finden sich ein Roman, die Melusine, die Reisebeschreibungen des Jean de Mandeville, einige Gebets- und Erbauungsbüchlein, theologische Schriften, Fastenpredigten, die Leben der Heiligen Fridolin und Meinrad, das berühmte Narrenschiff sowie die Exempelsammlung des Ritters vom Thurn.\n

\nDie Internetpublikation macht das digitalisierte Korpus dieser Frühdrucke durch die Möglichkeiten nichtlinearer Verknüpfung und Kommentierung der Bilder und Texte, für die wissenschaftliche Edition sowie für die Erforschung der Bilder und Texte nutzbar machen. Auch können bereits bestehende und entstehende Online-Editionen damit verknüpft werden , wodurch die Nutzung von Datenbanken anderer Institutionen im Hinblick auf unser Corpus optimiert wird.\n

"}],"id":"http://rdfh.ch/projects/0803","keywords":["Basel","Basler Frühdrucke","Bilderfolgen","Contectualisation of images","Inkunabel","Kunsthistorisches Seminar Universität Basel","Late Middle Ages","Letterpress Printing","Narrenschiff","Sebastian Brant","Wiegendrucke","early print","incunabula","ship of fools"],"logo":"incunabula_logo.png","longname":"Bilderfolgen Basler Frühdrucke","ontologies":["http://www.knora.org/ontology/0803/incunabula"],"selfjoin":false,"shortcode":"0803","shortname":"incunabula","status":true},{"description":[{"value":"Dokubib"}],"id":"http://rdfh.ch/projects/0804","keywords":[],"logo":null,"longname":"Dokubib","ontologies":["http://www.knora.org/ontology/0804/dokubib"],"selfjoin":false,"shortcode":"0804","shortname":"dokubib","status":false},{"description":[{"value":"Historisch-kritische Edition des Gesamtschaffens von Anton Webern."}],"id":"http://rdfh.ch/projects/08AE","keywords":[],"logo":null,"longname":"Anton Webern Gesamtausgabe","ontologies":[],"selfjoin":false,"shortcode":"08AE","shortname":"webern","status":true},{"description":[{"value":"Bernoulli-Euler Online"}],"id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF","keywords":[],"logo":null,"longname":"Bernoulli-Euler Online","ontologies":["http://www.knora.org/ontology/0801/leibniz","http://www.knora.org/ontology/0801/biblio","http://www.knora.org/ontology/0801/newton","http://www.knora.org/ontology/0801/beol"],"selfjoin":false,"shortcode":"0801","shortname":"beol","status":true},{"description":[{"value":"Knora Shared Ontologies Project","language":"en"}],"id":"http://www.knora.org/ontology/knora-admin#DefaultSharedOntologiesProject","keywords":[],"logo":null,"longname":"Knora Default Shared Ontologies Project","ontologies":[],"selfjoin":false,"shortcode":"0000","shortname":"DefaultSharedOntologiesProject","status":true},{"description":[{"value":"Knora System Project","language":"en"}],"id":"http://www.knora.org/ontology/knora-admin#SystemProject","keywords":[],"logo":null,"longname":"Knora System Project","ontologies":["http://www.knora.org/ontology/standoff","http://www.knora.org/ontology/knora-base","http://www.knora.org/ontology/knora-admin","http://www.knora.org/ontology/salsah-gui"],"selfjoin":false,"shortcode":"FFFF","shortname":"SystemProject","status":true}]} \ No newline at end of file diff --git a/test/data/api/v2/ontologies/all-ontology-metadata-response-expanded.json b/test/data/api/v2/ontologies/all-ontology-metadata-response-expanded.json index dd8db1491..01fa07629 100644 --- a/test/data/api/v2/ontologies/all-ontology-metadata-response-expanded.json +++ b/test/data/api/v2/ontologies/all-ontology-metadata-response-expanded.json @@ -1 +1 @@ -{"@graph":[{"@id":"http://0.0.0.0:3333/ontology/0001/anything/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://api.knora.org/ontology/knora-api/v2#lastModificationDate":{"@type":"http://www.w3.org/2001/XMLSchema#dateTimeStamp","@value":"2017-12-19T15:23:42.166Z"},"http://www.w3.org/2000/01/rdf-schema#label":"The anything ontology"},{"@id":"http://0.0.0.0:3333/ontology/0001/minimal/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://api.knora.org/ontology/knora-api/v2#lastModificationDate":{"@type":"http://www.w3.org/2001/XMLSchema#dateTimeStamp","@value":"2019-09-10T08:57:46.633162Z"},"http://www.w3.org/2000/01/rdf-schema#label":"A minimal ontology"},{"@id":"http://0.0.0.0:3333/ontology/0001/something/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://www.w3.org/2000/01/rdf-schema#label":"The something ontology"},{"@id":"http://0.0.0.0:3333/ontology/00FF/images/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/00FF"},"http://www.w3.org/2000/01/rdf-schema#label":"The images demo ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/beol/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The BEOL ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/biblio/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The Biblio ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/leibniz/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The Briefportal Leibniz ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/newton/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The Newton-Project ontology"},{"@id":"http://0.0.0.0:3333/ontology/0803/incunabula/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0803"},"http://www.w3.org/2000/01/rdf-schema#label":"The incunabula ontology"},{"@id":"http://0.0.0.0:3333/ontology/0804/dokubib/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0804"},"http://www.w3.org/2000/01/rdf-schema#label":"The dokubib ontology"},{"@id":"http://0.0.0.0:3333/ontology/08AE/webern/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/08AE"},"http://www.w3.org/2000/01/rdf-schema#label":"The Anton Webern project ontology"},{"@id":"http://api.knora.org/ontology/knora-admin/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The Knora admin ontology"},{"@id":"http://api.knora.org/ontology/knora-api/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The knora-api ontology in the complex schema"},{"@id":"http://api.knora.org/ontology/salsah-gui/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The salsah-gui ontology"},{"@id":"http://api.knora.org/ontology/standoff/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The standoff ontology"}]} \ No newline at end of file +{"@graph":[{"@id":"http://0.0.0.0:3333/ontology/0001/anything/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://api.knora.org/ontology/knora-api/v2#lastModificationDate":{"@type":"http://www.w3.org/2001/XMLSchema#dateTimeStamp","@value":"2017-12-19T15:23:42.166Z"},"http://www.w3.org/2000/01/rdf-schema#label":"The anything ontology"},{"@id":"http://0.0.0.0:3333/ontology/0001/minimal/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://api.knora.org/ontology/knora-api/v2#lastModificationDate":{"@type":"http://www.w3.org/2001/XMLSchema#dateTimeStamp","@value":"2019-09-10T08:57:46.633162Z"},"http://www.w3.org/2000/01/rdf-schema#label":"A minimal ontology"},{"@id":"http://0.0.0.0:3333/ontology/0001/something/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://www.w3.org/2000/01/rdf-schema#label":"The something ontology"},{"@id":"http://0.0.0.0:3333/ontology/00FF/foo/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/00FF"},"http://api.knora.org/ontology/knora-api/v2#lastModificationDate":{"@type":"http://www.w3.org/2001/XMLSchema#dateTimeStamp","@value":"2020-06-18T09:42:41.506895Z"},"http://www.w3.org/2000/01/rdf-schema#label":"The foo ontology"},{"@id":"http://0.0.0.0:3333/ontology/00FF/images/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/00FF"},"http://www.w3.org/2000/01/rdf-schema#label":"The images demo ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/beol/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The BEOL ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/biblio/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The Biblio ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/leibniz/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The Briefportal Leibniz ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/newton/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The Newton-Project ontology"},{"@id":"http://0.0.0.0:3333/ontology/0803/incunabula/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0803"},"http://www.w3.org/2000/01/rdf-schema#label":"The incunabula ontology"},{"@id":"http://0.0.0.0:3333/ontology/0804/dokubib/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0804"},"http://www.w3.org/2000/01/rdf-schema#label":"The dokubib ontology"},{"@id":"http://api.knora.org/ontology/knora-admin/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The Knora admin ontology"},{"@id":"http://api.knora.org/ontology/knora-api/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The knora-api ontology in the complex schema"},{"@id":"http://api.knora.org/ontology/salsah-gui/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The salsah-gui ontology"},{"@id":"http://api.knora.org/ontology/standoff/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The standoff ontology"}]} \ No newline at end of file diff --git a/test/data/api/v2/ontologies/all-ontology-metadata-response.json b/test/data/api/v2/ontologies/all-ontology-metadata-response.json index 27f40f2dc..099f19a37 100644 --- a/test/data/api/v2/ontologies/all-ontology-metadata-response.json +++ b/test/data/api/v2/ontologies/all-ontology-metadata-response.json @@ -28,6 +28,17 @@ "@id" : "http://rdfh.ch/projects/0001" }, "rdfs:label" : "The something ontology" + }, { + "@id" : "http://0.0.0.0:3333/ontology/00FF/foo/v2", + "@type" : "owl:Ontology", + "knora-api:attachedToProject" : { + "@id" : "http://rdfh.ch/projects/00FF" + }, + "knora-api:lastModificationDate" : { + "@type" : "xsd:dateTimeStamp", + "@value" : "2020-06-18T09:42:41.506895Z" + }, + "rdfs:label" : "The foo ontology" }, { "@id" : "http://0.0.0.0:3333/ontology/00FF/images/v2", "@type" : "owl:Ontology", @@ -77,13 +88,6 @@ "@id" : "http://rdfh.ch/projects/0804" }, "rdfs:label" : "The dokubib ontology" - }, { - "@id" : "http://0.0.0.0:3333/ontology/08AE/webern/v2", - "@type" : "owl:Ontology", - "knora-api:attachedToProject" : { - "@id" : "http://rdfh.ch/projects/08AE" - }, - "rdfs:label" : "The Anton Webern project ontology" }, { "@id" : "http://api.knora.org/ontology/knora-admin/v2", "@type" : "owl:Ontology", diff --git a/test/data/api/v2/ontologies/get-ontologies-project-anything-response-expanded.json b/test/data/api/v2/ontologies/get-ontologies-project-anything-response-expanded.json new file mode 100644 index 000000000..f9fa5aa51 --- /dev/null +++ b/test/data/api/v2/ontologies/get-ontologies-project-anything-response-expanded.json @@ -0,0 +1 @@ +{"@graph":[{"@id":"http://0.0.0.0:3333/ontology/0001/anything/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://api.knora.org/ontology/knora-api/v2#lastModificationDate":{"@type":"http://www.w3.org/2001/XMLSchema#dateTimeStamp","@value":"2017-12-19T15:23:42.166Z"},"http://www.w3.org/2000/01/rdf-schema#label":"The anything ontology"},{"@id":"http://0.0.0.0:3333/ontology/0001/minimal/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://api.knora.org/ontology/knora-api/v2#lastModificationDate":{"@type":"http://www.w3.org/2001/XMLSchema#dateTimeStamp","@value":"2019-09-10T08:57:46.633162Z"},"http://www.w3.org/2000/01/rdf-schema#label":"A minimal ontology"},{"@id":"http://0.0.0.0:3333/ontology/0001/something/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://www.w3.org/2000/01/rdf-schema#label":"The something ontology"}]} \ No newline at end of file diff --git a/test/data/api/v2/ontologies/get-ontologies-project-anything-response.json b/test/data/api/v2/ontologies/get-ontologies-project-anything-response.json new file mode 100644 index 000000000..49c8c93c3 --- /dev/null +++ b/test/data/api/v2/ontologies/get-ontologies-project-anything-response.json @@ -0,0 +1,38 @@ +{ + "@graph" : [ { + "@id" : "http://0.0.0.0:3333/ontology/0001/anything/v2", + "@type" : "owl:Ontology", + "knora-api:attachedToProject" : { + "@id" : "http://rdfh.ch/projects/0001" + }, + "knora-api:lastModificationDate" : { + "@type" : "xsd:dateTimeStamp", + "@value" : "2017-12-19T15:23:42.166Z" + }, + "rdfs:label" : "The anything ontology" + }, { + "@id" : "http://0.0.0.0:3333/ontology/0001/minimal/v2", + "@type" : "owl:Ontology", + "knora-api:attachedToProject" : { + "@id" : "http://rdfh.ch/projects/0001" + }, + "knora-api:lastModificationDate" : { + "@type" : "xsd:dateTimeStamp", + "@value" : "2019-09-10T08:57:46.633162Z" + }, + "rdfs:label" : "A minimal ontology" + }, { + "@id" : "http://0.0.0.0:3333/ontology/0001/something/v2", + "@type" : "owl:Ontology", + "knora-api:attachedToProject" : { + "@id" : "http://rdfh.ch/projects/0001" + }, + "rdfs:label" : "The something ontology" + } ], + "@context" : { + "knora-api" : "http://api.knora.org/ontology/knora-api/v2#", + "xsd" : "http://www.w3.org/2001/XMLSchema#", + "rdfs" : "http://www.w3.org/2000/01/rdf-schema#", + "owl" : "http://www.w3.org/2002/07/owl#" + } +} \ No newline at end of file From 7952def1a64b4fae810581f75d4d14f1d09112f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Thu, 18 Jun 2020 16:04:21 +0200 Subject: [PATCH 02/20] feat(ontology): Get project specific ontologies --- src/api/v2/ontology/ontologies-endpoint-v2.ts | 19 ++++++++++++ .../v2/ontology/ontologies-endpoint.spec.ts | 29 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/api/v2/ontology/ontologies-endpoint-v2.ts b/src/api/v2/ontology/ontologies-endpoint-v2.ts index 319e00c40..4584fa414 100644 --- a/src/api/v2/ontology/ontologies-endpoint-v2.ts +++ b/src/api/v2/ontology/ontologies-endpoint-v2.ts @@ -58,4 +58,23 @@ export class OntologiesEndpointV2 extends Endpoint { ); } + /** + * Requests metadata about all ontologies from specific project + * + * @param projectIri the IRI of the project + */ + getOntologiesByProjectIri(projectIri: string): Observable { + + return this.httpGet("/metadata/" + encodeURIComponent(projectIri)).pipe( + mergeMap((ajaxResponse: AjaxResponse) => { + return jsonld.compact(ajaxResponse.response, {}); + }), map((jsonldobj: object) => { + return this.jsonConvert.deserializeObject(jsonldobj, OntologiesMetadata); + }), + catchError(error => { + return this.handleError(error); + }) + ); + } + } diff --git a/src/api/v2/ontology/ontologies-endpoint.spec.ts b/src/api/v2/ontology/ontologies-endpoint.spec.ts index 90d65cf35..4421acf18 100644 --- a/src/api/v2/ontology/ontologies-endpoint.spec.ts +++ b/src/api/v2/ontology/ontologies-endpoint.spec.ts @@ -168,4 +168,33 @@ describe("OntologiesEndpoint", () => { }); + describe("Method getOntologiesByProjectIri", () => { + + it("should return all ontologies from 'anything' project", done => { + + knoraApiConnection.v2.onto.getOntologiesByProjectIri("http://rdfh.ch/projects/0001").subscribe( + (response: OntologiesMetadata) => { + expect(response.ontologies.length).toEqual(3); + expect(response.ontologies[0].id).toEqual("http://0.0.0.0:3333/ontology/0001/anything/v2"); + expect(response.ontologies[1].id).toEqual("http://0.0.0.0:3333/ontology/0001/minimal/v2"); + expect(response.ontologies[2].id).toEqual("http://0.0.0.0:3333/ontology/0001/something/v2"); + done(); + } + ); + + const request = jasmine.Ajax.requests.mostRecent(); + + const ontoMetadata = require("../../../../test/data/api/v2/ontologies/get-ontologies-project-anything-response.json"); + + request.respondWith(MockAjaxCall.mockResponse(JSON.stringify(ontoMetadata))); + + expect(request.url).toBe("http://0.0.0.0:3333/v2/ontologies/metadata/http%3A%2F%2Frdfh.ch%2Fprojects%2F0001"); + + expect(request.method).toEqual("GET"); + + }); + + }); + + }); From d40ce7a272ef86082d18a54d7fce3e0cd291b95e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Thu, 18 Jun 2020 17:01:11 +0200 Subject: [PATCH 03/20] fix(test): Reverse previous commit --- .../admin/projects/get-projects-response.json | 2 +- ...ll-ontology-metadata-response-expanded.json | 2 +- .../all-ontology-metadata-response.json | 18 +++++++----------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/test/data/api/admin/projects/get-projects-response.json b/test/data/api/admin/projects/get-projects-response.json index 53bd65a11..b839c649e 100644 --- a/test/data/api/admin/projects/get-projects-response.json +++ b/test/data/api/admin/projects/get-projects-response.json @@ -1 +1 @@ -{"projects":[{"description":[{"value":"Anything Project"}],"id":"http://rdfh.ch/projects/0001","keywords":["arbitrary test data","things"],"logo":null,"longname":"Anything Project","ontologies":["http://www.knora.org/ontology/0001/anything","http://www.knora.org/ontology/0001/minimal","http://www.knora.org/ontology/0001/something"],"selfjoin":false,"shortcode":"0001","shortname":"anything","status":true},{"description":[{"value":"A demo project of a collection of images","language":"en"}],"id":"http://rdfh.ch/projects/00FF","keywords":["collection","images"],"logo":null,"longname":"Image Collection Demo","ontologies":["http://www.knora.org/ontology/00FF/images","http://www.knora.org/ontology/00FF/foo"],"selfjoin":false,"shortcode":"00FF","shortname":"images","status":true},{"description":[{"value":"

Das interdisziplinäre Forschungsprojekt \"Die Bilderfolgen der Basler Frühdrucke: Spätmittelalterliche Didaxe als Bild-Text-Lektüre\" verbindet eine umfassende kunstwissenschaftliche Analyse der Bezüge zwischen den Bildern und Texten in den illustrierten Basler Inkunabeln mit der Digitalisierung der Bestände der Universitätsbibliothek und der Entwicklung einer elektronischen Edition in der Form einer neuartigen Web-0.2-Applikation.\n

\n

Das Projekt wird durchgeführt vom Kunsthistorischen Seminar der Universität Basel (Prof. B. Schellewald) und dem Digital Humanities Lab der Universität Basel (PD Dr. L. Rosenthaler).\n

\n

\nDas Kernstück der digitalen Edition besteht aus rund zwanzig reich bebilderten Frühdrucken aus vier verschiedenen Basler Offizinen. Viele davon sind bereits vor 1500 in mehreren Ausgaben erschienen, einige fast gleichzeitig auf Deutsch und Lateinisch. Es handelt sich um eine ausserordentlich vielfältige Produktion; neben dem Heilsspiegel finden sich ein Roman, die Melusine, die Reisebeschreibungen des Jean de Mandeville, einige Gebets- und Erbauungsbüchlein, theologische Schriften, Fastenpredigten, die Leben der Heiligen Fridolin und Meinrad, das berühmte Narrenschiff sowie die Exempelsammlung des Ritters vom Thurn.\n

\nDie Internetpublikation macht das digitalisierte Korpus dieser Frühdrucke durch die Möglichkeiten nichtlinearer Verknüpfung und Kommentierung der Bilder und Texte, für die wissenschaftliche Edition sowie für die Erforschung der Bilder und Texte nutzbar machen. Auch können bereits bestehende und entstehende Online-Editionen damit verknüpft werden , wodurch die Nutzung von Datenbanken anderer Institutionen im Hinblick auf unser Corpus optimiert wird.\n

"}],"id":"http://rdfh.ch/projects/0803","keywords":["Basel","Basler Frühdrucke","Bilderfolgen","Contectualisation of images","Inkunabel","Kunsthistorisches Seminar Universität Basel","Late Middle Ages","Letterpress Printing","Narrenschiff","Sebastian Brant","Wiegendrucke","early print","incunabula","ship of fools"],"logo":"incunabula_logo.png","longname":"Bilderfolgen Basler Frühdrucke","ontologies":["http://www.knora.org/ontology/0803/incunabula"],"selfjoin":false,"shortcode":"0803","shortname":"incunabula","status":true},{"description":[{"value":"Dokubib"}],"id":"http://rdfh.ch/projects/0804","keywords":[],"logo":null,"longname":"Dokubib","ontologies":["http://www.knora.org/ontology/0804/dokubib"],"selfjoin":false,"shortcode":"0804","shortname":"dokubib","status":false},{"description":[{"value":"Historisch-kritische Edition des Gesamtschaffens von Anton Webern."}],"id":"http://rdfh.ch/projects/08AE","keywords":[],"logo":null,"longname":"Anton Webern Gesamtausgabe","ontologies":[],"selfjoin":false,"shortcode":"08AE","shortname":"webern","status":true},{"description":[{"value":"Bernoulli-Euler Online"}],"id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF","keywords":[],"logo":null,"longname":"Bernoulli-Euler Online","ontologies":["http://www.knora.org/ontology/0801/leibniz","http://www.knora.org/ontology/0801/biblio","http://www.knora.org/ontology/0801/newton","http://www.knora.org/ontology/0801/beol"],"selfjoin":false,"shortcode":"0801","shortname":"beol","status":true},{"description":[{"value":"Knora Shared Ontologies Project","language":"en"}],"id":"http://www.knora.org/ontology/knora-admin#DefaultSharedOntologiesProject","keywords":[],"logo":null,"longname":"Knora Default Shared Ontologies Project","ontologies":[],"selfjoin":false,"shortcode":"0000","shortname":"DefaultSharedOntologiesProject","status":true},{"description":[{"value":"Knora System Project","language":"en"}],"id":"http://www.knora.org/ontology/knora-admin#SystemProject","keywords":[],"logo":null,"longname":"Knora System Project","ontologies":["http://www.knora.org/ontology/standoff","http://www.knora.org/ontology/knora-base","http://www.knora.org/ontology/knora-admin","http://www.knora.org/ontology/salsah-gui"],"selfjoin":false,"shortcode":"FFFF","shortname":"SystemProject","status":true}]} \ No newline at end of file +{"projects":[{"description":[{"value":"Anything Project"}],"id":"http://rdfh.ch/projects/0001","keywords":["arbitrary test data","things"],"logo":null,"longname":"Anything Project","ontologies":["http://www.knora.org/ontology/0001/anything","http://www.knora.org/ontology/0001/minimal","http://www.knora.org/ontology/0001/something"],"selfjoin":false,"shortcode":"0001","shortname":"anything","status":true},{"description":[{"value":"A demo project of a collection of images","language":"en"}],"id":"http://rdfh.ch/projects/00FF","keywords":["collection","images"],"logo":null,"longname":"Image Collection Demo","ontologies":["http://www.knora.org/ontology/00FF/images"],"selfjoin":false,"shortcode":"00FF","shortname":"images","status":true},{"description":[{"value":"

Das interdisziplinäre Forschungsprojekt \"Die Bilderfolgen der Basler Frühdrucke: Spätmittelalterliche Didaxe als Bild-Text-Lektüre\" verbindet eine umfassende kunstwissenschaftliche Analyse der Bezüge zwischen den Bildern und Texten in den illustrierten Basler Inkunabeln mit der Digitalisierung der Bestände der Universitätsbibliothek und der Entwicklung einer elektronischen Edition in der Form einer neuartigen Web-0.2-Applikation.\n

\n

Das Projekt wird durchgeführt vom Kunsthistorischen Seminar der Universität Basel (Prof. B. Schellewald) und dem Digital Humanities Lab der Universität Basel (PD Dr. L. Rosenthaler).\n

\n

\nDas Kernstück der digitalen Edition besteht aus rund zwanzig reich bebilderten Frühdrucken aus vier verschiedenen Basler Offizinen. Viele davon sind bereits vor 1500 in mehreren Ausgaben erschienen, einige fast gleichzeitig auf Deutsch und Lateinisch. Es handelt sich um eine ausserordentlich vielfältige Produktion; neben dem Heilsspiegel finden sich ein Roman, die Melusine, die Reisebeschreibungen des Jean de Mandeville, einige Gebets- und Erbauungsbüchlein, theologische Schriften, Fastenpredigten, die Leben der Heiligen Fridolin und Meinrad, das berühmte Narrenschiff sowie die Exempelsammlung des Ritters vom Thurn.\n

\nDie Internetpublikation macht das digitalisierte Korpus dieser Frühdrucke durch die Möglichkeiten nichtlinearer Verknüpfung und Kommentierung der Bilder und Texte, für die wissenschaftliche Edition sowie für die Erforschung der Bilder und Texte nutzbar machen. Auch können bereits bestehende und entstehende Online-Editionen damit verknüpft werden , wodurch die Nutzung von Datenbanken anderer Institutionen im Hinblick auf unser Corpus optimiert wird.\n

"}],"id":"http://rdfh.ch/projects/0803","keywords":["Basel","Basler Frühdrucke","Bilderfolgen","Contectualisation of images","Inkunabel","Kunsthistorisches Seminar Universität Basel","Late Middle Ages","Letterpress Printing","Narrenschiff","Sebastian Brant","Wiegendrucke","early print","incunabula","ship of fools"],"logo":"incunabula_logo.png","longname":"Bilderfolgen Basler Frühdrucke","ontologies":["http://www.knora.org/ontology/0803/incunabula"],"selfjoin":false,"shortcode":"0803","shortname":"incunabula","status":true},{"description":[{"value":"Dokubib"}],"id":"http://rdfh.ch/projects/0804","keywords":[],"logo":null,"longname":"Dokubib","ontologies":["http://www.knora.org/ontology/0804/dokubib"],"selfjoin":false,"shortcode":"0804","shortname":"dokubib","status":false},{"description":[{"value":"Historisch-kritische Edition des Gesamtschaffens von Anton Webern."}],"id":"http://rdfh.ch/projects/08AE","keywords":[],"logo":null,"longname":"Anton Webern Gesamtausgabe","ontologies":["http://www.knora.org/ontology/08AE/webern"],"selfjoin":false,"shortcode":"08AE","shortname":"webern","status":true},{"description":[{"value":"Bernoulli-Euler Online"}],"id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF","keywords":[],"logo":null,"longname":"Bernoulli-Euler Online","ontologies":["http://www.knora.org/ontology/0801/leibniz","http://www.knora.org/ontology/0801/biblio","http://www.knora.org/ontology/0801/newton","http://www.knora.org/ontology/0801/beol"],"selfjoin":false,"shortcode":"0801","shortname":"beol","status":true},{"description":[{"value":"Knora Shared Ontologies Project","language":"en"}],"id":"http://www.knora.org/ontology/knora-admin#DefaultSharedOntologiesProject","keywords":[],"logo":null,"longname":"Knora Default Shared Ontologies Project","ontologies":[],"selfjoin":false,"shortcode":"0000","shortname":"DefaultSharedOntologiesProject","status":true},{"description":[{"value":"Knora System Project","language":"en"}],"id":"http://www.knora.org/ontology/knora-admin#SystemProject","keywords":[],"logo":null,"longname":"Knora System Project","ontologies":["http://www.knora.org/ontology/standoff","http://www.knora.org/ontology/knora-base","http://www.knora.org/ontology/knora-admin","http://www.knora.org/ontology/salsah-gui"],"selfjoin":false,"shortcode":"FFFF","shortname":"SystemProject","status":true}]} \ No newline at end of file diff --git a/test/data/api/v2/ontologies/all-ontology-metadata-response-expanded.json b/test/data/api/v2/ontologies/all-ontology-metadata-response-expanded.json index 01fa07629..dd8db1491 100644 --- a/test/data/api/v2/ontologies/all-ontology-metadata-response-expanded.json +++ b/test/data/api/v2/ontologies/all-ontology-metadata-response-expanded.json @@ -1 +1 @@ -{"@graph":[{"@id":"http://0.0.0.0:3333/ontology/0001/anything/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://api.knora.org/ontology/knora-api/v2#lastModificationDate":{"@type":"http://www.w3.org/2001/XMLSchema#dateTimeStamp","@value":"2017-12-19T15:23:42.166Z"},"http://www.w3.org/2000/01/rdf-schema#label":"The anything ontology"},{"@id":"http://0.0.0.0:3333/ontology/0001/minimal/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://api.knora.org/ontology/knora-api/v2#lastModificationDate":{"@type":"http://www.w3.org/2001/XMLSchema#dateTimeStamp","@value":"2019-09-10T08:57:46.633162Z"},"http://www.w3.org/2000/01/rdf-schema#label":"A minimal ontology"},{"@id":"http://0.0.0.0:3333/ontology/0001/something/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://www.w3.org/2000/01/rdf-schema#label":"The something ontology"},{"@id":"http://0.0.0.0:3333/ontology/00FF/foo/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/00FF"},"http://api.knora.org/ontology/knora-api/v2#lastModificationDate":{"@type":"http://www.w3.org/2001/XMLSchema#dateTimeStamp","@value":"2020-06-18T09:42:41.506895Z"},"http://www.w3.org/2000/01/rdf-schema#label":"The foo ontology"},{"@id":"http://0.0.0.0:3333/ontology/00FF/images/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/00FF"},"http://www.w3.org/2000/01/rdf-schema#label":"The images demo ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/beol/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The BEOL ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/biblio/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The Biblio ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/leibniz/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The Briefportal Leibniz ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/newton/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The Newton-Project ontology"},{"@id":"http://0.0.0.0:3333/ontology/0803/incunabula/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0803"},"http://www.w3.org/2000/01/rdf-schema#label":"The incunabula ontology"},{"@id":"http://0.0.0.0:3333/ontology/0804/dokubib/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0804"},"http://www.w3.org/2000/01/rdf-schema#label":"The dokubib ontology"},{"@id":"http://api.knora.org/ontology/knora-admin/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The Knora admin ontology"},{"@id":"http://api.knora.org/ontology/knora-api/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The knora-api ontology in the complex schema"},{"@id":"http://api.knora.org/ontology/salsah-gui/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The salsah-gui ontology"},{"@id":"http://api.knora.org/ontology/standoff/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The standoff ontology"}]} \ No newline at end of file +{"@graph":[{"@id":"http://0.0.0.0:3333/ontology/0001/anything/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://api.knora.org/ontology/knora-api/v2#lastModificationDate":{"@type":"http://www.w3.org/2001/XMLSchema#dateTimeStamp","@value":"2017-12-19T15:23:42.166Z"},"http://www.w3.org/2000/01/rdf-schema#label":"The anything ontology"},{"@id":"http://0.0.0.0:3333/ontology/0001/minimal/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://api.knora.org/ontology/knora-api/v2#lastModificationDate":{"@type":"http://www.w3.org/2001/XMLSchema#dateTimeStamp","@value":"2019-09-10T08:57:46.633162Z"},"http://www.w3.org/2000/01/rdf-schema#label":"A minimal ontology"},{"@id":"http://0.0.0.0:3333/ontology/0001/something/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0001"},"http://www.w3.org/2000/01/rdf-schema#label":"The something ontology"},{"@id":"http://0.0.0.0:3333/ontology/00FF/images/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/00FF"},"http://www.w3.org/2000/01/rdf-schema#label":"The images demo ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/beol/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The BEOL ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/biblio/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The Biblio ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/leibniz/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The Briefportal Leibniz ontology"},{"@id":"http://0.0.0.0:3333/ontology/0801/newton/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/yTerZGyxjZVqFMNNKXCDPF"},"http://www.w3.org/2000/01/rdf-schema#label":"The Newton-Project ontology"},{"@id":"http://0.0.0.0:3333/ontology/0803/incunabula/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0803"},"http://www.w3.org/2000/01/rdf-schema#label":"The incunabula ontology"},{"@id":"http://0.0.0.0:3333/ontology/0804/dokubib/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0804"},"http://www.w3.org/2000/01/rdf-schema#label":"The dokubib ontology"},{"@id":"http://0.0.0.0:3333/ontology/08AE/webern/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/08AE"},"http://www.w3.org/2000/01/rdf-schema#label":"The Anton Webern project ontology"},{"@id":"http://api.knora.org/ontology/knora-admin/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The Knora admin ontology"},{"@id":"http://api.knora.org/ontology/knora-api/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The knora-api ontology in the complex schema"},{"@id":"http://api.knora.org/ontology/salsah-gui/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The salsah-gui ontology"},{"@id":"http://api.knora.org/ontology/standoff/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://www.knora.org/ontology/knora-admin#SystemProject"},"http://api.knora.org/ontology/knora-api/v2#isBuiltIn":true,"http://www.w3.org/2000/01/rdf-schema#label":"The standoff ontology"}]} \ No newline at end of file diff --git a/test/data/api/v2/ontologies/all-ontology-metadata-response.json b/test/data/api/v2/ontologies/all-ontology-metadata-response.json index 099f19a37..27f40f2dc 100644 --- a/test/data/api/v2/ontologies/all-ontology-metadata-response.json +++ b/test/data/api/v2/ontologies/all-ontology-metadata-response.json @@ -28,17 +28,6 @@ "@id" : "http://rdfh.ch/projects/0001" }, "rdfs:label" : "The something ontology" - }, { - "@id" : "http://0.0.0.0:3333/ontology/00FF/foo/v2", - "@type" : "owl:Ontology", - "knora-api:attachedToProject" : { - "@id" : "http://rdfh.ch/projects/00FF" - }, - "knora-api:lastModificationDate" : { - "@type" : "xsd:dateTimeStamp", - "@value" : "2020-06-18T09:42:41.506895Z" - }, - "rdfs:label" : "The foo ontology" }, { "@id" : "http://0.0.0.0:3333/ontology/00FF/images/v2", "@type" : "owl:Ontology", @@ -88,6 +77,13 @@ "@id" : "http://rdfh.ch/projects/0804" }, "rdfs:label" : "The dokubib ontology" + }, { + "@id" : "http://0.0.0.0:3333/ontology/08AE/webern/v2", + "@type" : "owl:Ontology", + "knora-api:attachedToProject" : { + "@id" : "http://rdfh.ch/projects/08AE" + }, + "rdfs:label" : "The Anton Webern project ontology" }, { "@id" : "http://api.knora.org/ontology/knora-admin/v2", "@type" : "owl:Ontology", From 29aead757ff3c4278dbbfc6bbd226845ed970a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Fri, 19 Jun 2020 11:57:21 +0200 Subject: [PATCH 04/20] test(ontology): Update test framework and e2e test --- test-framework/e2e/src/app.e2e-spec.ts | 15 ++++++++++++++ test-framework/src/app/app.component.html | 8 ++++++++ test-framework/src/app/app.component.ts | 24 ++++++++++++++++++++++- test-framework/yalc.lock | 2 +- 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/test-framework/e2e/src/app.e2e-spec.ts b/test-framework/e2e/src/app.e2e-spec.ts index 3ed323b75..1d159554b 100644 --- a/test-framework/e2e/src/app.e2e-spec.ts +++ b/test-framework/e2e/src/app.e2e-spec.ts @@ -93,6 +93,21 @@ describe('workspace-project App', () => { }); + + it('request the anything project ontologies', () => { + + page.navigateTo(); + + const button = page.getEle('div section#ontologyendpoint button.get'); + + button.click(); + + const size = page.getEle('div section#ontologyendpoint span.ontology'); + + expect(size.getText()).toEqual('3 ontologies'); + + }); + it('request a resource', () => { page.navigateTo(); diff --git a/test-framework/src/app/app.component.html b/test-framework/src/app/app.component.html index 2afa5c9f9..2a91b3527 100644 --- a/test-framework/src/app/app.component.html +++ b/test-framework/src/app/app.component.html @@ -28,6 +28,14 @@

Ontology Cache

+
+

OntologyEndpoint

+ +
+ Anything project has
{{projectOntologies?.ontologies.length | i18nPlural: itemPluralMapping['ontology']}} +
+
+

Resource



diff --git a/test-framework/src/app/app.component.ts b/test-framework/src/app/app.component.ts index d86e5a621..cea2d2465 100644 --- a/test-framework/src/app/app.component.ts +++ b/test-framework/src/app/app.component.ts @@ -26,7 +26,9 @@ import { UserResponse, UsersResponse, WriteValueResponse, - DeleteResourceResponse + DeleteResourceResponse, + OntologiesMetadata, + ApiResponseError } from "@dasch-swiss/dsp-js"; import { map } from "rxjs/operators"; @@ -43,6 +45,7 @@ export class AppComponent implements OnInit { userCache: UserCache; ontologies: Map; + projectOntologies: OntologiesMetadata; resource: ReadResource; @@ -57,6 +60,13 @@ export class AppComponent implements OnInit { resourceStatus = ''; + itemPluralMapping = { + ontology: { + '=1': '1 ontology', + other: '# ontologies' + } + }; + ngOnInit() { const config = new KnoraApiConfig('http', '0.0.0.0', 3333, undefined, undefined, true); this.knoraApiConnection = new KnoraApiConnection(config); @@ -115,6 +125,18 @@ export class AppComponent implements OnInit { ); } + getOntologiesByProjectIri(iri: string) { + this.knoraApiConnection.v2.onto.getOntologiesByProjectIri(iri).subscribe( + (response: OntologiesMetadata) => { + console.log('project ontologies ', response); + this.projectOntologies = response; + }, + (error: ApiResponseError) => { + console.error('project ontologies error', error); + } + ) + } + getResourceClass(iri: string) { this.knoraApiConnection.v2.ontologyCache.getResourceClassDefinition(iri).subscribe( diff --git a/test-framework/yalc.lock b/test-framework/yalc.lock index 54006d67e..2739a1bde 100644 --- a/test-framework/yalc.lock +++ b/test-framework/yalc.lock @@ -2,7 +2,7 @@ "version": "v1", "packages": { "@dasch-swiss/dsp-js": { - "signature": "2a3cf026372af1912a17c32ec4c1188f", + "signature": "5307eb7530f2eb06476c8732f98419f1", "file": true } } From 03214454c2eaa2df3e0d80fb3ccc5803e478fbbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Tue, 23 Jun 2020 07:20:08 +0200 Subject: [PATCH 05/20] test(e2e): Get project ontologies --- test-framework/e2e/src/app.e2e-spec.ts | 18 ++++++++++++++++-- test-framework/src/app/app.component.html | 8 ++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/test-framework/e2e/src/app.e2e-spec.ts b/test-framework/e2e/src/app.e2e-spec.ts index 1d159554b..e910f4532 100644 --- a/test-framework/e2e/src/app.e2e-spec.ts +++ b/test-framework/e2e/src/app.e2e-spec.ts @@ -98,16 +98,30 @@ describe('workspace-project App', () => { page.navigateTo(); - const button = page.getEle('div section#ontologyendpoint button.get'); + const button = page.getEle('div section#ontologyendpoint button.anything'); button.click(); - const size = page.getEle('div section#ontologyendpoint span.ontology'); + const size = page.getEle('div section#ontologyendpoint span.anything'); expect(size.getText()).toEqual('3 ontologies'); }); + it('request the image project ontologies', () => { + + page.navigateTo(); + + const button = page.getEle('div section#ontologyendpoint button.image'); + + button.click(); + + const size = page.getEle('div section#ontologyendpoint span.image'); + + expect(size.getText()).toEqual('1 ontology'); + + }); + it('request a resource', () => { page.navigateTo(); diff --git a/test-framework/src/app/app.component.html b/test-framework/src/app/app.component.html index 2a91b3527..bc288c088 100644 --- a/test-framework/src/app/app.component.html +++ b/test-framework/src/app/app.component.html @@ -30,9 +30,13 @@

Ontology Cache

OntologyEndpoint

- +
- Anything project has
{{projectOntologies?.ontologies.length | i18nPlural: itemPluralMapping['ontology']}} + Anything project has
{{projectOntologies?.ontologies.length | i18nPlural: itemPluralMapping['ontology']}} +
+ +
+ Image project has
{{projectOntologies?.ontologies.length | i18nPlural: itemPluralMapping['ontology']}}
From 0a2ba4009bf47e25135846636e602e33a2b46fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Tue, 23 Jun 2020 15:20:28 +0200 Subject: [PATCH 06/20] feat(onto): ReadOntologySequence --- src/api/v2/ontology/ontologies-endpoint-v2.ts | 1 + .../v2/ontologies/OntologyConversionUtil.ts | 38 +++++++++++++++++++ .../v2/ontologies/read-ontology-sequence.ts | 13 +++++++ 3 files changed, 52 insertions(+) create mode 100644 src/models/v2/ontologies/read-ontology-sequence.ts diff --git a/src/api/v2/ontology/ontologies-endpoint-v2.ts b/src/api/v2/ontology/ontologies-endpoint-v2.ts index 4584fa414..c5a296abc 100644 --- a/src/api/v2/ontology/ontologies-endpoint-v2.ts +++ b/src/api/v2/ontology/ontologies-endpoint-v2.ts @@ -69,6 +69,7 @@ export class OntologiesEndpointV2 extends Endpoint { mergeMap((ajaxResponse: AjaxResponse) => { return jsonld.compact(ajaxResponse.response, {}); }), map((jsonldobj: object) => { + // if not a @graph convert into graph and use as above return this.jsonConvert.deserializeObject(jsonldobj, OntologiesMetadata); }), catchError(error => { diff --git a/src/models/v2/ontologies/OntologyConversionUtil.ts b/src/models/v2/ontologies/OntologyConversionUtil.ts index 15e49c3e0..434d55c17 100644 --- a/src/models/v2/ontologies/OntologyConversionUtil.ts +++ b/src/models/v2/ontologies/OntologyConversionUtil.ts @@ -1,4 +1,6 @@ import { JsonConvert } from "json2typescript"; +import { forkJoin, Observable, of } from "rxjs"; +import { map, mergeMap } from "rxjs/operators"; import { KnoraApiConfig } from "../../../knora-api-config"; import { Constants } from "../Constants"; import { IHasProperty } from "./class-definition"; @@ -8,6 +10,7 @@ import { ResourceClassDefinition } from "./resource-class-definition"; import { ResourcePropertyDefinition } from "./resource-property-definition"; import { StandoffClassDefinition } from "./standoff-class-definition"; import { SystemPropertyDefinition } from "./system-property-definition"; +import { ReadOntologySequence } from "./read-ontology-sequence"; export namespace OntologyConversionUtil { @@ -219,4 +222,39 @@ export namespace OntologyConversionUtil { }; + /** + * Given a JSON-LD representing zero, one or more ontologies, converts it to an array of ReadOntology. + * + * JSON-LD is expected to have expanded prefixes (processed by jsonld processor). + * + * @param ontologiesJsonld a JSON-LD object with expanded prefixes representing zero, one or more ontologies. + * @param jsonConvert instance of JsonConvert to be used. + */ + export const createReadOntologySequence = (ontologiesJsonld: object, jsonConvert: JsonConvert, knoraApiConfig: KnoraApiConfig): Observable => { + + if (ontologiesJsonld.hasOwnProperty("@graph")) { + // sequence of resources + return forkJoin((ontologiesJsonld as { [index: string]: object[] })["@graph"] + .map((onto: { [index: string]: object[] | string }) => convertOntology(onto, jsonConvert, knoraApiConfig))).pipe( + map((ontologies: ReadOntology[]) => { + return new ReadOntologySequence(ontologies); + }) + ); + } else { + // one or no ontology + if (Object.keys(ontologiesJsonld).length === 0) { + return of(new ReadOntologySequence([])); + } else { + // return OntologyConversionUtil.convertOntology(jsonldobj, this.jsonConvert, this.knoraApiConfig); + return forkJoin([convertOntology(ontologiesJsonld as { [index: string]: object[] | string }, jsonConvert, knoraApiConfig)]).pipe( + map((resources: ReadOntology[]) => { + return new ReadOntologySequence(resources); + }) + ); + } + } + }; } + + +// \ No newline at end of file diff --git a/src/models/v2/ontologies/read-ontology-sequence.ts b/src/models/v2/ontologies/read-ontology-sequence.ts new file mode 100644 index 000000000..cbbd82bb4 --- /dev/null +++ b/src/models/v2/ontologies/read-ontology-sequence.ts @@ -0,0 +1,13 @@ +import { ReadOntology } from "./read-ontology"; + +export class ReadOntologySequence { + + /** + * Represents a sequence of ontologies. + * + * @param ontologies sequence of ontologies. + */ + constructor(readonly ontologies: ReadOntology[]) { + } + +} From ac6d6f31dbc6616221e9d51a2527c50605c6f0c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Tue, 23 Jun 2020 21:47:46 +0200 Subject: [PATCH 07/20] chore(gh): Ignore yalc.lock --- .gitignore | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 60fae5451..dc9a9c128 100644 --- a/.gitignore +++ b/.gitignore @@ -6,9 +6,6 @@ /docs .DS_Store -# Do not add package-lock.json of the test app to git because it could lead to problems when some dependency version change in the lib and is not adapted here. -test-framework/package-lock.json - ############################ # PhpStorm/WebStorm ignore # ############################ @@ -37,7 +34,10 @@ test-framework/package-lock.json .idea/**/dbnavigator.xml ############################ +# Do not add package-lock.json of the test app to git because it could lead to problems when some dependency version change in the lib and is not adapted here. +test-framework/package-lock.json +/test-framework/yalc.lock +/test-framework/dist /test-framework/node_modules /test-framework/.yalc -/test-framework/dist /.tmp From 3ee67341ca7a01eaa90c31860d7c755d24f8f541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Tue, 23 Jun 2020 22:07:45 +0200 Subject: [PATCH 08/20] test: Get project ontologies for e2e test --- test-framework/e2e/src/app.e2e-spec.ts | 6 ++--- test-framework/src/app/app.component.html | 8 +++---- test-framework/src/app/app.component.ts | 29 +++++++++++++++++------ 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/test-framework/e2e/src/app.e2e-spec.ts b/test-framework/e2e/src/app.e2e-spec.ts index e910f4532..7ee709736 100644 --- a/test-framework/e2e/src/app.e2e-spec.ts +++ b/test-framework/e2e/src/app.e2e-spec.ts @@ -108,15 +108,15 @@ describe('workspace-project App', () => { }); - it('request the image project ontologies', () => { + it('request the dokubib project ontologies', () => { page.navigateTo(); - const button = page.getEle('div section#ontologyendpoint button.image'); + const button = page.getEle('div section#ontologyendpoint button.dokubib'); button.click(); - const size = page.getEle('div section#ontologyendpoint span.image'); + const size = page.getEle('div section#ontologyendpoint span.dokubib'); expect(size.getText()).toEqual('1 ontology'); diff --git a/test-framework/src/app/app.component.html b/test-framework/src/app/app.component.html index bc288c088..746361745 100644 --- a/test-framework/src/app/app.component.html +++ b/test-framework/src/app/app.component.html @@ -30,13 +30,13 @@

Ontology Cache

OntologyEndpoint

- +
- Anything project has
{{projectOntologies?.ontologies.length | i18nPlural: itemPluralMapping['ontology']}} + Anything project has
{{anythingOntologies?.length | i18nPlural: itemPluralMapping['ontology']}}
- +
- Image project has
{{projectOntologies?.ontologies.length | i18nPlural: itemPluralMapping['ontology']}} + Dokubib project has
{{dokubibOntologies?.length | i18nPlural: itemPluralMapping['ontology']}}
diff --git a/test-framework/src/app/app.component.ts b/test-framework/src/app/app.component.ts index cea2d2465..206c6a49b 100644 --- a/test-framework/src/app/app.component.ts +++ b/test-framework/src/app/app.component.ts @@ -28,10 +28,12 @@ import { WriteValueResponse, DeleteResourceResponse, OntologiesMetadata, - ApiResponseError + ApiResponseError, + OntologyMetadata } from "@dasch-swiss/dsp-js"; import { map } from "rxjs/operators"; +import { ReadOntologySequence } from '@dasch-swiss/dsp-js/src/models/v2/ontologies/read-ontology-sequence'; @Component({ selector: 'app-root', @@ -45,7 +47,8 @@ export class AppComponent implements OnInit { userCache: UserCache; ontologies: Map; - projectOntologies: OntologiesMetadata; + anythingOntologies: OntologyMetadata[]; + dokubibOntologies: OntologyMetadata[]; resource: ReadResource; @@ -125,17 +128,29 @@ export class AppComponent implements OnInit { ); } - getOntologiesByProjectIri(iri: string) { - this.knoraApiConnection.v2.onto.getOntologiesByProjectIri(iri).subscribe( - (response: OntologiesMetadata) => { - console.log('project ontologies ', response); - this.projectOntologies = response; + getAnythingOntologies() { + this.knoraApiConnection.v2.onto.getOntologiesByProjectIri('http://rdfh.ch/projects/0001').subscribe( + (response: OntologyMetadata[]) => { + console.log('anythingOntologies ', response); + this.anythingOntologies = response; }, (error: ApiResponseError) => { console.error('project ontologies error', error); } ) } + getDokubibOntologies() { + this.knoraApiConnection.v2.onto.getOntologiesByProjectIri('http://rdfh.ch/projects/0804').subscribe( + (response: OntologyMetadata[]) => { + console.log('dokubibOntologies ', response); + this.dokubibOntologies = response; + }, + (error: ApiResponseError) => { + console.error('project ontologies error', error); + } + ) + } + getResourceClass(iri: string) { From 598e12705d522a74ed48c0d7d2770d0ce37adc75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Tue, 23 Jun 2020 22:08:24 +0200 Subject: [PATCH 09/20] feat(onto): Get project ontologies --- src/api/v2/ontology/ontologies-endpoint-v2.ts | 16 ++++++-- .../v2/ontology/ontologies-endpoint.spec.ts | 12 +++--- .../v2/ontologies/OntologyConversionUtil.ts | 38 ------------------- test-framework/yalc.lock | 2 +- 4 files changed, 19 insertions(+), 49 deletions(-) diff --git a/src/api/v2/ontology/ontologies-endpoint-v2.ts b/src/api/v2/ontology/ontologies-endpoint-v2.ts index c5a296abc..a6f0772a6 100644 --- a/src/api/v2/ontology/ontologies-endpoint-v2.ts +++ b/src/api/v2/ontology/ontologies-endpoint-v2.ts @@ -2,7 +2,7 @@ import { Observable } from "rxjs"; import { AjaxResponse } from "rxjs/ajax"; import { catchError, map, mergeMap } from "rxjs/operators"; import { ApiResponseError } from "../../../models/api-response-error"; -import { OntologiesMetadata } from "../../../models/v2/ontologies/ontology-metadata"; +import { OntologiesMetadata, OntologyMetadata } from "../../../models/v2/ontologies/ontology-metadata"; import { OntologyConversionUtil } from "../../../models/v2/ontologies/OntologyConversionUtil"; import { ReadOntology } from "../../../models/v2/ontologies/read-ontology"; import { Endpoint } from "../../endpoint"; @@ -63,19 +63,27 @@ export class OntologiesEndpointV2 extends Endpoint { * * @param projectIri the IRI of the project */ - getOntologiesByProjectIri(projectIri: string): Observable { + getOntologiesByProjectIri(projectIri: string): Observable { return this.httpGet("/metadata/" + encodeURIComponent(projectIri)).pipe( mergeMap((ajaxResponse: AjaxResponse) => { + // TODO: @rosenth Adapt context object + // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map((jsonldobj: object) => { - // if not a @graph convert into graph and use as above - return this.jsonConvert.deserializeObject(jsonldobj, OntologiesMetadata); + // console.log('jsonldobj', jsonldobj) + // return OntologyConversionUtil.concatOntologyMetadata(jsonldobj, this.jsonConvert); + if (jsonldobj.hasOwnProperty("@graph")) { + return (this.jsonConvert.deserializeObject(jsonldobj, OntologiesMetadata).ontologies as OntologyMetadata[]); + } else { + return ([this.jsonConvert.deserializeObject(jsonldobj, OntologyMetadata)] as OntologyMetadata[]); + } }), catchError(error => { return this.handleError(error); }) ); + } } diff --git a/src/api/v2/ontology/ontologies-endpoint.spec.ts b/src/api/v2/ontology/ontologies-endpoint.spec.ts index 4421acf18..d5f687b69 100644 --- a/src/api/v2/ontology/ontologies-endpoint.spec.ts +++ b/src/api/v2/ontology/ontologies-endpoint.spec.ts @@ -1,7 +1,7 @@ import { MockAjaxCall } from "../../../../test/mockajaxcall"; import { KnoraApiConfig } from "../../../knora-api-config"; import { KnoraApiConnection } from "../../../knora-api-connection"; -import { OntologiesMetadata } from "../../../models/v2/ontologies/ontology-metadata"; +import { OntologiesMetadata, OntologyMetadata } from "../../../models/v2/ontologies/ontology-metadata"; import { ReadOntology } from "../../../models/v2/ontologies/read-ontology"; import { ResourceClassDefinition } from "../../../models/v2/ontologies/resource-class-definition"; import { ResourcePropertyDefinition } from "../../../models/v2/ontologies/resource-property-definition"; @@ -173,11 +173,11 @@ describe("OntologiesEndpoint", () => { it("should return all ontologies from 'anything' project", done => { knoraApiConnection.v2.onto.getOntologiesByProjectIri("http://rdfh.ch/projects/0001").subscribe( - (response: OntologiesMetadata) => { - expect(response.ontologies.length).toEqual(3); - expect(response.ontologies[0].id).toEqual("http://0.0.0.0:3333/ontology/0001/anything/v2"); - expect(response.ontologies[1].id).toEqual("http://0.0.0.0:3333/ontology/0001/minimal/v2"); - expect(response.ontologies[2].id).toEqual("http://0.0.0.0:3333/ontology/0001/something/v2"); + (response: OntologyMetadata[]) => { + expect(response.length).toEqual(3); + expect(response[0].id).toEqual("http://0.0.0.0:3333/ontology/0001/anything/v2"); + expect(response[1].id).toEqual("http://0.0.0.0:3333/ontology/0001/minimal/v2"); + expect(response[2].id).toEqual("http://0.0.0.0:3333/ontology/0001/something/v2"); done(); } ); diff --git a/src/models/v2/ontologies/OntologyConversionUtil.ts b/src/models/v2/ontologies/OntologyConversionUtil.ts index 434d55c17..15e49c3e0 100644 --- a/src/models/v2/ontologies/OntologyConversionUtil.ts +++ b/src/models/v2/ontologies/OntologyConversionUtil.ts @@ -1,6 +1,4 @@ import { JsonConvert } from "json2typescript"; -import { forkJoin, Observable, of } from "rxjs"; -import { map, mergeMap } from "rxjs/operators"; import { KnoraApiConfig } from "../../../knora-api-config"; import { Constants } from "../Constants"; import { IHasProperty } from "./class-definition"; @@ -10,7 +8,6 @@ import { ResourceClassDefinition } from "./resource-class-definition"; import { ResourcePropertyDefinition } from "./resource-property-definition"; import { StandoffClassDefinition } from "./standoff-class-definition"; import { SystemPropertyDefinition } from "./system-property-definition"; -import { ReadOntologySequence } from "./read-ontology-sequence"; export namespace OntologyConversionUtil { @@ -222,39 +219,4 @@ export namespace OntologyConversionUtil { }; - /** - * Given a JSON-LD representing zero, one or more ontologies, converts it to an array of ReadOntology. - * - * JSON-LD is expected to have expanded prefixes (processed by jsonld processor). - * - * @param ontologiesJsonld a JSON-LD object with expanded prefixes representing zero, one or more ontologies. - * @param jsonConvert instance of JsonConvert to be used. - */ - export const createReadOntologySequence = (ontologiesJsonld: object, jsonConvert: JsonConvert, knoraApiConfig: KnoraApiConfig): Observable => { - - if (ontologiesJsonld.hasOwnProperty("@graph")) { - // sequence of resources - return forkJoin((ontologiesJsonld as { [index: string]: object[] })["@graph"] - .map((onto: { [index: string]: object[] | string }) => convertOntology(onto, jsonConvert, knoraApiConfig))).pipe( - map((ontologies: ReadOntology[]) => { - return new ReadOntologySequence(ontologies); - }) - ); - } else { - // one or no ontology - if (Object.keys(ontologiesJsonld).length === 0) { - return of(new ReadOntologySequence([])); - } else { - // return OntologyConversionUtil.convertOntology(jsonldobj, this.jsonConvert, this.knoraApiConfig); - return forkJoin([convertOntology(ontologiesJsonld as { [index: string]: object[] | string }, jsonConvert, knoraApiConfig)]).pipe( - map((resources: ReadOntology[]) => { - return new ReadOntologySequence(resources); - }) - ); - } - } - }; } - - -// \ No newline at end of file diff --git a/test-framework/yalc.lock b/test-framework/yalc.lock index 2739a1bde..29aefd9dd 100644 --- a/test-framework/yalc.lock +++ b/test-framework/yalc.lock @@ -2,7 +2,7 @@ "version": "v1", "packages": { "@dasch-swiss/dsp-js": { - "signature": "5307eb7530f2eb06476c8732f98419f1", + "signature": "bc4cf32ca189265b54b5a17831377df7", "file": true } } From f17473ea4e3ca0e5b8d3fc9bcc49708852888856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Tue, 23 Jun 2020 22:41:47 +0200 Subject: [PATCH 10/20] chore: Ignore build in test-framework --- .gitignore | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index dc9a9c128..f716ce75f 100644 --- a/.gitignore +++ b/.gitignore @@ -36,8 +36,8 @@ # Do not add package-lock.json of the test app to git because it could lead to problems when some dependency version change in the lib and is not adapted here. test-framework/package-lock.json -/test-framework/yalc.lock -/test-framework/dist -/test-framework/node_modules -/test-framework/.yalc +test-framework/yalc.lock +test-framework/dist +test-framework/node_modules +test-framework/.yalc /.tmp From 1b8607c901bb7ab6d8dcfd9e5639b87e6dcf2bec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Tue, 23 Jun 2020 22:44:14 +0200 Subject: [PATCH 11/20] fix: Fix comma issue --- test-framework/src/app/app.component.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test-framework/src/app/app.component.ts b/test-framework/src/app/app.component.ts index 70ee844d3..bf7b2702a 100644 --- a/test-framework/src/app/app.component.ts +++ b/test-framework/src/app/app.component.ts @@ -27,9 +27,8 @@ import { UsersResponse, WriteValueResponse, DeleteResourceResponse, - OntologiesMetadata, ApiResponseError, - OntologyMetadata + OntologyMetadata, MockOntology, MockProjects, MockUsers From dded53b4ce9b6bc02d5e9102693a780d5a8dd927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Tue, 23 Jun 2020 23:05:15 +0200 Subject: [PATCH 12/20] test: Rename variable --- test-framework/e2e/src/app.e2e-spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test-framework/e2e/src/app.e2e-spec.ts b/test-framework/e2e/src/app.e2e-spec.ts index 7ee709736..668439453 100644 --- a/test-framework/e2e/src/app.e2e-spec.ts +++ b/test-framework/e2e/src/app.e2e-spec.ts @@ -102,9 +102,9 @@ describe('workspace-project App', () => { button.click(); - const size = page.getEle('div section#ontologyendpoint span.anything'); + const result = page.getEle('div section#ontologyendpoint span.anything'); - expect(size.getText()).toEqual('3 ontologies'); + expect(result.getText()).toEqual('3 ontologies'); }); @@ -116,9 +116,9 @@ describe('workspace-project App', () => { button.click(); - const size = page.getEle('div section#ontologyendpoint span.dokubib'); + const result = page.getEle('div section#ontologyendpoint span.dokubib'); - expect(size.getText()).toEqual('1 ontology'); + expect(result.getText()).toEqual('1 ontology'); }); From 1b26545fcb2ba6f8ce53c5e48a1e2584e77d5a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Tue, 23 Jun 2020 23:05:33 +0200 Subject: [PATCH 13/20] Delete yalc.lock --- test-framework/yalc.lock | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 test-framework/yalc.lock diff --git a/test-framework/yalc.lock b/test-framework/yalc.lock deleted file mode 100644 index 759d115f8..000000000 --- a/test-framework/yalc.lock +++ /dev/null @@ -1,9 +0,0 @@ -{ - "version": "v1", - "packages": { - "@dasch-swiss/dsp-js": { - "signature": "2df54bb628f04a0a2240cf87ff007f83", - "file": true - } - } -} \ No newline at end of file From 6e30bade71d6b955ace4da4195c381643143afe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Tue, 23 Jun 2020 23:45:34 +0200 Subject: [PATCH 14/20] refactor(onto): Clean up --- src/api/v2/ontology/ontologies-endpoint-v2.ts | 2 -- src/models/v2/ontologies/read-ontology-sequence.ts | 13 ------------- test-framework/src/app/app.component.ts | 1 - 3 files changed, 16 deletions(-) delete mode 100644 src/models/v2/ontologies/read-ontology-sequence.ts diff --git a/src/api/v2/ontology/ontologies-endpoint-v2.ts b/src/api/v2/ontology/ontologies-endpoint-v2.ts index a6f0772a6..fd1ae2b07 100644 --- a/src/api/v2/ontology/ontologies-endpoint-v2.ts +++ b/src/api/v2/ontology/ontologies-endpoint-v2.ts @@ -71,8 +71,6 @@ export class OntologiesEndpointV2 extends Endpoint { // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map((jsonldobj: object) => { - // console.log('jsonldobj', jsonldobj) - // return OntologyConversionUtil.concatOntologyMetadata(jsonldobj, this.jsonConvert); if (jsonldobj.hasOwnProperty("@graph")) { return (this.jsonConvert.deserializeObject(jsonldobj, OntologiesMetadata).ontologies as OntologyMetadata[]); } else { diff --git a/src/models/v2/ontologies/read-ontology-sequence.ts b/src/models/v2/ontologies/read-ontology-sequence.ts deleted file mode 100644 index cbbd82bb4..000000000 --- a/src/models/v2/ontologies/read-ontology-sequence.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ReadOntology } from "./read-ontology"; - -export class ReadOntologySequence { - - /** - * Represents a sequence of ontologies. - * - * @param ontologies sequence of ontologies. - */ - constructor(readonly ontologies: ReadOntology[]) { - } - -} diff --git a/test-framework/src/app/app.component.ts b/test-framework/src/app/app.component.ts index bf7b2702a..bbc53bbd5 100644 --- a/test-framework/src/app/app.component.ts +++ b/test-framework/src/app/app.component.ts @@ -35,7 +35,6 @@ import { } from "@dasch-swiss/dsp-js"; import { map } from "rxjs/operators"; -import { ReadOntologySequence } from '@dasch-swiss/dsp-js/src/models/v2/ontologies/read-ontology-sequence'; @Component({ selector: 'app-root', From cf3870a1c7354b77129ae99b1145ca8d64685e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Thu, 25 Jun 2020 17:11:22 +0200 Subject: [PATCH 15/20] refactor(onto): Return OntologiesMetadata --- src/api/v2/ontology/ontologies-endpoint-v2.ts | 9 ++++++--- src/api/v2/ontology/ontologies-endpoint.spec.ts | 10 +++++----- test-framework/src/app/app.component.ts | 13 +++++++------ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/api/v2/ontology/ontologies-endpoint-v2.ts b/src/api/v2/ontology/ontologies-endpoint-v2.ts index fd1ae2b07..24e302979 100644 --- a/src/api/v2/ontology/ontologies-endpoint-v2.ts +++ b/src/api/v2/ontology/ontologies-endpoint-v2.ts @@ -62,8 +62,9 @@ export class OntologiesEndpointV2 extends Endpoint { * Requests metadata about all ontologies from specific project * * @param projectIri the IRI of the project + * @return OntologiesMetadata or an error */ - getOntologiesByProjectIri(projectIri: string): Observable { + getOntologiesByProjectIri(projectIri: string): Observable { return this.httpGet("/metadata/" + encodeURIComponent(projectIri)).pipe( mergeMap((ajaxResponse: AjaxResponse) => { @@ -72,9 +73,11 @@ export class OntologiesEndpointV2 extends Endpoint { return jsonld.compact(ajaxResponse.response, {}); }), map((jsonldobj: object) => { if (jsonldobj.hasOwnProperty("@graph")) { - return (this.jsonConvert.deserializeObject(jsonldobj, OntologiesMetadata).ontologies as OntologyMetadata[]); + return (this.jsonConvert.deserializeObject(jsonldobj, OntologiesMetadata) as OntologiesMetadata); } else { - return ([this.jsonConvert.deserializeObject(jsonldobj, OntologyMetadata)] as OntologyMetadata[]); + const ontos: OntologiesMetadata = new OntologiesMetadata(); + ontos.ontologies = [this.jsonConvert.deserializeObject(jsonldobj, OntologyMetadata)] + return ontos; } }), catchError(error => { diff --git a/src/api/v2/ontology/ontologies-endpoint.spec.ts b/src/api/v2/ontology/ontologies-endpoint.spec.ts index d5f687b69..4b3428289 100644 --- a/src/api/v2/ontology/ontologies-endpoint.spec.ts +++ b/src/api/v2/ontology/ontologies-endpoint.spec.ts @@ -173,11 +173,11 @@ describe("OntologiesEndpoint", () => { it("should return all ontologies from 'anything' project", done => { knoraApiConnection.v2.onto.getOntologiesByProjectIri("http://rdfh.ch/projects/0001").subscribe( - (response: OntologyMetadata[]) => { - expect(response.length).toEqual(3); - expect(response[0].id).toEqual("http://0.0.0.0:3333/ontology/0001/anything/v2"); - expect(response[1].id).toEqual("http://0.0.0.0:3333/ontology/0001/minimal/v2"); - expect(response[2].id).toEqual("http://0.0.0.0:3333/ontology/0001/something/v2"); + (response: OntologiesMetadata) => { + expect(response.ontologies.length).toEqual(3); + expect(response.ontologies[0].id).toEqual("http://0.0.0.0:3333/ontology/0001/anything/v2"); + expect(response.ontologies[1].id).toEqual("http://0.0.0.0:3333/ontology/0001/minimal/v2"); + expect(response.ontologies[2].id).toEqual("http://0.0.0.0:3333/ontology/0001/something/v2"); done(); } ); diff --git a/test-framework/src/app/app.component.ts b/test-framework/src/app/app.component.ts index bbc53bbd5..366a205dc 100644 --- a/test-framework/src/app/app.component.ts +++ b/test-framework/src/app/app.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from "@angular/core"; import { ApiResponseData, + ApiResponseError, Constants, CountQueryResponse, CreateBooleanValue, @@ -14,6 +15,7 @@ import { KnoraApiConnection, ListNodeV2, LoginResponse, + OntologiesMetadata, ReadOntology, ReadResource, ReadResourceSequence, @@ -27,11 +29,10 @@ import { UsersResponse, WriteValueResponse, DeleteResourceResponse, - ApiResponseError, OntologyMetadata, MockOntology, MockProjects, - MockUsers + MockUsers, } from "@dasch-swiss/dsp-js"; import { map } from "rxjs/operators"; @@ -48,8 +49,8 @@ export class AppComponent implements OnInit { userCache: UserCache; ontologies: Map; - anythingOntologies: OntologyMetadata[]; - dokubibOntologies: OntologyMetadata[]; + anythingOntologies: OntologiesMetadata; + dokubibOntologies: OntologiesMetadata; resource: ReadResource; @@ -132,7 +133,7 @@ export class AppComponent implements OnInit { getAnythingOntologies() { this.knoraApiConnection.v2.onto.getOntologiesByProjectIri('http://rdfh.ch/projects/0001').subscribe( - (response: OntologyMetadata[]) => { + (response: OntologiesMetadata) => { console.log('anythingOntologies ', response); this.anythingOntologies = response; }, @@ -143,7 +144,7 @@ export class AppComponent implements OnInit { } getDokubibOntologies() { this.knoraApiConnection.v2.onto.getOntologiesByProjectIri('http://rdfh.ch/projects/0804').subscribe( - (response: OntologyMetadata[]) => { + (response: OntologiesMetadata) => { console.log('dokubibOntologies ', response); this.dokubibOntologies = response; }, From f67fefbc77d72f2fa2aaf40924f37220f1b8b684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Thu, 25 Jun 2020 17:46:44 +0200 Subject: [PATCH 16/20] test(onto): Additional project example --- scripts/v2-test-data-config.json | 4 ++++ src/api/v2/ontology/ontologies-endpoint-v2.ts | 10 ++------- .../v2/ontology/ontologies-endpoint.spec.ts | 22 +++++++++++++++++++ .../v2/ontologies/OntologyConversionUtil.ts | 14 ++++++++++++ 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/scripts/v2-test-data-config.json b/scripts/v2-test-data-config.json index eec74b5db..66c0b75d1 100644 --- a/scripts/v2-test-data-config.json +++ b/scripts/v2-test-data-config.json @@ -24,6 +24,10 @@ "source": "/v2/ontologies/get-ontologies-project-anything-response.json", "destination": "./test/data/api/v2/ontologies/get-ontologies-project-anything-response.json" }, + { + "source": "/v2/ontologies/get-ontologies-project-incunabula-response.json", + "destination": "./test/data/api/v2/ontologies/get-ontologies-project-incunabula-response.json" + }, { "source": "/v2/resources/testding.json", "destination": "./test/data/api/v2/resources/testding.json" diff --git a/src/api/v2/ontology/ontologies-endpoint-v2.ts b/src/api/v2/ontology/ontologies-endpoint-v2.ts index 24e302979..912c346ac 100644 --- a/src/api/v2/ontology/ontologies-endpoint-v2.ts +++ b/src/api/v2/ontology/ontologies-endpoint-v2.ts @@ -27,7 +27,7 @@ export class OntologiesEndpointV2 extends Endpoint { // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map((jsonldobj: object) => { - return this.jsonConvert.deserializeObject(jsonldobj, OntologiesMetadata); + return OntologyConversionUtil.convertOntologiesList(jsonldobj, this.jsonConvert); }), catchError(error => { return this.handleError(error); @@ -72,13 +72,7 @@ export class OntologiesEndpointV2 extends Endpoint { // TODO: adapt getOntologyIriFromEntityIri return jsonld.compact(ajaxResponse.response, {}); }), map((jsonldobj: object) => { - if (jsonldobj.hasOwnProperty("@graph")) { - return (this.jsonConvert.deserializeObject(jsonldobj, OntologiesMetadata) as OntologiesMetadata); - } else { - const ontos: OntologiesMetadata = new OntologiesMetadata(); - ontos.ontologies = [this.jsonConvert.deserializeObject(jsonldobj, OntologyMetadata)] - return ontos; - } + return OntologyConversionUtil.convertOntologiesList(jsonldobj, this.jsonConvert); }), catchError(error => { return this.handleError(error); diff --git a/src/api/v2/ontology/ontologies-endpoint.spec.ts b/src/api/v2/ontology/ontologies-endpoint.spec.ts index 4b3428289..13354c794 100644 --- a/src/api/v2/ontology/ontologies-endpoint.spec.ts +++ b/src/api/v2/ontology/ontologies-endpoint.spec.ts @@ -194,6 +194,28 @@ describe("OntologiesEndpoint", () => { }); + it("should return all ontologies from 'incunabula' project", done => { + + knoraApiConnection.v2.onto.getOntologiesByProjectIri("http://rdfh.ch/projects/0803").subscribe( + (response: OntologiesMetadata) => { + expect(response.ontologies.length).toEqual(1); + expect(response.ontologies[0].id).toEqual("http://0.0.0.0:3333/ontology/0803/incunabula/v2"); + done(); + } + ); + + const request = jasmine.Ajax.requests.mostRecent(); + + const ontoMetadata = require("../../../../test/data/api/v2/ontologies/get-ontologies-project-incunabula-response.json"); + + request.respondWith(MockAjaxCall.mockResponse(JSON.stringify(ontoMetadata))); + + expect(request.url).toBe("http://0.0.0.0:3333/v2/ontologies/metadata/http%3A%2F%2Frdfh.ch%2Fprojects%2F0803"); + + expect(request.method).toEqual("GET"); + + }); + }); diff --git a/src/models/v2/ontologies/OntologyConversionUtil.ts b/src/models/v2/ontologies/OntologyConversionUtil.ts index 15e49c3e0..50d7651cc 100644 --- a/src/models/v2/ontologies/OntologyConversionUtil.ts +++ b/src/models/v2/ontologies/OntologyConversionUtil.ts @@ -8,6 +8,7 @@ import { ResourceClassDefinition } from "./resource-class-definition"; import { ResourcePropertyDefinition } from "./resource-property-definition"; import { StandoffClassDefinition } from "./standoff-class-definition"; import { SystemPropertyDefinition } from "./system-property-definition"; +import { OntologiesMetadata, OntologyMetadata } from "./ontology-metadata"; export namespace OntologyConversionUtil { @@ -219,4 +220,17 @@ export namespace OntologyConversionUtil { }; + export const convertOntologiesList = (ontologiesJsonld: object, jsonConvert: JsonConvert): OntologiesMetadata => { + + let ontologies: OntologiesMetadata = new OntologiesMetadata(); + + if (ontologiesJsonld.hasOwnProperty("@graph")) { + ontologies = jsonConvert.deserializeObject(ontologiesJsonld, OntologiesMetadata); + } else { + ontologies.ontologies = [jsonConvert.deserializeObject(ontologiesJsonld, OntologyMetadata)]; + } + + return ontologies; + } + } From 4151e1e06eab5fc628726970574a31a6cae48857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Thu, 25 Jun 2020 18:08:47 +0200 Subject: [PATCH 17/20] test(app): Rename section id --- test-framework/e2e/src/app.e2e-spec.ts | 8 ++++---- test-framework/src/app/app.component.html | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test-framework/e2e/src/app.e2e-spec.ts b/test-framework/e2e/src/app.e2e-spec.ts index 668439453..47b075404 100644 --- a/test-framework/e2e/src/app.e2e-spec.ts +++ b/test-framework/e2e/src/app.e2e-spec.ts @@ -98,11 +98,11 @@ describe('workspace-project App', () => { page.navigateTo(); - const button = page.getEle('div section#ontologyendpoint button.anything'); + const button = page.getEle('div section#ontologymetadata button.anything'); button.click(); - const result = page.getEle('div section#ontologyendpoint span.anything'); + const result = page.getEle('div section#ontologymetadata span.anything'); expect(result.getText()).toEqual('3 ontologies'); @@ -112,11 +112,11 @@ describe('workspace-project App', () => { page.navigateTo(); - const button = page.getEle('div section#ontologyendpoint button.dokubib'); + const button = page.getEle('div section#ontologymetadata button.dokubib'); button.click(); - const result = page.getEle('div section#ontologyendpoint span.dokubib'); + const result = page.getEle('div section#ontologymetadata span.dokubib'); expect(result.getText()).toEqual('1 ontology'); diff --git a/test-framework/src/app/app.component.html b/test-framework/src/app/app.component.html index 746361745..704a3e042 100644 --- a/test-framework/src/app/app.component.html +++ b/test-framework/src/app/app.component.html @@ -28,15 +28,15 @@

Ontology Cache

-
-

OntologyEndpoint

+
+

Project specific ontologies

- Anything project has
{{anythingOntologies?.length | i18nPlural: itemPluralMapping['ontology']}} + Anything project has
{{anythingOntologies?.ontologies.length | i18nPlural: itemPluralMapping['ontology']}}
- Dokubib project has
{{dokubibOntologies?.length | i18nPlural: itemPluralMapping['ontology']}} + Dokubib project has
{{dokubibOntologies?.ontologies.length | i18nPlural: itemPluralMapping['ontology']}}
From b4ed75ecd14c8abf56bab026dac26bceee2ad985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Thu, 25 Jun 2020 18:22:40 +0200 Subject: [PATCH 18/20] test(data): Update test data --- ...ogies-project-incunabula-response-expanded.json | 1 + ...get-ontologies-project-incunabula-response.json | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 test/data/api/v2/ontologies/get-ontologies-project-incunabula-response-expanded.json create mode 100644 test/data/api/v2/ontologies/get-ontologies-project-incunabula-response.json diff --git a/test/data/api/v2/ontologies/get-ontologies-project-incunabula-response-expanded.json b/test/data/api/v2/ontologies/get-ontologies-project-incunabula-response-expanded.json new file mode 100644 index 000000000..f510c734b --- /dev/null +++ b/test/data/api/v2/ontologies/get-ontologies-project-incunabula-response-expanded.json @@ -0,0 +1 @@ +{"@id":"http://0.0.0.0:3333/ontology/0803/incunabula/v2","@type":"http://www.w3.org/2002/07/owl#Ontology","http://api.knora.org/ontology/knora-api/v2#attachedToProject":{"@id":"http://rdfh.ch/projects/0803"},"http://www.w3.org/2000/01/rdf-schema#label":"The incunabula ontology"} \ No newline at end of file diff --git a/test/data/api/v2/ontologies/get-ontologies-project-incunabula-response.json b/test/data/api/v2/ontologies/get-ontologies-project-incunabula-response.json new file mode 100644 index 000000000..ef3c03d05 --- /dev/null +++ b/test/data/api/v2/ontologies/get-ontologies-project-incunabula-response.json @@ -0,0 +1,14 @@ +{ + "@id" : "http://0.0.0.0:3333/ontology/0803/incunabula/v2", + "@type" : "owl:Ontology", + "knora-api:attachedToProject" : { + "@id" : "http://rdfh.ch/projects/0803" + }, + "rdfs:label" : "The incunabula ontology", + "@context" : { + "knora-api" : "http://api.knora.org/ontology/knora-api/v2#", + "xsd" : "http://www.w3.org/2001/XMLSchema#", + "rdfs" : "http://www.w3.org/2000/01/rdf-schema#", + "owl" : "http://www.w3.org/2002/07/owl#" + } +} \ No newline at end of file From da44f1449e9569961ede2db44db6f953eab20599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Fri, 26 Jun 2020 11:48:01 +0200 Subject: [PATCH 19/20] refactor(onto): Update jsdocs and simplified --- src/api/v2/ontology/ontologies-endpoint-v2.ts | 2 +- src/models/v2/ontologies/OntologyConversionUtil.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/api/v2/ontology/ontologies-endpoint-v2.ts b/src/api/v2/ontology/ontologies-endpoint-v2.ts index 912c346ac..1e6a0f64e 100644 --- a/src/api/v2/ontology/ontologies-endpoint-v2.ts +++ b/src/api/v2/ontology/ontologies-endpoint-v2.ts @@ -59,7 +59,7 @@ export class OntologiesEndpointV2 extends Endpoint { } /** - * Requests metadata about all ontologies from specific project + * Requests metadata about all ontologies from a specific project * * @param projectIri the IRI of the project * @return OntologiesMetadata or an error diff --git a/src/models/v2/ontologies/OntologyConversionUtil.ts b/src/models/v2/ontologies/OntologyConversionUtil.ts index 50d7651cc..a3306bbe4 100644 --- a/src/models/v2/ontologies/OntologyConversionUtil.ts +++ b/src/models/v2/ontologies/OntologyConversionUtil.ts @@ -220,17 +220,23 @@ export namespace OntologyConversionUtil { }; + /** + * Converts a list of ontolgies or a single ontology serialized as JSON-LD to an instance of `OntologiesMetadata` + * + * @param ontologiesJsonld + * @param jsonConvert + */ export const convertOntologiesList = (ontologiesJsonld: object, jsonConvert: JsonConvert): OntologiesMetadata => { - let ontologies: OntologiesMetadata = new OntologiesMetadata(); - + if (ontologiesJsonld.hasOwnProperty("@graph")) { - ontologies = jsonConvert.deserializeObject(ontologiesJsonld, OntologiesMetadata); + return jsonConvert.deserializeObject(ontologiesJsonld, OntologiesMetadata); } else { + const ontologies: OntologiesMetadata = new OntologiesMetadata(); ontologies.ontologies = [jsonConvert.deserializeObject(ontologiesJsonld, OntologyMetadata)]; + return ontologies; } - return ontologies; } } From c7da0960e82c608e99f2dacc75c6238bf0a9d3f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kilchenmann?= Date: Fri, 26 Jun 2020 12:00:56 +0200 Subject: [PATCH 20/20] fix(onto): Add missing semicolon --- src/models/v2/ontologies/OntologyConversionUtil.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/models/v2/ontologies/OntologyConversionUtil.ts b/src/models/v2/ontologies/OntologyConversionUtil.ts index a3306bbe4..b3cd347c7 100644 --- a/src/models/v2/ontologies/OntologyConversionUtil.ts +++ b/src/models/v2/ontologies/OntologyConversionUtil.ts @@ -236,7 +236,6 @@ export namespace OntologyConversionUtil { ontologies.ontologies = [jsonConvert.deserializeObject(ontologiesJsonld, OntologyMetadata)]; return ontologies; } - - } + }; }