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
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
\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