|
Re: Converting to and from using XMI UUIDs [message #517906 is a reply to message #517882] |
Tue, 02 March 2010 13:49 |
Ed Merks 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/
|
|
|
Powered by
FUDForum. Page generated in 0.02729 seconds