|How to derive a collection of objects [message #1758975]
||Tue, 04 April 2017 22:10
| Cristina Vicente-Chicote
Registered: April 2017
I am completly stucked trying to derive a collection from another collection. Let me summarize the problem:
- I have a Repository containing component definitions (ComponentDef). Each component definition has: (1) a name; and (2) a set of Ports. Ports only have a name.
- I want to reuse these components in different systems. Thus, I model my System as a set of components (Component). Similar to component definitions, Each Component has: (1) a name, and (2) a set of ports, but they also contain (3) a reference to one of the component definitions stored in the the Respository.
- I want to initialize each system component deriving its name and ports from the name and ports of its definition , i.e., as soon as I set the definition to a ComponentDef, I want its name and ports to be automatically obtained from the corresponding ComponentDef.
- Deriving the name of the component is trivial. However, deriving the list of ports seems absolutely impossible to me. I have managed to get the first port of the component definition (I attach the .ecore file => see the derive_ports() operation). However, I do not know how to derive the whole list of ports. In fact, I have not been able to check if the definition is empty and, in case it is not, if it contains ports or not to safely access them, i.e., to avoid runtime exceptions. As soon as I modify the body of the operation trying to check these conditions, I get an error.
Any help will be very wellcome!
Thanks in advance,
BTW: I am using Eclipse Oxygen with EMF 2.13.0 and OCL 6.3.0
Powered by FUDForum
. Page generated in 0.01670 seconds