mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 14:48:02 +00:00
Add changeset versioning to Brick add/remove
This commit is contained in:
@@ -38,8 +38,9 @@ class Brick(blenderbim.core.tool.Brick):
|
|||||||
def add_brick(cls, namespace, brick_class):
|
def add_brick(cls, namespace, brick_class):
|
||||||
ns = Namespace(namespace)
|
ns = Namespace(namespace)
|
||||||
brick = ns[ifcopenshell.guid.expand(ifcopenshell.guid.new())]
|
brick = ns[ifcopenshell.guid.expand(ifcopenshell.guid.new())]
|
||||||
BrickStore.graph.add((brick, RDF.type, URIRef(brick_class)))
|
with BrickStore.graph.new_changeset("PROJECT") as cs:
|
||||||
BrickStore.graph.add((brick, URIRef("http://www.w3.org/2000/01/rdf-schema#label"), Literal("Unnamed")))
|
cs.add((brick, RDF.type, URIRef(brick_class)))
|
||||||
|
cs.add((brick, URIRef("http://www.w3.org/2000/01/rdf-schema#label"), Literal("Unnamed")))
|
||||||
return str(brick)
|
return str(brick)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -281,8 +282,9 @@ class Brick(blenderbim.core.tool.Brick):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def remove_brick(cls, brick_uri):
|
def remove_brick(cls, brick_uri):
|
||||||
for triple in BrickStore.graph.triples((URIRef(brick_uri), None, None)):
|
with BrickStore.graph.new_changeset("PROJECT") as cs:
|
||||||
BrickStore.graph.remove(triple)
|
for triple in BrickStore.graph.triples((URIRef(brick_uri), None, None)):
|
||||||
|
cs.remove(triple)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_assign_brick_reference(cls, element=None, library=None, brick_uri=None):
|
def run_assign_brick_reference(cls, element=None, library=None, brick_uri=None):
|
||||||
@@ -329,7 +331,6 @@ class BrickStore:
|
|||||||
graph = None # this is the VersionedGraphCollection with 2 arbitrarily named graphs: "schema" and "project"
|
graph = None # this is the VersionedGraphCollection with 2 arbitrarily named graphs: "schema" and "project"
|
||||||
# "SCHEMA" holds the Brick.ttl metadata; "PROJECT" holds all the authored entities
|
# "SCHEMA" holds the Brick.ttl metadata; "PROJECT" holds all the authored entities
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def purge():
|
def purge():
|
||||||
BrickStore.schema = None
|
BrickStore.schema = None
|
||||||
|
|||||||
Reference in New Issue
Block a user