]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java
Default property editing restores assertions
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / util / Layer0Utils.java
index 08dd63ce0e25c4bf11084bc8402eb802cd51a49d..103c9bb0129259bd5dd0c2000410a95fc147bc53 100644 (file)
@@ -1386,4 +1386,18 @@ public class Layer0Utils {
         return PrettyPrintTG.print(tg);
     }
 
+    public static Resource getPossibleAssertedObject(ReadGraph graph, Resource resource, Resource predicate) throws DatabaseException {
+       Resource result = null;
+       for(Resource type : graph.getPrincipalTypes(resource)) {
+               Collection<Resource> rs = graph.getAssertedObjects(type, predicate);
+               if(rs.size() > 1) return null;
+               if(rs.size() == 1) {
+                       Resource ass = rs.iterator().next();
+                       if (result != null && !result.equals(ass)) return null;
+                       result = ass;
+               }
+       }
+       return result;
+    }
+    
 }