4141import org .slf4j .LoggerFactory ;
4242
4343import java .lang .ref .WeakReference ;
44+ import java .util .ArrayList ;
4445import java .util .List ;
4546import java .util .Map ;
4647import java .util .UUID ;
@@ -71,7 +72,7 @@ public class GraphWithContextTransactional implements GraphContext {
7172 private final ConcurrentHashMap <UUID , CustomDiagram > customDiagrams = new ConcurrentHashMap <>();
7273
7374 /** The fixed participants that are always part of every transaction. */
74- private final List <TransactionParticipant > coreTransactionParticipants ;
75+ private final List <RDFGraphDelta > graphParticipants ;
7576
7677 private final List <NamedRewindable > coreRewindables ;
7778 private final AtomicInteger stepsSinceNamedCommit = new AtomicInteger (0 );
@@ -94,7 +95,7 @@ public GraphWithContextTransactional(Graph base) {
9495 this .customSHACL =
9596 new RDFGraphDelta (
9697 GraphFactory .createDefaultGraph (), maxVersions , compressCount , txnContext );
97- this .coreTransactionParticipants = List .of (rdfGraph , diagramLayout , customSHACL , changeLog );
98+ this .graphParticipants = List .of (rdfGraph , customSHACL );
9899 this .coreRewindables =
99100 List .of (
100101 new NamedRewindable ("rdf" , rdfGraph ),
@@ -107,12 +108,11 @@ public GraphWithContextTransactional(Graph base) {
107108 // Helpers — build the effective participant / rewindable lists
108109 // -------------------------------------------------------------------------
109110
110- /**
111- * Returns the core transaction participants. Custom diagrams are managed separately since they
112- * are not part of the undo/redo history.
113- */
114- private List <TransactionParticipant > allTransactionParticipants () {
115- return coreTransactionParticipants ;
111+ private List <TransactionParticipant > allParticipants () {
112+ var all = new ArrayList <TransactionParticipant >(graphParticipants );
113+ all .add (diagramLayout );
114+ all .add (changeLog );
115+ return all ;
116116 }
117117
118118 /**
@@ -182,9 +182,13 @@ public void commit() {
182182 }
183183 GraphUtils .enhanceWithUUIDs (rdfGraph );
184184 changeLog .clearRedo ();
185- allTransactionParticipants ().forEach (TransactionParticipant ::commit );
185+ if (graphParticipants .stream ().anyMatch (TransactionParticipant ::hasChanges )) {
186+ graphParticipants .forEach (TransactionParticipant ::commit );
187+ stepsSinceNamedCommit .incrementAndGet ();
188+ }
189+ diagramLayout .commit ();
190+ changeLog .commit ();
186191 customDiagrams .values ().forEach (CustomDiagram ::commit );
187- stepsSinceNamedCommit .incrementAndGet ();
188192 logger .debug ("Context committed." );
189193 }
190194
@@ -349,7 +353,7 @@ public void abort() {
349353 if (txnContext .transactionMode () == ReadWrite .READ ) {
350354 throw new GraphTransactionException ("Cannot abort a read transaction." );
351355 }
352- allTransactionParticipants ().forEach (TransactionParticipant ::abort );
356+ allParticipants ().forEach (TransactionParticipant ::abort );
353357 customDiagrams .values ().forEach (CustomDiagram ::abort );
354358 logger .debug ("Context aborted." );
355359 }
@@ -361,10 +365,9 @@ public void end() {
361365 }
362366 if (txnContext .transactionMode () == ReadWrite .WRITE
363367 && !rdfGraph .isClosed ()
364- && allTransactionParticipants ().stream ()
365- .anyMatch (TransactionParticipant ::hasChanges )) {
368+ && allParticipants ().stream ().anyMatch (TransactionParticipant ::hasChanges )) {
366369 logger .warn ("Ending write transaction with uncommitted changes — aborting." );
367- allTransactionParticipants ().forEach (TransactionParticipant ::abort );
370+ allParticipants ().forEach (TransactionParticipant ::abort );
368371 customDiagrams .values ().forEach (CustomDiagram ::abort );
369372 }
370373 var lock =
0 commit comments