Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EAnnotation references between ecore models
EAnnotation references between ecore models [message #903523] Fri, 24 August 2012 06:44 Go to next message
Al B is currently offline Al BFriend
Messages: 47
Registered: June 2012
Member
Is it possible to create an eannotation that references a feature in another ecore model? The file containing the feature is in a different relative location though.

TIA!
Re: EAnnotation references between ecore models [message #903527 is a reply to message #903523] Fri, 24 August 2012 06:57 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Yes.

Within Eclipse the true physical locations behind disparate workspace
contributions are nicely virtualized by platform:/plugin and
platform:/resource URIs allowing arbitrary inter-model references.

However, if you run standalone, you will need to ensure that this
virtualization is replicated in your application.
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=361063)

Regards

Ed Willink

On 24/08/2012 07:44, AJ Ben wrote:
> Is it possible to create an eannotation that references a feature in
> another ecore model? The file containing the feature is in a
> different relative location though.
>
> TIA!
Re: EAnnotation references between ecore models [message #903655 is a reply to message #903527] Fri, 24 August 2012 17:36 Go to previous messageGo to next message
Al B is currently offline Al BFriend
Messages: 47
Registered: June 2012
Member
Hi Ed#2,

I tried your suggestion, but the new attribute is not populated with the data referenced in the other model. Maybe I missed something, here is what I did:

<eStructuralFeatures xsi:type="ecore:EAttribute" name="stpStopDate" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EDate">
<eAnnotations references="platform:/resource/org.eclipse.test/models/fdpa.ecore#//SAPInit/stpStopDate"/>
</eStructuralFeatures>

Thanks!
Re: EAnnotation references between ecore models [message #903658 is a reply to message #903655] Fri, 24 August 2012 18:10 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Your terminology is confusing.

A reference is a reference. It references the data; it doesn't copy it.

Regards

Ed Willink

On 24/08/2012 18:36, AJ Ben wrote:
> Hi Ed#2,
>
> I tried your suggestion, but the new attribute is not populated with
> the data referenced in the other model. Maybe I missed something,
> here is what I did:
>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="stpStopDate"
> eType="ecore:EDataType
> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EDate">
> <eAnnotations
> references="platform:/resource/org.eclipse.test/models/fdpa.ecore#//SAPInit/stpStopDate"/>
> </eStructuralFeatures>
>
> Thanks!
Re: EAnnotation references between ecore models [message #903668 is a reply to message #903655] Fri, 24 August 2012 19:48 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
AJ,

Comments below.

On 24/08/2012 7:36 PM, AJ Ben wrote:
> Hi Ed#2,
>
> I tried your suggestion, but the new attribute is not populated with
> the data referenced in the other model.
Note that the generated EPackage will not generate the contents or
references features of an EAnnotation. If you set the GenPackage's
Initialize by Loading property to true, the generated package will
initialize by loading a serialized version of the Ecore model and that
will help preserve the containment and cross references of the EAnnotations.
> Maybe I missed something, here is what I did:
>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="stpStopDate"
> eType="ecore:EDataType
> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EDate">
> <eAnnotations
> references="platform:/resource/org.eclipse.test/models/fdpa.ecore#//SAPInit/stpStopDate"/>
I would have expected this to be a relative reference within the
workspace. I imagine it will be problematic to load this at runtime if
this model isn't available in the workspace at runtime.

An alternative approach is that you record in the annotations details
map a key with the value <nsURI>#<fragmentURI> of the model you expect
will be available at runtime. So you can use
EPackage.Registry.INSTANCE.getEPackage(<nsURI>).eResource().getEObject(<fragmentURI>)
to locate the feature you're referencing.
> </eStructuralFeatures>
>
> Thanks!


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:How to get nationalized feature name
Next Topic:[EMF Compare] Steps to do Graphical Comparison with Eclipse (Solved)
Goto Forum:
  


Current Time: Thu Mar 28 11:01:12 GMT 2024

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

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

Back to the top