Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Multiple Input Models Issue
[ATL] Multiple Input Models Issue [message #23664] Fri, 16 March 2007 15:38 Go to next message
Ronan is currently offline RonanFriend
Messages: 10
Registered: July 2009
Junior Member
Hi,
My ATL transform takes in a number of input models (WSDL interfaces) and
produces one output model (UML Class Diagram). The problem is that each
time the root transformation(ProcessToRoot) runs (once for every input
model) it creates a new model in the output UML Class diagram. I want
there to be only one output model with a number of classes in it
representing each input interface. My attempt so far is below..

module XMLtoUML; -- Module Template
create OUT : UML from IN : XML, IN2 : XML;

rule ProcessToRoot{
from
r: XML!Root
--merge the two input models
using{
a:Set(XML!Root) =
XML!Root.allInstancesFrom('IN')->union(XML!Root.allInstancesFrom('IN2'));
}
to
rt : UML!Model(
packagedElement <-
a->collect(e|e.children->select(e|e.name='wsdl:portType')- >collect(e|thisModule.PortTypeToInterface(e)))
)
}

lazy rule PortTypeToInterface{
from
pt: XML!Element(
pt.name = 'wsdl:portType'
)
to
inf : UML!Interface(
name <- pt.children->select(e|e.name='name')->first().value,
ownedOperation <-
pt.children->select(e|e.name='wsdl:operation')->collect(e|thisModule.OperationToOperation(e))
)
}

lazy rule OperationToOperation{
from
opx: XML!Element
to
opu : UML!Operation(
name <- opx.children->select(e|e.name='name')->first().value
)
}

I have successfully got the 2nd and 3rd rules merging correctly but need
the first rule to only fire once in order to create only one output model.
Any ideas?

Also is there any way to merge all input models without having to
explicitly enumerate them as I have done with the allInstancesFrom method
in a using block?

Cheers,
Ronan
Re: [ATL] Multiple Input Models Issue [message #23911 is a reply to message #23664] Fri, 16 March 2007 17:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: marcos.didonet-del-fabro.univ-nantes.fr

Hello,

We have implemented a couple of helpers that may answer your first question. We used it to
generate a single primitive type (e.g., String or Integer) to merge two KM3 metamodels.

I adapted them to your example. You can try it to verify if it works. :)

rule ProcessToRoot{
from
r: XML!Root (r.isUnique)
--merge the two input models
-- the rule
}

---- the helpers ------------------------------------------------------------ --

helper context XML!Root def: isUnique : Boolean =
self.uniqueValue = self;

helper context XML!Root def: key : OclAny =
self.name;

helper def: rootByKey : Map(OclAny, XML!Root) =
XML!Root.allInstances()->iterate(e; acc : Map(OclAny, XML!Root) = Map {} |
acc.including(e.key, e)
);

helper context XML!Root def: uniqueValue : XML!Root =
thisModule.rootByKey.get(self.key);

------------------------------------------------------------ ------

Regards,

Marcos.



Ronan wrote:
> Hi,
> My ATL transform takes in a number of input models (WSDL interfaces) and
> produces one output model (UML Class Diagram). The problem is that each
> time the root transformation(ProcessToRoot) runs (once for every input
> model) it creates a new model in the output UML Class diagram. I want
> there to be only one output model with a number of classes in it
> representing each input interface. My attempt so far is below..
>
> module XMLtoUML; -- Module Template
> create OUT : UML from IN : XML, IN2 : XML;
>
> rule ProcessToRoot{
> from r: XML!Root
> --merge the two input models
> using{
> a:Set(XML!Root) =
> XML!Root.allInstancesFrom('IN')->union(XML!Root.allInstancesFrom('IN2'));
> }
> to
> rt : UML!Model(
> packagedElement <-
> a->collect(e|e.children->select(e|e.name='wsdl:portType')- >collect(e|thisModule.PortTypeToInterface(e)))
>
> )
> }
>
> lazy rule PortTypeToInterface{
> from pt: XML!Element(
> pt.name = 'wsdl:portType'
> )
> to
> inf : UML!Interface(
> name <- pt.children->select(e|e.name='name')->first().value,
> ownedOperation <-
> pt.children->select(e|e.name='wsdl:operation')->collect(e|thisModule.OperationToOperation(e))
>
> )
> }
>
> lazy rule OperationToOperation{
> from opx: XML!Element
> to
> opu : UML!Operation(
> name <- opx.children->select(e|e.name='name')->first().value
> )
> }
>
> I have successfully got the 2nd and 3rd rules merging correctly but need
> the first rule to only fire once in order to create only one output
> model. Any ideas?
>
> Also is there any way to merge all input models without having to
> explicitly enumerate them as I have done with the allInstancesFrom
> method in a using block?
>
> Cheers,
> Ronan
>
Re: [ATL] Multiple Input Models Issue [message #25047 is a reply to message #23911] Fri, 23 March 2007 11:40 Go to previous message
Ronan is currently offline RonanFriend
Messages: 10
Registered: July 2009
Junior Member
Hi Marcos,
Thanks you for those excellent helpers. I tried them out and they work
perfectly. Using a Map to maintain state is a very elegant solution to my
problem. Previously I had tried to use a counter, but this failed as the
do block for executed only after both models had been transformed.
Thanks again,
Ronan
Previous Topic:[ATL] Re-usable modules with metamodels as formal parameters?
Next Topic:[ATL]on defining source and domains with more than one element
Goto Forum:
  


Current Time: Thu Dec 26 09:56:19 GMT 2024

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

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

Back to the top