]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.db/scl/Simantics/DB.scl
Merged changes from feature/scl to master.
[simantics/platform.git] / bundles / org.simantics.scl.db / scl / Simantics / DB.scl
index e91b7d78667a95a74da0f238ab37f7aca44c27b2..ae092cfa8d62aafe6cd203d29e20e9a7f9885903 100644 (file)
@@ -11,31 +11,6 @@ effect WriteGraph
     "graph"\r
     "org.simantics.db.WriteGraph"\r
     \r
-importJava "org.simantics.databoard.type.Datatype" where\r
-    data Datatype\r
-    @JavaName toString\r
-    showDatatype :: Datatype -> String\r
-\r
-instance Show Datatype where\r
-    show = showDatatype\r
-\r
-importJava "org.simantics.databoard.Bindings" where\r
-    @JavaName getBinding    \r
-    datatypeBinding :: Datatype -> Binding Dynamic\r
-\r
-importJava "org.simantics.databoard.binding.mutable.Variant" where\r
-    @JavaName "<init>"\r
-    createVariant_ :: Binding Dynamic -> Dynamic -> Variant\r
-    @JavaName "type"\r
-    variantDatatype :: Variant -> Datatype\r
-\r
-createVariant :: Datatype -> Dynamic -> Variant\r
-createVariant dt v = createVariant_ (datatypeBinding dt) v\r
-\r
-importJava "org.simantics.databoard.Datatypes" where\r
-    @JavaName translate\r
-    translateDatatype :: String -> Datatype\r
-\r
 importJava "org.simantics.db.Resource" where\r
     "A resource is a node in a semantic graph."\r
     data Resource\r
@@ -47,21 +22,9 @@ importJava "org.simantics.db.Resource" where
 importJava "org.simantics.db.ReadGraph" where\r
     data ReadGraphX\r
     \r
-importJava "java.lang.Object" where    \r
-    @JavaName equals\r
-    resourceEquals :: Resource -> Resource -> Boolean\r
-    @JavaName hashCode\r
-    resourceHash :: Resource -> Integer\r
-\r
-instance Eq Resource where\r
-    (==) = resourceEquals\r
-\r
 instance Ord Resource where\r
     compare a b = compare (resourceId a) (resourceId b)\r
-    \r
-instance Hashable Resource where\r
-    hashP = hashP . resourceHash\r
-    \r
+  \r
 instance Show Resource where\r
     show r = "#" + show (resourceId r)\r
 \r
@@ -86,6 +49,9 @@ importJava "org.simantics.db.ReadGraph" where
     \r
     getDataType :: Resource -> <ReadGraph> Datatype\r
 \r
+    @JavaName getSupertypes\r
+    superTypesOf :: Resource -> <ReadGraph> Set.T Resource\r
+    \r
     @private\r
     @JavaName getURI\r
     uriOfResource :: Resource -> <ReadGraph> String\r
@@ -452,4 +418,28 @@ lift2Write f x y = syncWrite (\_ -> f x y)
 \r
 @inline\r
 lift3Write :: (a -> b -> c -> <WriteGraph,Proc> d) -> (a -> b -> c -> <Proc> d)\r
-lift3Write f x y z = syncWrite (\_ -> f x y z)
\ No newline at end of file
+lift3Write f x y z = syncWrite (\_ -> f x y z)\r
+\r
+"""\r
+Returns a child Browsable of the specified parent that has that is the child\r
+of the specified parent with the specified name path.\r
+"""\r
+childWithPath :: Browsable a => a -> [String] -> <ReadGraph> a\r
+childWithPath parent path = \r
+    foldl (\r name -> match possibleChild r name with\r
+              Just c -> c\r
+              Nothing -> fail ("Didn't find " + name + ".") \r
+          ) \r
+          parent path\r
+\r
+"""\r
+Like `childWithPath` but returns Maybe a which will be `Nothing` if no child\r
+was found.\r
+"""\r
+possibleChildWithPath :: Browsable a => a -> [String] -> <ReadGraph> Maybe a\r
+possibleChildWithPath parent path = \r
+    foldl (\r name -> match r with\r
+              Just c -> possibleChild c name\r
+              Nothing -> Nothing \r
+          ) \r
+          (Just parent) path\r