Skip to main content



      Home
Home » Archived » M2M (model-to-model transformation) » [ATL] one to many Transformation ([ATL])
[ATL] one to many Transformation [message #537802] Thu, 03 June 2010 12:57 Go to next message
Eclipse UserFriend
Hi,

I want to create multiple instances in the target model from a single source element. The problem is the number is an integer attribute of the source element which is variable. So is there any way that I can use ATL for this purpose?

Thanks in advance
Pej
Re: [ATL] one to many Transformation [message #537912 is a reply to message #537802] Fri, 04 June 2010 03:36 Go to previous messageGo to next message
Eclipse UserFriend
you can use a distinct foreach pattern (even though it's deprecated it still works nicely)

to
t : distinct MM!EE foreach(e in XX)(

)

XX has to be a collection though. If you have to iterate on an Integer, then you can use a Number Sequence :
helper def : numberSeq : Sequence(Integer) =
Sequence{1,2,3, etc..}
;
and then use as collection

thisModule.numberSeq->subSequence(1,myInteger)
Re: [ATL] one to many Transformation [message #538132 is a reply to message #537912] Sat, 05 June 2010 09:57 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Sylvain for your answer.

So the sequence of integers(Sequence{1,2,3, etc..}) should be created manually.More specifically the end of sequence should be defined by me. In that case one should know what is the maximum number of instances need to be created and thus them maximum size of the collection statically and at implementation time(not run time). At run time the number of instances that are gonna be created should be lower than that maximum.Am I right?

Thanks,
Pejman

[Updated on: Sat, 05 June 2010 09:59] by Moderator

Re: [ATL] one to many Transformation [message #538601 is a reply to message #538132] Tue, 08 June 2010 03:58 Go to previous messageGo to next message
Eclipse UserFriend
Pejman wrote on Sat, 05 June 2010 09:57
Thanks Sylvain for your answer.

So the sequence of integers(Sequence{1,2,3, etc..}) should be created manually.More specifically the end of sequence should be defined by me. In that case one should know what is the maximum number of instances need to be created and thus them maximum size of the collection statically and at implementation time(not run time). At run time the number of instances that are gonna be created should be lower than that maximum.Am I right?

Thanks,
Pejman

With this solution I'm afraid the answer is yes.
But if the number varies then that's because it depends on something. Then you could iterate on that something instead of a fixed length.
Re: [ATL] one to many Transformation [message #538731 is a reply to message #538601] Tue, 08 June 2010 09:54 Go to previous message
Eclipse UserFriend
Actually I have solved the problem using a recursive helper function which takes the integer as an input and decrease it in each iteration and instantiating one instance of the certain class. Apparently there is no better solution since the only available information is the value of an integer attribute in the input model.
Previous Topic:[ATL] construct/obtain .asm file programmatically
Next Topic:[QVTo] 1-to-* transformation does only result in one deeper transformationtree
Goto Forum:
  


Current Time: Sun Apr 20 22:39:19 EDT 2025

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

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

Back to the top