X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling%2Fscl%2FSimantics%2FQuery.scl;h=d2809ff65d51219dd8a15c4f1cb3ea1fd0347988;hp=16878f499cd661e011783dd59c384df29f600b2e;hb=refs%2Fchanges%2F38%2F238%2F2;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.modeling/scl/Simantics/Query.scl b/bundles/org.simantics.modeling/scl/Simantics/Query.scl index 16878f499..d2809ff65 100644 --- a/bundles/org.simantics.modeling/scl/Simantics/Query.scl +++ b/bundles/org.simantics.modeling/scl/Simantics/Query.scl @@ -1,64 +1,64 @@ -include "Simantics/DB" -include "Simantics/Ontologies" -include "Simantics/Variables" -include "Spreadsheet/All" - -createSCLQueryAction :: Resource -> () -createSCLQueryAction res = do - syncWrite (\() -> createSCLQueryDefault res) - () - -createSCLQueryTypeAction :: Resource -> () -createSCLQueryTypeAction res = do - syncWrite (\() -> createSCLQueryTypeDefault res) - () - -createSCLQueryDefault :: Resource -> Resource -> Resource -createSCLQueryDefault library queryType = createSCLQuery library queryType $ findFreshEscapedName "Query" library - -createSCLQuery :: Resource -> Resource -> String -> Resource -createSCLQuery library queryType name = do - markUndoPoint () - module = newResource () - claim module L0.InstanceOf queryType - claimRelatedValue module L0.HasName name - claim module L0.PartOf library - sheet = createSheet module "Sheet" - range = createRange sheet SHEET.ExpressionRange "Range1" "queryCells $ sheetQueryValue self input" - addCommentMetadata ("Created SCL Query " + name) - module - -createSCLQueryTypeDefault :: Resource -> Resource -createSCLQueryTypeDefault library = createSCLQueryType library $ findFreshEscapedName "QueryType" library - -createSCLQueryType :: Resource -> String -> Resource -createSCLQueryType library name = do - markUndoPoint () - queryType = newResource () - claim queryType L0.Inherits MOD.SCLQuery - claimRelatedValue queryType L0.HasName name - claimAssertion MOD.SCLQuery.values $ createSCLValueIndependent MOD.SCLQuery.Value "[]" - claim queryType L0.PartOf library - addCommentMetadata ("Created SCL Query Type " + name) - queryType - -queryValue :: Variable -> Variable -> a -queryValue variable input = do - untypedValue $ browse (makeProxyVariable variable input) "#values" - -sheetQueryVariable :: Variable -> Variable -> Variable -sheetQueryVariable self input = do - query = variableParent $ proxyVariableBase self - makeProxyVariable query input - -sheetQueryValue :: Variable -> Variable -> a -sheetQueryValue self input = do - var = sheetQueryVariable self input - untypedValue $ browse var "#values" - -importJava "org.simantics.db.layer0.variable.ProxyVariables" where - inputVariable :: Variable -> Variable - sessionVariable :: Variable -> Variable - proxyVariableBase :: Variable -> Variable - makeProxyVariable :: Variable -> Variable -> Variable +include "Simantics/DB" +include "Simantics/Ontologies" +include "Simantics/Variables" +include "Spreadsheet/All" + +createSCLQueryAction :: Resource -> () +createSCLQueryAction res = do + syncWrite (\() -> createSCLQueryDefault res) + () + +createSCLQueryTypeAction :: Resource -> () +createSCLQueryTypeAction res = do + syncWrite (\() -> createSCLQueryTypeDefault res) + () + +createSCLQueryDefault :: Resource -> Resource -> Resource +createSCLQueryDefault library queryType = createSCLQuery library queryType $ findFreshEscapedName "Query" library + +createSCLQuery :: Resource -> Resource -> String -> Resource +createSCLQuery library queryType name = do + markUndoPoint () + module = newResource () + claim module L0.InstanceOf queryType + claimRelatedValue module L0.HasName name + claim module L0.PartOf library + sheet = createSheet module "Sheet" + range = createRange sheet SHEET.ExpressionRange "Range1" "queryCells $ sheetQueryValue self input" + addCommentMetadata ("Created SCL Query " + name) + module + +createSCLQueryTypeDefault :: Resource -> Resource +createSCLQueryTypeDefault library = createSCLQueryType library $ findFreshEscapedName "QueryType" library + +createSCLQueryType :: Resource -> String -> Resource +createSCLQueryType library name = do + markUndoPoint () + queryType = newResource () + claim queryType L0.Inherits MOD.SCLQuery + claimRelatedValue queryType L0.HasName name + claimAssertion MOD.SCLQuery.values $ createSCLValueIndependent MOD.SCLQuery.Value "[]" + claim queryType L0.PartOf library + addCommentMetadata ("Created SCL Query Type " + name) + queryType + +queryValue :: Variable -> Variable -> a +queryValue variable input = do + untypedValue $ browse (makeProxyVariable variable input) "#values" + +sheetQueryVariable :: Variable -> Variable -> Variable +sheetQueryVariable self input = do + query = variableParent $ proxyVariableBase self + makeProxyVariable query input + +sheetQueryValue :: Variable -> Variable -> a +sheetQueryValue self input = do + var = sheetQueryVariable self input + untypedValue $ browse var "#values" + +importJava "org.simantics.db.layer0.variable.ProxyVariables" where + inputVariable :: Variable -> Variable + sessionVariable :: Variable -> Variable + proxyVariableBase :: Variable -> Variable + makeProxyVariable :: Variable -> Variable -> Variable \ No newline at end of file