From cff26560449d62073ae14a9c1bb5442532f34de2 Mon Sep 17 00:00:00 2001 From: Antti Villberg Date: Mon, 20 Mar 2017 07:46:49 +0200 Subject: [PATCH] Predicate by label request into Layer0Utils refs #7035 Change-Id: I322dbcb8f51fd16e39d4408a6a5043713ddd8530 --- .../org/simantics/db/layer0/util/Layer0Utils.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java index 538f22478..adc51c16d 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java @@ -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 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 { -- 2.47.1