Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] mapping to a set, adding to result does not work
[QVTO] mapping to a set, adding to result does not work [message #500227] Wed, 25 November 2009 12:42 Go to next message
Eclipse UserFriend
Originally posted by: vanbeerst.gmail.com

This is a multi-part message in MIME format.
--------------010609080201040201080806
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

I'm having trouble mapping a class to a set of classes that already
exist. The problem is that when I initialize result as an empty set and
then try to add elements to the set, those elements aren't really added.
When I put the elements in the set in the init - section everything
works fine.

Is this a bug, or is this expected behaviour?

In attachment you'll find a toy example which shows what I mean. In the
init section of the mapping operation there is a line commented out.
When you uncomment that line, you'll get the results I expect / want.

Dear regards,
Tony.

--------------010609080201040201080806
Content-Type: text/plain;
name="test.qvto"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="test.qvto"

bW9kZWx0eXBlIFVNTCAic3RyaWN0IiB1c2VzIHVtbCgnaHR0cDovL3d3dy5l Y2xpcHNlLm9y
Zy91bWwyLzMuMC4wL1VNTCcpOwoKdHJhbnNmb3JtYXRpb24gdGVzdCgpOwoK bWFpbigpIHsK
Cgl2YXIgYzEgOj0gb2JqZWN0IENsYXNzeyBuYW1lIDo9ICJjMSIgfTsKCXZh ciBjMiA6PSBv
YmplY3QgQ2xhc3N7IG5hbWUgOj0gImMyIiB9OwoJdmFyIGMzIDo9IG9iamVj dCBDbGFzc3sg
bmFtZSA6PSAiYzMiIH07CgkKCXZhciByZXMgOj0gYzEubWFwIG1hcHRvKGMy LCBjMyk7Cgls
b2coInJlcy0+c2l6ZSgpID0gIiArIHJlcy0+c2l6ZSgpLnRvU3RyaW5nKCkp OwoJCgl2YXIg
Y3Jlc29sdmVkIDo9IGMxLnJlc29sdmUoKTsKCWxvZygiY3Jlc29sdmVkLT5z aXplKCkgPSAi
ICsgY3Jlc29sdmVkLT5zaXplKCkudG9TdHJpbmcoKSk7CgkKCXZhciByZXN1 bHRzZXQgOj0g
Y3Jlc29sdmVkLm9jbEFzVHlwZShTZXQoQ2xhc3MpKTsKCWxvZygicmVzdWx0 c2V0LT5zaXpl
KCkgPSAiICsgcmVzdWx0c2V0LT5zaXplKCkudG9TdHJpbmcoKSk7CgoJcmVz dWx0c2V0LT5m
b3JFYWNoKGMpCgl7CgkJbG9nKCJpbiByZXN1bHRzZXQgOiAiICsgYy5uYW1l KTsKCX07Cn0K
CgptYXBwaW5nIENsYXNzOjptYXB0byhjMiA6IENsYXNzLCBjMyA6IENsYXNz KSA6IFNldChD
bGFzcykKewoJaW5pdAoJewoJCS8vIFRoaXMgd2F5IGl0IGdpdmVzIHRoZSBl eHBlY3RlZCBy
ZXN1bHRzCgkJLy9yZXN1bHQgOj0gU2V0eyBjMiwgYzN9OwoJCQoJCXJlc3Vs dCA6PSBTZXR7
fTsKCX0KCQoJcmVzdWx0ICs9IGMyOwoJcmVzdWx0ICs9IGMzOwoJCglsb2co IlttYXB0b10g
cmVzdWx0LT5zaXplKCkgPSAiICsgcmVzdWx0LT5zaXplKCkudG9TdHJpbmco KSk7CglyZXN1
bHQtPmZvckVhY2goYykKCXsKCQlsb2coIlttYXB0b10gaW4gcmVzdWx0IDog IiArIGMubmFt
ZSk7Cgl9Cn0=
--------------010609080201040201080806--
Re: [QVTO] mapping to a set, adding to result does not work [message #500350 is a reply to message #500227] Wed, 25 November 2009 17:46 Go to previous message
Eclipse UserFriend
Originally posted by: dvorak.radek.gmail.com

Hi Tony,

Which version of QVTO do you use? It works for me.
However, it's not correct ;)

After the init section, the result variable should be already assigned and
that value has already been used in the trace record.

You should do that in the init section.

Note, Set is actually immutable OCL type, so result += obj is mapped as
creating
a new Set with the original elements including the new one and this is
assigned to the
result variable.

Regards,
/Radek


On Wed, 25 Nov 2009 13:42:11 +0100, Tony Van Beers <vanbeerst@gmail.com>
wrote:

> Hi,
>
> I'm having trouble mapping a class to a set of classes that already
> exist. The problem is that when I initialize result as an empty set and
> then try to add elements to the set, those elements aren't really added.
> When I put the elements in the set in the init - section everything
> works fine.
>
> Is this a bug, or is this expected behaviour?
>
> In attachment you'll find a toy example which shows what I mean. In the
> init section of the mapping operation there is a line commented out.
> When you uncomment that line, you'll get the results I expect / want.
>
> Dear regards,
> Tony.
Previous Topic:[QVTo] Unrecognized variable
Next Topic:[QVTO] Can QVTO handle ecore models with extended metadata?
Goto Forum:
  


Current Time: Sat Sep 21 20:19:55 GMT 2019

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

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

Back to the top