Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » long-winded to copy all properties
long-winded to copy all properties [message #88897] Mon, 25 August 2008 10:12 Go to next message
Eclipse UserFriend
Originally posted by: xxx.tullball.no

I am defining a transformation where the source and target models are both
UML 2 activity models.

I use superimposition on the UML2Copy module in order to simply keep the
unchanged parts.
In my transformation I will override the ControlFlow rule since I will
only keep non-circular edges. The only change is to add a rule guard
(inCF.source <> inCF.target):

rule ControlFlow {
from inCF : UML2 ! ControlFlow (inCF.source <> inCF.target)
to outCF: UML2 ! ControlFlow (
source <- inCF.source,
target <- inCF.target,
guard <- inCF.guard,
-- All the other properties will also be copied...
)
}

It is long-winded to relist all the properties of a control flow object.
Is there no super() method or similar when doing superimposition?
I also tried to skip the copy part (the to-body) and add the follow do
section instead:

do {
outCF <- inCF;
}

But the latter does not work.

Am I missing something or is there no clever way to do this?
Re: long-winded to copy all properties [message #88912 is a reply to message #88897] Mon, 25 August 2008 14:23 Go to previous messageGo to next message
Alfons Laarman is currently offline Alfons LaarmanFriend
Messages: 71
Registered: July 2009
Member
Hi

Try using rule inheritance:
http://wiki.eclipse.org/ATL_Language_Troubleshooter#Rule_inh eritance
Same thing for queries: http://wiki.eclipse.org/ATL_2006


Regards,

Alfons


"Roy "Gr
Re: long-winded to copy all properties [message #88954 is a reply to message #88912] Tue, 26 August 2008 06:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: xxx.tullball.no

Now I tried your suggestion to use inheritance,
but I get a compilation error. The compiler cannot find the super rule,
ControlFlow. It is maybe not surprising, since the the ControlFlow rule
appears in the UML2Copy rule, and the transformation module I am writing
on is superimposed on the UML2Copy.

Does this mean I do not get any further, since I cannot combine
superimpose and do inheritance on the superimposed module?

rule SubControlFlow extends ControlFlow { -- COMPILATION ERROR: superRule
ControlFlow not found!
from inCF : UML2 ! ControlFlow (inCF.source <> inCF.target)
to outCF: UML2 ! ControlFlow (
)
}
[ATL] Re: long-winded to copy all properties [message #88983 is a reply to message #88954] Tue, 26 August 2008 07:46 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 301
Registered: July 2009
Senior Member
Hello,

Roy Grønmo a écrit :
>
> Now I tried your suggestion to use inheritance,
> but I get a compilation error. The compiler cannot find the super rule,
> ControlFlow. It is maybe not surprising, since the the ControlFlow rule
> appears in the UML2Copy rule, and the transformation module I am writing
> on is superimposed on the UML2Copy.

That's the point, the inherited rule must be specified in the same file.
But you can try to duplicate the ControlFlow rule into the superimposed
module.

Best regards,

William
>
> Does this mean I do not get any further, since I cannot combine
> superimpose and do inheritance on the superimposed module?
>
> rule SubControlFlow extends ControlFlow { -- COMPILATION ERROR:
> superRule ControlFlow not found!
> from inCF : UML2 ! ControlFlow (inCF.source <> inCF.target)
> to outCF: UML2 ! ControlFlow (
> )
> }
>
Re: [ATL] Re: long-winded to copy all properties [message #89123 is a reply to message #88983] Tue, 26 August 2008 11:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: xxx.tullball.no

William wrote "But you can try to duplicate the ControlFlow rule into the
superimposed module".
================================

Yes, but that would then be the same as copying all the properties.
And the conclusion is that I have to copy all the properties within my
transformation module.
Re: [ATL] Re: long-winded to copy all properties [message #89169 is a reply to message #89123] Tue, 26 August 2008 20:36 Go to previous message
Alfons Laarman is currently offline Alfons LaarmanFriend
Messages: 71
Registered: July 2009
Member
You could try to use reflection on model elements + newInsatnce call:

helper def : allFeatures(t : OclType) : Set(OclAny) =
t.eStructuralFeatures->union(t.eSuperTypes->collect(st |
hisModule.allFeatures(st))->flatten()->asSet());

rule copyElementX {
from a : MM!X
to b : MM!X
do {
for ( f in a.oclType().eStructuralFeatures() ) {
b.refSetValue(f.name, a.refGetValue(f.name).newInstance() );
}
}
}

And on another thought: the MOF meta-meta-model you can access as %EMF (in
the saandard VM), before I did something like this:

abstract rule ToModelElement {
from d : OGML!LocatedElement
to t : MMX!ModelElement (
properties <- thisModule.allFeatures(d.oclType())->collect(f |
thisModule.ToProperty(f, d))
)
}

lazy abstract rule ToProperty {
from f : "%EMF"!EStructuralFeature
to p : MMX!Property (
name <- f.name,
)
}

lazy rule ToNonLiteralProperty extends ToProperty {
from f : "%EMF"!EReference
to p : MMX!Property (
value <-if d.refGetValue(f.name).oclIsUndefined() then
Sequence{}
else
d.refGetValue(f.name)
endif
)
}

lazy rule ToLiteralProperty extends ToProperty {
from f : "%EMF"!EAttribute
to p : MMX!Property (
value <- if f.isMany() then
d.refGetValue(f.name)->collect(v |
thisModule.createLiteral(v))
else
thisModule.createLiteral(d.refGetValue(f.name) )
endif,
)
}

You could try to do the same thing for "%EMF"!EObject, that could save you
allot of writing.

I'm not sure if either works, just to get you started trying...


Kind regards,
Alfons

-> iterate(f ; res : String
= ' -> ' |
let val : OclAny = self.refGetValue(f.name) in
val.debug('The value of '+ f.oclType().toString() +' '+ f.name +' from
model element "'+ self.toString() +'" is');



"Roy "Gr
Previous Topic:[ATL] refining and abstract metaclass
Next Topic:[ATL]Problem to return a enumeration inside helper (no enumeration literal)
Goto Forum:
  


Current Time: Thu Apr 25 00:23:05 GMT 2024

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

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

Back to the top