mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
Change brick attributes query "name" and "value" to "predicate" and "object"
This commit is contained in:
@@ -64,39 +64,38 @@ class BrickschemaData:
|
|||||||
PREFIX brick: <https://brickschema.org/schema/Brick#>
|
PREFIX brick: <https://brickschema.org/schema/Brick#>
|
||||||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
|
||||||
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
||||||
SELECT DISTINCT ?name ?value ?sp ?sv WHERE {
|
SELECT DISTINCT ?predicate ?object ?sp ?sv WHERE {
|
||||||
<{uri}> ?name ?value .
|
<{uri}> ?predicate ?object .
|
||||||
OPTIONAL {
|
OPTIONAL {
|
||||||
{ ?name rdfs:range brick:TimeseriesReference . }
|
{ ?predicate rdfs:range brick:TimeseriesReference . }
|
||||||
UNION
|
UNION
|
||||||
{ ?name a brick:EntityProperty . }
|
{ ?predicate a brick:EntityProperty . }
|
||||||
?value ?sp ?sv }
|
?object ?sp ?sv }
|
||||||
}
|
}
|
||||||
""".replace(
|
""".replace(
|
||||||
"{uri}", uri
|
"{uri}", uri
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
for row in query:
|
for row in query:
|
||||||
name = row.get("name").toPython().split("#")[-1]
|
predicate = row.get("predicate").toPython().split("#")[-1]
|
||||||
value = row.get("value")
|
object = row.get("object")
|
||||||
results.append(
|
results.append(
|
||||||
{
|
{
|
||||||
"name": name,
|
"predicate": predicate,
|
||||||
"value": value.toPython().split("#")[-1],
|
"object": object.toPython().split("#")[-1],
|
||||||
"is_uri": isinstance(value, URIRef),
|
"is_uri": isinstance(object, URIRef),
|
||||||
"value_uri": value.toPython(),
|
"object_uri": object.toPython(),
|
||||||
"is_globalid": name == "globalID",
|
"is_globalid": predicate == "globalID",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if isinstance(row.get("value"), BNode):
|
if isinstance(row.get("object"), BNode):
|
||||||
for s, p, o in BrickStore.graph.triples((value, None, None)):
|
for s, p, o in BrickStore.graph.triples((object, None, None)):
|
||||||
results.append(
|
results.append(
|
||||||
{
|
{
|
||||||
"name": name + ":" + p.toPython().split("#")[-1],
|
"predicate": predicate + ":" + p.toPython().split("#")[-1],
|
||||||
"value": o.toPython().split("#")[-1],
|
"object": o.toPython().split("#")[-1],
|
||||||
"is_uri": isinstance(o, URIRef),
|
"is_uri": isinstance(o, URIRef),
|
||||||
"value_uri": o.toPython(),
|
"object_uri": o.toPython(),
|
||||||
"is_globalid": p.toPython().split("#")[-1] == "globalID",
|
"is_globalid": p.toPython().split("#")[-1] == "globalID",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -109,14 +109,14 @@ class BIM_PT_brickschema(Panel):
|
|||||||
|
|
||||||
for attribute in BrickschemaData.data["attributes"]:
|
for attribute in BrickschemaData.data["attributes"]:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text=attribute["name"])
|
row.label(text=attribute["predicate"])
|
||||||
row.label(text=attribute["value"])
|
row.label(text=attribute["object"])
|
||||||
if attribute["is_uri"]:
|
if attribute["is_uri"]:
|
||||||
op = row.operator("bim.view_brick_item", text="", icon="DISCLOSURE_TRI_RIGHT")
|
op = row.operator("bim.view_brick_item", text="", icon="DISCLOSURE_TRI_RIGHT")
|
||||||
op.item = attribute["value_uri"]
|
op.item = attribute["object_uri"]
|
||||||
if attribute["is_globalid"]:
|
if attribute["is_globalid"]:
|
||||||
op = row.operator("bim.select_global_id", icon="RESTRICT_SELECT_OFF", text="")
|
op = row.operator("bim.select_global_id", icon="RESTRICT_SELECT_OFF", text="")
|
||||||
op.global_id = attribute["value"]
|
op.global_id = attribute["object"]
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_ifc_brickschema_references(Panel):
|
class BIM_PT_ifc_brickschema_references(Panel):
|
||||||
|
|||||||
Reference in New Issue
Block a user