Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Create ecore annotation model and use it in another ecore model
Create ecore annotation model and use it in another ecore model [message #1854804] Mon, 12 September 2022 15:25 Go to next message
Steve Peters is currently offline Steve PetersFriend
Messages: 12
Registered: September 2020
Junior Member
I want use custom annotations for code generation from an ecore model.
For test and demonstration I created two models. The first model should contains
all my annotation and in the second I want assign it to a Package element. But my defined
URI doesn't appear in the list of EAnnotation elements. The models are located in different plugins.
I haven't found any tutorial, documentation or How To for creating stereotypes/annotation in ecore.

Annotation Model:
index.php/fa/42480/0/

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="annotation" nsURI="http://www.example.org/annotation" nsPrefix="annotation">
  <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
    <details key="schemaLocation" value="http://www.example.org/annotation"/>
  </eAnnotations>
  <eClassifiers xsi:type="ecore:EClass" name="Package">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="myname" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>
</ecore:EPackage>


Model:
index.php/fa/42482/0/

But the EAnnontation(http://www.example.org/annotation) doesn't appear in the menu:
index.php/fa/42481/0/

Someone an idea what I'm doing wrong or has somebody an tutorial link?
  • Attachment: anno_model.png
    (Size: 17.10KB, Downloaded 180 times)
  • Attachment: menu2.png
    (Size: 77.75KB, Downloaded 179 times)
  • Attachment: model_anno.png
    (Size: 20.15KB, Downloaded 176 times)
Re: Create ecore annotation model and use it in another ecore model [message #1854809 is a reply to message #1854804] Mon, 12 September 2022 17:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
What appears in the menu is determined by things that are contributing to the org.eclipse.emf.ecore.edit.annotation_item_provider_adapter_factory extension point in addition to finding the EAnnotation.sourceURI of any annotation reachable from the *.ecore that you've loaded. There is no concept of "stereotype" in Ecore. Even the annotation_item_provider_adapter_factory is just an "authoring" convenience. In the end, EAnnotation is just something with a sourceURI and a details string-to-string map. That's it. Any meaning is determined by the consumer of the annotation and that consumer can use the annotation_item_provider_adapter_factory extension point to making authoring easier.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Create ecore annotation model and use it in another ecore model [message #1854810 is a reply to message #1854809] Mon, 12 September 2022 17:45 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
EDITED: EdMerks next comment is much more accurate. org.eclipse.emf.ecore.edit.annotation_item_provider_adapter_factory is needed too.

HI

It is a long time since I implemented the OCL EAnnotations, but what seems to be distinctive is that the OCL ones all have validator definitions:

<extension point="org.eclipse.emf.ecore.annotation_validator">
<validator uri="http://www.eclipse.org/emf/2002/Ecore/OCL"
class="org.eclipse.ocl.pivot.internal.validation.Ecore_OCL_AnnotationValidator$Blank"/>
<validator uri="http://www.eclipse.org/emf/2002/Ecore/OCL/Debug"
class="org.eclipse.ocl.pivot.internal.validation.Ecore_OCL_AnnotationValidator$Debug"/>
<validator uri="http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot"
class="org.eclipse.ocl.pivot.internal.validation.Ecore_OCL_AnnotationValidator$Pivot"/>
<validator uri="http://www.eclipse.org/OCL/ASLibrary"
class="org.eclipse.ocl.pivot.internal.validation.OCL_ASLibrary_AnnotationValidator"/>
<validator uri="http://www.eclipse.org/OCL/ASMetamodel"
class="org.eclipse.ocl.pivot.internal.validation.OCL_ASMetamodel_AnnotationValidator"/>
<validator uri="http://www.eclipse.org/OCL/Collection"
class="org.eclipse.ocl.pivot.internal.validation.OCL_Collection_AnnotationValidator"/>
<validator uri="http://www.eclipse.org/OCL/Import"
class="org.eclipse.ocl.pivot.internal.validation.OCL_Import_AnnotationValidator"/>
<validator uri="http://www.eclipse.org/OCL/MetaAnnotation"
class="org.eclipse.ocl.pivot.internal.validation.OCL_MetaAnnotation_AnnotationValidator"/>
</extension>

Have you defined these extensions?

Regards

Ed Willink

[Updated on: Mon, 12 September 2022 18:30]

Report message to a moderator

Re: Create ecore annotation model and use it in another ecore model [message #1854830 is a reply to message #1854810] Tue, 13 September 2022 18:32 Go to previous messageGo to next message
Steve Peters is currently offline Steve PetersFriend
Messages: 12
Registered: September 2020
Junior Member
Both models are located within the same workspace, that's why I can't use extension points. I thought annotations are a common use case.
It is possible to load/map the annotation in the corresponding Ecore Model Object?

For example:

XYZ_Utils.getAnnotation(ecore::EPackage, NS_URI_FROM_ANNO_MODEL => http://www.example.org/annotation) => This method would be returned the Package(annotation.ecore) Object.

The only thing I want is ot add some extra information to my EClass.

For example:

@DslAnnotation(keyword="restservice")
class RestApiService extends MyNamedDslElement {

}

May be there's another way to do that?

[Updated on: Tue, 13 September 2022 18:42]

Report message to a moderator

Re: Create ecore annotation model and use it in another ecore model [message #1854836 is a reply to message #1854830] Wed, 14 September 2022 04:44 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI

You are being distracted by the opportunities provided by the new disciplined support that validates EAnnoation content.

You can still use the older approach. Just add a 'blank' EAnnotation and paste the source in the Properties View.

Regards

Ed Willink
Re: Create ecore annotation model and use it in another ecore model [message #1854839 is a reply to message #1854836] Wed, 14 September 2022 06:07 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
As I mentioned, is no concept of "stereotype" in Ecore. Any association of an annotation to a specific EClass is something you'd have to implement programmatically, at which point you could generate your annotation model and could use an extension point to implement your specialized support for it, that is if eModelElement.getEAnnotation("sourceURI").getDetails().get("key") is not sufficient for your "extra information" purposes.

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:EMF Combo Box in GenericEditor
Next Topic:[CDO][NET4J] SSL and negotiator type="challenge"
Goto Forum:
  


Current Time: Thu May 02 11:56:01 GMT 2024

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

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

Back to the top