Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Problem with simple ATL transformation
Problem with simple ATL transformation [message #1735070] Wed, 15 June 2016 09:37 Go to next message
Michele Guerriero is currently offline Michele GuerrieroFriend
Messages: 6
Registered: June 2016
Junior Member
Hi all, I'm trying to run an ATL transformation compiled with EMFTVM. The transformation code is the following:

module Composed2Simple;
create OUT : Simple from IN : Composed;

rule Composed2Simple {
	from
		composed : Composed!Department
	to 
		simple : Simple!DepartmentSimple (
			hasSubject <- composed.hasProfessor -> collect(prof | prof.hasSubject -> collect(sub | thisModule.getSubject(sub)))

		)
}

lazy rule getSubject{
	from
		compSub : Composed!Subject
	to
		simSub : Simple!SimpleSubject(
			id <- compSub.name
		)
}


When I run the transformation I get the following error:

org.eclipse.m2m.atl.emftvm.util.VMException: java.lang.ClassCastException: org.eclipse.m2m.atl.emftvm.util.LazyList$7 cannot be cast to org.eclipse.emf.ecore.EObject
at rule Composed2Simple@applier#6(platform:/resource//ATLauncher/transformations/Composed2Simple.atl#[13:4-13:119])
	Local variables: [__trace__: TRACE!TraceLink = c260a8a:TRACE!TraceLink, composed: Composed!Department = testDep:Composed!Department, simple: Simple!DepartmentSimple = 560cfc60:Simple!DepartmentSimple]
at static EMFTVM!ExecEnv::main() : Object(platform:/resource//ATLauncher/transformations/Composed2Simple.atl)
	Local variables: []


I think I'm doing something wrong in the 2 nested collect, but I cannot understand what.

Thanks a lot in advance for any help.

Michele Guerriero
Re: Problem with simple ATL transformation [message #1735532 is a reply to message #1735070] Mon, 20 June 2016 20:16 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 350
Registered: September 2012
Location: Belgium
Senior Member

That's a very ugly error message for trying to assign a collection of collections to a many-valued property: EMFTVM assumes you assign a collection of model elements, so the cast of the collection elements goes wrong. The solution is to add
->flatten()
at the end of your expression like this:
hasSubject <- composed.hasProfessor -> collect(prof | prof.hasSubject -> collect(sub | thisModule.getSubject(sub)))->flatten()


I've created Bug # 496434 for this.


Cheers,
Dennis
Previous Topic:How to add a GMF diagram to the output model
Next Topic:2 models to model transformation
Goto Forum:
  


Current Time: Sat Sep 23 00:25:35 GMT 2017

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

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