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