Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » One-to-many with 0..1 cardinality possible?
One-to-many with 0..1 cardinality possible? [message #1836198] Wed, 23 December 2020 21:41 Go to next message
Burak Karaduman is currently offline Burak KaradumanFriend
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 #1836216 is a reply to message #1836198] Thu, 24 December 2020 12:41 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

You need to add a condition to the rule that transforms A into C. I've added the ATLAssociationSplit example to https://github.com/dwagelaar/atl.examples to demonstrate this.

Cheers,
Dennis
Re: One-to-many with 0..1 cardinality possible? [message #1836226 is a reply to message #1836216] Thu, 24 December 2020 20:23 Go to previous message
Burak Karaduman is currently offline Burak KaradumanFriend
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

Previous Topic:Multiple ATL files to Single XMI file output possible?
Next Topic:Module and Library inclusion problem
Goto Forum:
  


Current Time: Sat Nov 11 08:17:43 GMT 2023

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

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

Back to the top