You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/global/modules/core/pages/howto/mps-model-server-plugin.adoc
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,6 @@
3
3
4
4
5
5
You can run a *light version* of the `model-server` directly in MPS via the dedicated *MPS as Modelix Model Server Plugin*, which is published over at the https://plugins.jetbrains.com/plugin/22834-mps-as-modelix-model-server[JetBrains Marketplace^].
6
-
It always supports the latest MPS versions.
7
6
8
7
NOTE: More information on the component in general can be found in the xref:core:reference/component-mps-model-server-plugin.adoc[corresponding component reference].
Copy file name to clipboardExpand all lines: docs/global/modules/core/pages/howto/usage-model-client-v2.adoc
+29-15Lines changed: 29 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,37 +55,51 @@ We can consequently assume that its data is always correct and up-to-date.
55
55
56
56
[source, kotlin]
57
57
--
58
+
// create a new repository
58
59
val myRepoId: RepositoryId = RepositoryId("myRepository")
59
-
modelClientV2.initRepository(myRepoId)
60
+
client.initRepository(myRepoId)
60
61
62
+
// obtain the main branch created by default
61
63
val myBranchReference: BranchReference = BranchReference(repositoryId = myRepoId, branchName = RepositoryId.DEFAULT_BRANCH)
62
-
val replicatedModel: ReplicatedModel = modelClientV2.getReplicatedModel(myBranchReference)
64
+
65
+
// replicate the branch content
66
+
val replicatedModel: ReplicatedModel = client.getReplicatedModel(myBranchReference)
67
+
// start the continuous replication
63
68
replicatedModel.start()
64
69
--
65
70
66
71
To ensure that read and write are executed correctly, we need to use read and write transactions whenever we interact with the content, e.g. by adding a new child:
67
72
68
73
[source, kotlin]
69
74
--
70
-
var rootNode: INode? = null
71
-
// we need to start a read transaction to obtain model content
println("All nodes in repository: ${(rootNode?.getDescendants(true)?.toMutableList().map { (it as PNodeAdapter).nodeId.toString() })}")
84
+
// to get model content we need a read transaction
85
+
replicatedModel.getBranch().runRead {
86
+
println("All nodes in repository: ${(rootNode.getDescendants(true).toMutableList())}")
86
87
}
87
88
--
88
89
90
+
Which will yield the following output:
91
+
92
+
[source]
93
+
--
94
+
Added node PNode2100000001 under parent PNode1
95
+
All nodes in repository: [PNode1, PNode2100000001]
96
+
--
97
+
89
98
CAUTION: If you try to access a node that does not exist, an exception is thrown.
90
99
100
+
Browsing to the `model-sever` content explorer over at http://localhost:28101/repos[] and selecting _Explore Latest Version_ for _myRepository_ you should see this:
101
+
102
+
image::model-client-v2-sample.png[Result in `model-server` of the above code]
103
+
104
+
91
105
For more information how to deal with `INodes` and the `client`, check the https://api.modelix.org/latest/model-api/index.html[model API] and the https://api.modelix.org/latest/model-client/org.modelix.model.client2/-model-client-v2/index.html[ModelClientV2 API] respectively.
0 commit comments