I am trying to achieve an M2M transformation using ATL. So I am transforming a source model (1) to target model (2), I am very new to ATL and I can't find any documentation on how to enable many to many transformations. What I am trying to do is: transform (1) Source model with a class named "operation", which references another class named "parameter", the reference is named "operationInput" and its cardinality is (0..n) to (2) Target model with a class named "function", which references another class named "Param", the reference is named "functionInput" and its cardinality is (0..n). So i wrote the following ATL transformation:
rule operation2Function {
from
s: Source!operation
to
t: Target!Function
(
functionInput<-s.operationInput)
}
However, it did not seem to work because the cardinality is many to many , soi tried the following code:
rule operation2Function {
from
s: Source!operation
to
t: Target!Function
(
functionInput<-Source!operation.allInstances() ->select(e | e.oclIsTypeOf(Source!operation)->collect(e| e.operationInput),
)
}
I still don't get the proper result even though I initialized an instance of the source metamodel.
I would appreciate your help on how to enable many to many ((0..n) or (1..n)) transformations.