Modelio MDA API¶
The Modelio API is the API that Modelio is providing to the developers of modules.
Modelio API is structured into several services specific to a particular aspect of Module development. In practical terms, these services are not strictly independent. For example, you will need to use model services to access to some model elements required by model components services.
The Modelio API is currently delivered as a unique jar file (modelio.jar) that you must use in your development projects.
The Modelio API services are:
- Model services
- access and explore the currently opened model
- create/modify/delete model elements
- react to model changes (model listener)
- Diagram services
- get a handle on a diagram
- read/create/delete/modify a diagram contents
- Model components services
- deploy a model components
- package a model component
- Module services
- manage the project modules
- call a module’s peer services
- Navigation services
- fire and listen to navigation events
- Picking services
- be a picking provider
- use picking
- Transaction api
- using the transaction API
- Audit services
- check a model element
- Log services
- log a message
- Image services
- get a model element’s image
- Script services
- get a Python interpreter to execute a Python script
- Edition services
- open a text editor
- Context services
- get the workspace
- get I18n and versionning data
- Metamodel services
- get a metaclass by name
- get a metaclass name
- FAQ
Accessing the Modelio API services¶
The unique access point to these services is provided by the Modelio
singleton which acts as a ‘handle’ to the whole Modelio application.
For each service, Modelio can provide an object that provides the concrete service API as a bunch of specific methods.
In the following code fragment, Modelio is used to apply an audit check to the root package of the model.
1 // Get the model services: the modeling session
2 IModelingSession session = Modelio.getInstance().getModelingSession();
3
4 // Get the Modelio audit service
5 IAuditService audit = Modelio.getInstance().getAuditService();
6
7 // Get all work models roots
8 for (MObject rootObj : session.getModel().getModelRoots() ) {
9 // Look for a Project instance
10 if (rootObj instanceof Project) {
11 // Get the model root package
12 Package root = ((Project) rootObj).getModel();
13
14 // And now ask for an audit on the root package
15 audit.check(root);
16 }
17 }