Capella code generation

My primary question is how to generate code from a capella project?
But that can be broken down into -

  1. Can any of the project files be opened in some code editor where I can programmatically select data I need?
  2. Say I want to write a piece of code that scans the project and fetches the data I’m looking for (actor description for example), how and where do I begin?
  3. I’ve gone through
    this and
    this. Unfortunately, I wasn’t able to gather much information needed for me to begin my exploration. Most of the links used are pretty old and I’m unable to use them now.

Hello Adityia,
If you take a look at the .melodymodeller file, you will find all the semantic information in your model.
But even better, if you use the API, you can program yourself some Java code that will fetch the data in the model. Check:
-> Help
-> Capella Guide -> Developer Manual -> Reference -> Capella API
There are other solutions out there, I let other people complete mine.
Hope it helps.

Hello Adityia,
Capella Studio is dedicated to the development of Capella addons, viewpoints for instance but also code generation in your case. It could be the generator of your choice as long as you use the Capella API.
Benoît

Navas Juan wrote on Mon, 25 May 2020 16:18
Hello Adityia,
If you take a look at the .melodymodeller file, you will find all the semantic information in your model.
But even better, if you use the API, you can program yourself some Java code that will fetch the data in the model. Check:
-> Help
-> Capella Guide -> Developer Manual -> Reference -> Capella API
There are other solutions out there, I let other people complete mine.
Hope it helps.
Hi,
You can also follow tutorials available on Capella Github repository.
https://github.com/eclipse/capella/wiki#seedling-extends-capella

  • The first one will show you how to create an addon
  • The second and third, how you can add a menu into capella / edit / access to elements.
    For instance, you can add a menu on element of your model, retrieve all actors and extract their description of actors.
    API of capella is quite straighforward, to retrieve description, it will be getDescription on an element.
    Regards
1 Like

Hi Philippe,
Thank you for a detailed reply. I had indeed already gone through the github page but what I’d realized was that I still have some very basic doubts. For instance,
Most of the guides talk about using capella studio for development, but none of them talk about basic things like what project or configuration am I supposed to create or use.
This link, for example, talks about the technical stuff but I’m still clueless as to how to use them in actual practice.
While exploring, I created a plugin project with the hello world template. When I wanted to extend the functionality, I tried importing one of the capella API libraries. However, I was greeted with errors on trying to do that. The project contains “org.eclipse…” imports while the capella API has “org.polarsys…” library names, and my capella studio wasn’t able to import it. I wasn’t even able to find jar files of the libraries.
I apologize if I’m asking basic and silly doubts, but even with good coding experience, I’m having a very hard time trying to figure out the bits and pieces.

Hi Navas,
Thank you for a quick reply.
I have gone through all the replies here, but sadly I’m in no better condition than when I started. I’m having a hard time using the libraries that all capella studio guides and tutorials talk about.
If you don’t mind, could you explain more on how I can access the .melodymodeller file for the semantic information in the editor?

You can find the *.melodymodeller file in your workspace:
eclipse/workspace/projectName/projectName.melodymodeller
It is a quite rich XML-like file. I still believe that the best thing to do to generate code from the model is through the API. I hope other people will be able to help you on overcoming the difficulties you are experiencing.

Copyright © Eclipse Capella, the Eclipse Capella logo, Eclipse and the Eclipse logo are Trademarks of The Eclipse Foundation.