Skip to content

Metamodel

Philippe DUL edited this page May 5, 2023 · 16 revisions

Retrieve type of an element

When developping an addon, knowing by heart all metamodels is not relevant, and many of us doesn't know it either.

To manipulate or create an element with a simple API, you just need to know its type. It is often displayed on the top left of Property views when you click on an element.

With its type, for instance, a PhysicalFunction, you will be able to retrieve its sub functions ((PhysicalFunction)function).getOwnedFunctions().

To create a PhysicalFunction, you will need to know from which metamodel part it is defined. Using Open Type wizard with Ctrl+Shift+T and writing the type, you will find its metamodel.

For instance, with PhysicalFunction, you will see org.polarsys.capella.xxx.pa.PhysicalFunction, meaning it is coming from pa metamodel (Physical Architecture)

Using PaFactory, you will have access to PaFactory.eINSTANCE.createPhysicalFunction() allowing you to create a Physical Function.

To open Open Type wizard, you have to be in Capella Studio, Eclipse development platform or at least within Capella with Java features enabled (see Development Environment) (Make sure you have the view Package Explorer active and not the Project Explorer)

Don't forget to add some dependencies to your plugin, at least org.polarsys.capella.core.model.helpers org.polarsys.capella.core.model.handler will do the job.

Browse Metamodels

See Glossary section on the User Manual

Click onto the link belows to access to online documentation about detailled API concepts. (notice that some concepts on Metamodel are not tooled-up within Capella or can be deprecated)

(exemple: LogicalFunction - PhysicalComponent - Class - StateMachine)

Name Package prefix Java ePackage Java eFactory
Capella Modeller capellamodeller CapellamodellerPackage CapellamodellerFactory
Capella Core capellacore CapellacorePackage CapellacoreFactory
Capella Common capellacommon CapellacommonPackage CapellacommonFactory
Composite Structure cs CsPackage CsFactory
Operational Analysis oa OaPackage OaFactory
System Analysis ctx CtxPackage CtxFactory
Logical Architecture la LaPackage LaFactory
Physical Architecture pa PaPackage PaFactory
Deployment deployment DeploymentPackage DeploymentFactory
EPBS epbs EpbsPackage EpbsFactory
Functional Analysis fa FaPackage FaFactory
Shared Model sharedmodel SharedmodelPackage SharedmodelFactory
Requirement requirement RequirementPackage RequirementFactory
Interaction interaction InteractionPackage InteractionFactory
Information information InformationPackage InformationFactory
Communication communication CommunicationPackage CommunicationFactory
Data Type datatype DatatypePackage DatatypeFactory
Data Value datavalue DatavaluePackage DatavalueFactory
Modelling Core modellingcore ModellingcorePackage ModellingcoreFactory
Behavior behavior BehaviorPackage BehaviorFactory
Activity activity ActivityPackage ActivityFactory
Replicable Elements Re RePackage ReFactory
Libraries libraries LibrariesPackage LibrariesFactory

Additional information can be found here : dsd-dbs.github.io/how-to-explore-capella-mm

Metamodel are defined in ecore files located under plugins ending by *.gen

Model Analysis

Model Analysis documentation

One easiest way to retrieve references or attributes is to open the Properties View and go the Expert tab then choose relevant references/attributes for your query

You just have to write the reference name in a camelCaseFormat to use it with Aql (e.g. Available In States => availableInStates) or in some case with the corresponding getter function getAvailableInStates

Clone this wiki locally