Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Getting value of an Attribute with reference to EAttribute metaclass
[ATL] Getting value of an Attribute with reference to EAttribute metaclass [message #70048] Thu, 20 December 2007 17:17 Go to next message
José Carlos Herrero is currently offline José Carlos HerreroFriend
Messages: 5
Registered: July 2009
Junior Member
Hi everyone,

I am developing a model synchronizer. I am using EMF Compare and ATL.
The problem I have is that EMF Compare metamodel has an attribute named
"attribute", it is a reference to EAttribute metaclass. The ATL compiler
raises ClassCastException because the type of attribute is EAttribute
instead of EClass.

Any ideas?

Thanks.
Re: [ATL] Getting value of an Attribute with reference to EAttribute metaclass [message #70088 is a reply to message #70048] Thu, 20 December 2007 22:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

José,

I guess you mean the "attribute" EReference of type "EAttribute" in the
diff.ecore model?

<eClassifiers xsi:type="ecore:EClass" name="AttributeChange"
eSuperTypes="#//DiffElement">
<eStructuralFeatures xsi:type="ecore:EReference" name="attribute"
eType="ecore:EClass
platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E Attribute "/>

This feature is an EReference and it references the EAttribute EClass of
the Ecore model itself. So this should properly be an EClass that can
be cast to EClass. Maybe there's more going on than meets the eye...


José Carlos Herrero wrote:
> Hi everyone,
>
> I am developing a model synchronizer. I am using EMF Compare and ATL.
> The problem I have is that EMF Compare metamodel has an attribute
> named "attribute", it is a reference to EAttribute metaclass. The ATL
> compiler raises ClassCastException because the type of attribute is
> EAttribute instead of EClass.
>
> Any ideas?
>
> Thanks.
Re: [ATL] Getting value of an Attribute with reference to EAttribute metaclass [message #70128 is a reply to message #70088] Fri, 21 December 2007 09:57 Go to previous message
José Carlos Herrero is currently offline José Carlos HerreroFriend
Messages: 5
Registered: July 2009
Junior Member
Hi Ed,

As you said, this is the exact problem. I have studied it and it seems
to be an unhandled case in the Ecore Implementation.

In the class org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.java the
following code tests if the type of EStructuralFeature is EClass. This
is correct in case we are handling the Ecore model, but if we handle low
level models (like Diff.ecore) with an attribute that is a direct
reference to high level model, then the type isn't anymore EClass.

public Object dynamicGet(...
....
if (!eClass.isInstance(resolvedEObject)) {
throw new ClassCastException...
}
....

I have done a small modification in the above code and apparently EMF
handles it correctly. Here is the modification:

....
if (!eClass.isInstance(resolvedEObject) &&
!(resolvedEObject instanceof EAttribute))
....

What do you think?

Thanks.


Ed Merks escribió:
> José,
>
> I guess you mean the "attribute" EReference of type "EAttribute" in the
> diff.ecore model?
>
> <eClassifiers xsi:type="ecore:EClass" name="AttributeChange"
> eSuperTypes="#//DiffElement">
> <eStructuralFeatures xsi:type="ecore:EReference" name="attribute"
> eType="ecore:EClass
> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E Attribute "/>
>
> This feature is an EReference and it references the EAttribute EClass of
> the Ecore model itself. So this should properly be an EClass that can
> be cast to EClass. Maybe there's more going on than meets the eye...
>
>
> José Carlos Herrero wrote:
>> Hi everyone,
>>
>> I am developing a model synchronizer. I am using EMF Compare and ATL.
>> The problem I have is that EMF Compare metamodel has an attribute
>> named "attribute", it is a reference to EAttribute metaclass. The ATL
>> compiler raises ClassCastException because the type of attribute is
>> EAttribute instead of EClass.
>>
>> Any ideas?
>>
>> Thanks.
Previous Topic:Can I use foreach in called rules?
Next Topic:[ATL] How to know if an attribute is cross reference.
Goto Forum:
  


Current Time: Tue May 11 23:51:46 GMT 2021

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

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

Back to the top