Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Package.eINSTANCE.getElement not equals reference.etype - ResourceFactory or Registry Problem?
Package.eINSTANCE.getElement not equals reference.etype - ResourceFactory or Registry Problem? [message #1790866] Tue, 19 June 2018 09:39 Go to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 54
Registered: March 2015
Member
Hello,

i have a Problem with equality between the *Packe.eINSTANCE.getModelAElement and a directly referenced Modelelement.

I have a Metamodel that allows my user to reference Elements from a loaded *.ecore File, wich contains the Class ModelAElement. To reference these the user has to use the load-Resource Option from the context-menu and then enter the platform:/plugin/mymodel/mymodel.ecore uri

in my editor if i find a reference that links to ModelAElement i want to react in a special way. i tryed to make a comparison:

if(ereference.getEType() == MyModelPackage.eINSTANCE.getModelAElement)

but this never returns true. if i make some debug PrintLines i can see that they have different Hashcodes and EcoreResourceFactorys with different uris:

one has platform:/plugin/.... and the other has http://...

The EClasses are the right ones but with different hashcodes.

What can i do to fix this issue?

Thank you for your time.
Simon
Re: Package.eINSTANCE.getElement not equals reference.etype - ResourceFactory or Registry Problem? [message #1790867 is a reply to message #1790866] Tue, 19 June 2018 09:52 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6037
Registered: July 2009
Senior Member
Hi

This is a classic example of metamodel schizophrenia. You must never load the 'same' metamodel by more than one mechanism else you get X is not equal to X anomalies.

The simplest approach is to ensure that you are consistent in what you load.

If you configure the URImap, perhaps aided by the EcorePlugin.ExtensionProcessor, you can ensure that the 'wrong' mechanism is redirected to the 'right' one.

If you really can't control your users/usage you may use the (Standalone)ProjectMap from Eclipse OCL to ensure that metamodels are distinct wrt their nsURI rather than their external URI.

Regards

Ed Willink

Re: Package.eINSTANCE.getElement not equals reference.etype - ResourceFactory or Registry Problem? [message #1790872 is a reply to message #1790867] Tue, 19 June 2018 11:45 Go to previous messageGo to next message
Simon BBBBBBB is currently offline Simon BBBBBBBFriend
Messages: 54
Registered: March 2015
Member
Hello Ed, thanks for your answer. I still cant find a solution.

The user loads the resource as a direct dependency, so it has to have the plaatform:/plugin/... uri, right?

But i have to access the package in a programmatical way so i have to use the NamePacke.eINSTANCE.get... what resolvs to the http:// reference. is there a different way for me to retrieve that one specific eclass?

i can get the resource set from my current object, find the right resource, navigate threw the model and then get my class, but that cant be the right way, or is it?

another hint would be nice.

Greetings
Re: Package.eINSTANCE.getElement not equals reference.etype - ResourceFactory or Registry Problem? [message #1790873 is a reply to message #1790872] Tue, 19 June 2018 12:13 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6037
Registered: July 2009
Senior Member
Hi

You provide no clues as to your environment so I have to guess, How does the user load ? Using a shovel?

If you have org.eclipse.emf.ecore checked out in your workspace you have three candidate for http://www.eclipse.org/emf/2002/Ecore.
- the Java classes associated with org.eclipse.emf.ecore.EPackage
- the platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore content in the EMF JAR
- the platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore content in your workspace
in addition to various file: navigations in your file system.

You just use just one and ensure that referebces to otgher are redirected.

If you are running under Eclipse OSGI the redirections happen automatically so using any of the above three can be equivalent.

If your are running standalone see https://wiki.eclipse.org/EMF/FAQ#How_do_I_make_my_EMF_standalone_application_Eclipse-aware.3F amngst others.

Regards

Ed Willink
Previous Topic:Mapping dateTime
Next Topic:Problem Reloading Genmodel. `<>` operator is not allowed for source level below 1.7
Goto Forum:
  


Current Time: Wed Sep 19 18:16:02 GMT 2018

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

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

Back to the top