]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/scl/Simantics/Model.scl
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.modeling / scl / Simantics / Model.scl
1 include "Simantics/Entity" hiding (nameOf)\r
2 include "Simantics/Ontologies"\r
3 \r
4 type Model = Resource\r
5 type Configuration = Resource\r
6 \r
7 """\r
8     model name\r
9     \r
10 Returns an existing model in the current project with the given `name`\r
11 """\r
12 model :: String -> <ReadGraph> Model\r
13 model name = match possibleResourceChild (currentProject ()) name with\r
14     Just m -> fromResource m\r
15     Nothing -> fail $ "Didn't find a model " + name + "." \r
16 \r
17 """\r
18     configurationOf model\r
19     \r
20 Returns the configuration of the given `model`\r
21 and returns the `configuration` resource\r
22 """\r
23 configurationOf :: Model -> <ReadGraph> Configuration\r
24 configurationOf m = do\r
25     conf = singleObject (toResource m) SIMU.HasConfiguration \r
26     fromResource conf\r
27 \r
28 """\r
29 Returns the list of all models in the current project.\r
30 """\r
31 allModels :: () -> <ReadGraph> [Model]\r
32 allModels _ = map fromResource $ objectsWithType (currentProject ()) L0.ConsistsOf SIMU.Model\r
33 \r
34 importJava "org.simantics.modeling.ModelingUtils" where\r
35     """Removes the index associated with the model."""\r
36     removeIndex :: Model -> <WriteGraph> ()\r
37     \r
38     resetIssueSources :: Model -> <WriteGraph> ()\r
39     \r
40     """Copies annotation types from one model to another."""\r
41     copyAnnotationTypes :: Model -> Model -> <WriteGraph> ()\r
42     \r
43     deleteIndex :: Resource -> <WriteGraph> ()\r
44     releaseMemory :: () -> <WriteGraph> ()\r
45     \r
46     searchByType :: Resource -> Resource -> <ReadGraph> [Resource]\r
47     searchByTypeShallow :: Resource -> Resource -> <ReadGraph> [Resource]\r
48     searchByTypeAndName :: Resource -> Resource -> String -> <ReadGraph> [Resource]\r
49     searchByTypeAndNameShallow :: Resource -> Resource -> String -> <ReadGraph> [Resource]\r
50     searchByQuery :: Resource -> String -> <ReadGraph> [Resource]\r
51     searchByQueryShallow :: Resource -> String -> <ReadGraph> [Resource]\r
52     searchByTypeAndFilter :: Resource -> Resource -> (Resource -> <ReadGraph> Boolean) -> <ReadGraph> [Resource]\r
53     \r
54     listIndexEntries :: Resource -> String -> <ReadGraph> String\r
55     activateModel :: Resource -> <WriteGraph> Boolean\r
56     \r
57     @JavaName createModel\r
58     createGenericModel :: Resource -> String -> <WriteGraph> Resource\r
59 \r
60 importJava "org.simantics.modeling.ModelingUtils" where\r
61     @JavaName getPossibleModel\r
62     getPossibleModel :: Resource -> <ReadGraph> Model\r
63     possibleIndexRoot :: Resource -> <ReadGraph> Maybe Resource\r
64 \r
65 activateModelAction :: Resource -> <Proc> ()\r
66 activateModelAction model = do\r
67   syncWrite (\() -> activateModel model)\r
68   ()\r
69     \r
70