]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Predicate by label request into Layer0Utils 67/367/1
authorAntti Villberg <antti.villberg@semantum.fi>
Mon, 20 Mar 2017 05:46:49 +0000 (07:46 +0200)
committerAntti Villberg <antti.villberg@semantum.fi>
Mon, 20 Mar 2017 05:46:49 +0000 (07:46 +0200)
refs #7035

Change-Id: I322dbcb8f51fd16e39d4408a6a5043713ddd8530

bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java

index 538f22478d00f1708a4b0c89e2059adae754f1a4..adc51c16d88ef0f74f1f849f421e9156398c69f1 100644 (file)
@@ -1349,6 +1349,18 @@ public class Layer0Utils {
        return null;
     }
     
+    public static Resource getPossiblePredicateByLabel(ReadGraph graph, Resource instance, String predicateName) throws DatabaseException {
+       Layer0 L0 = Layer0.getInstance(graph);
+       for(Resource type : graph.getPrincipalTypes(instance)) {
+               Map<String, Resource> domainOf = getDomainOf(graph, type);
+               for(Resource r : domainOf.values()) {
+                       String label = graph.getPossibleRelatedValue(r, L0.HasLabel, Bindings.STRING);
+                       if(predicateName.equals(label))
+                               return r;
+               }
+       }
+       return null;
+    }
     
     public static void claimLiteralDataboard(WriteGraph graph, Resource container, Resource property, String valueText) throws DatabaseException {