Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit 9d84172

Browse files
committed
Add changeset versioning to Brick add/remove
1 parent 8341931 commit 9d84172

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/blenderbim/blenderbim/tool/brick.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ class Brick(blenderbim.core.tool.Brick):
3838
def add_brick(cls, namespace, brick_class):
3939
ns = Namespace(namespace)
4040
brick = ns[ifcopenshell.guid.expand(ifcopenshell.guid.new())]
41-
BrickStore.graph.add((brick, RDF.type, URIRef(brick_class)))
42-
BrickStore.graph.add((brick, URIRef("http://www.w3.org/2000/01/rdf-schema#label"), Literal("Unnamed")))
41+
with BrickStore.graph.new_changeset("PROJECT") as cs:
42+
cs.add((brick, RDF.type, URIRef(brick_class)))
43+
cs.add((brick, URIRef("http://www.w3.org/2000/01/rdf-schema#label"), Literal("Unnamed")))
4344
return str(brick)
4445

4546
@classmethod
@@ -281,8 +282,9 @@ def pop_brick_breadcrumb(cls):
281282

282283
@classmethod
283284
def remove_brick(cls, brick_uri):
284-
for triple in BrickStore.graph.triples((URIRef(brick_uri), None, None)):
285-
BrickStore.graph.remove(triple)
285+
with BrickStore.graph.new_changeset("PROJECT") as cs:
286+
for triple in BrickStore.graph.triples((URIRef(brick_uri), None, None)):
287+
cs.remove(triple)
286288

287289
@classmethod
288290
def run_assign_brick_reference(cls, element=None, library=None, brick_uri=None):
@@ -329,7 +331,6 @@ class BrickStore:
329331
graph = None # this is the VersionedGraphCollection with 2 arbitrarily named graphs: "schema" and "project"
330332
# "SCHEMA" holds the Brick.ttl metadata; "PROJECT" holds all the authored entities
331333

332-
333334
@staticmethod
334335
def purge():
335336
BrickStore.schema = None

0 commit comments

Comments
 (0)