]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.db/scl/Simantics/Variables.scl
VariableOrResource SCL type
[simantics/platform.git] / bundles / org.simantics.scl.db / scl / Simantics / Variables.scl
index 721d52b15696fe5748947daeec249671006c586c..47bf1a944cb92cdf824cce774e4fc6b385791f17 100644 (file)
@@ -1,3 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2019 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
 include "Simantics/Model"
 include "Simantics/DB"
 import "Simantics/DB" as DB
@@ -21,6 +32,12 @@ Example:
     """
     variable :: String -> <ReadGraph> Variable
     
+    @JavaName getPossibleVariable
+    possibleResourceVariable :: Resource -> <ReadGraph> Maybe Variable
+
+    @JavaName getPossibleVariable
+    possibleVariable :: String -> <ReadGraph> Maybe Variable
+
     @JavaName getVariable
     """
 Function **resourceVariable** converts a resource to a corresponding variable.
@@ -73,6 +90,11 @@ Example:
     instanceIndexRoot :: Variable -> <ReadGraph> Resource
     
     createValueAccessor :: (Variable -> <ReadGraph> a) -> (Variable -> Binding b -> <ReadGraph> b) -> (Variable -> c -> <WriteGraph> ()) -> (Variable -> d -> Binding d -> <WriteGraph> ()) -> (Variable -> <ReadGraph> Datatype) -> ValueAccessor
+
+    @JavaName getConfigurationContext
+    possibleConfigurationContext :: Resource -> <ReadGraph> Variable
+
+    setRVIProperty :: Variable -> RVI -> <WriteGraph> ()
     
 importJava "org.simantics.db.layer0.function.All" where
 
@@ -85,11 +107,21 @@ importJava "org.simantics.db.layer0.function.All" where
 importJava "org.simantics.db.layer0.variable.VariableMap" where
     data VariableMap
 
+importJava "org.simantics.db.layer0.variable.StructuredProperty" where
+    data StructuredProperty
+
+importJava "org.simantics.db.layer0.variable.ResourceCollectionVariableMap" where
+    @JavaName "<init>"
+    createVariableMap :: [Resource] -> VariableMap
+
 importJava "org.simantics.db.layer0.variable.ValueAccessor" where
     data ValueAccessor
 
 importJava "org.simantics.db.layer0.variable.Variable" where
     data Variable
+
+    @JavaName getRVI
+    rviOf :: Variable -> <ReadGraph> RVI
     
     @JavaName getProperties
     properties_ :: Variable -> <ReadGraph> Collection Variable
@@ -390,6 +422,7 @@ instance Show Variable where
 instance Browsable Variable where
     fromUri = variable
     uriOf = uri
+    possibleUriOf v = Just (uri v)
     nameOf = name
     possibleNameOf v = Just (name v)
     children v = collectionToList (children_ v)
@@ -399,7 +432,31 @@ instance Browsable Variable where
     variantValueOf v = createVariant (datatype v) (untypedValue v :: Dynamic)
     child = child_
     possibleChild = possibleChild_
+    
+    genericRelatedValue v rel = untypedPropertyValue v (nameOf rel)
+    genericPossibleRelatedValue v rel = untypedPossiblePropertyValue v (nameOf rel)
 
 propertiesClassified :: Variable -> Resource -> <ReadGraph> [Variable]
 propertiesClassified parent classified = do
-    collectionToList $ propertiesClassified_ parent classified
\ No newline at end of file
+    collectionToList $ propertiesClassified_ parent classified
+
+importJava "org.simantics.db.layer0.variable.RVI" where
+    data RVI
+    
+    resolvePossible :: RVI -> Variable -> <ReadGraph> Maybe Variable
+
+instantiateUnder :: Resource -> Resource -> <WriteGraph> Resource
+instantiateUnder container typeToInstantiate = do
+    fn = (resourceVariable typeToInstantiate)#methods#instantiateUnder :: Resource -> Resource -> <WriteGraph> Resource  
+    fn container typeToInstantiate
+
+@JavaType "org.simantics.db.layer0.variable.VariableOrResource"
+data VariableOrResource =
+    @JavaType "org.simantics.db.layer0.variable.ResourceX"
+    @FieldNames [value]
+    ResourceX Resource
+  | @JavaType "org.simantics.db.layer0.variable.VariableX"
+    @FieldNames [value]
+    VariableX Variable
+    
+    
\ No newline at end of file