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

Fix property names for incoming links #1144

Merged
merged 7 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/paradox/00-release-notes/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Also, please change the "HINT" to the appropriate level:

## HINT => LEVEL

- MAJOR CHANGE: Fix property names for incoming links (@github[#1144](#1144))
- BUGFIX CHANGE: Triplestore connection error when using dockerComposeUp (@github[#1122](#1122))
- MINOR CHANGE: Update resource metadata in API v2 (@github[#1131](#1131))
- BUGFIX CHANGE: Reject link value properties in Gravsearch queries in the simple schema (@github[#1145](#1145))
Expand Down
13 changes: 7 additions & 6 deletions docs/src/paradox/03-apis/api-v2/query-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ as explained under @ref:[CONSTRUCT Clause](#construct-clause).

## Virtual incoming Links

Depending on the ontology design, a resource A points to B or vice versa.
For example, a page A is part of a book B using the property `incunabula:partOf`.
If A is marked as the main resource, then B is nested as a dependent resource
Depending on the ontology design, a resource A points to B or vice versa.
For example, a page A is part of a book B using the property `incunabula:partOf`.
If A is marked as the main resource, then B is nested as a dependent resource
in its link value `incunabula:partOfValue`. But in case B is marked as the main resource,
B does not have a link value pointing to A because in fact B is pointed to by A.
B does not have a link value pointing to A because in fact B is pointed to by A.
Instead, B has a virtual property `knora-api:hasIncomingLink` containing A's link value:

```
"knora-api:hasIncomingLink" : {
"knora-api:hasIncomingLinkValue" : {
"@id" : "http://rdfh.ch/A/values/xy",
"@type" : "knora-api:LinkValue",
"knora-api:linkValueHasSource" : {
Expand All @@ -163,7 +163,8 @@ Instead, B has a virtual property `knora-api:hasIncomingLink` containing A's lin
}
}
},
```
```

Note that the virtually inserted link value inverts the relation by using `knora-api:linkValueHasSource`.
The source of the link is A and its target B is only represented by an Iri (`knora-api:linkValueHasTargetIri`)
since B is the main resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ object OntologyConstants {

val ResourceProperty: IRI = KnoraBasePrefixExpansion + "resourceProperty"
val HasValue: IRI = KnoraBasePrefixExpansion + "hasValue"
val HasIncomingLink: IRI = KnoraBasePrefixExpansion + "hasIncomingLink"
val HasIncomingLinkValue: IRI = KnoraBasePrefixExpansion + "hasIncomingLinkValue"
val HasFileValue: IRI = KnoraBasePrefixExpansion + "hasFileValue"
val HasStillImageFileValue: IRI = KnoraBasePrefixExpansion + "hasStillImageFileValue"
val HasMovingImageFileValue: IRI = KnoraBasePrefixExpansion + "hasMovingImageFileValue"
Expand Down Expand Up @@ -770,7 +770,7 @@ object OntologyConstants {
val ValueHas: IRI = KnoraApiV2PrefixExpansion + "valueHas"
val HasLinkTo: IRI = KnoraApiV2PrefixExpansion + "hasLinkTo"
val HasLinkToValue: IRI = KnoraApiV2PrefixExpansion + "hasLinkToValue"
val HasIncomingLink: IRI = KnoraApiV2PrefixExpansion + "hasIncomingLink"
val HasIncomingLinkValue: IRI = KnoraApiV2PrefixExpansion + "hasIncomingLinkValue"

val IsPartOf: IRI = KnoraApiV2PrefixExpansion + "isPartOf"
val IsPartOfValue: IRI = KnoraApiV2PrefixExpansion + "isPartOfValue"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,29 @@ object KnoraApiV2SimpleTransformationRules extends KnoraBaseTransformationRules
)
)

private val HasIncomingLink: ReadPropertyInfoV2 = makeProperty(
propertyIri = OntologyConstants.KnoraApiV2Simple.HasIncomingLink,
propertyType = OntologyConstants.Owl.ObjectProperty,
subjectType = Some(OntologyConstants.KnoraApiV2Simple.Resource),
objectType = Some(OntologyConstants.KnoraApiV2Simple.Resource),
subPropertyOf = Set(OntologyConstants.KnoraApiV2Simple.HasLinkTo),
predicates = Seq(
makePredicate(
predicateIri = OntologyConstants.Rdfs.Label,
objectsWithLang = Map(
LanguageCodes.DE -> "hat eingehenden Verweis",
LanguageCodes.EN -> "has incoming link"
)
),
makePredicate(
predicateIri = OntologyConstants.Rdfs.Comment,
objectsWithLang = Map(
LanguageCodes.EN -> "Indicates that this resource referred to by another resource"
)
)
)
)

private val ResourceCardinalites = Map(
OntologyConstants.KnoraApiV2Simple.HasIncomingLink -> Cardinality.MayHaveMany
)
Expand Down Expand Up @@ -486,7 +509,8 @@ object KnoraApiV2SimpleTransformationRules extends KnoraBaseTransformationRules
HasValue,
ResourceProperty,
SubjectType,
ObjectType
ObjectType,
HasIncomingLink
).map {
propertyInfo => propertyInfo.entityInfoContent.propertyIri -> propertyInfo
}.toMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ object KnoraApiV2WithValueObjectsTransformationRules extends KnoraBaseTransforma
objectType = Some(OntologyConstants.Xsd.String)
)

private val HasIncomingLink: ReadPropertyInfoV2 = makeProperty(
propertyIri = OntologyConstants.KnoraApiV2WithValueObjects.HasIncomingLink,
private val HasIncomingLinkValue: ReadPropertyInfoV2 = makeProperty(
propertyIri = OntologyConstants.KnoraApiV2WithValueObjects.HasIncomingLinkValue,
isResourceProp = true,
propertyType = OntologyConstants.Owl.ObjectProperty,
subjectType = Some(OntologyConstants.KnoraApiV2WithValueObjects.Resource),
Expand All @@ -319,8 +319,8 @@ object KnoraApiV2WithValueObjectsTransformationRules extends KnoraBaseTransforma
makePredicate(
predicateIri = OntologyConstants.Rdfs.Label,
objectsWithLang = Map(
LanguageCodes.DE -> "hat eingehende Verweise",
LanguageCodes.EN -> "has incoming links"
LanguageCodes.DE -> "hat eingehenden Verweis",
LanguageCodes.EN -> "has incoming link"
)
),
makePredicate(
Expand Down Expand Up @@ -1177,7 +1177,7 @@ object KnoraApiV2WithValueObjectsTransformationRules extends KnoraBaseTransforma
)

private val ResourceCardinalities = Map(
OntologyConstants.KnoraApiV2WithValueObjects.HasIncomingLink -> Cardinality.MayHaveMany
OntologyConstants.KnoraApiV2WithValueObjects.HasIncomingLinkValue -> Cardinality.MayHaveMany
)

private val DateBaseCardinalities = Map(
Expand Down Expand Up @@ -1439,7 +1439,7 @@ object KnoraApiV2WithValueObjectsTransformationRules extends KnoraBaseTransforma
OntologyName,
MappingHasName,
ValueAsString,
HasIncomingLink,
HasIncomingLinkValue,
SubjectType,
ObjectType,
TextValueHasStandoff,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ case class ReadResourceV2(resourceIri: IRI,

// In the simple schema, use link properties instead of link value properties.
val adaptedPropertyIri = if (targetSchema == ApiV2Simple) {
// If all the property's values are link values, it's a link value property.
val isLinkProp = readValues.forall {
readValue =>
readValue.valueContent match {
Expand All @@ -234,6 +235,7 @@ case class ReadResourceV2(resourceIri: IRI,
}
}

// If it's a link value property, use the corresponding link property.
if (isLinkProp) {
propertyIriInTargetSchema.fromLinkValuePropToLinkProp
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ object GravsearchQueryChecker {
OntologyConstants.KnoraApiV2WithValueObjects.IsInherited,
OntologyConstants.KnoraApiV2WithValueObjects.OntologyName,
OntologyConstants.KnoraApiV2WithValueObjects.MappingHasName,
OntologyConstants.KnoraApiV2WithValueObjects.HasIncomingLink,
OntologyConstants.KnoraApiV2WithValueObjects.HasIncomingLinkValue,
OntologyConstants.KnoraApiV2WithValueObjects.DateValueHasStartYear,
OntologyConstants.KnoraApiV2WithValueObjects.DateValueHasEndYear,
OntologyConstants.KnoraApiV2WithValueObjects.DateValueHasStartMonth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ object ConstructResponseUtilV2 {

if (incomingLinkAssertions.nonEmpty) {
// create a virtual property representing an incoming link
val incomingProps: (IRI, Seq[ValueRdfData]) = OntologyConstants.KnoraBase.HasIncomingLink -> incomingLinkAssertions.values.toSeq.flatten.map {
val incomingProps: (IRI, Seq[ValueRdfData]) = OntologyConstants.KnoraBase.HasIncomingLinkValue -> incomingLinkAssertions.values.toSeq.flatten.map {
Copy link
Author

Choose a reason for hiding this comment

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

This is the key place where this actually gets used.

linkValue: ValueRdfData =>

// get the source of the link value (it points to the resource that is currently processed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"knora-api:isInherited" : true,
"owl:minCardinality" : 0,
"owl:onProperty" : {
"@id" : "knora-api:hasIncomingLink"
"@id" : "knora-api:hasIncomingLinkValue"
}
}, {
"@type" : "owl:Restriction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,81 +20,81 @@
<rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A shared thing.</rdfs:comment>
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">shared thing</rdfs:label>
<rdfs:subClassOf rdf:resource="http://api.knora.org/ontology/knora-api/v2#Resource"/>
<rdfs:subClassOf rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b0"/>
<rdfs:subClassOf rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b1"/>
<rdfs:subClassOf rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b2"/>
<rdfs:subClassOf rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b3"/>
<rdfs:subClassOf rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b4"/>
<rdfs:subClassOf rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b5"/>
<rdfs:subClassOf rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b6"/>
<rdfs:subClassOf rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b7"/>
<rdfs:subClassOf rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b8"/>
<rdfs:subClassOf rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b9"/>
<rdfs:subClassOf rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b10"/>
<rdfs:subClassOf rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b11"/>
<rdfs:subClassOf rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b12"/>
<rdfs:subClassOf rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b0"/>
<rdfs:subClassOf rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b1"/>
<rdfs:subClassOf rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b2"/>
<rdfs:subClassOf rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b3"/>
<rdfs:subClassOf rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b4"/>
<rdfs:subClassOf rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b5"/>
<rdfs:subClassOf rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b6"/>
<rdfs:subClassOf rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b7"/>
<rdfs:subClassOf rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b8"/>
<rdfs:subClassOf rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b9"/>
<rdfs:subClassOf rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b10"/>
<rdfs:subClassOf rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b11"/>
<rdfs:subClassOf rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b12"/>
</owl:Class>
<owl:Restriction rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b0">
<owl:Restriction rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b0">
<knora-api:isInherited rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</knora-api:isInherited>
<owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1</owl:cardinality>
<owl:onProperty rdf:resource="http://api.knora.org/ontology/knora-api/v2#attachedToProject"/>
</owl:Restriction>
<owl:Restriction rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b1">
<owl:Restriction rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b1">
<knora-api:isInherited rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</knora-api:isInherited>
<owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1</owl:cardinality>
<owl:onProperty rdf:resource="http://api.knora.org/ontology/knora-api/v2#attachedToUser"/>
</owl:Restriction>
<owl:Restriction rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b2">
<owl:Restriction rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b2">
<knora-api:isInherited rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</knora-api:isInherited>
<owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1</owl:cardinality>
<owl:onProperty rdf:resource="http://api.knora.org/ontology/knora-api/v2#creationDate"/>
</owl:Restriction>
<owl:Restriction rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b3">
<owl:Restriction rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b3">
<knora-api:isInherited rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</knora-api:isInherited>
<owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1</owl:maxCardinality>
<owl:onProperty rdf:resource="http://api.knora.org/ontology/knora-api/v2#deleteComment"/>
</owl:Restriction>
<owl:Restriction rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b4">
<owl:Restriction rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b4">
<knora-api:isInherited rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</knora-api:isInherited>
<owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1</owl:maxCardinality>
<owl:onProperty rdf:resource="http://api.knora.org/ontology/knora-api/v2#deleteDate"/>
</owl:Restriction>
<owl:Restriction rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b5">
<owl:Restriction rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b5">
<knora-api:isInherited rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</knora-api:isInherited>
<owl:minCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0</owl:minCardinality>
<owl:onProperty rdf:resource="http://api.knora.org/ontology/knora-api/v2#hasIncomingLink"/>
<owl:onProperty rdf:resource="http://api.knora.org/ontology/knora-api/v2#hasIncomingLinkValue"/>
</owl:Restriction>
<owl:Restriction rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b6">
<owl:Restriction rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b6">
<knora-api:isInherited rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</knora-api:isInherited>
<owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1</owl:cardinality>
<owl:onProperty rdf:resource="http://api.knora.org/ontology/knora-api/v2#hasPermissions"/>
</owl:Restriction>
<owl:Restriction rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b7">
<owl:Restriction rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b7">
<knora-api:isInherited rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</knora-api:isInherited>
<owl:minCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0</owl:minCardinality>
<owl:onProperty rdf:resource="http://api.knora.org/ontology/knora-api/v2#hasStandoffLinkTo"/>
</owl:Restriction>
<owl:Restriction rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b8">
<owl:Restriction rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b8">
<knora-api:isInherited rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</knora-api:isInherited>
<owl:minCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0</owl:minCardinality>
<owl:onProperty rdf:resource="http://api.knora.org/ontology/knora-api/v2#hasStandoffLinkToValue"/>
</owl:Restriction>
<owl:Restriction rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b9">
<owl:Restriction rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b9">
<knora-api:isInherited rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</knora-api:isInherited>
<owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1</owl:cardinality>
<owl:onProperty rdf:resource="http://api.knora.org/ontology/knora-api/v2#isDeleted"/>
</owl:Restriction>
<owl:Restriction rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b10">
<owl:Restriction rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b10">
<knora-api:isInherited rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</knora-api:isInherited>
<owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1</owl:maxCardinality>
<owl:onProperty rdf:resource="http://api.knora.org/ontology/knora-api/v2#lastModificationDate"/>
</owl:Restriction>
<owl:Restriction rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b11">
<owl:Restriction rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b11">
<knora-api:isInherited rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</knora-api:isInherited>
<owl:cardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1</owl:cardinality>
<owl:onProperty rdf:resource="http://www.w3.org/2000/01/rdf-schema#label"/>
</owl:Restriction>
<owl:Restriction rdf:nodeID="genid-bc5f09fe4ec84b77b330a3892ff28d92-b12">
<owl:Restriction rdf:nodeID="genid-9ad22ed3d3284b7a97757fd37e55015a-b12">
<salsah-gui:guiOrder rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0</salsah-gui:guiOrder>
<owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1</owl:maxCardinality>
<owl:onProperty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ example-box:Box a owl:Class;
], [ a owl:Restriction;
knora-api:isInherited true;
owl:minCardinality 0;
owl:onProperty knora-api:hasIncomingLink
owl:onProperty knora-api:hasIncomingLinkValue
], [ a owl:Restriction;
knora-api:isInherited true;
owl:cardinality 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"knora-api:isInherited" : true,
"owl:minCardinality" : 0,
"owl:onProperty" : {
"@id" : "knora-api:hasIncomingLink"
"@id" : "knora-api:hasIncomingLinkValue"
}
}, {
"@type" : "owl:Restriction",
Expand Down Expand Up @@ -171,7 +171,7 @@
"knora-api:isInherited" : true,
"owl:minCardinality" : 0,
"owl:onProperty" : {
"@id" : "knora-api:hasIncomingLink"
"@id" : "knora-api:hasIncomingLinkValue"
}
}, {
"@type" : "owl:Restriction",
Expand Down Expand Up @@ -534,7 +534,7 @@
"knora-api:isInherited" : true,
"owl:minCardinality" : 0,
"owl:onProperty" : {
"@id" : "knora-api:hasIncomingLink"
"@id" : "knora-api:hasIncomingLinkValue"
}
}, {
"@type" : "owl:Restriction",
Expand Down Expand Up @@ -771,7 +771,7 @@
"knora-api:isInherited" : true,
"owl:minCardinality" : 0,
"owl:onProperty" : {
"@id" : "knora-api:hasIncomingLink"
"@id" : "knora-api:hasIncomingLinkValue"
}
}, {
"@type" : "owl:Restriction",
Expand Down
Loading