Use STR.Component base type for resolving actual type. 60/2660/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 20 Feb 2019 15:34:56 +0000 (17:34 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Wed, 20 Feb 2019 15:34:56 +0000 (17:34 +0200)
This change should fix at least some problems with multi-instances.

gitlab #259

Change-Id: Id8496ba4bc03d9c0e7dba3cc0d0db858896ddce1

bundles/org.simantics.structural2/src/org/simantics/structural2/Functions.java

index 9b5fc4586a9281d16751d002c6103e3047e78bd9..970e6f9e813dc710545aeed3d6c0ee1c6cf234cd 100644 (file)
@@ -562,8 +562,14 @@ public class Functions {
                        }
                        throw new DatabaseException("No type for " + variable.getURI(graph));
                } else {
-                   Resource possibleType = graph.getPossibleType(represents, Layer0.getInstance(graph).Entity);
-                   if (graph.syncRequest(new IsInstanceOf(possibleType, StructuralResource2.getInstance(graph).ReplaceableDefinedComponentType), TransientCacheListener.instance()) ) {
+                       StructuralResource2 STR = StructuralResource2.getInstance(graph);
+                   Resource possibleType = graph.getPossibleType(represents, STR.Component);
+                   if (possibleType == null) {
+                       possibleType = graph.getPossibleType(represents, Layer0.getInstance(graph).Entity);
+                       if (possibleType == null)
+                               return null;
+                   }
+                   if (graph.syncRequest(new IsInstanceOf(possibleType, STR.ReplaceableDefinedComponentType), TransientCacheListener.instance()) ) {
                        return graph.syncRequest(new StructuralOverrideDataWalkRequest(variable, represents, possibleType), TransientCacheListener.instance());
                    } else {
                        return null;
@@ -600,8 +606,8 @@ public class Functions {
 
                @Override
                public Variable getVariable(ReadGraph graph, Variable context, String name) throws DatabaseException {
-                       
-                       Resource type = context.getPossibleType(graph);
+                       StructuralResource2 STR = StructuralResource2.getInstance(graph);
+                       Resource type = context.getPossibleType(graph, STR.Component);
                        if(type == null) return null;
                    
                        Tuple2 result = graph.syncRequest(new StructureTypeAndChildMapRequest(type), TransientCacheListener.instance());