Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » For-Loop: Getting the context of the outer element
For-Loop: Getting the context of the outer element [message #1765345] Thu, 08 June 2017 15:09 Go to next message
William Coh is currently offline William CohFriend
Messages: 15
Registered: June 2017
Junior Member
Hey there,

after my "Begin" starts, I'll set the context to InstanceA (TypeA). Then the system iterates through a For-Loop (size n = depending on TypeZ which has nothing to do with InstanceA).

Inside this For-Loop, I want to create n new instances of TypeB and assign each of those instances to InstanceA (InstanceA holds a collection of elements of TypeB).

However, the For-Loop automatically changes the context to instances of TypeZ and I can't see how I can access InstanceA from inside the For-Loop, because there is no connection between TypeA and TypeZ in my underlying model.

e.g. aql:self returns an instance from TypeZ

Is there a way to access my InstanceA from inside the For-Loop?

[Updated on: Thu, 08 June 2017 15:10]

Report message to a moderator

Re: For-Loop: Getting the context of the outer element [message #1765350 is a reply to message #1765345] Thu, 08 June 2017 15:32 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Hello William,
You can use the let operation. It allows to register a variable to the result of an expression and use it after.

So you would have the following structure

ChangeContext
            Let myVar<-aql:self
                      For i
                              ChangeContext var:myVar
                                        CreateInstance TypeA Reference name


Hope this answers your question

Regards,

Pierre


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: For-Loop: Getting the context of the outer element [message #1765376 is a reply to message #1765350] Thu, 08 June 2017 20:42 Go to previous messageGo to next message
William Coh is currently offline William CohFriend
Messages: 15
Registered: June 2017
Junior Member
Good evening Pierre,

thank you for your reply.

I'm a little bit confused where to put your suggested expression "Let myVar<-aql:self". Should I put it into the first "Change Context"? That doesn't work.

What kind of operation can I use for the let operation? e.g. change context, set, unset, ... nothing seems to work so far.

Regards
Re: For-Loop: Getting the context of the outer element [message #1765398 is a reply to message #1765376] Fri, 09 June 2017 08:16 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Yes, the structure I gave you start from your first context.
A did a picture to represent a working usage similar to yours:
index.php/fa/29596/0/

This should work if everything else is ok.

To know what a let can have, juts right click on it and you will have all operations you can use that is all operations.

If this does not work, be sure all your expressions are correct and that you have no warnings about those in error log.
Also make sure the refrence in the create instance is correct.

I also wonder how you retrieve typeZ in for loop if they have no links with type A?

Regards,


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius

[Updated on: Fri, 09 June 2017 08:20]

Report message to a moderator

Re: For-Loop: Getting the context of the outer element [message #1765404 is a reply to message #1765398] Fri, 09 June 2017 08:59 Go to previous messageGo to next message
William Coh is currently offline William CohFriend
Messages: 15
Registered: June 2017
Junior Member
Hello Pierre,

your explanation and corresponding picture makes absolutely sense, but I can't create a Let expression. That's the point.

I just figured out, that the Let expression will come with Sirius 5.0.0 which is released on June 28, 2017 [1]. Right now I'm using Obeo Designer Community 9.1.1 which is based on Sirius 4.1.3.

Are you using Sirius 5.0 and is there an opportunity to download Sirius 5.0 right now?

Regards

[1] https://projects.eclipse.org/projects/modeling.sirius/releases/5.0.0
Re: For-Loop: Getting the context of the outer element [message #1765432 is a reply to message #1765404] Fri, 09 June 2017 12:07 Go to previous message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Ah ok that makes more sense.
Indeed this feature is for Sirius 5.0.0.

If you want to go for Sirius 5.0.0. In this case you can use the stable snapshot update site available only for neon or oxygen on https://wiki.eclipse.org/Sirius/Update_Sites and update to the final release when it makes out.
I don't see another solution if type A instance cannot be find from a type z instance even with eContainer() relation

Regards


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Getting usage information
Next Topic:Same instances created many times in same canvas
Goto Forum:
  


Current Time: Wed Sep 18 19:27:10 GMT 2024

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

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

Back to the top