Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Issue with assignment of a String
Issue with assignment of a String [message #1844024] Fri, 27 August 2021 16:41 Go to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 146
Registered: July 2014
Senior Member
Hi all,

I've to write a transformation where the input metamodel is UML and the output one is an Ecore metamodel (TGTMM)

At the time being, in this transformation I just have this simple rule:

module MyModule;

create OUT: TGTMM from IN: UML;

rule fromClass {

from src: UML!Class

to tgt: TGTMM!TClass (name <- src.name)
}

When I try to execute this transformation on a simple model I get the following error:

org.eclipse.m2m.atl.emftvm.util.VMException: java.lang.ClassCastException: The value of type 'class java.lang.String' must be of type 'org.eclipse.emf.ecore.impl.EDataTypeImpl@12b5b511 (eProxyURI: platform:/resource/org.eclipse.uml2.types/model/Types.ecore#//String)'

If, in the assignment, I replace src.name by a constant string (e.g. 'myname'), I get the same. If I remove the assignment completely. The transformation runs without error.

Note: in the TGTMM.ecore file, which is generated by Eclipse from an UML file the attribute "name of TClass has the type: java.lang.String, which it a bit surprising to me.

How can I fix that?

Yves


Yves
Re: Issue with assignment of a String [message #1844029 is a reply to message #1844024] Sat, 28 August 2021 10:03 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

This is an exception thrown by EMF; you'll have to run the transformation in a Java debugger to see what is going on. Alternatively, you can attach a POC Eclipse project here for me to reproduce your problem.

Cheers,
Dennis
Re: Issue with assignment of a String [message #1844077 is a reply to message #1844029] Tue, 31 August 2021 11:58 Go to previous messageGo to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 146
Registered: July 2014
Senior Member
Hello Dennis,

Thanks for your proposal.

Here is a couple of files that illustrate the issue on a simplified case.

Edited: my sample model (M000.uml) could be useful as well, I have added it.
  • Attachment: TGTMM2UML.atl
    (Size: 0.25KB, Downloaded 48 times)
  • Attachment: TGTMM.ecore
    (Size: 2.43KB, Downloaded 41 times)
  • Attachment: types.ecore
    (Size: 2.11KB, Downloaded 40 times)
  • Attachment: M000.uml
    (Size: 1.12KB, Downloaded 47 times)


Yves

[Updated on: Tue, 31 August 2021 16:03]

Report message to a moderator

Re: Issue with assignment of a String [message #1844118 is a reply to message #1844077] Wed, 01 September 2021 21:06 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

The problem lies in the reference to Types.ecore in TGTMM.ecore: this refers to another Eclipse project "org.eclipse.uml2.types":

        <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false"
            eType="ecore:EDataType ../org.eclipse.uml2.types/model/Types.ecore#//String"/>


The exception is thrown if EMF cannot resolve the reference to the EDataType, so it doesn't known that its instanceClass is java.lang.String. You've included "types.ecore", and if I reference that file directly, the transformation works:

        <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" ordered="false"
            eType="ecore:EDataType types.ecore#//String"/>


However, you say that TGTMM.ecore was generated from UML. I'm surprised that a "platform:/resource/..." type of reference is generated, which is a workspace resource (e.g. Eclipse project), instead of "http://www.eclipse.org/uml2/5.0.0/Types", which is a globally registered EMF resource.

I tried out generating my own Ecore model from M000.uml, and found that it also generates the "types.ecore" model, and includes a direct reference to it:

      <eStructuralFeatures xsi:type="ecore:EAttribute" name="p2" ordered="false" eType="ecore:EDataType types.ecore#//Integer"/>


so it's not trying to navigate to another Eclipse project first. Somehow, you must have changed TGTMM.ecore after it was generated...?


Cheers,
Dennis
Re: Issue with assignment of a String [message #1844152 is a reply to message #1844118] Fri, 03 September 2021 09:30 Go to previous message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 146
Registered: July 2014
Senior Member
Hi Denis,
Thanks for your time in investigating this.

The TGTMM model is just a small extract of the (bigger) model on which I'm actually working. I created it for the sake of this exchange. But actually, I did edit the generated file but the purpose was to change the package name only. However I should have done something else by inadvertence because the problem has disappear with the new version of the generated file, despite the name change that I did as well.

Checking the generated ecore file, I confirm that the reference to the type is actually made as you describe.

So, I cannot explain what happened with my previous generated model but in any case it looks fine now.

Thank you again.
Yves


Yves
Previous Topic:ATL to ATL transformation: Order of source elements is getting changed in the output transformation
Next Topic:References to enumerations defined in a profile
Goto Forum:
  


Current Time: Sat Nov 11 08:17:26 GMT 2023

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

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

Back to the top