X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.procore%2Fsrc%2Ffi%2Fvtt%2Fsimantics%2Fprocore%2Finternal%2FClusterTable.java;h=7df13315f8f68b093fdbf6cb91b0359b5bb909e1;hp=c6fd11c4eb35900763e1176b51fe90f7001819e3;hb=60ef4f8b863d892019a61978a63119dc1ebd852f;hpb=bdab0adcee131a18290393e1c2fca72de48c10d2 diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java index c6fd11c4e..7df13315f 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java @@ -289,14 +289,29 @@ public final class ClusterTable implements IClusterTable { } } - synchronized void replaceCluster(ClusterI cluster) { - //printMaps("replaceCluster"); + synchronized void replaceCluster(ClusterI cluster_) { + ClusterImpl cluster = (ClusterImpl) cluster_; checkCollect(); int clusterKey = cluster.getClusterKey(); - ClusterI existing = clusterArray[clusterKey]; + ClusterImpl existing = (ClusterImpl) clusterArray[clusterKey]; if (existing.hasVirtual()) cluster.markVirtual(); + if (existing.cc != null) { + if (existing.isLoaded()) { + // This shall be promoted to actual exception in the future - + // for now, minimal changes + new Exception("Trying to replace cluster with pending changes " + existing.getClusterUID()) + .printStackTrace(); + } else { + // Adopt changes to loaded cluster + cluster.cc = existing.cc; + cluster.cc.adopt(cluster); + cluster.foreignLookup = existing.foreignLookup; + cluster.change = existing.change; + } + } + importanceMap.remove(existing.getImportance()); if (collectorPolicy != null) collectorPolicy.removed((ClusterImpl)existing); @@ -589,7 +604,6 @@ public final class ClusterTable implements IClusterTable { public boolean execute(int clusterKey) { ClusterImpl proxy = clusterArray[clusterKey]; ClusterUID clusterUID = proxy.getClusterUID(); - System.err.println("writeOnlyInvalidate " + clusterUID); clusters.freeProxy(proxy); return true; }