Generate code from CapellaModeller.genmodel

Hello to everyone, I don’t know if it is the place to ask about this, it is my first time commenting in this kind of forums. For an university project I did some modifications in the CapellaModeller.ecore that I want to use in a new Sirius viewpoint but when I generate the .genmodel and then I try to generate de Model, Edit and Editor code, the code generated is wrong, some methods are not in the files, for example in PaFactory.java is not the method PhysicalFunction createPhisicalFunction(String name_p). I read that this method comes from a customization of the standard EMF generator. How can I generate the Model, Edit and Editor code in a proper way?

Capella uses a tool named EGF to generate the model code. You need Capella Studio, then you can try to perform the steps described here:
https://wiki.polarsys.org/Capella/Technical_Information#Gene rating_the_Metamodel

I believe there are a few online videos explaining how Capella Studio works.
However, I would suggest to extend the ecore model of Capella, not change it. Or at least, expect severe trouble with the Capella current tooling if you change the metamodel.

I was trying to follow the steps in
https://wiki.polarsys.org/Capella/Technical_Information#Gene rating_the_Metamodel . What I did is to download and run capella studio, then I imported all the projects, including all releng project, *gen, *.gen.edit from core and common plugins, and m2 folder. I did some modifications in the .ecore inside the data.def but when I want to run the EGF Activity in org.polarsys.capella.common.extension.migration.egf I can´t do it, my Capella Studio doesn’t have anything at the run menu. How can I run the EGF Activities?

Hi,
To run EGF activities:

  • Open the EGF file located into the egf folder of the plugin ‘org.polarsys.capella.common.extension.migration.egf’ (double click)
  • On the root element called ‘G3&G4’, right clik on it, then Run EGF Activity.
    It
    shall work but errors on generation of capella metamodel are not always (never) helpful to understand what is wrong.
    If it not working on the first time:
  • you may have to restart the Capella Studio
  • you may have to import into your workspace plugins called ‘org.polarsys.kitalpha.emde.model’ ‘org.polarsys.kitalpha.emde’. (Import / Plugin Developement / Plugin and fragment / Next / Select both plugin)
  • EGF generation will not complete if you have compilation issues in your workspace (even on the generated code), so sometimes, you have to cleanup manually generated code to have a complete generation
  • If you have another eclipse/capella opening the same java projects, you will have to disable the automatic compilation in the other running eclipse
    Best regards,
    Philippe
1 Like

Thank you for your answer. I run the EGF Activities without errors by importing ‘org.polarsys.kitalpha.emde.model’ ‘org.polarsys.kitalpha.emde’. The problem now is that the generated code has errors at the .util package. The errors are at xxSwitch.java when calling these two methods:
if (result == null) result = caseExtensibleElement(abstractCapabilityPkg);
if (result == null) result = caseElement(abstractCapabilityPkg);
I am running the tasks without changing any metamodel definition.
When I tried to run the rcp I get an error “The import org.polarsys.kitalpha.emde.model.EmdePackage collides with another import statement”. I tried by deleting the imported packages ‘org.polarsys.kitalpha.emde.model’ ‘org.polarsys.kitalpha.emde’.
Thank you in advance!

I reinstall everything, to do a second try. I did a modification in the FunctionalAnalysis.ecore by adding a new FunctionKind. When I run G3&G4 everything is ok, but when running the Capella Generation Launcher I got and error:
InvocationException
org.eclipse.egf.model.pattern.PatternRuntimeException: org.eclipse.egf.model.pattern.PatternException: org.eclipse.egf.model.pattern.PatternRuntimeException: org.eclipse.egf.model.pattern.PatternException: org.eclipse.emf.common.util.WrappedException: java.io.IOException: Resource ‘/org.polarsys.capella.common.data.core.gen/generated/org/po larsys/capella/common/data/modellingcore’ does not exist.

Hi,
Do you have this plugin in your workspace?
I think you shall import all .gen and .gen.edit plugins, from core and common plugins
/common/plugins and
/core/plugins.
Regards

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