Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » output structured model by called rules
output structured model by called rules [message #1005562] Sat, 26 January 2013 17:33 Go to next message
Alessandro Ranieri is currently offline Alessandro Ranieri
Messages: 16
Registered: November 2012
Junior Member
Hello,

I want to know what is, for you, the best approach to my kind of problem:

I have to map an input element on an output element, but the latter has an internal structure such that i have to create other elements to complete the trasformation.

My first idea is to create the element of output model and then to invoke a called rule to create the nested elements.

Unfortunately performing this approach I encountered an error. For example:

rule process(stateMac : UML!StateMachine, component : UML!Class ){
	to
		process : PROMELA!process
		(			
			name <- component.name,	
			mainLoop <- loop
		),
		loop : PROMELA!loop
		(			
			cases <- stateMac.region.first().subvertex->collect( v | thisModule.createStateCond(v.name) ) 
		)
}


rule createStateCond( state : String )
{
	to
	        cond : PROMELA!condition
		(
			statement <- 'state == '.concat(state)
		)	
}




This example gave me the error:

org.eclipse.m2m.atl.engine.emfvm.VMException: Operation not found: vvp2promela : ASMModule.including(java.util.ArrayList)
	at process#41(vvp2promela.atl[130:13-130:97])
		local variables: self=vvp2promela : ASMModule, stateMac=TSR!TSR_Sm, component=TSR!TSR, states=Sequence {}, process=TSRPRO!TSR, loop=TSRPRO!<unnamed>, v=TSR!Initial0
	at __applystatesTransitions2enumeration#105(vvp2promela.atl[101:3-101:43])
		local variables: self=vvp2promela : ASMModule, link=TransientLink {rule = statesTransitions2enumeration, sourceElements = {stateMac = org.eclipse.uml2.uml.internal.impl.StateMachineImpl@1fb3806 (name: TSR_Sm, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false) (isReentrant: false), component = org.eclipse.uml2.uml.internal.impl.ClassImpl@1a85206 (name: TSR, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)}, targetElements = {state_enum = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1615705 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1766c97 (name: mtypeEnumeration) (instanceClassName: null) (abstract: false, interface: false)), transition_enum = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1981f83 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1766c97 (name: mtypeEnumeration) (instanceClassName: null) (abstract: false, interface: false))}, variables = {}}, component=TSR!TSR, stateMac=TSR!TSR_Sm, state_enum=TSRPRO!state, transition_enum=TSRPRO!transition
	at __exec__#18(vvp2promela.atl)
		local variables: self=vvp2promela : ASMModule, e=TransientLink {rule = statesTransitions2enumeration, sourceElements = {stateMac = org.eclipse.uml2.uml.internal.impl.StateMachineImpl@1fb3806 (name: TSR_Sm, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false) (isReentrant: false), component = org.eclipse.uml2.uml.internal.impl.ClassImpl@1a85206 (name: TSR, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)}, targetElements = {state_enum = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1615705 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1766c97 (name: mtypeEnumeration) (instanceClassName: null) (abstract: false, interface: false)), transition_enum = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1981f83 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1766c97 (name: mtypeEnumeration) (instanceClassName: null) (abstract: false, interface: false))}, variables = {}}
	at main#26(vvp2promela.atl)
		local variables: self=vvp2promela : ASMModule




Thanks in advance for the help!

Alessandro

[Updated on: Sat, 26 January 2013 18:55]

Report message to a moderator

Re: output structured model with called rules [message #1005584 is a reply to message #1005562] Sat, 26 January 2013 19:41 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis Wagelaar
Messages: 166
Registered: September 2012
Senior Member

Op 26/01/13 18:33, Alessandro Ranieri schreef:
> Hello,
>
> I want to know what is, for you, the best approach to my kind of problem:
>
> I have to map a input an element on an output element, but the latter has an
> internal structure such that i have to create other elements to complete the
> trasformation.
>
> My first idea is to create the element of output model and then to invoke a
> called rule to create the nested elements.
> Unfortunately performing this approach I encountered an error. For example:
>
>
> rule process(stateMac : UML!StateMachine, component : UML!Class ){
> to
> process : PROMELA!process
> (
> name <- component.name,
> mainLoop <- loop
> ),
> loop : PROMELA!loop
> (
> cases <- stateMac.region.first().subvertex->collect( v |
> thisModule.createStateCond(v.name) ) )
> }
>
>
> rule createStateCond( state : String )
> {
> to
> cond : PROMELA!condition
> (
> statement <- 'state == '.concat(state)
> )
> }

I recall a question similar to yours coming up in the newsgroups before, where
another user was also trying to program his/her own model traversal strategy.
This is not how to use ATL by default.

ATL has something called the "implicit tracing mechanism", which works only on
matched rules
(http://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Language#Matched_Rules).
This means that whenever you use the binding operator ('<-'), the right-hand
value is first checked against the transformation traces to see if the value
got transformed. I yes, the right-hand value is implicitly replaced by its
transformation result before being assigned.

Unfortunately, I found no good documentation on this on the ATL wiki(!). The
Class2Relational example is missing. Normally, Open Model Course Ware has this
tutorial (http://www.eclipse.org/gmt/omcw/), but it appears to have been
removed(?).

In any case, your specific transformation would follow this skeleton:

rule StateMachineToProcess
{
from
stateMac : UML!StateMachine
using {
component : UML!Class = stateMac...;
}
to
process : PROMELA!process
(
name <- component.name,
mainLoop <- loop
),
loop : PROMELA!loop
(
cases <- stateMac.region.first().subvertex
)
}


rule StateToCondition
{
from
state : UML!State
to
cond : PROMELA!condition
(
statement <- 'state == ' + state.toString()
)
}

In this transformation, stateMac.region.first().subvertex is automatically
translated from a collection of UML!State to a collection of
PROMELA!condition, because of the traces generated by the StateToCondition rule.

Regards,
Dennis


Cheers,
Dennis
Re: output structured model with called rules [message #1005585 is a reply to message #1005584] Sat, 26 January 2013 19:45 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis Wagelaar
Messages: 166
Registered: September 2012
Senior Member

Op 26/01/13 20:41, Dennis Wagelaar schreef:
> Unfortunately, I found no good documentation on this on the ATL wiki(!). The
> Class2Relational example is missing. Normally, Open Model Course Ware has this
> tutorial (http://www.eclipse.org/gmt/omcw/), but it appears to have been
> removed(?).

Correction: it's still there:

http://www.eclipse.org/gmt/omcw/resources/chapter10/downloads/ATLpresentation.INRIA.ppt

Dennis


Cheers,
Dennis
Re: output structured model with called rules [message #1005601 is a reply to message #1005585] Sun, 27 January 2013 09:39 Go to previous messageGo to next message
Alessandro Ranieri is currently offline Alessandro Ranieri
Messages: 16
Registered: November 2012
Junior Member
Thanks a lot, it is illuminating, but I'm a bit dissappointed that ATL documentation doesn't give the right emphasis to this feature.



Re: output structured model with called rules [message #1006971 is a reply to message #1005601] Sun, 03 February 2013 11:27 Go to previous messageGo to next message
Alessandro Ranieri is currently offline Alessandro Ranieri
Messages: 16
Registered: November 2012
Junior Member

I see the example List Metamodel Refactoring, but still I don't find a more complex case when the target pattern is made of several elements. In this case how can I refere to a precise element of the output pattern? Have to use the resolveTemp method?

Thanks again,

Alessandro R.
Re: output structured model with called rules [message #1007180 is a reply to message #1006971] Mon, 04 February 2013 19:21 Go to previous message
Dennis Wagelaar is currently offline Dennis Wagelaar
Messages: 166
Registered: September 2012
Senior Member

Op 03-02-13 12:27, Alessandro Ranieri schreef:
>
> I see the example
> http://www.eclipse.org/atl/documentation/basicExamples_Patterns/article.php?file=ListMetamodelRefactoring/index.html,
> but still I don't find a more complex case when the target pattern is made of
> several elements. In this case how can I refere to a precise element of the
> output pattern? Have to use the resolveTemp method?
> Thanks again,
>
> Alessandro R.

Indeed. thisModule.resolveTemp(sourceElement, 'targetElementName').

Dennis


Cheers,
Dennis
Previous Topic:Runtime exception handling?
Next Topic:Replace input ecore model by code
Goto Forum:
  


Current Time: Tue Oct 21 02:23:23 GMT 2014

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

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