|
|
|
Re: Capella code generation [message #1827915 is a reply to message #1827851] |
Tue, 26 May 2020 19:14 |
Philippe Dul Messages: 25 Registered: November 2013 |
Junior Member |
|
|
Navas Juan wrote on Mon, 25 May 2020 16:18Hello 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 |
Aditya B 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 #1827979 is a reply to message #1827923] |
Thu, 28 May 2020 07:46 |
Navas Juan 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 #1859514 is a reply to message #1827822] |
Tue, 13 June 2023 07:59 |
Eclipse User |
|
|
|
Aditya B wrote on Mon, 25 May 2020 07:11My 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
|
|
|
Powered by
FUDForum. Page generated in 0.03894 seconds