Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Polarsys » Capella workbench » Capella code generation
Capella code generation [message #1827822] Mon, 25 May 2020 07:11 Go to next message
Aditya B is currently offline Aditya BFriend
Messages: 13
Registered: April 2020
Junior Member
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.
Re: Capella code generation [message #1827851 is a reply to message #1827822] Mon, 25 May 2020 16:18 Go to previous messageGo to next message
Navas Juan is currently offline Navas JuanFriend
Messages: 49
Registered: January 2020
Member
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.
Re: Capella code generation [message #1827873 is a reply to message #1827851] Tue, 26 May 2020 07:18 Go to previous messageGo to next message
Benoit Langlois is currently offline Benoit LangloisFriend
Messages: 18
Registered: July 2009
Junior Member
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
Re: Capella code generation [message #1827915 is a reply to message #1827851] Tue, 26 May 2020 19:14 Go to previous messageGo to next message
Philippe Dul is currently offline Philippe DulFriend
Messages: 25
Registered: November 2013
Junior Member
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.

Project project = ProjectExt.getProject(element);
for (EObject object : EObjectExt.getAll(project, CsPackage.Literals.COMPONENT)) {
      Component component = (Component) object;
      
      if (component.isActor()) {
        String description = component.getDescription();
        //Doing something with it.
      }
}


Regards
Re: Capella code generation [message #1827921 is a reply to message #1827915] Wed, 27 May 2020 05:36 Go to previous messageGo to next message
Aditya B is currently offline Aditya BFriend
Messages: 13
Registered: April 2020
Junior Member
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.

[Updated on: Wed, 27 May 2020 05:38]

Report message to a moderator

Re: Capella code generation [message #1827923 is a reply to message #1827851] Wed, 27 May 2020 05:44 Go to previous messageGo to next message
Aditya B is currently offline Aditya BFriend
Messages: 13
Registered: April 2020
Junior Member
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?
Re: Capella code generation [message #1827979 is a reply to message #1827923] Thu, 28 May 2020 07:46 Go to previous messageGo to next message
Navas Juan is currently offline Navas JuanFriend
Messages: 49
Registered: January 2020
Member
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.

[Updated on: Thu, 28 May 2020 07:46]

Report message to a moderator

Re: Capella code generation [message #1840485 is a reply to message #1827979] Fri, 16 April 2021 08:57 Go to previous messageGo to next message
ka be is currently offline ka beFriend
Messages: 3
Registered: April 2021
Junior Member
Navas Juan wrote on Thu, 28 May 2020 07:46
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.


Hello,
I am still new with Capella, i did not find the ".melodymodeller" and i need it. Where can it be found?
Re: Capella code generation [message #1843870 is a reply to message #1827851] Sun, 22 August 2021 18:13 Go to previous messageGo to next message
rus lan is currently offline rus lanFriend
Messages: 1
Registered: August 2021
Junior Member
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.


can you pls explain it in more detail how to get access to the capella API? Im using the 5.1.0 version and i get only to:
Help -> Help Contents -> Capella Guide -> Developer Manual -> and then there is no "Reference"
Re: Capella code generation [message #1859514 is a reply to message #1827822] Tue, 13 June 2023 07:59 Go to previous message
Eclipse UserFriend
Aditya B wrote on Mon, 25 May 2020 07:11
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 to mass unfollow on instagram), 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.

Generating code from a Capella project typically involves leveraging the Capella APIs and integrating them into your own code. Here's a general overview of the process:

Accessing project files: Capella projects are typically stored in a .aird format, which is an Eclipse-specific file format. To programmatically access the project data, you'll need to work with the Eclipse Modeling Framework (EMF) APIs. These APIs allow you to load and interact with the project files, accessing the underlying model elements.

Using code editors: Capella projects are primarily designed to be managed and edited within the Capella modeling environment. While it is possible to programmatically open and modify the project files using Eclipse APIs, it's generally not recommended to directly edit the project files outside of the Capella environment. Instead, it's better to utilize the Capella APIs to navigate and extract the desired data.

Getting started with Capella APIs: The official Capella documentation and forums are good starting points for understanding and exploring the available APIs. It's important to refer to the version-specific documentation to ensure compatibility. You can access the Capella API through plugins provided by the Capella installation.

Navigating the Capella model: To fetch specific data from a Capella project, you need to understand the underlying metamodel structure and how the different model elements are organized. The Capella API provides classes and methods to navigate the model elements and extract the desired information. This involves using concepts like EClasses, EObjects, and features to traverse the model hierarchy and access the desired properties.

Developing custom code: Once you have a good understanding of the Capella API and the structure of the project model, you can start developing your custom code to scan the project and fetch the required data. This involves writing code in a programming language that is compatible with the Eclipse and EMF frameworks, such as Java.

While outdated resources may still provide some general guidance, it's best to refer to the latest official Capella documentation and community resources for up-to-date information and examples specific to your version of Capella.

Remember that Capella is a complex tool, and working with its APIs requires a solid understanding of the underlying metamodel and Eclipse/EMF frameworks. It may be beneficial to collaborate with experienced Capella developers or seek assistance from the Capella community or forums for more specific guidance and support.

[Updated on: Tue, 13 June 2023 08:01] by Moderator

Report message to a moderator

Previous Topic:Can't find the "melodymodeller" file?
Next Topic:PVMT and Sub-System Transition
Goto Forum:
  


Current Time: Tue Apr 23 14:21:13 GMT 2024

Powered by FUDForum. Page generated in 0.03894 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top