Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » how generate string from a Sequence of Tuple
how generate string from a Sequence of Tuple [message #734859] Mon, 10 October 2011 08:19 Go to next message
Fi Fi is currently offline Fi Fi
Messages: 133
Registered: March 2010
Senior Member
I 'd generate from a Sequence of tuples a String
I try with this code
helper def : getinstancesname (instancesequence:Sequence (TupleType(position: Integer , instances : MetaModel!Instance))) : String =

	instancesequence->iterate(t; y : String = 'a' |y+t.position.toString()+t.instance.name)



but that generate an Exception when I run Sad

please help me
thanks

[Updated on: Mon, 10 October 2011 08:33]

Report message to a moderator

Re: how generate string from a Sequence of Tuple [message #735027 is a reply to message #734859] Mon, 10 October 2011 16:23 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
Hi

From an OCL perspective 'TupleType' should be Tuple, but perhaps ATL
allows it.

'instances' and 'instance' are spelled differently; but perhaps that is
a type.

You don't give us any clue as to the Exception; there shouldn't be one;
but perhaps ATL throws an Exception for invalid which could arise if any
element of the instancesequence or any field of the tuple is null.

Regards

Ed Willink

On 10/10/2011 09:19, ZALILA Faiez wrote:
> I 'd generate from a Sequence of tuples a String
> I try with this code
> helper def : getinstancesname (instancesequence:Sequence
> (TupleType(position: Integer , instances : MetaModel!Instance))) :
> String =
>
> instancesequence->iterate(t; y : String = 'a'
> |y+t.position.toString()+t.instance.name)
>
>
>
> but that generate an Exception when I run Sad
>
> please help me
> thanks
Re: how generate string from a Sequence of Tuple [message #735176 is a reply to message #735027] Tue, 11 October 2011 07:23 Go to previous messageGo to next message
Fi Fi is currently offline Fi Fi
Messages: 133
Registered: March 2010
Senior Member
Hi
I change the helper with the other attribute "position"
helper def : getinstancesname (instancesequence:Sequence (TupleType(position: Integer , instances : FiacreMetaModel!Instance))) : String =

	instancesequence->iterate(t; y : String = 'a' |y+t.position.toString())

but that is the same exception
Quote:

org.eclipse.m2m.atl.engine.emfvm.VMException
at getinstancesname#8(Instancie2Lie.atl[872:51-872:72])
local variables: self=Instancie2Lie : ASMModule, instancesequence=Sequence {Tuple {p = 1, i = FiacreModel!org.eclipse.emf.ecore.impl.DynamicEObjectImpl@2504e1f (eClass: org.eclipse.emf.ecore.impl.EClassImpl@15596774 (name: Name) (instanceClassName: null) (abstract: false, interface: false))}, Tuple {p = 1, i = FiacreModel!org.eclipse.emf.ecore.impl.DynamicEObjectImpl@6638d668 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@15596774 (name: Name) (instanceClassName: null) (abstract: false, interface: false))}, Tuple {p = 1, i = FiacreModel!org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1d847a46 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@15596774 (name: Name) (instanceClassName: null) (abstract: false, interface: false))}, Tuple {p = 1, i = FiacreModel!org.eclipse.emf.ecore.impl.DynamicEObjectImpl@647798cd (eClass: org.eclipse.emf.ecore.impl.EClassImpl@15596774 (name: Name) (instanceClassName: null) (abstract: false, interface: false))}, Tuple {p = 1, i = FiacreModel!org.eclipse.emf.ecore.impl.DynamicEObjectImpl@67d0ee42 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@15596774 (name: Name) (instanceClassName: null) (abstract: false, interface: false))}, Tuple {p = 1, i = FiacreModel!org.eclipse.emf.ecore.impl.DynamicEObjectImpl@45ca644d (eClass: org.eclipse.emf.ecore.impl.EClassImpl@15596774 (name: Name) (instanceClassName: null) (abstract: false, interface: false))}, Tuple {p = 1, i = FiacreModel!org.eclipse.emf.ecore.impl.DynamicEObjectImpl@6a7f1f06 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@15596774 (name: Name) (instanceClassName: null) (abstract: false, interface: false))}, Tuple {p = 1, i = FiacreModel!org.eclipse.emf.ecore.impl.DynamicEObjectImpl@3fcdf989 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@15596774 (name: Name) (instanceClassName: null) (abstract: false, interface: false))}, Tuple {p = 1, i = FiacreModel!org.eclipse.emf.ecore.impl.DynamicEObjectImpl@6bb9b218 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@15596774 (name: Name) (instanceClassName: null) (abstract: false, interface: false))}}, y='a', t=Tuple {p = 1, i = FiacreModel!org.eclipse.emf.ecore.impl.DynamicEObjectImpl@2504e1f (eClass: org.eclipse.emf.ecore.impl.EClassImpl@15596774 (name: Name) (instanceClassName: null) (abstract: false, interface: false))}
at __applyTransition2Transition#60(Instancie2Lie.atl[484:11-484:142])
local variables: self=Instancie2Lie : ASMModule, link=TransientLink {rule = Transition2Transition, sourceElements = {transition_ins = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@76c6415a (eClass: org.eclipse.emf.ecore.impl.EClassImpl@68f35bd3 (name: Transition) (instanceClassName: null) (abstract: false, interface: false))}, targetElements = {transition_lie = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@2a42895e (eClass: org.eclipse.emf.ecore.impl.EClassImpl@45e83537 (name: Transition) (instanceClassName: null) (abstract: false, interface: false))}, variables = {}}, transition_ins=InstancieModel!<unnamed>, transition_lie=LieModel!<unnamed>
at __exec__#528(Instancie2Lie.atl)
local variables: self=Instancie2Lie : ASMModule, e=TransientLink {rule = Transition2Transition, sourceElements = {transition_ins = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@76c6415a (eClass: org.eclipse.emf.ecore.impl.EClassImpl@68f35bd3 (name: Transition) (instanceClassName: null) (abstract: false, interface: false))}, targetElements = {transition_lie = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@2a42895e (eClass: org.eclipse.emf.ecore.impl.EClassImpl@45e83537 (name: Transition) (instanceClassName: null) (abstract: false, interface: false))}, variables = {}}
at main#24(Instancie2Lie.atl)
local variables: self=Instancie2Lie : ASMModule
Java Stack:
org.eclipse.m2m.atl.engine.emfvm.VMException
at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:643)
at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:388)
at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:388)
at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:388)
at org.eclipse.m2m.atl.engine.emfvm.ASM.run(ASM.java:208)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.internalLaunch(EMFVMLauncher.java:170)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMUILauncher.launch(EMFVMUILauncher.java:46)
at org.eclipse.m2m.atl.core.service.LauncherService.launch(LauncherService.java:136)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launchOrDebug(AtlLaunchConfigurationDelegate.java:300)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:237)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:702)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:923)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1126)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NullPointerException


I 'd know how to navigate in a tuple
thanks
Re: how generate string from a Sequence of Tuple [message #735386 is a reply to message #735176] Tue, 11 October 2011 16:13 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARD
Messages: 522
Registered: July 2009
Senior Member
By looking at the logs, it seems your Tuple is Tuple (p,i) and not TupleType(position, instances)
Re: how generate string from a Sequence of Tuple [message #736114 is a reply to message #735386] Thu, 13 October 2011 15:49 Go to previous message
Fi Fi is currently offline Fi Fi
Messages: 133
Registered: March 2010
Senior Member
Thanks Sylvain Smile
right
Previous Topic:[ATL] Complete Documentation for the ATL Metamodel
Next Topic:[QVTO] Any way to speed up transformation?
Goto Forum:
  


Current Time: Sat Sep 20 22:19:18 GMT 2014

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

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