Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » How to derive a collection of objects(How to derive a collection of objects)
How to derive a collection of objects [message #1758975] Tue, 04 April 2017 22:10 Go to next message
Cristina Vicente-Chicote is currently offline Cristina Vicente-ChicoteFriend
Messages: 5
Registered: April 2017
Junior Member
Dear all,

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,
Christina

BTW: I am using Eclipse Oxygen with EMF 2.13.0 and OCL 6.3.0
Re: How to derive a collection of objects [message #1759055 is a reply to message #1758975] Wed, 05 April 2017 15:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5929
Registered: July 2009
Senior Member
Hi

A quick glance shows that ports has a 0..1 multiplicity. Perhaps that's your problem

Regards

Ed Willink
Re: How to derive a collection of objects [message #1759078 is a reply to message #1759055] Wed, 05 April 2017 17:36 Go to previous message
Cristina Vicente-Chicote is currently offline Cristina Vicente-ChicoteFriend
Messages: 5
Registered: April 2017
Junior Member
Dear Ed,

Thank you for your prompt answer. You are right; I modified the multiplicity of "ports" to try something, and then forgot to change it back again. The correct cardinality is 1..*

Anyway, the problem is not the cardinality, but the lack of an operation that allows me to iterate on the ports of the ComponentDefinition and, for each of these ports, to create a copy and to insert the copy in the list of ports of the Component. Maybe the operation/iterator exists but I do not know it, or I do not know how to use it for this purpose :-S.

All I managed to do in the example I sent yesterday was to initialize the ports of a Component with the first port of its ComponentDefinition. How can I add all the others?

I would really appreciate any hint on this issue.

Thank you in advance!

Cristina
Previous Topic:limit OCL validation of an invariant
Next Topic:Programmatical creation
Goto Forum:
  


Current Time: Wed Jun 20 00:28:32 GMT 2018

Powered by FUDForum. Page generated in 0.02352 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top