Skip to main content



      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 12:17 Go to next message
Eclipse UserFriend
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 17: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 04:57 Go to previous message
Eclipse UserFriend
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: Wed Apr 30 08:31:19 EDT 2025

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

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

Back to the top