Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for shared ontologies #987

Merged
merged 18 commits into from
Sep 13, 2018

Conversation

subotic
Copy link
Collaborator

@subotic subotic commented Sep 4, 2018

Summary

  • Add built-in DefaultSharedOntologiesProject with project code 0000.
  • Change SmartIri to support ontology IRIs containing the segment shared, using api.knora.org as their hostname in API v2:
    • http://www.knora.org/ontology/shared/example-box (internal)
    • http://api.knora.org/ontology/shared/example-box/v2 (external, complex schema)
    • http://api.knora.org/ontology/shared/example-box/simple/v2 (external, simple schema)
    • The project code of a shared ontology IRI defaults to 0000.
    • SmartIri can support additional shared ontology projects (by specifying the project code) if we decide to add them later (see StringFormatterSpec). I think this will probably end up being more convenient if we have a lot of shared ontologies.
  • Allow shared ontologies to be created via API v2.
  • Enforce these rules:
    • An ontology can refer to a Knora ontology in another project only if the other ontology is built-in or shared.
    • Shared ontologies must belong to DefaultSharedOntologiesProject, which can contain only shared ontologies.
    • You can't create a resource in one project whose class is defined in a non-shared ontology in another project (so far API v1 only, because we can't yet create resources in v2).
  • In API v2 (complex schema), to make things easier for Salsah:
    • Serve shared ontologies with knora-api:isShared true.
    • Serve built-in ontologies with knora-api:isBuiltIn true.
  • Add tests.
  • Add a dummy parole-religieuse ontology to make DrawingsGodsV1E2ESpec work (because it previously created anything:Thing resources in the parole-religieuse project, which is now forbidden).
  • Update docs and release notes.

Issues

@benjamingeer benjamingeer changed the title feature (webapi): add support for shared ontologies Add support for shared ontologies Sep 5, 2018
@benjamingeer benjamingeer mentioned this pull request Sep 5, 2018
@codecov
Copy link

codecov bot commented Sep 5, 2018

Codecov Report

Merging #987 into develop will increase coverage by 0.09%.
The diff coverage is 95.97%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop    #987      +/-   ##
==========================================
+ Coverage    82.31%   82.4%   +0.09%     
==========================================
  Files          153     153              
  Lines        17689   17826     +137     
  Branches      1647    1669      +22     
==========================================
+ Hits         14560   14690     +130     
- Misses        3129    3136       +7
Flag Coverage Δ
#integration 45.12% <71.26%> (+0.18%) ⬆️
#unit_e2e 81.28% <95.97%> (+0.1%) ⬆️
Impacted Files Coverage Δ
...ora/webapi/responders/v1/ProjectsResponderV1.scala 91.33% <ø> (ø) ⬆️
...rg/knora/webapi/routing/v2/OntologiesRouteV2.scala 87.67% <ø> (ø) ⬆️
...esponder/ontologymessages/OntologyMessagesV2.scala 90.25% <100%> (+0.09%) ⬆️
.../ontologymessages/KnoraApiV2WithValueObjects.scala 98.94% <100%> (+0.02%) ⬆️
...ain/scala/org/knora/webapi/OntologyConstants.scala 99.58% <100%> (ø) ⬆️
...min/responder/usersmessages/UsersMessagesADM.scala 76.64% <100%> (ø) ⬆️
...ora/webapi/responders/v1/OntologyResponderV1.scala 81.11% <100%> (ø) ⬆️
...webapi/responders/admin/ProjectsResponderADM.scala 94.21% <100%> (ø) ⬆️
...ra/webapi/responders/v1/ResourcesResponderV1.scala 94.36% <100%> (+0.12%) ⬆️
...ora/webapi/responders/v2/OntologyResponderV2.scala 91.06% <91.04%> (+0.05%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dce986f...47c87a4. Read the comment docs.

Benjamin Geer added 10 commits September 10, 2018 17:24
…non-shared ontologies.

- Add example of a shared ontology.
- Add tests.
…(for development).

- Remove tests that are no longer relevant.
# Conflicts:
#	webapi/src/test/resources/test-data/ontologyR2RV2/allOntologyMetadata.rdf
#	webapi/src/test/resources/test-data/ontologyR2RV2/allOntologyMetadata.ttl
#	webapi/src/test/scala/org/knora/webapi/e2e/admin/ProjectsADME2ESpec.scala
#	webapi/src/test/scala/org/knora/webapi/e2e/v1/ProjectsV1E2ESpec.scala
…hared ontology in another project.

- Add tests.
…multiple shared ontology projects.

- Fix tests.
- Add more tests.
- Add docs.
- Update release notes.
@benjamingeer
Copy link

@subotic I'd like to request a review from you, but GitHub won't let me do it, because you created the PR.

@benjamingeer
Copy link

@subotic I guess that if you review the PR, I can approve it. :)

@subotic
Copy link
Collaborator Author

subotic commented Sep 12, 2018

No problem. I will review it and then you can approve :-)

@subotic
Copy link
Collaborator Author

subotic commented Sep 12, 2018

Just a thought, which we can address at a later time. I think that shared ontologies should be hostable at a URL other than http://api.knora.org/ontology/shared/[name]. If they can only be hosted at this URL, then anybody wanting to use Knora and add shared ontologies would need to publish them with us. We (as the DaSCH) can only host shared ontologies that have something to do with the DaSCH. We (as the developers of Knora) cannot host anything but the core ontologies.

@benjamingeer
Copy link

I think you’re right. I could imagine that a group of projects (all hosted on different servers) might create a shared ontology together, which they would all use. The ontology would have to be in the triplestore on each server, but its external IRI would contain the hostname of a single “authoritative” server that would serve the ontology. I guess each participating server would need to have a lookup table in a configuration file, which would enable SmartIri to produce the correct hostname for each shared ontology.

@benjamingeer
Copy link

Or I guess the hostname could be part of the definition of a shared ontology project. Then each shared ontology project would have to be duplicated on each participating server.

@subotic
Copy link
Collaborator Author

subotic commented Sep 13, 2018

I was thinking about a default setting of www.knora.org and then somewhere a lookup table for remapping IRIs to URLs.

I also think that it shouldn't be such a problem to publish the base ontologies on Github.

@benjamingeer
Copy link

I was thinking about a default setting of www.knora.org

In IRIs, the domain www.knora.org is reserved for internal IRIs, but we could make shared.knora.org or something like that.

a lookup table for remapping IRIs to URLs

That would be the easiest implementation. It could be in application.conf.

I also think that it shouldn't be such a problem to publish the base ontologies on Github.

Yes, we could do that with Github Pages, but we would need a web server to process the HTTP Accept header and redirect to the file in the requested format (JSON-LD, Turtle, or RDF/XML).

Copy link
Collaborator Author

@subotic subotic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM :-)

# Conflicts:
#	docs/src/paradox/00-release-notes/v1.8.0.md
#	webapi/src/test/resources/test-data/ontologyR2RV2/incunabulaOntologySimple.rdf
#	webapi/src/test/resources/test-data/ontologyR2RV2/incunabulaOntologyWithValueObjects.rdf
#	webapi/src/test/resources/test-data/ontologyR2RV2/incunabulaPageAndBookWithValueObjects.rdf
#	webapi/src/test/resources/test-data/ontologyR2RV2/knoraApiDate.rdf
#	webapi/src/test/resources/test-data/ontologyR2RV2/knoraApiDateValue.rdf
#	webapi/src/test/resources/test-data/ontologyR2RV2/knoraApiOntologySimple.rdf
#	webapi/src/test/resources/test-data/ontologyR2RV2/knoraApiOntologyWithValueObjects.rdf
#	webapi/src/test/resources/test-data/ontologyR2RV2/standoffOntologyWithValueObjects.rdf
@benjamingeer
Copy link

Thanks for reviewing!

@benjamingeer benjamingeer merged commit d28239e into develop Sep 13, 2018
@benjamingeer benjamingeer deleted the wip/986-allow-shared-ontologies branch September 13, 2018 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow shared ontologies
2 participants