]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Database backwards compatibility fix for fail-safe import changes 98/398/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 3 Apr 2017 12:10:34 +0000 (15:10 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 3 Apr 2017 12:10:34 +0000 (15:10 +0300)
To keep databases created before Mar 30 18:39 compatible with the
current git master version.

refs #7016

Change-Id: Ic327809eae90d01d115cfb880a33b9dc37051a36

bundles/org.simantics.graph.db/src/org/simantics/graph/db/CoreInitialization.java

index 096f0a00f2ff50ae80be27aa68b28d067c5e2505..b641490326b4be2c7874cd47d939b6210413f9dc 100644 (file)
@@ -28,6 +28,10 @@ public class CoreInitialization {
        }
 
        static {
+               // IMPORTANT NOTICE:
+               // DO NOT alter the order of these definitions in any way
+               // unless you deliberately want to make the system incompatible
+               // with databases that have been created before changing these.
                addLayer0Builtin("InstanceOf");
                addLayer0Builtin("Inherits");
                addLayer0Builtin("SubrelationOf");
@@ -38,7 +42,6 @@ public class CoreInitialization {
 
                addLayer0Builtin("ConsistsOf");
                addLayer0Builtin("PartOf");
-               addLayer0Builtin("ExternalEntity");
 
                addLayer0Builtin("String");
                addLayer0Builtin("Library");
@@ -50,7 +53,33 @@ public class CoreInitialization {
                addLayer0Builtin("HasPredicateInverse");
                addLayer0Builtin("HasObject");
 
+               // #7016: This bogus URI replaces the builtin entry
+               // that was originally http://Projects.
+               //
+               // addBuiltin("http://Projects") was removed because its existence
+               // resulted in a non-functioning URI space because:
+               //
+               // 1. http://Projects was added as a "built-in resource" when the database
+               //    is first initialized which means that ReadGraph.getResource("http://Projects")
+               //    would succeed even when the resource was not yet properly imported
+               //    from the project ontology.
+               //
+               // 2. When the project ontology is imported, a new resource is
+               //    created to represent http://Projects instead of using the existing
+               //    uninitialized "built-in resource". The L0.ExternalEntity changes made
+               //    to the standard transferable graph import in this patch caused the
+               //    code to find the built-in resource for "http://Projects" and think
+               //    that it has to be a resource that's already properly initialized.
+               //    This led to the TG import not initializing the resource at all.
+               //    Previously there was a bug here as well but it was hidden by the fact
+               //    that the system would import the actual/new "http://Projects"
+               //    resource from the ontology anyway. This effectively left the
+               //    uninitialized built-in resource just hanging in the database as
+               //    trash.
+               //addBuiltin("http://Projects");
+               addBuiltin("75e23fb39121b4b37cf2e6a26ccb34c52f77522d-do-not-remove");
                addBuiltin("http:/");
+               addLayer0Builtin("ExternalEntity");
        }
 
     public static void initializeBuiltins(Session session) throws DatabaseException {