Skip to main content



      Home
Home » Modeling » EMF » Generation of ID's (How to generate ID's of classes automatically? )
Generation of ID's [message #1822573] Tue, 10 March 2020 04:31 Go to next message
Eclipse UserFriend
Hello,

Good day..!!

I have used XML language in generator to create an application. Inside application i want to generate GUID and link it with other classes as references. How can i do it in generator? Is it possible to make some changes in meta-model so that it creates ID automatically?

Will be looking forward for a response.

Regards,
Adil
Re: Generation of ID's [message #1822618 is a reply to message #1822573] Tue, 10 March 2020 10:29 Go to previous messageGo to next message
Eclipse UserFriend
Hi

The xmi:id is nothing to do with your model; it is an artifact of its serialization in XML. Consequently no tools provide first class support for xmi:id although some provide a backdoor helper.

In EMF, the serialization is controlled by your XXXResourceImpl, provided you enabled resource generation in your genmodel. You can override useIds or useUUIDs in your XXXResourceImpl or even implement getId/setID to do something really specialized.

Be very careful about very strong xmi:ids. You can very easily discover that they can be a major PITA, since nothing can ever evolve ever again unless you have some tedious reconciliation wrt previous xmi:ids. I recommend that you do nothing to 'improve' your xmi:ids until you have used the defaults for at least 3 months and think very hard about what you are actually trying to achieve before doing something different.

Regards

Ed Willink
Re: Generation of ID's [message #1822631 is a reply to message #1822618] Tue, 10 March 2020 11:19 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

Thanks for your reply. Purpose is to automatically generate ID's on run-time using GUID. Please see attached screenshot. This application was generated using XML code in Acceleo. Next thing what i am looking to

implement is GUID. From the image. Water level under American coffee is referring to water level under instance list. In order to do implementation, i need to write java code which implements GUID. Is it possible to

use header files of Java and write Java code for GUID and connect somehow with XML to achieve the purpose?

If yes, then kindly let me know, i am stuck here since many days now.

Looking forward

Best regards,
Adil

[Updated on: Tue, 10 March 2020 11:20] by Moderator

Re: Generation of ID's [message #1822676 is a reply to message #1822631] Wed, 11 March 2020 05:37 Go to previous message
Eclipse UserFriend
Hi

OK. It seems like your use of XML and ID in the same paragraph confused me. You are not interested in xmi:id at all, but an ordinary model attribute that has a GUID value.

It is fairly easy to specify a custom EDataType that auto-allocates unique values using the EcoreUtil.generateUUID().

Once you have implemented it, you can then start to tackle the following bugs that are probably due to a lack of consideration of what you actually want to achieve.

- when you reload the model different UUIDs are allocated
- when you cut and paste in the editor, duplicate UUIDs appear
- when you change an ancestor, the UUID is not changed
- when you change an ancestor and then change it back again the UUID remains changed

I think I might be inclined to maintain a load-time GUID-to-EObject map, a think-of-a-new-GUID cell editor action, and a validation that each actual GUID is consistent with load-time and subsequently created elements.

Regards

Ed Willink
Previous Topic:How to add a attribute or property to a EAttribute type?
Next Topic:Ecore data types for array, vector and list
Goto Forum:
  


Current Time: Sat Jul 12 20:01:55 EDT 2025

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

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

Back to the top