|
14 | 14 | from rdflib.term import Node |
15 | 15 |
|
16 | 16 | from buildingmotif.database.errors import TemplateNotFound |
17 | | -from buildingmotif.namespaces import OWL, PARAM, RDF, SH, XSD, bind_prefixes |
| 17 | +from buildingmotif.namespaces import OWL, PARAM, RDF, RDFS, SH, XSD, bind_prefixes |
18 | 18 |
|
19 | 19 | if TYPE_CHECKING: |
20 | 20 | from buildingmotif.dataclasses import Library, Template |
@@ -224,6 +224,7 @@ def get_template_parts_from_shape( |
224 | 224 | - sh:property with sh:qualifiedMinCount |
225 | 225 | - sh:class |
226 | 226 | - sh:node |
| 227 | + - rdfs:subClassOf |
227 | 228 |
|
228 | 229 | :param shape_name: name of shape |
229 | 230 | :type shape_name: URIRef |
@@ -297,6 +298,16 @@ def process_shape(shape_node: Node, focus_param: URIRef): |
297 | 298 | if isinstance(cls, URIRef): |
298 | 299 | body.add((focus_param, RDF.type, cls)) |
299 | 300 |
|
| 301 | + superclass_nodes: Set[Node] = set() |
| 302 | + for graph in [shape_graph, *depedency_graphs.values()]: |
| 303 | + superclass_nodes.update(graph.objects(shape_node, RDFS["subClassOf"])) |
| 304 | + |
| 305 | + for superclass in superclass_nodes: |
| 306 | + if isinstance(superclass, URIRef) and is_nodeshape(superclass): |
| 307 | + add_dependency(superclass, focus_param) |
| 308 | + elif isinstance(superclass, URIRef): |
| 309 | + body.add((focus_param, RDF.type, superclass)) |
| 310 | + |
300 | 311 | for node_shape in shape_graph.objects(shape_node, SH["node"]): |
301 | 312 | if isinstance(node_shape, URIRef): |
302 | 313 | add_dependency(node_shape, focus_param) |
|
0 commit comments