| Unique element ID before saving [message #891654] |
Mon, 25 June 2012 08:15  |
Tex Iano Messages: 98 Registered: February 2012 |
Member |
|
|
Hi,
within my application I have to find elements by means of a unique ID. However, the resource is not saved yet. Otherwise, I found out that I could use:
element.eResource().getURIFragment(element);
But what if the element is not part of the resource yet as it is not saved? How can I get a unique identifier?
Using package1.package2.elementName is not unique as within the same package several elements with the same name can exist.
Regards,
Tex
|
|
|
|
| Re: Unique element ID before saving [message #900218 is a reply to message #891671] |
Sun, 05 August 2012 13:07   |
Tex Iano Messages: 98 Registered: February 2012 |
Member |
|
|
Hi,
I am still having problems with this point.
I am creating a UML model programmatically and I do not want to save it every time I change something. So I came to the conclusion that working on the resource is not a good idea.
However, sometimes on my UI I have to select a UML element etc. and have to transfer a unique identifier from my presentation layer to the business layer. What can I use as unique ID? As I wrote, my first thought was to use the name and its package location:
package1.package2.myClass
However in package2 several elements with the name "myClass" can exist. So: How can I identify a UML element within a model before it is saved? You said, I could assign an ID. But what kind of ID is it? The XMI ID? Is there no other way independent of XMI to reference an element?
Regards,
Tex
[Updated on: Sun, 05 August 2012 13:08] Report message to a moderator
|
|
|
|
| Re: Unique element ID before saving [message #900304 is a reply to message #900222] |
Mon, 06 August 2012 08:35  |
Tex Iano Messages: 98 Registered: February 2012 |
Member |
|
|
Hi,
ah ok thanks.
And for other interested parties:
String id = element.eResource().getURIFragment(element);
System.out.println("ID: " + element.eResource().getURIFragment(element));
System.out.println("Element: " + element.eResource().getEObject(id))
This is how to get the object by ID.
Regards,
Tex
|
|
|
Powered by
FUDForum. Page generated in 0.01806 seconds