Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » SOLVED! :-) [ATL] Sequence with values but how to get further?
SOLVED! :-) [ATL] Sequence with values but how to get further? [message #547772] Mon, 19 July 2010 15:09 Go to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
I managed to get a value in my sequence. The OCL query so far looks like:

helper context EPK!Event def: isConditionExpressionEvent() : Boolean =
	EPK!ControlFlow.allInstances() -> collect(i | i.target)-> asSet() -> intersection(self.id -> asSet()) -> asSequence() 
	


So far I have in my Sequence a '2'. That is what I expected. My next step is now quite hard and I don't know how to solve. If I do the same step in SQL it would be something like:

select (f | f.source where f.target=Sequence('2'))


How could I do something like that?

Thanks for your help...

Cheers Roger

[Updated on: Wed, 21 July 2010 16:07]

Report message to a moderator

Re: [ATL] Sequence with values but how to get further? [message #547786 is a reply to message #547772] Mon, 19 July 2010 15:43 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
Use a select for the 'where' condition and a collect for what you want to select (yes, this sounds strange).

select (f | f.target=Sequence('2'))->collect(f | f.source)
Re: [ATL] Sequence with values but how to get further? [message #547793 is a reply to message #547772] Mon, 19 July 2010 15:55 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
Ok, so far so good. Smile
Now my last question for today, hopefully. Smile

In the where clause i have now, Sequence('2'), but I want to have this more general, is it possible to use it like an array?
Lets say, If I have more than one Sequence.

Example:
Sequence{1,2,3}
Sequence{3,4,5}
Sequence{576,4,67}

Is it the possible to get access just to the first wth a statement like Sequence{0} or something else?

Thanks.
Re: [ATL] Sequence with values but how to get further? [message #547802 is a reply to message #547793] Mon, 19 July 2010 16:06 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
Something doesn't work, when I debug the following error occur:

org.eclipse.m2m.atl.engine.vm.VMException: Get unsupported on OclAny.
	at MEPK!Event;.isConditionExpressionEvent() : ??#28(EPL2BPMN.atl[48:136-48:144])
		local variables = {f='2', self=IN! Loan request }
		local stack = [Sequence {}, Sequence {}]


My helper with the error is the following:

	EPK!ControlFlow.allInstances() -> collect(i | i.target)-> asSet() -> intersection(self.id -> asSet())  -> asSequence() -> select (f | f.target=Sequence {'2'})->collect(f | f.source).debug() -> includes(EPK!XOR.allInstances() -> collect(d | d.id));


Until here everything is fine:

EPK!ControlFlow.allInstances() -> collect(i | i.target)-> asSet() -> intersection(self.id -> asSet())  -> asSequence() 

Result: Sequence{'2'} when I debug after that the error from above occur! Sad
Re: [ATL] Sequence with values but how to get further? [message #547804 is a reply to message #547793] Mon, 19 July 2010 16:10 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHEFriend
Messages: 129
Registered: July 2009
Senior Member
Le 19/07/2010 17:55, Roger80 a écrit :
> Ok, so far so good. :) Now my last question for today, hopefully. :)
>
> In the where clause i have now, Sequence('2'), but I want to have this
> more general, is it possible to use it like an array? Lets say, If I
> have more than one Sequence.
>
> Example:
> Sequence{1,2,3}
> Sequence{3,4,5}
> Sequence{576,4,67}
>
> Is it the possible to get access just to the first wth a statement like
> Sequence{0} or something else?

yourSequence->first()

>
> Thanks.


--
Cordialement

Vincent MAHÉ

Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
Re: [ATL] Sequence with values but how to get further? [message #547810 is a reply to message #547804] Mon, 19 July 2010 16:25 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
Hello vincent

I do not mean to the element in the sequence but to the sequence itself? I just want to put for example

(f | f.target=Sequence) The Sequence in this case is like a variable or array.

Thanks and cheers

Roger
Re: [ATL] Sequence with values but how to get further? [message #547880 is a reply to message #547772] Tue, 20 July 2010 04:51 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
Hello I just wanted to summarize where I stand so far what are my open issues are:

1) I created my OCL statement, there is something wrong with it as I always get an error which I do not understand. The error is located in the region with the 'Sequence{'2'}'.

My error is the following:

org.eclipse.m2m.atl.engine.vm.VMException: Get unsupported on OclAny.
	at MEPK!Event;.isConditionExpressionEvent() : ??#28(EPL2BPMN.atl[48:136-48:144])
		local variables = {f='2', self=IN! Loan request }
		local stack = [Sequence {}, Sequence {}]



My helper with the error is the following:

	EPK!ControlFlow.allInstances() -> collect(i | i.target)-> asSet() -> intersection(self.id -> asSet())  -> asSequence() -> select (f | f.target=Sequence {'2'})->collect(f | f.source).debug() -> includes(EPK!XOR.allInstances() -> collect(d | d.id));



Until here everything is fine:

EPK!ControlFlow.allInstances() -> collect(i | i.target)-> asSet() -> intersection(self.id -> asSet())  -> asSequence() 


Result: Sequence{'2'} when I debug after that the error from above occur! Sad

2) I want to replace the Sequence{2} with a more general thing. Because the entry in my Sequence is not always 2. Is there a thing like a variable I can use or is it possible to get access to the Sequence like an array?

Thank you very much! If you could help me that would be really nice.

Cheers and thanks a lot...

Roger
Re: [ATL] Sequence with values but how to get further? [message #547950 is a reply to message #547772] Tue, 20 July 2010 09:07 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
Please can you help me, or should I provide some more information?
I have just 1.5 weeks to do my thesis and I have to solve 2-3 three more problems, please help. Thank you...
Re: [ATL] Sequence with values but how to get further? [message #547955 is a reply to message #547880] Tue, 20 July 2010 09:24 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
Roger80 wrote on Tue, 20 July 2010 00:51

EPK!ControlFlow.allInstances() -> collect(i | i.target)-> asSet() -> intersection(self.id -> asSet())  -> asSequence() 


Result: Sequence{'2'}

If the result is a Sequence, you can't do -> select (f | f.target=Sequence {'2'}) on that because f = '2' and you can't get the attribute target on a String leading to the error that you get.
Re: [ATL] Sequence with values but how to get further? [message #547966 is a reply to message #547810] Tue, 20 July 2010 09:25 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHEFriend
Messages: 129
Registered: July 2009
Senior Member
Le 19/07/2010 18:25, Roger80 a écrit :
> Hello vincent
>
> I do not mean to the element in the sequence but to the sequence itself?
> I just want to put for example
> (f | f.target=Sequence) The Sequence in this case is like a variable or
> array.
>
> Thanks and cheers
> Roger

if you want to test if the target is a sequence:

oclIsKindOf(t : oclType) returns a boolean value stating whether self
is either an instance of t or of one of its subtypes;
--
Cordialement

Vincent MAHÉ

Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
Re: [ATL] Sequence with values but how to get further? [message #547970 is a reply to message #547955] Tue, 20 July 2010 09:54 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
Ok, I do not understand you 100%, is there no possibility to get the attribute target then? What should I do instead.

1) My problem is that I first need the target from the event where the id is like the target. That is working (first part of OCL statement).

2) Then I need attribute source where the f.target is like the values I get from the sequence in the first statement. This is were I am actually on and you try to help me.

3) I need to check if the source is included in the XOR element. This is I think also not a problem. I try it like that...

-> includes(EPK!XOR.allInstances() -> collect(d | d.id));


So thanks for your help....


[Updated on: Tue, 20 July 2010 10:44]

Report message to a moderator

Re: [ATL] Sequence with values but how to get further? [message #547974 is a reply to message #547772] Tue, 20 July 2010 10:09 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
Extract of the ATL Manual :

includes(o : oclAny) returns a boolean stating whether the object o is part of the collection self;
Re: [ATL] Sequence with values but how to get further? [message #547985 is a reply to message #547772] Tue, 20 July 2010 10:45 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
So, ok is it possible to do that or not? I am confused and lost. Sad
Re: [ATL] Sequence with values but how to get further? [message #548094 is a reply to message #547772] Tue, 20 July 2010 16:01 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
Ok, I try it now with a picture that should help to understand my problem and the case I want to reach. Please could you help me to find a OCL statement or to tell me that it is not working. Thank you...

http://www.haar-em.ch/test/helper.jpg


As you know, I already had the following OCL statement:

EPK!ControlFlow.allInstances() -> collect(i | i.target)-> asSet() -> intersection(self.id -> asSet())  -> asSequence() -> select (f | f.target=Sequence {'2'})->collect(f | f.source).debug() -> includes(EPK!XOR.allInstances() -> collect(d | d.id));


Thank you, I know that I am not easy, but thanks a lot!

Cheers Roger
Re: [ATL] Sequence with values but how to get further? [message #548118 is a reply to message #547772] Tue, 20 July 2010 17:20 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
It seems clear enough in your mind for you to be able to write the OCL Statement with technical help if needed.

You should try to divide things in different helpers, this will probably help you to handle the problem.
Re: [ATL] Sequence with values but how to get further? [message #548195 is a reply to message #548118] Wed, 21 July 2010 04:44 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
Hi Sylvain

How can I handle it in several helpers, if I need a false or a true, this would be possible if I can save the results in between in a variable and then call this variable in another helper.
But to be honest, I newer saw that in the documentation. So I this is possible please let me now and provide me an example if possible, Thank you!!!

Kind regards Roger
Re: [ATL] Sequence with values but how to get further? [message #548232 is a reply to message #547772] Wed, 21 July 2010 08:06 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
You could start by making a helper to list the IDs of all the XORelements :

helper def : xorElements : Sequence(Integer) =
EPK!XOR.allInstances() -> collect(d | d.id)
;

You can then call that sequence by using thisModule.xorElements where you need it.
Re: SOLVED! :-) [ATL] Sequence with values but how to get further? [message #548387 is a reply to message #547772] Wed, 21 July 2010 16:09 Go to previous message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
For all the people who want to now the solution here is the solution:

helper def: xorElements : Set(String) =	
	EPK!XOR.allInstances() -> collect(d | d.id) -> asSet();


--Create helperConditionalFlowEvents Rule 13 Support
helper context EPK!Event def: isConditionExpressionEvent() : Boolean =
if EPK!ControlFlow.allInstances() -> select(e | e.target=self.id)->collect(e | e.source) -> asSet() -> intersection(thisModule.xorElements).isEmpty() then -- -> includes(thisModule.xorElements).debug();	
	false
else
	true
endif;

Previous Topic:[QVTO/OCL] Usage of non-standard "closure" operator
Next Topic:XSD to ECORE Transformation
Goto Forum:
  


Current Time: Tue Dec 10 22:25:11 GMT 2024

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

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

Back to the top