2 include "Simantics/Ontologies"
3 include "Simantics/Variables"
4 include "Spreadsheet/All"
6 createSCLQueryAction :: Resource -> <Proc> ()
7 createSCLQueryAction res = do
8 syncWrite (\() -> createSCLQueryDefault res)
11 createSCLQueryTypeAction :: Resource -> <Proc> ()
12 createSCLQueryTypeAction res = do
13 syncWrite (\() -> createSCLQueryTypeDefault res)
16 createSCLQueryDefault :: Resource -> Resource -> <WriteGraph> Resource
17 createSCLQueryDefault library queryType = createSCLQuery library queryType $ findFreshEscapedName "Query" library
19 createSCLQuery :: Resource -> Resource -> String -> <WriteGraph> Resource
20 createSCLQuery library queryType name = do
22 module = newResource ()
23 claim module L0.InstanceOf queryType
24 claimRelatedValue module L0.HasName name
25 claim module L0.PartOf library
26 sheet = createSheet module "Sheet"
27 range = createRange sheet SHEET.ExpressionRange "Range1" "queryCells $ sheetQueryValue self input"
28 addCommentMetadata ("Created SCL Query " + name)
31 createSCLQueryTypeDefault :: Resource -> <WriteGraph> Resource
32 createSCLQueryTypeDefault library = createSCLQueryType library $ findFreshEscapedName "QueryType" library
34 createSCLQueryType :: Resource -> String -> <WriteGraph> Resource
35 createSCLQueryType library name = do
37 queryType = newResource ()
38 claim queryType L0.Inherits MOD.SCLQuery
39 claimRelatedValue queryType L0.HasName name
40 claimAssertion queryType MOD.SCLQuery.values $ createSCLValueIndependent MOD.SCLQuery.Value "[]"
41 claim queryType L0.PartOf library
42 addCommentMetadata ("Created SCL Query Type " + name)
45 queryValue :: Variable -> Variable -> <ReadGraph> a
46 queryValue variable input = do
47 untypedValue $ browse (makeProxyVariable variable input) "#values"
49 sheetQueryVariable :: Variable -> Variable -> <ReadGraph> Variable
50 sheetQueryVariable self input = do
51 query = variableParent $ proxyVariableBase self
52 makeProxyVariable query input
54 sheetQueryValue :: Variable -> Variable -> <ReadGraph> a
55 sheetQueryValue self input = do
56 var = sheetQueryVariable self input
57 untypedValue $ browse var "#values"
59 importJava "org.simantics.db.layer0.variable.ProxyVariables" where
60 inputVariable :: Variable -> <ReadGraph> Variable
61 sessionVariable :: Variable -> <ReadGraph> Variable
62 proxyVariableBase :: Variable -> <ReadGraph> Variable
63 makeProxyVariable :: Variable -> Variable -> <ReadGraph> Variable