Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Accessing Data Type Converters(How to create an EDataType instance that is a "Java Long")
icon5.gif  Accessing Data Type Converters [message #986426] Tue, 20 November 2012 11:47 Go to next message
Jörn Guy Süß is currently offline Jörn Guy SüßFriend
Messages: 320
Registered: July 2009
Location: Anstead, Brisbane, Queens...
Senior Member

I have an ecore metamodel that defines an EDatatype 'Integer', whose underlying type is a primitive java long. I need to create an instance of this datatype in ATL. The assignment below:

range: UML!MultiplicityRange (
	lower <- 1,
	upper <- -1
)


provokes the following error:

org.eclipse.m2m.atl.engine.emfvm.VMException: java.lang.Integer cannot be cast to java.lang.Long


I believe that I have to call the type conversion or constructor explicitly, but could not find anything in the syntax that allows me to do this.

[Updated on: Tue, 20 November 2012 11:47]

Report message to a moderator

Re: Accessing Data Type Converters [message #986436 is a reply to message #986426] Tue, 20 November 2012 12:18 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
Hello,

Negative numbers have to be declared using the "-" binary operator (http://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Language#Numerical_data_type_operations).
So the correct syntax in ATL is:
upper <- 0-1

Hugo


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: Accessing Data Type Converters [message #986555 is a reply to message #986436] Tue, 20 November 2012 22:20 Go to previous messageGo to next message
Jörn Guy Süß is currently offline Jörn Guy SüßFriend
Messages: 320
Registered: July 2009
Location: Anstead, Brisbane, Queens...
Senior Member

Thanks for this advice, however, the error is raised on the first line. Sorry, I should have made that clear in the test case. Again: How do I declare a value to be a java long, so the type cast error does not occur?
Re: Accessing Data Type Converters [message #986585 is a reply to message #986555] Wed, 21 November 2012 05:10 Go to previous messageGo to next message
Jörn Guy Süß is currently offline Jörn Guy SüßFriend
Messages: 320
Registered: July 2009
Location: Anstead, Brisbane, Queens...
Senior Member

I should point out that this is a special case where a transformation needs to set a feature of a user-defined EDatatype, whose value is created by a data type conversion from a string. This should be a fairly common operation, and has also been present via reflection in JMI. If this does not exist, the use of ATL is limited quite substantially, w.r.t. practical models (where custom datatypes are common).
Re: Accessing Data Type Converters [message #986641 is a reply to message #986585] Wed, 21 November 2012 09:41 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
I don't know if this will help you to solve your particular problem but ATL allows to invoke operations defined within your metamodel when required, either directly or by calling them via the refInvokeOperation(opName : String, args : Sequence) operation.
Anyway, the current version of ATL only supports 4 primitive data types.

Hugo


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: Accessing Data Type Converters [message #986656 is a reply to message #986641] Wed, 21 November 2012 10:10 Go to previous messageGo to next message
Jörn Guy Süß is currently offline Jörn Guy SüßFriend
Messages: 320
Registered: July 2009
Location: Anstead, Brisbane, Queens...
Senior Member

Thanks. This is what I had feared. I have no control over the metamodel, and can not add any methods. This seems to imply that ATL is not fit as a general purpose language for Ecore. Sad about the time invested Sad
Re: Accessing Data Type Converters [message #986658 is a reply to message #986656] Wed, 21 November 2012 10:13 Go to previous messageGo to next message
Jörn Guy Süß is currently offline Jörn Guy SüßFriend
Messages: 320
Registered: July 2009
Location: Anstead, Brisbane, Queens...
Senior Member

I also do not believe that this would help, as you would need to add this to every context class you are using. Can I edit the wiki to add this. I really believe this deserves a warning to spare people from disappointment. I have spent about three days learning the language, and now I will have to go back all the way...
Re: Accessing Data Type Converters [message #986701 is a reply to message #986426] Wed, 21 November 2012 11:35 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 82
Registered: June 2012
Member
I'm not sure if that is what you need, but have you tried something like
value <- 1 -> longValue()
Re: Accessing Data Type Converters [message #988760 is a reply to message #986701] Sun, 02 December 2012 22:48 Go to previous messageGo to next message
Jörn Guy Süß is currently offline Jörn Guy SüßFriend
Messages: 320
Registered: July 2009
Location: Anstead, Brisbane, Queens...
Senior Member

Thanks Gunnar, that does not work. I have patched /org.eclipse.m2m.atl.engine.emfvm/src/org/eclipse/m2m/atl/engine/emfvm/adapter/EMFModelAdapter.java:576ff to get it to do the trick, however this is only for longs, as this is what I needed.
@Hugo: do you think such a patch is worth contributing? I also think using the converter should not be too hard, however I do not understand if the weaver code may not be doing something similar, so I am hesitant to 'just hack it in'.
Re: Accessing Data Type Converters [message #988817 is a reply to message #988760] Mon, 03 December 2012 10:36 Go to previous message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
Hello Jörn,

I think it is totally relevant to raise a bug proposing to improve the support for custom datatypes.
I also encourage you to attach to it any patch bringing a concrete (even if partial) solution to that problem.

Best regards,

Hugo


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Previous Topic:does lazy rules from clause works?
Next Topic:Problem ATL
Goto Forum:
  


Current Time: Thu Mar 28 08:11:19 GMT 2024

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

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

Back to the top