Hello,
I am trying to reproduce the eContainer(eClass) in Python4Capella.
This helps to obtain the eContainer element when you don’t know priori where the targeted class is located.
It can be used to find the Logical Architeture in top of a vert low level sub logical component. Or to find the Capella Module of a Capella Requirement. etc.
Let’s say my tree is like this:
I want to obtain the Capella Module, starting from the REQ (which text is “Any Random…”).
Let’s say our REQ variable is A:
print(A.eContainer())
→
org.polarsys.kitalpha.vp.requirements.Requirements.impl.FolderImpl@5a215b15 (id: 8a40b2b2-9aae-427b-a26f-f60a3304cc35) (ReqIFIdentifier: null, ReqIFDescription: null, ReqIFLongName: null) (ReqIFName: Folder, ReqIFPrefix: null, ReqIFChapterName: null, ReqIFForeignID: null, ReqIFText: null, requirementTypeProxy: null)
Now let’s say we don’t know where is the Capella Module is located, we can’t use a double “eContainer()”.
What is obvious would be to try the following:
A.eContainer(Requirements::Module)
A.eContainer("Requirements::Module")
A.eContainer(variableContainingCapellaModule*)
(*) = org.eclipse.emf.ecore.impl.EClassImpl@5a9bb7dd (name: CapellaModule) (instanceClassName: null) (abstract: false, interface: false)
A.eContainer(variableContainingCapellaModule_Eclass
**)
(*2) = org.polarsys.capella.vp.requirements.CapellaRequirements.impl.CapellaModuleImpl@48acdfe0 (id: 14187bb6-a635-4a3c-9d6e-371b45254adc) (ReqIFIdentifier: null, ReqIFDescription: null, ReqIFLongName: null) (ReqIFName: null, ReqIFPrefix: null)
As you might expect, this failed.
How could we tackle this? There must be a way to reproduce the “eContainer(eClass)” other than iterating multiple "eContainer()"s and checking their eClass name, what do you think?
Thanks a lot.
Best regards,
KaBe