]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.acorn/src/org/simantics/acorn/internal/AcornDatabase.java
Merge branch 'feature/funcwrite'
[simantics/platform.git] / bundles / org.simantics.acorn / src / org / simantics / acorn / internal / AcornDatabase.java
index be505c6039712e322ce80ffa653c1b4c6babac13..1025cc6a5dac0a2e6d5b940b1ad0d17ba971fa00 100644 (file)
@@ -19,7 +19,10 @@ import org.simantics.db.Database;
 import org.simantics.db.DatabaseUserAgent;
 import org.simantics.db.ServiceLocator;
 import org.simantics.db.common.utils.Logger;
+import org.simantics.db.exception.SDBException;
+import org.simantics.db.server.DatabaseStartException;
 import org.simantics.db.server.ProCoreException;
+import org.simantics.db.server.internal.InternalException;
 
 /**
  * @author Tuukka Lehtonen
@@ -27,6 +30,8 @@ import org.simantics.db.server.ProCoreException;
 public class AcornDatabase implements Database {
 
     private final Path folder;
+    
+    private GraphClientImpl2 currentClient;
 
     private DatabaseUserAgent userAgent;
 
@@ -190,22 +195,22 @@ public class AcornDatabase implements Database {
 
     @Override
     public void purgeDatabase() throws ProCoreException {
-        // TODO: implement
-        throw new UnsupportedOperationException();
+       if(currentClient == null) throw new IllegalStateException("No current session.");
+       currentClient.purgeDatabase();
     }
 
     @Override
     public long serverGetTailChangeSetId() throws ProCoreException {
-        // "We have it all"
-        // But after purging we don't so beware.
-        // TODO: beware for purge
-        return 1;
+       if(currentClient == null) throw new IllegalStateException("No current session.");
+       return currentClient.getTailChangeSetId();
     }
 
     @Override
     public Session newSession(ServiceLocator locator) throws ProCoreException {
         try {
-            return new GraphClientImpl2(this, folder, locator);
+               if(currentClient != null) throw new DatabaseStartException(folder.toFile(), "A session is already running. Only one session is supported.");
+               currentClient = new GraphClientImpl2(this, folder, locator); 
+            return currentClient;
         } catch (IOException e) {
             throw new ProCoreException(e);
         }