SHACL → entities¶
app.shacl_to_entities
¶
SHACL → EntityShape descriptors for SPARQL build and GeoJSON decode.
Parallel to shacl_to_filters: both walk the same NodeShapes; this
module projects EntityShape descriptors, not filter UI widgets. Instance
data is filled later by SPARQL over compass.ttl.
EntityShape
¶
Bases: BaseModel
One property descriptor projected from SHACL (not an instance).
get_shacl_property(g)
¶
Yield every sh:property IRI of every NodeShape that has a sh:targetClass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
g
|
Graph
|
Merged ontology graph (shapes + data + vocab). |
required |
Yields:
| Type | Description |
|---|---|
URIRef
|
|
Source code in src/backend/app/shacl_to_entities.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
get_shacl_label(g, subject, predicate, lang)
¶
Return a label in lang, falling back to English, then any available label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
g
|
Graph
|
Ontology graph. |
required |
subject
|
URIRef
|
Resource whose label is sought. |
required |
predicate
|
URIRef
|
Preferred label predicate (e.g. |
required |
lang
|
str
|
BCP 47 language tag. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Best-matching label string, or the subject's local name as last resort. |
Source code in src/backend/app/shacl_to_entities.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
get_entity_shape_from_shacl(g)
¶
Project SHACL property shapes into EntityShape descriptors for query and decode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
g
|
Graph
|
Merged ontology graph. |
required |
Returns:
| Type | Description |
|---|---|
list[EntityShape]
|
One |
Source code in src/backend/app/shacl_to_entities.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
_infer_category(datatype, is_iri)
¶
Map SHACL datatype / IRI-ness to a SPARQL binding category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datatype
|
Node | None
|
|
required |
is_iri
|
bool
|
True when the property values are IRIs (class, nodeKind, or sh:in). |
required |
Returns:
| Type | Description |
|---|---|
PropertyCategory
|
Category string consumed by the SPARQL builder and GeoJSON translator. |
Source code in src/backend/app/shacl_to_entities.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
_infer_filter_type(path, category, datatype)
¶
Choose the filter widget for a property, or none if display-only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Node
|
Property path URIRef. |
required |
category
|
str
|
Inferred |
required |
datatype
|
Node | None
|
|
required |
Returns:
| Type | Description |
|---|---|
FilterType
|
Filter widget type used by the panel, or |
Source code in src/backend/app/shacl_to_entities.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |