Model manipulation describes how REST API can be used to manipulate data in Teamwork Cloud at the Eclipse modeling framework (EMF) level. However, using the API at the EMF level may become difficult when working with larger projects and more complex compositioncompositions.
Therefore, to facilitate most common model manipulation tasks, TWC REST API has MagicDraw-specific extensions that help minimize the amount number of calls necessary to find primary MagicDraw UML model within project decomposition.
Inspecting model decomposition
Normally, MagicDraw has different kinds of models within TWC resources. The term “models” here refers to the data structure required to store MagicDraw-specific project information that the tool needs when loading up projects on the client side. Currently, TWC REST API exposes two kinds of such models – decomposition and umlUML, as shown in the code below. You can retrieve a list of available models within the master branch and chosen resource revision by issuing GET to /resources/{resourceId}/revisions/{revision}/models.
You can further inspect the content of each of the models by issuing GET to /resources/{resourceId}/revisions/{revision}/models/{modelId}, where modelId is decomposition or uml respectively.
Decomposition model
This model lists all of the Used Project hierarchy within the chosen resource. The excerpt of the results after calling /resources/{resourceId}/revisions/{revision}/models/decomposition is shown below.
The main root project which the call is executed against has a type of models:PrimaryProject. You can find all of its directly used projects within the models:uses array. Since the decomposition model covers the full hierarchy, it includes both locally used projects (usually concerning Standard/System profiles) and server projects.
Each of the directly used projects has a type of models:UsedProject that has its own decomposition, hence enabling the full breakdown of usage structure from the primary project perspective covering both, directly and indirectly, used projects.
Note
title
Note
The id attribute refers to the project ID of esiproject:EsiProject type, not the UML model root element.
UML model
Different from the decomposition model previously described, umlthe UMLmodel provides a flat view of the structure of the target model. Note that the term project should not be confused with the term UML model here. The purpose of umlthe UMLmodel is to expose direct links to root elements of UML models in primary projects, and both of its, directly and indirectly, used projects.
The excerpt of the results after calling /resources/{resourceId}/revisions/{revision}/models/uml is shown below.
The models:PrimaryModel type object provides a direct link to the main project’s UML model root element via the models:root attribute. Compared to the EMF-based approach described in Model manipulation, using the above REST API extension is a matter of a single call and requires only the resource ID and revision number to be known in advance.