The current SPARQL queries for loading associations of a class in CIM have the following problems:
Some associations are missing because an association may inherit its class membership from its ancestor. This is possible in both directions, either the current class is the domain of an association or it is its range.
Some associations are missing because an association does not have specified the other class associated with the current one. The other class is inherited from its ancestor. Because we suppose that there is one and only one such other class, only the closest ancestor with the other class specified must be considered.
Associations from (1) shall be presented to the user w.r.t. the inheritance hierarchy. This issue does not specify how this should be presented in the UI but extends the SPARQL query so that it will be possible.
Query for loading associations having the current element as domain (example https://slovník.gov.cz/legislativní/sbírka/56/2001/pojem/silniční-vozidlo, https://slovník.gov.cz/legislativní/sbírka/361/2000/pojem/vozidlo is also a good example):
PREFIX z: <https://slovník.gov.cz/základní/pojem/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
CONSTRUCT {
?outwardsRelation a z:typ-vztahu ;
rdfs:domain <https://slovník.gov.cz/legislativní/sbírka/56/2001/pojem/silniční-vozidlo> ;
rdfs:range ?rangeElement ;
skos:prefLabel ?outwardsRelationLabel ;
skos:definition ?outwardsRelationDefinition ;
skos:inScheme ?outwardsRelationGlossary ;
# (4) relationship to the parent association in the inheritance hierarchy, only ?parentRelation returned also as ?outwardsRelation is valid. A ?parentRelation is returned as ?outwardsRelation iff it has the mandatory properties such as skos:prefLabel etc. START
rdfs:subPropertyOf ?parentRelation .
# (4) relationship to the parent association in the inheritance hierarchy END
?rangeElement a z:typ-objektu ;
skos:prefLabel ?rangeLabel ;
skos:definition ?rangeDefinition ;
skos:inScheme ?rangeGlossary .
} WHERE {
?outwardsRelation a z:typ-vztahu ;
skos:prefLabel ?outwardsRelationLabel ;
skos:inScheme ?outwardsRelationGlossary .
{
?outwardsRelation rdfs:subClassOf [
owl:allValuesFrom <https://slovník.gov.cz/legislativní/sbírka/56/2001/pojem/silniční-vozidlo> ;
owl:onProperty z:má-vztažený-prvek-1
]
} UNION {
# (1) associations inheriting their membership START
?ancestorOutwardsRelation rdfs:subClassOf [
owl:allValuesFrom <https://slovník.gov.cz/legislativní/sbírka/56/2001/pojem/silniční-vozidlo> ;
owl:onProperty z:má-vztažený-prvek-1
] .
?outwardsRelation rdfs:subClassOf+ ?ancestorOutwardsRelation .
# (1) associations inheriting their membership END
}
{
?outwardsRelation rdfs:subClassOf [
owl:allValuesFrom ?rangeElement ;
owl:onProperty z:má-vztažený-prvek-2
]
# (2) associations inheriting their other class START
} UNION {
# (2.1) associations inheriting their other class from an inheritance parent START
?outwardsRelation rdfs:subClassOf/rdfs:subClassOf [
owl:allValuesFrom ?rangeElement ;
owl:onProperty z:má-vztažený-prvek-2
]
FILTER NOT EXISTS {
?outwardsRelation rdfs:subClassOf/owl:onProperty z:má-vztažený-prvek-2 .
}
# (2.1) associations inheriting their other class from an inheritance parent END
} UNION {
# (2.2) associations inheriting their other class from an inheritance grand^{+}parent START
### This branch is non-optimal. If query executions are too slow, this branch can be removed. The result will not be complete but this branch covers quite rare cases.
?outwardsRelation rdfs:subClassOf+/rdfs:subClassOf ?rangeDefinition .
?rangeDefinition owl:allValuesFrom ?rangeElement ;
owl:onProperty z:má-vztažený-prvek-2 .
FILTER NOT EXISTS {
?outwardsRelation rdfs:subClassOf+ ?specificOutwardsRelation .
?specificOutwardsRelation rdfs:subClassOf+ ?rangeDefinition ;
rdfs:subClassOf ?rangeDefinition1 .
?rangeDefinition1 owl:onProperty z:má-vztažený-prvek-2 .
}
# (2.2) associations inheriting their other class from an inheritance grand^{+}parent END
}
# (2) associations inheriting their other class END
OPTIONAL { ?outwardsRelation skos:definition ?outwardsRelationDefinition }
?rangeElement skos:prefLabel ?rangeLabel ;
skos:inScheme ?rangeGlossary .
OPTIONAL { ?rangeElement skos:definition ?rangeDefinition }
# (4) relationship to the parent association in the inheritance hierarchy START
OPTIONAL {
?outwardsRelation rdfs:subClassOf ?parentRelation .
?parentRelation a z:typ-vztahu.
FILTER(?parentRelation != <https://slovník.gov.cz/základní/pojem/vztah>)
}
# (4) relationship to the parent association in the inheritance hierarchy END
}
The current SPARQL queries for loading associations of a class in CIM have the following problems:
Query for loading associations having the current element as domain (example
https://slovník.gov.cz/legislativní/sbírka/56/2001/pojem/silniční-vozidlo
,https://slovník.gov.cz/legislativní/sbírka/361/2000/pojem/vozidlo
is also a good example):And for range symmetrically: