X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.db%2Fscl%2FSimantics%2FDB.scl;h=74bc4220436dbe2d7a991012d9385a8eab08e136;hp=e91b7d78667a95a74da0f238ab37f7aca44c27b2;hb=602614f4502aae85ecf3967abb7152d2d62903e3;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.scl.db/scl/Simantics/DB.scl b/bundles/org.simantics.scl.db/scl/Simantics/DB.scl index e91b7d786..74bc42204 100644 --- a/bundles/org.simantics.scl.db/scl/Simantics/DB.scl +++ b/bundles/org.simantics.scl.db/scl/Simantics/DB.scl @@ -11,31 +11,6 @@ effect WriteGraph "graph" "org.simantics.db.WriteGraph" -importJava "org.simantics.databoard.type.Datatype" where - data Datatype - @JavaName toString - showDatatype :: Datatype -> String - -instance Show Datatype where - show = showDatatype - -importJava "org.simantics.databoard.Bindings" where - @JavaName getBinding - datatypeBinding :: Datatype -> Binding Dynamic - -importJava "org.simantics.databoard.binding.mutable.Variant" where - @JavaName "" - createVariant_ :: Binding Dynamic -> Dynamic -> Variant - @JavaName "type" - variantDatatype :: Variant -> Datatype - -createVariant :: Datatype -> Dynamic -> Variant -createVariant dt v = createVariant_ (datatypeBinding dt) v - -importJava "org.simantics.databoard.Datatypes" where - @JavaName translate - translateDatatype :: String -> Datatype - importJava "org.simantics.db.Resource" where "A resource is a node in a semantic graph." data Resource @@ -86,6 +61,9 @@ importJava "org.simantics.db.ReadGraph" where getDataType :: Resource -> Datatype + @JavaName getSupertypes + superTypesOf :: Resource -> Set.T Resource + @private @JavaName getURI uriOfResource :: Resource -> String @@ -452,4 +430,28 @@ lift2Write f x y = syncWrite (\_ -> f x y) @inline lift3Write :: (a -> b -> c -> d) -> (a -> b -> c -> d) -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) + +""" +Returns a child Browsable of the specified parent that has that is the child +of the specified parent with the specified name path. +""" +childWithPath :: Browsable a => a -> [String] -> a +childWithPath parent path = + foldl (\r name -> match possibleChild r name with + Just c -> c + Nothing -> fail ("Didn't find " + name + ".") + ) + parent path + +""" +Like `childWithPath` but returns Maybe a which will be `Nothing` if no child +was found. +""" +possibleChildWithPath :: Browsable a => a -> [String] -> Maybe a +possibleChildWithPath parent path = + foldl (\r name -> match r with + Just c -> possibleChild c name + Nothing -> Nothing + ) + (Just parent) path