-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
It appears that redo()
for the VersionedGraphCollection
, although indeed adding the changeset back to the collection, it doesn't do it under the same graph name. So if I serialize the entire graph collection after undoing and redoing, it appears in the graph/file, but if I serialize only the specific graph I specified originally, it no longer appears in the file even though it is part of the graph collection.
from brickschema.persistent import VersionedGraphCollection, Changeset
from brickschema.namespaces import A, BRICK
from rdflib import Namespace
vg = VersionedGraphCollection("sqlite://")
BLDG = Namespace("test:")
with vg.new_changeset("my-building") as cs:
cs.add((BLDG.zone1, A, BRICK.HVAC_Zone))
with vg.new_changeset("my-building") as cs:
cs.add((BLDG.zone2, A, BRICK.HVAC_Zone))
vg.undo()
vg.redo()
vg.serialize("UndoRedo1.ttl") # serialize the entire graph collection
vg.graph_at(graph="my-building").serialize("UndoRedo2.ttl") # serialize only the graph "my-building"
A potential fix that seems to work might be this (persistent.py on line 171):
# persistent.py
# redo():
triple = pickle.loads(row["triple"])
graph = self.get_context(redo_record["graph"])
if row["is_insertion"]:
graph.remove((triple[0], triple[1], triple[2]))
else:
graph.add((triple[0], triple[1], triple[2]))
Metadata
Metadata
Assignees
Labels
No labels