Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] 1:M transformations
[ATL] 1:M transformations [message #94633] Thu, 06 November 2008 15:56 Go to next message
Mark Melia is currently offline Mark MeliaFriend
Messages: 142
Registered: July 2009
Senior Member
Hi all,

Does anyone know how to create x elements in the target model for one in
the source where x is unknown at development time.

For example, below I want to great x number of T, which is the number of
S-1 and the targetModelElementAttrubutes will be different for each of the
generated TargetModelElements.

rule learningResourceModel2LearningResourceModel{
from
s:S!SourceModelElement
to
t:T!TargetModelElement(
targetModelElementAttribute <- ???
)
}

Thanks for your help,
Mark
Re: [ATL] 1:M transformations [message #94650 is a reply to message #94633] Fri, 07 November 2008 01:19 Go to previous messageGo to next message
Alfons Laarman is currently offline Alfons LaarmanFriend
Messages: 71
Registered: July 2009
Member
Hi Mark,

I think you can only do this imperatively with a called rule:

rule learningResourceModel2LearningResourceModel(s:S!SourceModelE lement) {
t <- T!TargetModelElement.newInstance();
for (n = s.lower .. s.upper) {
t.targetModelElementAttribute <- T!????.newInstance();
}
}

But not sure about the syntax or the newInstance call. Hope it helps though.


Regards,

Alfons

"Mark Melia" <mark.melia@gmail.com> schreef in bericht
news:7e8814c4a06b0d2a2b156f660b767a64$1@www.eclipse.org...
> Hi all,
>
> Does anyone know how to create x elements in the target model for one in
> the source where x is unknown at development time.
>
> For example, below I want to great x number of T, which is the number of
> S-1 and the targetModelElementAttrubutes will be different for each of the
> generated TargetModelElements.
>
> rule learningResourceModel2LearningResourceModel{
> from s:S!SourceModelElement
> to
> t:T!TargetModelElement(
> targetModelElementAttribute <- ???
> )
> }
>
> Thanks for your help,
> Mark
>
Re: [ATL] 1:M transformations [message #94663 is a reply to message #94650] Fri, 07 November 2008 01:22 Go to previous messageGo to next message
Alfons Laarman is currently offline Alfons LaarmanFriend
Messages: 71
Registered: July 2009
Member
"Alfons Laarman" <a.w.laarman@student.utwente.nl> schreef in bericht
news:gf053q$6lj$1@build.eclipse.org...
> Hi Mark,
>
> I think you can only do this imperatively with a called rule:
>
> rule learningResourceModel2LearningResourceModel(s:S!SourceModelE lement) {
> t <- T!TargetModelElement.newInstance();
> for (n = s.lower .. s.upper) {
> t.targetModelElementAttribute <- T!????.newInstance();
> }
> }

On second thought, a called rule is maybe not needed:

rule learningResourceModel2LearningResourceModel{
from s:S!SourceModelElement
to t:T!TargetModelElement
do {
for (n = s.lower .. s.upper) {
t.targetModelElementAttribute <- T!????.newInstance();
}
}
}


good luck!
Re: [ATL] 1:M transformations [message #94678 is a reply to message #94633] Fri, 07 November 2008 09:09 Go to previous message
Max Bureck is currently offline Max BureckFriend
Messages: 72
Registered: July 2009
Member
I'm not sure what your mean by S-1. I am guessing you mean
S!SourceModelElement->allInstances()->size()-1
If you like a declarative approach, you can try something like this:

helper def : sourceElements : Sequence(S!SourceModelElement) =
S!SourceModelElement->allInstances()->asSequence();

helper def : sMinusOne : Sequence(S!SourceModelElement) =

thisModule.sourceElements->excluding(thisModule.sourceElements- >last());

rule learningResourceModel2LearningResourceModel{
from s:S!SourceModelElement
to
t:T!TargetModelElement(
targetModelElementAttribute <- thisModule.sMinusOne

->collect(se|thisModule.Source2Attribute(se));
)
}

lazy rule Source2Attribute {
from s:S!SourceModelElement
to
t:T!TargetModelElementAttribute()
}
Previous Topic:[QVTO] SimpleUML to RDB Example
Next Topic:[QVTO] Help Transforming data types?
Goto Forum:
  


Current Time: Sun Jul 14 04:45:21 GMT 2024

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

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

Back to the top