[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.modeling.m2m] Re: [ATL] Multiple Input Models Issue
|
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