]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics/src/org/simantics/SimanticsPlatform.java
Sync git svn branch with SVN repository r33249.
[simantics/platform.git] / bundles / org.simantics / src / org / simantics / SimanticsPlatform.java
index 89a5d3dbd52df2e7376cafb836b9b7f7724145ec..7e6bd9dd9be5c7c134baff73223061f535ce6e92 100644 (file)
@@ -39,8 +39,6 @@ import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;\r
 import org.eclipse.core.runtime.SubMonitor;\r
 import org.eclipse.osgi.service.resolver.BundleDescription;\r
-import org.simantics.SimanticsPlatform.OntologyRecoveryPolicy;\r
-import org.simantics.SimanticsPlatform.RecoveryPolicy;\r
 import org.simantics.databoard.Bindings;\r
 import org.simantics.databoard.Databoard;\r
 import org.simantics.datatypes.literal.Font;\r
@@ -199,13 +197,13 @@ public class SimanticsPlatform implements LifecycleListener {
         return application != null ? application : UUID.randomUUID().toString();\r
     }\r
 \r
-    private Session setupDatabase(String databaseId, IProgressMonitor progressMonitor, RecoveryPolicy workspacePolicy, PlatformUserAgent userAgent) throws PlatformException {\r
+    private Session setupDatabase(String databaseDriverId, IProgressMonitor progressMonitor, RecoveryPolicy workspacePolicy, PlatformUserAgent userAgent) throws PlatformException {\r
         if (progressMonitor == null)\r
             progressMonitor = new NullProgressMonitor();\r
         File dbLocation = Platform.getLocation().append("db").toFile();\r
         ServerManager serverManager;\r
         try {\r
-            serverManager = ServerManagerFactory.create(databaseId, dbLocation.getAbsolutePath());\r
+            serverManager = ServerManagerFactory.create(databaseDriverId, dbLocation.getAbsolutePath());\r
         } catch (DatabaseException | IOException e) {\r
             throw new PlatformException("Failed to initialize Server Manager", e);\r
         }\r
@@ -286,7 +284,9 @@ public class SimanticsPlatform implements LifecycleListener {
                     // Check hash of transferable graph to know whether to update or not.\r
                     if (platformBundle.getHashcode() == existingBundle.getHashcode())\r
                         continue;\r
-                    System.out.println("Ontology hashcodes does not match! platformBundle" + platformBundle.getName() + ".getHashCode()=" + platformBundle.getHashcode() + " existingBundle" + existingBundle.getName() + ".getHashCode()=" + existingBundle.getHashcode());\r
+                    //System.out.println("Ontology hashcodes do not match: platform bundle="\r
+                    //        + platformBundle.getVersionedId() + ", hash=" + platformBundle.getHashcode()\r
+                    //        + "; existing bundle=" + existingBundle.getVersionedId() + ", hash=" + existingBundle.getHashcode());\r
                     reinstallTGs.put(platformBundle, existingBundle);\r
                 }\r
             }\r
@@ -399,7 +399,7 @@ public class SimanticsPlatform implements LifecycleListener {
                                        boolean changes = TransferableGraphs.hasChanges(readGraph(), oldResources, delta);\r
                                        endTransaction();\r
                                        if (!changes) {\r
-                                           log.log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "Nothing to merge for "+tg.toString()));\r
+                                           //log.log(new Status(IStatus.INFO, Activator.PLUGIN_ID, "Nothing to merge for "+tg.toString()));\r
                                            continue;\r
                                        }\r
 \r
@@ -702,7 +702,7 @@ public class SimanticsPlatform implements LifecycleListener {
      *        startup or <code>null</code> to resort to default measures\r
      * @throws PlatformException\r
      */\r
-    public SessionContext startUp(String databaseId, IProgressMonitor progressMonitor, RecoveryPolicy workspacePolicy,\r
+    public SessionContext startUp(String databaseDriverId, IProgressMonitor progressMonitor, RecoveryPolicy workspacePolicy,\r
             OntologyRecoveryPolicy ontologyPolicy, boolean requireSynchronize, PlatformUserAgent userAgent)\r
     throws PlatformException\r
     {\r
@@ -729,9 +729,19 @@ public class SimanticsPlatform implements LifecycleListener {
         VariableRepository.clear();\r
         \r
         // 1. Assert there is a database at <workspace>/db\r
-        session = setupDatabase(databaseId, progressMonitor, workspacePolicy, userAgent);\r
+        session = setupDatabase(databaseDriverId, progressMonitor, workspacePolicy, userAgent);\r
         TimeLogger.log("Database setup complete");\r
-\r
+        \r
+        // 1.1 \r
+        XSupport support = session.getService(XSupport.class);\r
+        if (support.rolledback()) {\r
+            try {\r
+                DatabaseIndexing.deleteAllIndexes();\r
+            } catch (IOException e) {\r
+                throw new PlatformException(e);\r
+            }\r
+        }\r
+        \r
         // 2. Assert all graphs, and correct versions, are installed to the database\r
         synchronizeOntologies(progressMonitor, ontologyPolicy, requireSynchronize);\r
         TimeLogger.log("Synchronized ontologies");\r
@@ -1014,9 +1024,9 @@ public class SimanticsPlatform implements LifecycleListener {
         return false;\r
     }\r
 \r
-    public void reconnect(String databaseId) throws Exception {\r
+    public void reconnect(String databaseDriverId) throws Exception {\r
         // Starts database server.\r
-        SimanticsPlatform.INSTANCE.startUp(databaseId, null, RecoveryPolicy.ThrowError, OntologyRecoveryPolicy.ThrowError, true, null);\r
+        SimanticsPlatform.INSTANCE.startUp(databaseDriverId, null, RecoveryPolicy.ThrowError, OntologyRecoveryPolicy.ThrowError, true, null);\r
     }\r
 \r
     private void dumpPlatformBundleState() {\r