Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Converting to and from using XMI UUIDs
Converting to and from using XMI UUIDs [message #517882] Tue, 02 March 2010 07:52 Go to next message
Scott Dybiec is currently offline Scott DybiecFriend
Messages: 148
Registered: July 2009
Senior Member
I'd like to be able to convert back and forth between persisting
Resources with XMI UUIDs and not. I expected that when
XMLResourceImpl.useUUIDs() is switched back and forth to return true and
false, it would do this.

However, it appears that going to XMI IDs is a one way trip --- having
XMLResourceImpl.useUUIDs() return false has no effect when models are
loaded that already contain XMI IDs. Here's the current logic in
XMLResource.getID(EObject):

/*
* Javadoc copied from interface
*/
public String getID(EObject eObject)
{
if (eObjectToIDMap == null)
{
return null;
}
else
{
return eObjectToIDMap.get(eObject);
}
}

Because I'm using a generated subclass of XMIResource, I was able to
override XMLResource.getID(EObject) to get the expected behavior.

/*
* To enable a file to be converted back to not use UUIDs, we need
to ensure that getID() returns null
*/
@Override
public String getID(EObject eObject) {
String id;
if (useUUIDs()) {
id = super.getID(eObject);
} else {
id = null;
}
return id;
}

It seems to me that EMF developers should have the ability to able to
convert back and forth between persisting Resources with XMI UUIDs and
not using only XMLResourceImpl.useUUIDs().

$cott
Re: Converting to and from using XMI UUIDs [message #517906 is a reply to message #517882] Tue, 02 March 2010 13:49 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Scott,

Comments below.

Scott Dybiec wrote:
> I'd like to be able to convert back and forth between persisting
> Resources with XMI UUIDs and not. I expected that when
> XMLResourceImpl.useUUIDs() is switched back and forth to return true
> and false, it would do this.
Pretty much. Of course once you have extrinsic IDs associated, they'll
hang around.
>
> However, it appears that going to XMI IDs is a one way trip --- having
> XMLResourceImpl.useUUIDs() return false has no effect when models are
> loaded that already contain XMI IDs.
Exactly.
> Here's the current logic in XMLResource.getID(EObject):
>
> /*
> * Javadoc copied from interface
> */
> public String getID(EObject eObject)
> {
> if (eObjectToIDMap == null)
> {
> return null;
> }
> else
> {
> return eObjectToIDMap.get(eObject);
> }
> }
>
> Because I'm using a generated subclass of XMIResource, I was able to
> override XMLResource.getID(EObject) to get the expected behavior.
>
> /*
> * To enable a file to be converted back to not use UUIDs, we need
> to ensure that getID() returns null
> */
> @Override
> public String getID(EObject eObject) {
> String id;
> if (useUUIDs()) {
> id = super.getID(eObject);
> } else {
> id = null;
> }
> return id;
> }
>
> It seems to me that EMF developers should have the ability to able to
> convert back and forth between persisting Resources with XMI UUIDs and
> not using only XMLResourceImpl.useUUIDs().
The useUUIDs flag only guards whether a UUID will be created/computed
for each object as it's added to the resource (and is preserved when an
object is moved from resource to resource). If you want to eliminate the
IDs themselves, you'll need to clear the two maps that cache them.
>
> $cott


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:use cases for integration with powerdesigner
Next Topic:Propertysheet showing wrong values
Goto Forum:
  


Current Time: Wed Apr 24 17:47:25 GMT 2024

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

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

Back to the top