Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Annotated Java import issues with EMF 2.9
Annotated Java import issues with EMF 2.9 [message #1236459] Mon, 27 January 2014 09:03 Go to next message
Diego F is currently offline Diego FFriend
Messages: 3
Registered: April 2012
Junior Member
Hi to all,

after switching to EMF 2.9 I cannot correctly generate the Ecore/Genmodel anymore. The produced ecore contains EStructuralFeatures, EReferences and EAttribures as model items instead of referencing the EMF's ecore types.

To generate my model, I use the 'Annotated Java' model import option from the IDE.

The following method:
import org.eclipse.emf.ecore.EStructuralFeature;
...
	/**
	 * @model parameters = "EStructuralFeature"
	 */
	public boolean isDeclarationGroup(EStructuralFeature feature);

was imported into the model's ecore as follows until EMF 2.8
    <eOperations name="isDeclarationGroup" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean">
      <eParameters name="feature" eType="ecore:EClass platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EStructuralFeature"/>
    </eOperations>
    <eOperations name="getDeclarationGroup" eType="#//DeclarationGroup">
      <eParameters name="reference" eType="ecore:EClass platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EReference"/>
    </eOperations>

but since EMF 2.9 produces
    <eOperations name="isDeclarationGroup" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean">
      <eParameters name="feature" eType="#//EStructuralFeature"/>
    </eOperations>
    <eOperations name="getDeclarationGroup" eType="#//DeclarationGroup">
      <eParameters name="reference" eType="#//EReference"/>
    </eOperations>
  ...
  <eClassifiers xsi:type="ecore:EDataType" name="EStructuralFeature" instanceClassName="org.eclipse.emf.ecore.EStructuralFeature"/>
  <eClassifiers xsi:type="ecore:EDataType" name="EAttribute" instanceClassName="org.eclipse.emf.ecore.EAttribute"/>
  <eClassifiers xsi:type="ecore:EDataType" name="EReference" instanceClassName="org.eclipse.emf.ecore.EReference"/>

Opening the ecore and looking at the properties of the method there are two options for the EStructuralFeature: the first as 'EStructuralFeature [org.eclipse.emf.ecore.EStructuralFeature]' while the second one is also marked as ETypedElement (see image below).
index.php/fa/17332/0/
As far as I understood, for some reasons on EMF 2.9 the model importer fails to reference the correct classes from Ecore.ecore model and hence adds them to my model stuff.

I could not find any documentation about changes to EMF's Java Annotation introduced by EMF 2.9 or a migration to EMF 2.9. I've also searched in these forums but I could not find anyone expeciencing similar issues so I guess the problem might be with the annotation I'm providing.
I have also to mention that I've already tried to replace the
@model parameters = "EStructuralFeature"
annotation with the fully qualified name
@model parameters = "org.eclipse.emf.ecore.EStructuralFeature"
but that didn't fix the problem.
I'm pretty pointless on how to fix this issue and any suggestion is welcome.
Thank you in advance

Diego
  • Attachment: EMF_Bug.png
    (Size: 27.76KB, Downloaded 943 times)
Re: Annotated Java import issues with EMF 2.9 [message #1240943 is a reply to message #1236459] Fri, 07 February 2014 08:53 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Diego,

I'm not aware of any changes in 2.9 that would break this. Please open
a bugzilla with a reproducible test case and I'll investigate.
Unfortunately the 2.9 maintenance stream is final now so any fixes might
need to be done for 2.10 instead...


On 27/01/2014 10:03 AM, Diego F wrote:
> Hi to all,
>
> after switching to EMF 2.9 I cannot correctly generate the Ecore/Genmodel anymore. The produced ecore contains EStructuralFeatures, EReferences and EAttribures as model items instead of referencing the EMF's ecore types.
>
> To generate my model, I use the 'Annotated Java' model import option from the IDE.
>
> The following method:
>
> import org.eclipse.emf.ecore.EStructuralFeature;
> ..
> /**
> * @model parameters = "EStructuralFeature"
> */
> public boolean isDeclarationGroup(EStructuralFeature feature);
>
> was imported into the model's ecore as follows until EMF 2.8
>
> <eOperations name="isDeclarationGroup" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean">
> <eParameters name="feature" eType="ecore:EClass platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EStructuralFeature"/>
> </eOperations>
> <eOperations name="getDeclarationGroup" eType="#//DeclarationGroup">
> <eParameters name="reference" eType="ecore:EClass platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EReference"/>
> </eOperations>
>
> but since EMF 2.9 produces
>
> <eOperations name="isDeclarationGroup" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean">
> <eParameters name="feature" eType="#//EStructuralFeature"/>
> </eOperations>
> <eOperations name="getDeclarationGroup" eType="#//DeclarationGroup">
> <eParameters name="reference" eType="#//EReference"/>
> </eOperations>
> ...
> <eClassifiers xsi:type="ecore:EDataType" name="EStructuralFeature" instanceClassName="org.eclipse.emf.ecore.EStructuralFeature"/>
> <eClassifiers xsi:type="ecore:EDataType" name="EAttribute" instanceClassName="org.eclipse.emf.ecore.EAttribute"/>
> <eClassifiers xsi:type="ecore:EDataType" name="EReference" instanceClassName="org.eclipse.emf.ecore.EReference"/>
>
> Opening the ecore and looking at the properties of the method there are two options for the EStructuralFeature: the first as 'EStructuralFeature [org.eclipse.emf.ecore.EStructuralFeature]' while the second one is also marked as ETypedElement (see image below).
>
> As far as I understood, for some reasons on EMF 2.9 the model importer fails to reference the correct classes from Ecore.ecore model and hence adds them to my model stuff.
>
> I could not find any documentation about changes to EMF's Java Annotation introduced by EMF 2.9 or a migration to EMF 2.9. I've also searched in these forums but I could not find anyone expeciencing similar issues so I guess the problem might be with the annotation I'm providing.
> I have also to mention that I've already tried to replace the @model parameters = "EStructuralFeature" annotation with the fully qualified name @model parameters = "org.eclipse.emf.ecore.EStructuralFeature" but that didn't fix the problem.
> I'm pretty pointless on how to fix this issue and any suggestion is welcome.
> Thank you in advance
>
> Diego


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Annotated Java import issues with EMF 2.9 [message #1240994 is a reply to message #1240943] Fri, 07 February 2014 10:10 Go to previous message
Diego F is currently offline Diego FFriend
Messages: 3
Registered: April 2012
Junior Member
Hi Ed,

after a few more tries I managed to get it back working by applying the following changes to the annotation:

1. Always fully qualifing the referenced ecore Objects when used as method parameters. So the following occurences
@model parameters = "EStructuralFeature"
@model parameters = "EReference"
@model parameters = "EAttribute"

have been replaced by
@model parameters = "org.eclipse.emf.ecore.EStructuralFeature"
@model parameters = "org.eclipse.emf.ecore.EReference"
@model parameters = "org.eclipse.emf.ecore.EAttribute"


2. Adding the dataType annotation when ecore model objects are used as method return type.
The following case
/**
 * @model parameters = "String"
 */
public EStructuralFeature getFeature(String typeLabel);

has been updated with following annotation
/**
 * @model dataType="org.eclipse.emf.ecore.EStructuralFeature" parameters = "String"
 */
public EStructuralFeature getFeature(String typeLabel);


Apparently in the previous versions EMF where able to handle the missing dataType annotation and recognized the Ecore objects even when they weren't specified by their fully qualified name.

Diego
Previous Topic:EMF Localization questions
Next Topic:[CDO] CDOCommitInfo History for a particular user in CDO
Goto Forum:
  


Current Time: Tue Apr 16 15:32:58 GMT 2024

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

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

Back to the top