X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Futil%2FLayer0Utils.java;h=6b9b2fc6502845763871aa1383d8d8a1835ef33b;hb=5ea4ad47a74e042f8728f48a0635f5f291519b29;hp=c04ca3cd1e0b758d1d66a8a8628887dab576f5cc;hpb=f2f1f3fe7b467654a0afa4e586ebcd06a54ebfea;p=simantics%2Fplatform.git 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 c04ca3cd1..6b9b2fc65 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 @@ -74,6 +74,7 @@ import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.common.request.PossibleChild; import org.simantics.db.common.request.PossibleIndexRoot; import org.simantics.db.common.utils.NameUtils; +import org.simantics.db.event.ChangeListener; import org.simantics.db.exception.CancelTransactionException; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.ServiceException; @@ -99,6 +100,7 @@ import org.simantics.db.service.ClusterControl; import org.simantics.db.service.ClusteringSupport; import org.simantics.db.service.CollectionSupport; import org.simantics.db.service.DebugSupport; +import org.simantics.db.service.GraphChangeListenerSupport; import org.simantics.db.service.ManagementSupport; import org.simantics.db.service.UndoRedoSupport; import org.simantics.db.service.XSupport; @@ -1341,6 +1343,11 @@ public class Layer0Utils { } return result; } + + public static Resource getPossiblePredicateByNameFromType(ReadGraph graph, Resource type, String name) throws DatabaseException { + Map domain = getDomainOf(graph, type); + return domain.get(name); + } public static Resource getPossiblePredicateByName(ReadGraph graph, Resource instance, String predicateName) throws DatabaseException { for(Resource type : graph.getPrincipalTypes(instance)) { @@ -1430,4 +1437,13 @@ public class Layer0Utils { } return false; } + + public static void addMetadataListener(ChangeListener listener) { + SimanticsInternal.getSession().getService(GraphChangeListenerSupport.class).addMetadataListener(listener); + } + + public static void removeMetadataListener(ChangeListener listener) { + SimanticsInternal.getSession().getService(GraphChangeListenerSupport.class).removeMetadataListener(listener); + } + }