Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Reference a metamodel type from the model
Reference a metamodel type from the model [message #1842313] Wed, 16 June 2021 10:31 Go to next message
Francesco Bedini is currently offline Francesco BediniFriend
Messages: 21
Registered: March 2018
Junior Member
Hi, is it possible to set somehow in the model a reference to metamodel's types (EClass)?

Goal is letting the users specify that some model elements should only be applied/linked to certain types of elements (and that information will be used for example during the model validation).

I tried to set "EClass" as the reference type, I managed to have the required classes in the dropdown, but then I got an error when I tried to set one.

Another easy option would be defining an Enum with the types and putting some additional logic to map the literal value to the metamodel classes.

Is the enum the only option or there is another (nicer) option that I'm missing?
Re: Reference a metamodel type from the model [message #1842327 is a reply to message #1842313] Wed, 16 June 2021 14:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 32033
Registered: July 2009
Senior Member
Of course the GenModel has all kinds of references to things from the Ecore, so yes this is doable. When you say, "I got an error", perhaps you can be more clear on that? I expect controlling the choice of EClasses will likely be something you need to do manually and most importantly, if you're going to use it to control/restrict instances that may appear in various places, you'll likely want to be sure to use the generated/static model's EClasses are references. I don't understand how you intend to actually use this though...

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Reference a metamodel type from the model [message #1842337 is a reply to message #1842327] Wed, 16 June 2021 16:50 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7268
Registered: July 2009
Senior Member
Hi

If you hardwire EClasses you will find the solution very inflexible.

It would seem that your permitted usages might be called roles, so that that the permitted classes for RoleA could be implemented to overload a base isRoleA() that returns false, with a return true. Similarly for each of the other roles. Then when another EClass is added you just need a local set of isRoleA() etc overload declarations without any need to change every reference.

Regards

Ed Willink
Re: Reference a metamodel type from the model [message #1842376 is a reply to message #1842327] Thu, 17 June 2021 10:43 Go to previous messageGo to next message
Francesco Bedini is currently offline Francesco BediniFriend
Messages: 21
Registered: March 2018
Junior Member
Thanks for your answer and sorry for not being very precise.
I made a small model to show the goal:
index.php/fa/40642/0/
(Currently "EObject" is just a placeholder type.)

The users should be able to define various kinds of parameters, which can be applied to "some" elements of the model (but they should also specify which one).
Afterward, a validation can check if all required parameters are set on all objects / if some parameter that is not allowed on a given type is present.

I would try to run it, but unfortunately, currently, my Eclipse 2021-06 Modeling doesn't seem to cope well with EMF (starting a new "Eclipse Application" fails, but that's a separate issue). Later I will try it on an older version and get back to you.
Re: Reference a metamodel type from the model [message #1842380 is a reply to message #1842376] Thu, 17 June 2021 12:07 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7268
Registered: July 2009
Senior Member
Hi

Beware. 2021-06 was only released yesterday and sadly the Eclipse Modeling community is shrinking and so less actual exercising gets done although the increased churn of Java version breakages demands more. (Papyrus fell out of SimRel through lack of developer time to resolve a breakage.)

I have just raised a bug [1] that might be a problem for standalone EMF and users that are sticking with Java 8. Make sure you use at least Java 11.

Regards

Ed Willink

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=574259
Re: Reference a metamodel type from the model [message #1842382 is a reply to message #1842380] Thu, 17 June 2021 12:17 Go to previous messageGo to next message
Francesco Bedini is currently offline Francesco BediniFriend
Messages: 21
Registered: March 2018
Junior Member
Ed Willink wrote on Thu, 17 June 2021 12:07
Make sure you use at least Java 11.
[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=574259

I am using OpenJDK 16.0.1 on Windows.
I've attached the log file, it seems to be a different issue from the one in your bug. So far I didn't exactly get when the error starts to happen and when it doesn't.
  • Attachment: .log
    (Size: 19.74KB, Downloaded 12 times)
Re: Reference a metamodel type from the model [message #1842394 is a reply to message #1842382] Thu, 17 June 2021 15:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 32033
Registered: July 2009
Senior Member
That looks like here:

https://git.eclipse.org/c/cdo/cdo.git/tree/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/bundle/OM.java#n79

Try to run with the VM option -Dorg.eclipse.emf.cdo.common.disableURIHandlerRegistry=true



Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Reference a metamodel type from the model [message #1842398 is a reply to message #1842394] Thu, 17 June 2021 16:16 Go to previous messageGo to next message
Francesco Bedini is currently offline Francesco BediniFriend
Messages: 21
Registered: March 2018
Junior Member
Ed Merks wrote on Thu, 17 June 2021 15:43

Try to run with the VM option -Dorg.eclipse.emf.cdo.common.disableURIHandlerRegistry=true

That seems to make the second Eclipse start so far, but as I said sometimes it works, and then sometimes later it doesn't. I will keep an eye and report if it happens again. Thanks in the meanwhile!
Re: Reference a metamodel type from the model [message #1842399 is a reply to message #1842394] Thu, 17 June 2021 16:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 32033
Registered: July 2009
Senior Member
I suggest you also open a Bugzilla about the CDO problem.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Reference a metamodel type from the model [message #1842425 is a reply to message #1842399] Fri, 18 June 2021 09:40 Go to previous message
Francesco Bedini is currently offline Francesco BediniFriend
Messages: 21
Registered: March 2018
Junior Member
Ed Merks wrote on Thu, 17 June 2021 16:24
I suggest you also open a Bugzilla about the CDO problem.

Done: https://bugs.eclipse.org/bugs/show_bug.cgi?id=574300
I hope I guessed the right category and everything.
Previous Topic:[CDO] Prefetch policy
Next Topic:eContainer nulls attribute despite containment
Goto Forum:
  


Current Time: Tue Sep 28 20:59:48 GMT 2021

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

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

Back to the top