]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/VirtualGraphServerSupportImpl.java
Sync git svn branch with SVN repository r33249.
[simantics/platform.git] / bundles / org.simantics.db.procore / src / fi / vtt / simantics / procore / internal / VirtualGraphServerSupportImpl.java
index 6c86c100a0fe0d2a6f78b86250f816bccb26ccb0..227d9bcff1d533b02793c665f0ed214ed4b409cb 100644 (file)
@@ -38,6 +38,7 @@ import org.simantics.db.service.SerialisationSupport;
 import org.simantics.db.service.ServerInformation;\r
 import org.simantics.db.service.TransferableGraphSupport;\r
 import org.simantics.db.service.VirtualGraphSupport;\r
+import org.simantics.db.service.XSupport;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.utils.FileUtils;\r
 \r
@@ -63,14 +64,21 @@ public class VirtualGraphServerSupportImpl implements VirtualGraphSupport, Virtu
                this.virtualGraphStoragePath = path;\r
        }\r
 \r
-       void connect(String dbString) {\r
+    void connect(String dbString) throws Exception {\r
+        virtualId = new AtomicInteger(-2);\r
+        this.dbString = dbString;\r
 \r
-               virtualId = new AtomicInteger(-2);\r
-\r
-               this.dbString = dbString;\r
+        XSupport support = session.getService(XSupport.class);\r
+        if (support.rolledback()) {\r
+            for (File file : virtualGraphStoragePath.listFiles()) {\r
+                if (!file.delete()) {\r
+                    throw new IOException("Could not delete file " + file.getAbsolutePath());\r
+                }\r
+            }\r
+        }\r
 \r
                File file = new File(virtualGraphStoragePath, "virtualGraphs." + dbString + ".dat");\r
-\r
+               \r
                //      System.out.println("scanning " + file.getAbsolutePath());\r
 \r
                if(file.exists()) {\r
@@ -84,11 +92,15 @@ public class VirtualGraphServerSupportImpl implements VirtualGraphSupport, Virtu
 \r
                                hasVirtuals = true;\r
 \r
+                               String databaseId = session.getService(ServerInformation.class).getDatabaseId();\r
+                               String matcher = ".W." + databaseId + ".vg.";\r
+                               \r
                                // Load existing workspace persistent graphs\r
                                for(File virtualGraph : virtualGraphStoragePath.listFiles(new FilenameFilter() {\r
                                        @Override\r
                                        public boolean accept(File dir, String name) {\r
-                                               return name.endsWith(".vg");\r
+                                           boolean matches = name.contains(matcher);\r
+                                               return matches;\r
                                        }\r
                                })) {\r
                                        String name = virtualGraph.getName();\r