I'm new to ATL and OCL and I'm trying to transform this metamodel:enter image description here

into this one:enter image description here

The helper is meant to take all the tests created by the user admin and after that sum the id's of the Actions of that test.
I've done this helper:

helper def: actionsId: Integer=Test!Test.allInstances()->select(i | i.md.user='admin')->collect(n | n.act.id.toInteger())->sum();

But when I run the transformation I'm having this error:

org.eclipse.m2m.atl.engine.emfvm.VMException: Collections do not have properties, use ->collect()

This error is in the collect(n | n.act.id.toInteger()) part of the helper.

The rest of my code is this:

rule Testset2Testcase{from s: Test!Testto r: Testcase!Testcase(ident <- thisModule.actionId.toString(),date <- s.md.date,act <- thisModule.resolveTemp(s.act,'a'))do{'Bukatuta'.println(); }}rule Action2Activity{from s: Test!Actionto a: Testcase!Activity(ident <- s.id )}

Sorry for my bad english.

  • are You read 'atl' tag description?– Jacek CzMay 21 at 8:28
  • I've read it now, sorry I thought it was about the ATL transformation language. I'll change it.– Mikel MolinuevoMay 21 at 8:50

My teacher helped me with this.
The problem was in the helper.
Doing this:

helper def: actionsId: Integer=Test!Test.allInstances()->select(i | i.md.user='admin')->collect(n | n.act.id.toInteger())->sum();

I was trying to take the id of a collection of collections of the type Action instead of taking the id of each objects.

With that helper I was taking a collection of collections so using flattener this collection of collections became a collection of Actions.

The helper written in a correct way looks like this:

helper def: actionsId: Integer=Test!Test.allInstances()->select(i | i.md.user='admin')->collect(n | n.act)->flatten()->collect(x | x.id.toInteger())->sum();

    Your expression looks plausible, but without your metamodel it is difficult to see where ATL is unhappy about use of a Collection property. If Test::md is a collection, the expression would just be stupid, though not for the reason given.

    If ATL's hovertext doesn't help you understand your types, you might enter the same expression into the OCL Xtext Console and carefully hover over "." and "md" to get its accurate type analysis.

    But beware, ATL has an independently developed embedded OCL that is not as rich as Eclipse OCL. Perhaps your expression is too complex for ATL; try breaking it up with let's.

    • The metamodels are in the link. Test::md is made to check if the user attribute from Metadata equals 'admin'.– Mikel MolinuevoMay 21 at 8:51
    • I don't have any tooling that can load metamodels from image files. A zipped project is more useable.– Ed WillinkMay 21 at 12:23
    • I found the mistake– Mikel MolinuevoMay 21 at 13:53

    Your Answer

    By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

    Not the answer you're looking for? Browse other questions tagged or ask your own question.