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=2ff2f51acb11f455459bc64a8663e06961547129;hp=e42af1878214e75fdf90378fdafa57631b33aa57;hb=ff1c29bf73b3e5ea939dc1987540aa0240dc4ae6;hpb=4cfeb52c28469fdfb6d8b07bac43394bac684e7f diff --git a/bundles/org.simantics.scl.db/scl/Simantics/DB.scl b/bundles/org.simantics.scl.db/scl/Simantics/DB.scl index e42af1878..2ff2f51ac 100644 --- a/bundles/org.simantics.scl.db/scl/Simantics/DB.scl +++ b/bundles/org.simantics.scl.db/scl/Simantics/DB.scl @@ -1,5 +1,6 @@ import "JavaBuiltin" as Java include "http://www.simantics.org/Layer0-1.1" as L0 +import "Map" as Map infixl 5 (#) @@ -19,6 +20,8 @@ importJava "org.simantics.db.Resource" where @JavaName getResourceId resourceId :: Resource -> Long + isPersistent :: Resource -> Boolean + importJava "org.simantics.db.ReadGraph" where data ReadGraphX @@ -42,6 +45,8 @@ importJava "org.simantics.db.Statement" where @JavaName getObject objectOf :: Statement -> Resource + isAsserted :: Statement -> Resource -> Boolean + importJava "org.simantics.db.ReadGraph" where "Converts an absolute URI to a resource or returns `Nothing` if there is no such resource." @JavaName getPossibleResource @@ -55,6 +60,10 @@ importJava "org.simantics.db.ReadGraph" where @private @JavaName getURI uriOfResource :: Resource -> String + + @private + @JavaName getPossibleURI + possibleUriOfResource :: Resource -> Maybe String @JavaName getObjects objects_ :: Resource -> Resource -> Collection Resource @@ -84,6 +93,9 @@ importJava "org.simantics.db.ReadGraph" where @JavaName getSingleStatement singleStatement :: Resource -> Resource -> Statement + @JavaName getPossibleStatement + possibleStatement :: Resource -> Resource -> Maybe Statement + @JavaName getRelatedVariantValue relatedVariantValue :: Resource -> Resource -> Variant @@ -96,6 +108,9 @@ importJava "org.simantics.db.ReadGraph" where @JavaName getRelatedValue2 relatedValue2 :: Resource -> Resource -> a + @JavaName getPossibleRelatedValue2 + possibleRelatedValue2 :: Resource -> Resource -> Maybe a + @JavaName getRelatedVariantValue2 relatedVariantValue2 :: Resource -> Resource -> Variant @@ -121,6 +136,8 @@ importJava "org.simantics.db.ReadGraph" where @JavaName getInverse inverseOf :: Resource -> Resource + @JavaName getPossibleInverse + possibleInverseOf :: Resource -> Maybe Resource @JavaName getSingleType singleTypeOf :: Resource -> Resource -> Resource @@ -134,6 +151,11 @@ importJava "org.simantics.db.ReadGraph" where isInheritedFrom :: Resource -> Resource -> Boolean getRootLibrary :: () -> Resource + + @JavaName getPredicates + predicatesOf :: Resource -> [Resource] + + isImmutable :: Resource -> Boolean importJava "org.simantics.db.layer0.util.ExtendedUris" where "Converts an absolute URI to a resource" @@ -158,13 +180,19 @@ class Browsable a where "Returns the URI of the given value." uriOf :: a -> String - + + "Returns the URI of the given value if it exists or Nothing." + possibleUriOf :: a -> Maybe String + "Reads the name of the value." nameOf :: a -> String possibleNameOf :: a -> Maybe String valueOf :: Serializable v => a -> v + genericRelatedValue :: a -> Resource -> t + genericPossibleRelatedValue :: a -> Resource -> Maybe t + variantValueOf :: a -> Variant children :: a -> [a] @@ -177,12 +205,16 @@ class Browsable a where instance Browsable Resource where fromUri = resource uriOf = uriOfResource + possibleUriOf = possibleUriOfResource nameOf r = relatedValue r L0.HasName possibleNameOf r = possibleRelatedValue r L0.HasName @inline valueOf r = valueOf_ r binding variantValueOf = variantValueOf_ + genericRelatedValue = relatedValue2 + genericPossibleRelatedValue = possibleRelatedValue2 + children r = r # L0.ConsistsOf parent r = singleObject r L0.PartOf possibleParent r = possibleObject r L0.PartOf @@ -198,6 +230,8 @@ importJava "org.simantics.db.WriteGraph" where newResource :: () -> Resource "Adds a statement to the semantic graph." claim :: Resource -> Resource -> Resource -> () + @JavaName claim + claimWithInverse :: Resource -> Resource -> Maybe Resource -> Resource -> () @JavaName claimLiteral claimRelatedValue_ :: Resource -> Resource -> a -> Binding a -> () @JavaName claimLiteral @@ -256,6 +290,25 @@ importJava "org.simantics.db.common.utils.OrderedSetUtils" where importJava "org.simantics.db.common.utils.ListUtils" where @JavaName toList elementsOfList :: Resource -> [Resource] + + @JavaName create + createList :: [Resource] -> Resource + + @JavaName create + createListWithType :: Resource -> [Resource] -> Resource + + @javaName insertBack + insertBack :: Resource -> [Resource] -> () + + @javaName removeElement + removeElement :: Resource -> Resource -> Boolean + + @javaName swapWithPrevious + swapWithPrevious :: Resource -> Resource -> Boolean + + @javaName swapWithNext + swapWithNext :: Resource -> Resource -> Boolean + importJava "org.simantics.db.common.utils.CommonDBUtils" where isParent :: Resource -> Resource -> Boolean @@ -289,8 +342,8 @@ importJava "org.simantics.scl.db.SCLFunctions" where "Begins a write transaction and immediately returns." asyncWrite :: (() -> a) -> () - virtualSyncWriteMem :: String -> (() -> a) -> a - virtualSyncWriteWS :: String -> (() -> a) -> a + virtualSyncWriteMem :: String -> (() -> a) -> a + virtualSyncWriteWS :: String -> (() -> a) -> a safeExec :: (() -> a) -> a activateOnce :: Resource -> () @@ -302,6 +355,15 @@ importJava "org.simantics.scl.db.SCLFunctions" where unaryQuery :: (a -> b) -> a -> b unaryQueryCached :: (a -> b) -> a -> b + "Makes a new read request with given procedure for calculating the result. The request is cached only if the current request is listened." + subquery :: ( a) -> a + "Makes a new read request with given procedure for calculating the result. The request is always cached." + subqueryC :: ( a) -> a + "Makes a new read asynchronous request with function to handle the request result. The last `isDisposed` function parameter is used to determine if the listener is still alive or not." + subqueryL :: ( a) -> (a -> ()) -> (Throwable -> ()) -> ( Boolean) -> () + "Tries to convert the given Dynamic value to a value with the inferred type" + possibleFromDynamic :: Typeable a => String -> Dynamic -> Maybe a + importJava "org.simantics.db.layer0.util.Layer0Utils" where undo :: () -> String undoOperations :: Integer -> String @@ -314,12 +376,18 @@ importJava "org.simantics.db.layer0.util.Layer0Utils" where listOntologies :: () -> [Resource] emptyTrashBin :: () -> () purgeDatabase :: () -> () + prettyPrintResource :: Resource -> Boolean -> String @private @JavaName copyTo copyTo_ :: Resource -> Resource -> Collection Resource @JavaName getPossiblePredicateByName possiblePredicateByName :: Resource -> String -> Maybe Resource + @JavaName getPossiblePredicateByNameFromType + possiblePredicateByNameFromType :: Resource -> String -> Maybe Resource + + addMetadataListener :: ChangeListener -> () + removeMetadataListener :: ChangeListener -> () copyTo :: Resource -> Resource -> Resource copyTo targetContainer source = do @@ -392,6 +460,10 @@ currentModel = match activeModel (currentProject ()) with Just model -> model Nothing -> fail "No active model." +"Gives the current active model if it exists or Nothing otherwise." +possibleCurrentModel :: Maybe Resource +possibleCurrentModel = activeModel (currentProject ()) + startUndoPoint :: String -> () startUndoPoint string = do markUndoPoint () @@ -445,3 +517,12 @@ possibleChildWithPath parent path = Nothing -> Nothing ) (Just parent) path + +importJava "org.simantics.db.MetadataI" where + data MetadataI + +importJava "org.simantics.db.event.ChangeListener" where + data ChangeListener + +importJava "org.simantics.db.layer0.genericrelation.DependencyChanges" where + data DependencyChanges