EAnnotation usage in ecore [message #1694795] |
Fri, 08 May 2015 00:13 |
|
I am exploring emf framework, so excuse me for this novice question.
Can anybody explain the usage of EAnnotation in ecore, in terms of its specific fields (i.e., Source, Details, EModel Element, Contents, and References). I looked at its API documentation here, but could not get that much from there.
I am looking for a kind of guideline that explains by example what are the purpose of having annotations with such fields in ecore.
I asked this question here, but it seems there are less people of EMF in stackoverflow.
Thanks
|
|
|
Re: EAnnotation usage in ecore [message #1694806 is a reply to message #1694795] |
Fri, 08 May 2015 04:52 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Hamid,
Comments below.
On 08/05/2015 2:13 AM, Hamid Qartal wrote:
> I am exploring emf framework, so excuse me for this novice question.
>
> Can anybody explain the usage of EAnnotation in ecore, in terms of its
> specific fields (i.e., Source,
This should typically be a URI and helps identify/describe the purpose
of the annotation and is useful for looking it up using
org.eclipse.emf.ecore.util.EcoreUtil.getAnnotation(EModelElement,
String, String).
> Details,
These are key/value pairs. One generally hopes that all the additional
information you need to associate with the model can be represented in
this way exclusively and again, the above utility is useful for looking
things up...
> EModel Element,
An EAnnotation is an EModelElement, so can also be annotated. It's not
often used, but would allow you to build a complex structure...
> Contents,
EAnnotations can contain arbitrary other objects. This is also not
often used, and if you do use it, you can't generate a normal
XyzPackageImpl but must ensure that the GenPackage specifies "Initialize
by Loading"...
> and References).
EAnnotations can refer to arbitrary other objects. This is also not
often used, and the same caveat applies and for the contents...
> I looked at its API documentation
> http://download.eclipse.org/modeling/emf/emf/javadoc/2.4.2/org/eclipse/emf/ecore/EAnnotation.html#getReferences%28%29,
> but could not get that much from there.
> I am looking for a kind of guideline that explains by example what are
> the purpose of having annotations with such fields in ecore.
>
> I asked this question
> http://stackoverflow.com/questions/30112555/eannotation-usage-in-ecore, but
> it seems there are less people of EMF in stackoverflow.
Yes, I don't generally monitor that forum...
>
> Thanks
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: EAnnotation usage in ecore [message #1770264 is a reply to message #1694806] |
Wed, 09 August 2017 13:37 |
Matteo M. Messages: 40 Registered: May 2012 |
Member |
|
|
Hello,
Ed Merks wrote on Fri, 08 May 2015 00:52
On 08/05/2015 2:13 AM, Hamid Qartal wrote:
> [...]
> Contents,
EAnnotations can contain arbitrary other objects. This is also not
often used, and if you do use it, you can't generate a normal
XyzPackageImpl but must ensure that the GenPackage specifies "Initialize
by Loading"...
I have a complex structure (Class) that is supposed to bring more characterization to each Association (Reference/Composition) defined between Classes in my ecore metamodel. I tought I could use the References attribute of EAnnotation for this purpose.
Let's say that A is the Class that "enrich" any association in my metamodel with additional data. Then I have Classes P and Q that represent concepts in my metamodel. I can define a Reference qs that goes from P to Q to indicate that P references (many) Q(s). In addition, I define an EAnnotation in qs so that I can use its References attribute to refer the instance of A that is going to characterize qs at level M1.
Ideally I would like to express a kind of "derived Reference" in the EAnnotation. Indeed, my business model logic at M1 is such that, in principle, I could express the "derivation rule" in OCL, so that the qs' EAnnotation References attribute is automatically filled with the proper instance of A that characterize qs.
Is it possible to achieve this with direct OCL expressions in the ecore metamodel, or am I supposed to customize the generated editor to get the desired behavior?
And by the way, can you explain what is the purpose of enabling "Initialize
by Loading" in GenPackage? What is it useful for?
Thanks.
--
Matteo
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07332 seconds