Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » sequence as return of a helper
sequence as return of a helper [message #1314926] Fri, 25 April 2014 17:48 Go to next message
Samantha Parker is currently offline Samantha ParkerFriend
Messages: 4
Registered: April 2014
Junior Member
Hy, I have to write a helper that given a sequence, return the union of smaller sequence. This is my code

helper def: sw_events(events: Sequence(MODEL_A!ViewElement)): Sequence(MODEL_A!ViewElementEvent) =
	events->iterate(iter; res: Sequence(MODEL_A!ViewElementEvent) = Sequence{}|
	res.including(iter.viewElementEvents)
);


The result of this helper is a sequence of MODEL_A!ViewElement, as I want, but I can't use it. I have this error:
Collections do not have properties, use ->collect()


I have use res.union too but I have the same error.

What Can I do?
Thank you in advance for your help.
Re: sequence as return of a helper [message #1317864 is a reply to message #1314926] Sun, 27 April 2014 09:36 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4155
Registered: July 2009
Senior Member
Hi

UML (and Ecore) Models hava Objects and Multiplicities
OCL, on which ATL is based, reifies Multiplicities as Collections which
are different to Objects.

The "." operator is used for Object navigation
The "->" operator is used for Collection navigation (this is what the
error message is telling you)

Helpfully/confusingly the short forms
"." on a collection is implicit collect: "->collect(...)" (which is also
what the error message is telling you)
"->" on an Object is implicit convert to set

Regards

Ed Willink

On 26/04/2014 18:34, Samantha Parker wrote:
> Hy, I have to write a helper that given a sequence, return the union
> of smaller sequence. This is my code
>
> helper def: sw_events(events: Sequence(MODEL_A!ViewElement)):
> Sequence(MODEL_A!ViewElementEvent) =
> events->iterate(iter; res: Sequence(MODEL_A!ViewElementEvent) =
> Sequence{}|
> res.including(iter.viewElementEvents)
> );
>
> The result of this helper is a sequence of MODEL_A!ViewElement, as I
> want, but I can't use it. I have this error:
> Collections do not have properties, use ->collect()
>
> I have use res.union too but I have the same error.
>
> What Can I do?
> Thank you in advance for your help.
Re: sequence as return of a helper [message #1319675 is a reply to message #1317864] Mon, 28 April 2014 10:10 Go to previous messageGo to next message
Samantha Parker is currently offline Samantha ParkerFriend
Messages: 4
Registered: April 2014
Junior Member
Thanks for the reply, unfortunately I still have the same error when calling an element of the sequence

thisModule.sw_eventi(s.viewElements)->first().name.println();


this is the test that I do and the error is reported is up to .name
I also changed
res.including(iter.viewElementEvents)
in
res->including(iter.viewElementEvents)
Re: sequence as return of a helper [message #1321216 is a reply to message #1319675] Tue, 29 April 2014 06:41 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 168
Registered: September 2012
Senior Member

What is the type/multiplicity of ViewElement::viewElementEvents?
Where do you use the result of your helper (i.e. in what code)?


Cheers,
Dennis
Re: sequence as return of a helper [message #1321504 is a reply to message #1321216] Tue, 29 April 2014 10:22 Go to previous message
Samantha Parker is currently offline Samantha ParkerFriend
Messages: 4
Registered: April 2014
Junior Member
I solved it by running .debug () that I never used. The result of my helper was a sequence of sequence and I could not access the elements as I wanted. I solved it by this way:

helper def: sw_events(events: Sequence(MODEL_A!ViewElement)): MODEL_A!ViewElementEvent =
	events->iterate(iter; res: Sequence(MODEL_A!ViewElementEvent) = Sequence{}|
	res.union(iter.viewElementEvents)
);


Thanks to all for your interest!
Previous Topic:Running ATL Transformations programmatically inside Android
Next Topic:[EMFTVM] Problem with Back Slash character
Goto Forum:
  


Current Time: Fri Nov 28 21:01:41 GMT 2014

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

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