One-to-many with 0..1 cardinality possible? [message #1836198] |
Wed, 23 December 2020 21:41 |
Burak Karaduman Messages: 84 Registered: July 2018 |
Member |
|
|
Dear All,
I a source meta-model and a target meta-model.
They are shown by the attached figure.
I am trying to transform A to C, B to C,D. I successed with transformation of Class instances. However, I cannot transform, "con" to both "hon" and "kon" relations.
Is this possible in ATL?
Thanks.
-
Attachment: qq.png
(Size: 6.47KB, Downloaded 56 times)
[Updated on: Wed, 23 December 2020 21:43] Report message to a moderator
|
|
|
|
Re: One-to-many with 0..1 cardinality possible? [message #1836226 is a reply to message #1836216] |
Thu, 24 December 2020 20:23 |
Burak Karaduman Messages: 84 Registered: July 2018 |
Member |
|
|
Dear Dennis,
Thanks for the example you provided. They are really valuable for my upcoming studies. However, the main problem is that;
When the transformation is triggered;
a single instance of B with 0..1 cardinality has to be transformed into both an instance of D and an instance of E. Then, C shall contain both D and E via kon and hon relations.
So something like this can be implemented? I tried it like this,
rule AtoC {
from
s : INMULTIPLE!A
to
t : OUTMULTIPLE!C (
kon <- s.con,
hon <- s.con
)
}
rule BtoDandE {
from
s : INMULTIPLE!B (
)
to
t1 : OUTMULTIPLE!D,
t2 : OUTMULTIPLE!E
}
However, this kind of transformation generates type errors.
-- AFTER EDIT--
I have found the Solution using resolveTemp function;
-- @atlcompiler emftvm
-- @path INSINGLE=/ATLAssociationSplit/metamodels/insingle.ecore
-- @path OUTSINGLE=/ATLAssociationSplit/metamodels/outsingle.ecore
module AssociationSplitSingle;
create OUT : OUTSINGLE from IN : INSINGLE;
rule AtoC {
from
s : INSINGLE!A
to
t : OUTSINGLE!C (
kon <-
--if s.con.isD then
s.con
-- else
-- OclUndefined
-- endif
,
hon <- thisModule.resolveTemp(s.con, 't2')
-- if s.con.isD then
-- OclUndefined
-- else
-- endif
)
}
rule BtoD {
from
s : INSINGLE!B --(
--s.isD
-- )
to
t1 : OUTSINGLE!D,
t2 : OUTSINGLE!E
}
[Updated on: Thu, 24 December 2020 23:25] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01857 seconds