]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java
Add support for dependency changes in SCL
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / util / Layer0Utils.java
index c04ca3cd1e0b758d1d66a8a8628887dab576f5cc..6b9b2fc6502845763871aa1383d8d8a1835ef33b 100644 (file)
@@ -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<String,Resource> 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);
+    }
+
 }