Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Generating random values, etc.
Generating random values, etc. [message #1696092] Thu, 21 May 2015 16:01 Go to next message
Peter Johnsen is currently offline Peter JohnsenFriend
Messages: 60
Registered: January 2012
Member
Hi,

A quick question: is there a way to generate random number values or random strings in ATL? Or, invoke an imported Java method?

Also, if I have a source and target metamodel with classes that are identical - is it a shortcut for transferring objects of the source classes to the target classes without creating rules for each class?

Thanks!
Re: Generating random values, etc. [message #1696119 is a reply to message #1696092] Fri, 22 May 2015 06:57 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

Those are two quick questions Wink.

1.a. In regular ATL, it is only possible to invoke EOperations specified in the metamodel. You will have to generate Java code from your Ecore metamodel, and implement the EOperation in Java. Things like random numbers will have to be programmed in Java as well.

1.b. In the new EMFTVM, you can invoke any Java method. For example, you can generate unique UUIDs for each object like this:
--- Returns a random UUID for the given object.
helper context OclAny def : randomUUID : String =
	"#native"!"java::util::UUID".refInvokeStaticOperation('randomUUID', Sequence{}).toString();


2. Implicit "copying" is supported through refining mode. Refining mode requires input and output metamodels to be the same. The current implementation of refining mode does not actually copy elements, but performs in-place transformation on the input model.


Cheers,
Dennis
Re: Generating random values, etc. [message #1696121 is a reply to message #1696119] Fri, 22 May 2015 07:29 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

I've added a short section on native Java method invocation in EMFTVM on the wiki: https://wiki.eclipse.org/ATL/EMFTVM#Invoking_native_Java_methods

Cheers,
Dennis
[SOLVED] Re: Generating random values, etc. [message #1696776 is a reply to message #1696121] Thu, 28 May 2015 13:56 Go to previous message
Peter Johnsen is currently offline Peter JohnsenFriend
Messages: 60
Registered: January 2012
Member
Thanks very much to both of you. You have been most helpful! Smile
Previous Topic:Create a copy of an output-pattern-element
Next Topic:Drools Meta Model
Goto Forum:
  


Current Time: Fri Mar 29 01:44:45 GMT 2024

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

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

Back to the top