-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serve an ontology when its IRI is dereferenced #616
Conversation
…nfo in the simplified API.
…dinalities for link value properties.
…nora-api v2 with value objects.
…ntology route responses.
# Conflicts: # webapi/src/main/scala/org/knora/webapi/messages/v2/responder/resourcemessages/ResourceMessagesV2.scala # webapi/src/main/scala/org/knora/webapi/messages/v2/responder/searchmessages/SearchMessagesV2.scala # webapi/src/main/scala/org/knora/webapi/responders/v2/OntologyResponderV2.scala # webapi/src/main/scala/org/knora/webapi/responders/v2/SearchResponderV2.scala # webapi/src/main/scala/org/knora/webapi/routing/v2/ResourcesRouteV2.scala
…renced. - Add missing properties to API ontologies. - Don't throw an exception in OntologyResponderV2 if information about an entity isn't found (so we can handle schema.org properties). - Refactor OntologiesRouteV2.
Something missing here: a GUI would like to know which properties are editable. It could find out by walking up the property hierarchy to find out which properties are subproperties of We could add annotations to properties and classes:
|
Also, there are subclasses of
|
Conversation with @tobiasschweizer: would be better to use
|
@benjamingeer Shall I look at this PR or do you want to implemented the additional things you suggested last week? |
I'm working on those things now. Maybe you can look at it later today. I'll let you know. |
Ok, just let me know. |
OK, I added these to
|
ExamplesWith the value object schema
With the simple schema |
Shall I adapt the SALSAH 2 GUI accordingly? Are there other things that may break existing client code? |
Yes, and please see whether it works for you.
I don't think so, but we need to check. One thing that I'm not sure about is that if you request a class or property that doesn't exist, you don't get an error message. I wanted to change this, but it wasn't so simple, because the ontology responder gets requests for information about XSD properties, which it doesn't have. |
When I try this http://localhost:3333/v2/ontologies/namedgraphs/http%3A%2F%2Fapi.knora.org%2Fontology%2Fbeol%2Fv2 I get the error: "org.knora.webapi.BadRequestException: Can't identify schema of ontology entity http://xmlns.com/foaf/0.1/Person" this is because beol:Person is a subclass of foaf:Person and now it tries to get more information about foaf:person which we do not provide. So do we need to represent the subclass relation in a different way? I remember that we had the idea of a special semantic subclass. |
I can see two options:
|
Option (2) seems easier to me. |
Try it now? |
Yes, works fine now!
But would this be true for Knora Api complex too? |
I guess so. Not sure what else we could do. I'm leaving now, will see you tomorrow morning. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, a self-documenting software :-)
Please see my comments. Please see also dhlab-basel/Salsah#86
Could we start to add some tests?
objectType = Some(OntologyConstants.Xsd.Boolean) | ||
) | ||
|
||
val CanBeInstantiated: PropertyEntityInfoV2 = makeProperty( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this only present in JSONLD if set to true? (e.g., if false it is not present in JSONLD)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
) | ||
) | ||
|
||
val IsEditable: PropertyEntityInfoV2 = makeProperty( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question as below: is it only present in JSONLD if set to true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to be this way, because I can't set it to false on properties we don't control, like rdfs:label
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain what you mean by "we don't control"? Sufficient permissions provided, a resource's rdfs:label
can be edited.
Or do you want to say that we can't make assertions about rdfs:label
as an entity at all because it is defined elsewhere and not in our ontology?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the latter.
makePredicate( | ||
predicateIri = OntologyConstants.Rdfs.Label, | ||
objectsWithLang = Map( | ||
LanguageCodes.DE -> "hat Standofflink zu", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you see a practical possibility not to define rdfs:label and rdf:comment on entities (classes and properties) redundantly in knora-base.ttl
and in KnoraApiV2Simple.scala
as well as in KnoraApiV2WithValueObjects.scala
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the ontology cache is built on startup and all of knora-base is loaded, couldn't you just get this information form the cache (given the IRI)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, because the ontology cache contains knora-base
, which doesn't have the same structure as the knora-api
ontologies. There are properties and classes in knora-api
that have no equivalent in knora-base
. Also, some of the "same" classes have a different structure (e.g. DateValue
). So it makes sense that the labels and comments could be different. For example, the comment for knora-base:DateValue
should say that it stores Julian Day Numbers, but not the comment for knora-api:DateValue
.
Also, the objects in KnoraApiV2Simple
and KnoraApiV2WithValueObjects
are constructed when the JVM starts, before the ontology responder starts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get the point if things are actually different, but wouldn't it make sense to share information if they are the same?
Also I do not understand why knora-api:Region
has to be hard-coded. Like any other resource class defined in a project-ontology, it is a subclass of knora-base:Resource
and we already have the mechanisms to convert that to knora-api
.
I do understand why this is necessary for value classes though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for instance, the current implementation knora-api:Region in complex JSONLD is incomplete (label and comment are missing):
{
@id: "knora-api:Region",
@type: "owl:Class",
knora - api: belongsToOntology: "http://api.knora.org/ontology/knora-api/v2",
knora - api: canBeInstantiated: true,
rdfs: subClassOf: [
"http://api.knora.org/ontology/knora-api/v2#Resource",
{
@type: "owl:Restriction",
owl: maxCardinality: 1,
owl: onProperty: "http://api.knora.org/ontology/knora-api/v2#lastModificationDate"
},
{
@type: "owl:Restriction",
owl: cardinality: 1,
owl: onProperty: "http://api.knora.org/ontology/knora-api/v2#hasColor"
},
{
@type: "owl:Restriction",
owl: minCardinality: 1,
owl: onProperty: "http://api.knora.org/ontology/knora-api/v2#hasGeometry"
},
{
@type: "owl:Restriction",
owl: minCardinality: 1,
owl: onProperty: "http://api.knora.org/ontology/knora-api/v2#hasComment"
},
{
@type: "owl:Restriction",
owl: cardinality: 1,
owl: onProperty: "http://api.knora.org/ontology/knora-api/v2#creationDate"
},
{
@type: "owl:Restriction",
owl: cardinality: 1,
owl: onProperty: "http://schema.org/name"
},
{
@type: "owl:Restriction",
owl: cardinality: 1,
owl: onProperty: "http://api.knora.org/ontology/knora-api/v2#hasPermissions"
},
{
@type: "owl:Restriction",
owl: minCardinality: 0,
owl: onProperty: "http://api.knora.org/ontology/knora-api/v2#hasStandoffLinkTo"
},
{
@type: "owl:Restriction",
owl: cardinality: 1,
owl: onProperty: "http://api.knora.org/ontology/knora-api/v2#isRegionOf"
}
]
}
In general, our documentation is already poor (labels and comments are sometimes not available in all supported languages), and this won't improve if we have to do it in three different places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would mean implementing some way of deciding whether to use a hard-coded API entity definition or to convert a knora-base
definition. How would that decision be made?
Also, knora-base:Region
has predicates that knora-api:Region
doesn't have, and vice versa.
Yes, I'll add some. |
Great, thx. I guess that this is the perfection of documentation :-) |
I added a test: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final final approval
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final final final approval
* develop: fix (webapi): update lucene index on sparql update when using graphdb-free (#633) KnarQL Route and Documentation (#620) feature (extended search V1): support Boolean value in extended search V1 (#643) Make the hostname of project-specific API v2 ontologies configurable (#631) build (travis): deactivate browser tests (#640) test (salsah): add headless browser testing on Travis (#590) Serve an ontology when its IRI is dereferenced (#616) fix (webapi): When requested languages aren't available, take the first one in alphabetical order (#627). (#628) Use cardinalities to get referenced ontologies for XML import schemas. (#617) docs (webapi): add description (#622)
This adds a route,
/ontology
, which makes it possible to dereference an ontology IRI likehttp://api.knora.org/ontology/knora-api/v2
orhttp://api.knora.org/ontology/incunabula/v2
and get the ontology as JSON-LD. This works only if the Knora API server is actually accessible athttp://api.knora.org
.To make this work on localhost on macOS, add the following to
/etc/hosts
:Then run
webapi/scripts/macOS-port-forwarding.sh
to forward port 80 to port 3333. For details, see Mac pfctl Port Forwarding.These routes can now handle both API v2 schemas (simple and with value objects):
/ontology
/v2/ontologies/namedgraphs
/v2/ontologies/classes
/v2/ontologies/properties
If you request multiple entities, they all have to belong to the same schema, otherwise you get an error.
The
knora-api
ontologies are stored as hard-coded Scala objects:KnoraApiV2WithValueObjects
KnoraApiV2Simple
KnoraApiV2Simple
includes some custom datatypes, such asknora-api:Date
, which are defined by subclassingxsd:string
and restricting it with a regular expression. This probably has no effect in the triplestore, but should be useful for documentation.Value classes and custom datatypes are served by the ontology routes like any other class. Therefore, I renamed these properties defined in
OntologyConstants
:hasOntologiesWithResourceClasses
->hasOntologiesWithClasses
hasResourceClasses
->hasClasses
Currently the
v2
ontology routes only serve JSON-LD. In a subsequent PR I'll implement content negotiation so they can also serve XML and HTML.