]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/scl/Simantics/Model.scl
Fixed Simantics/Diagram/setElements to resolve attachment relations
[simantics/platform.git] / bundles / org.simantics.modeling / scl / Simantics / Model.scl
1 include "Simantics/Entity" hiding (nameOf)
2 include "Simantics/Ontologies"
3 import "Simantics/Misc"
4
5 type Model = Resource
6 type Configuration = Resource
7
8 """
9     model name
10     
11 Returns an existing model in the current project with the given `name`
12 """
13 model :: String -> <ReadGraph> Model
14 model name = match possibleResourceChild (currentProject ()) name with
15     Just m -> m
16     Nothing -> fail $ "Didn't find a model " + name + "." 
17
18 """
19     configurationOf model
20     
21 Returns the configuration of the given `model`
22 and returns the `configuration` resource
23 """
24 configurationOf :: Model -> <ReadGraph> Configuration
25 configurationOf m = singleObject m SIMU.HasConfiguration
26
27 """
28 Returns the list of all models in the current project.
29 """
30 allModels :: () -> <ReadGraph> [Model]
31 allModels _ = objectsWithType (currentProject ()) L0.ConsistsOf SIMU.Model
32
33 importJava "org.simantics.modeling.ModelingUtils" where
34     """Removes the index associated with the model."""
35     removeIndex :: Model -> <WriteGraph> ()
36     
37     resetIssueSources :: Model -> <WriteGraph> ()
38     
39     """Copies annotation types from one model to another."""
40     copyAnnotationTypes :: Model -> Model -> <WriteGraph> ()
41     
42     deleteIndex :: Resource -> <WriteGraph> ()
43     releaseMemory :: () -> <WriteGraph> ()
44     
45     searchByType :: Resource -> Resource -> <ReadGraph> [Resource]
46     searchByTypeShallow :: Resource -> Resource -> <ReadGraph> [Resource]
47     searchByTypeAndName :: Resource -> Resource -> String -> <ReadGraph> [Resource]
48     searchByTypeAndNameShallow :: Resource -> Resource -> String -> <ReadGraph> [Resource]
49     searchByQuery :: Resource -> String -> <ReadGraph> [Resource]
50     searchByQueryShallow :: Resource -> String -> <ReadGraph> [Resource]
51     searchByTypeAndFilter :: Resource -> Resource -> (Resource -> <ReadGraph> Boolean) -> <ReadGraph> [Resource]
52     
53     listIndexEntries :: Resource -> String -> <ReadGraph> String
54
55     """
56     Activates the specified model but does not wait for any of the effects
57     caused by the activation to be completed. In most cases the blocking
58     version [syncActivateModel](#syncActivateModel) should be used instead
59     of this function.
60     """
61     activateModel :: Resource -> <WriteGraph> Boolean
62     
63     @JavaName createModel
64     createGenericModel :: Resource -> String -> <WriteGraph> Resource
65
66 importJava "org.simantics.modeling.ModelingUtils" where
67     @JavaName getPossibleModel
68     getPossibleModel :: Resource -> <ReadGraph> Model
69     possibleIndexRoot :: Resource -> <ReadGraph> Maybe Resource
70
71 activateModelAction :: Resource -> <Proc> ()
72 activateModelAction model = do
73   syncWrite (\() -> activateModel model)
74   ()
75
76 """
77 Activates the specified model and blocks until all effects caused by the
78 activation have been completed. This function is a synchronous version of
79 the older [activateModel](#activateModel) function that does not wait for
80 activation completion, i.e. works asynchronously. In most cases it is
81 recommended to use this functions instead of 
82
83 The effect completion waiting works based on the `org.simantics.db.service.ServiceActivityMonitor`
84 service offered by the database client. Therefore implementation that want
85 to support waiting for activation completion need to register/unregister
86 activities with this service accordingly.
87 """
88 syncActivateModel :: Resource -> <Proc> Boolean
89 syncActivateModel model = do
90     result = syncWrite (\() -> activateModel model)
91     syncGraph ()
92     result