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%2FVirtualGraphServerSupportImpl.java;h=227d9bcff1d533b02793c665f0ed214ed4b409cb;hp=6c86c100a0fe0d2a6f78b86250f816bccb26ccb0;hb=ffdf837;hpb=d1a82fe1414c77b97bec886d6a3ae3c5d926c334 diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/VirtualGraphServerSupportImpl.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/VirtualGraphServerSupportImpl.java index 6c86c100a..227d9bcff 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/VirtualGraphServerSupportImpl.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/VirtualGraphServerSupportImpl.java @@ -38,6 +38,7 @@ import org.simantics.db.service.SerialisationSupport; import org.simantics.db.service.ServerInformation; import org.simantics.db.service.TransferableGraphSupport; import org.simantics.db.service.VirtualGraphSupport; +import org.simantics.db.service.XSupport; import org.simantics.layer0.Layer0; import org.simantics.utils.FileUtils; @@ -63,14 +64,21 @@ public class VirtualGraphServerSupportImpl implements VirtualGraphSupport, Virtu this.virtualGraphStoragePath = path; } - void connect(String dbString) { + void connect(String dbString) throws Exception { + virtualId = new AtomicInteger(-2); + this.dbString = dbString; - virtualId = new AtomicInteger(-2); - - this.dbString = dbString; + XSupport support = session.getService(XSupport.class); + if (support.rolledback()) { + for (File file : virtualGraphStoragePath.listFiles()) { + if (!file.delete()) { + throw new IOException("Could not delete file " + file.getAbsolutePath()); + } + } + } File file = new File(virtualGraphStoragePath, "virtualGraphs." + dbString + ".dat"); - + // System.out.println("scanning " + file.getAbsolutePath()); if(file.exists()) { @@ -84,11 +92,15 @@ public class VirtualGraphServerSupportImpl implements VirtualGraphSupport, Virtu hasVirtuals = true; + String databaseId = session.getService(ServerInformation.class).getDatabaseId(); + String matcher = ".W." + databaseId + ".vg."; + // Load existing workspace persistent graphs for(File virtualGraph : virtualGraphStoragePath.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { - return name.endsWith(".vg"); + boolean matches = name.contains(matcher); + return matches; } })) { String name = virtualGraph.getName();