]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Prevent exceptions in procedural substructure requests 30/3930/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Mon, 16 Mar 2020 20:00:33 +0000 (22:00 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 16 Mar 2020 23:32:04 +0000 (23:32 +0000)
gitlab #497

Change-Id: Iaec7ce4ac40fb07d7b91ab2d6d9f3609b10facaa
(cherry picked from commit 209d3c557147c8c2c8ae4d8500d1b9a8c5c3166d)

bundles/org.simantics.modeling/src/org/simantics/modeling/ProceduralSubstructureMapRequest.java

index e8c54fa987537401d8b448c35652c6a7fe32ff16..6256891b82ae17a96391e7a05399b2ef9ae3f640 100644 (file)
@@ -3,6 +3,7 @@ package org.simantics.modeling;
 import gnu.trove.map.hash.THashMap;
 
 import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.request.PropertyInfo;
 import org.simantics.db.layer0.request.PropertyInfoRequest;
@@ -21,19 +22,28 @@ public class ProceduralSubstructureMapRequest extends VariableRead<THashMap<Stri
     public THashMap<String, Pair<String,Type>> perform(ReadGraph graph) throws DatabaseException {
         THashMap<String, Pair<String,Type>> propertyMap = new THashMap<String, Pair<String,Type>>();
         for(Variable child : variable.getChildren(graph)) {
-               for(Variable property : child.getProperties(graph)) {
-                   PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(property.getPredicateResource(graph)));
+            for(Variable property : child.getProperties(graph)) {
+                Resource predicate = property.getPossiblePredicateResource(graph);
+                if (predicate == null)
+                    continue;
+                
+                PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(predicate));
                 propertyMap.put(child.getName(graph) + "." + propertyInfo.name,
                         Pair.make("/" + child.getName(graph) + "#" + propertyInfo.name,
                                 SCLTypeUtils.getType(propertyInfo)));
-               }
+            }
         }
-       for(Variable property : variable.getProperties(graph)) {
-           PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(property.getPredicateResource(graph)));
+        for(Variable property : variable.getProperties(graph)) {
+            Resource predicate = property.getPossiblePredicateResource(graph);
+            if (predicate == null)
+                continue;
+            
+            PropertyInfo propertyInfo = graph.syncRequest(new PropertyInfoRequest(predicate));
             propertyMap.put(propertyInfo.name,
                     Pair.make("#" + propertyInfo.name,
                             SCLTypeUtils.getType(propertyInfo)));
-       }
+        }
+        
         return propertyMap;
     }