Home » Archived » M2M (model-to-model transformation) » [ATL] Identify last Element
| | | | |
Re: [ATL] Identify last Element [message #546556 is a reply to message #546534] |
Tue, 13 July 2010 11:16 |
Roger80 Messages: 79 Registered: May 2010 |
Member |
|
|
Thank you very much for your answer!
Can you explain me how I have to read that, what I understand:
1) Collect from allInstances of the ControlFlow class the source elements. So I have for example: sequence{1, 5, 12, 13, 19}.
2) Exclude all which are undefined elements in the sequence. What does it mean with "undefined"? In what kind undefined?
3) Then I collect the id's. My question here do I not have to give the class where the id is located? Because I just want the id from the class event.
4) And include the the id in the self.id???
Sorry, that I ask so dumb questions, but I really want to understand it!
Cheers Roger
[Updated on: Tue, 13 July 2010 11:35] Report message to a moderator
|
|
|
Re: [ATL] Identify last Element [message #546563 is a reply to message #546556] |
Tue, 13 July 2010 11:41 |
Sylvain EVEILLARD Messages: 556 Registered: July 2009 |
Senior Member |
|
|
Roger80 | Can you explain me how I have to read that, what I understand:
1) Collect from allInstances of the ControlFlow class the source elements. So I have for example: sequence{1, 5, 12, 13, 19}.
|
I don't exactly know your meta-model but source is a reference to other elements right ? In that case you have a sequence of elements, not a sequence of Integers
Roger80 |
2) Exclude all which are undefined elements in the sequence. What does it mean with "undefined"? In what kind undefined?
|
Suppose you have a control flow without any source, if you collect all the sources, you'll get OclUndefined for this one. Then you can't do anything on OclUndefined and if you still do it will break so to be sure to not face the problem it's always more safe to handle that case like that.
Roger80 |
3) Then I collect the id's. My question here do I not have to give the class where the id is located? Because I just want the id from the class event.
|
Then you can filter the sequence of elements :
->select(e | e.oclIsTypeOf(MM!ClassEvent))
Roger80 |
4) And include the the id in the self.id???
|
Includes(s) on a a collection will return true if this collection contains s, false otherwise
Roger80 |
Sorry, that I ask so dumb questions, but I really want to understand it!
|
You should have a deep look at the ATL manuel, everything is explained there. Moreover it's really hard to answer those kind of questions without a good knowledge of the meta-models you're using.
|
|
|
Re: [ATL] Identify last Element [message #546565 is a reply to message #546556] |
Tue, 13 July 2010 11:25 |
Vincent MAHE Messages: 129 Registered: July 2009 |
Senior Member |
|
|
Le 13/07/2010 13:16, Roger80 a écrit :
> Thank you very much for your answer!
> Can you explain me how I have to read that, what I understand:
> 1) Collect from allInstances of the ControlFlow class the source
> elements. So I have for example: sequence{1, 5, 12, 13, 19}.
>
> 2) Exclude all which are undefined elements in the sequence. What does
> it mean with "undefined"? In what kind undefined?
It means OclUndefined which is the equivalent for OCL of Java/C null or
void
>
> 3) Then I collect the id's. My question here do I not have to give the
> class where the id is located? Because I just want the id from the class
> event.
the AllInstances returns a set of ContorlFlow instances so it'is typed
and you can handle them as ControlFlow instances.
>
> 4) And include the the id in the self.id???
> Sorry, that I answer so dumb questions, but I really want to understand it!
it is a comparing of the Id of the current item you are working on
(self.id) with the set elements ids
>
> Cheers Roger
>
--
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] Identify last Element [message #547581 is a reply to message #546360] |
Mon, 19 July 2010 04:13 |
Roger80 Messages: 79 Registered: May 2010 |
Member |
|
|
Hi all
I made now some investigations and try now to start here from beginning with my explanations:
I am creating a helper, but I do not work.
I have the following code:
helper context EPK!Event def: isNotEndEvent() : Boolean =
if EPK!Arc.allInstances() -> collect(i | i.source)->includes(self.id) then true
else false
endif;
So, my result is always false.What is my idea behind the rule:
EPK!Arc.allInstances() -> collect(i | i.source)
I take the "source" attribute of all allInstances I have in my source model. As my "source" attributes are something like this "3", I expect as a result a sequence like { "3", "7", "10", "15","20"}
Remark: The source attribute is of type String. Is that correct?
->includes(self.id)
Now I want to check if this result sequence { "3", "7", "10", "15","20"} is an element of the (self.id).
So for every Event this rule is checked and the id are something like { "3"} then {"7"} then {"10"} then {"15"} then {"16"} then {"20"}
My expectation than is that for "3", "7", "10", "15","20" the check is true, but not for "16" as this element is not in the first result sequence. But it doesn't work! What is wrong. Please help me.
2) By the way, how can a I see what is in the sequences, is there a statement to give out the values in a sequence?
Please, please help...
Thank you very much for your help! Cheers Roger
|
|
|
Re: [ATL] Identify last Element [message #547614 is a reply to message #546360] |
Mon, 19 July 2010 07:27 |
Roger80 Messages: 79 Registered: May 2010 |
Member |
|
|
I know now, why it is not working, but I need more support from your side:
My results out of the following first part
EPK!Arc.allInstances() -> collect(i | i.source).debug();
is:
org.eclipse.m2m.atl.engine.vm.VMException
NativeOperation public static org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.debug(org.eclipse.m2m.atl.engine.vm.StackFrame,org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny,org.eclipse.m2m.atl.engine.vm.nativelib.ASMString)
args = [Sequence {OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined, OclUndefined}]
It looks like that OCL can not grap out the attribute "source". Is something wrong with my meta model? Can you please help me?
Cheers Roger
|
|
| |
Goto Forum:
Current Time: Sat Sep 21 03:13:28 GMT 2024
Powered by FUDForum. Page generated in 0.04455 seconds
|