Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XMLResource.setID
XMLResource.setID [message #422178] Sun, 24 August 2008 22:32 Go to next message
Ben is currently offline BenFriend
Messages: 46
Registered: July 2009
Member
Hi,

I have an EClass with an EAttribute that has its ID property set to true,
however, it seems that I have to explicitly call
XMLResource::setID(EObject, String) method to populate the idToEObjectMap
HashMap.

Given that the objects are in a resource, does EMF have a mechanism to
automatically populate idToEObjectMap member when the resource is loaded?

Thanks in advance!
Re: XMLResource.setID [message #422179 is a reply to message #422178] Mon, 25 August 2008 02:27 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Ben,

Comments below.

Ben wrote:
> Hi,
>
> I have an EClass with an EAttribute that has its ID property set to true,
That's an intrinsic ID...
> however, it seems that I have to explicitly call
> XMLResource::setID(EObject, String) method to populate the
> idToEObjectMap HashMap.
That's for extrinsic IDs..
>
> Given that the objects are in a resource, does EMF have a mechanism to
> automatically populate idToEObjectMap member when the resource is loaded?
The extrinsic IDs are loaded there, such as when you use XMIResourceImpl
and you have xmi:ids in the file.

Maybe it's really ResourceImpl's setIntrinsicIDToEObjectMap you want to
exploit...
>
> Thanks in advance!
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XMLResource.setID [message #422180 is a reply to message #422179] Mon, 25 August 2008 04:15 Go to previous messageGo to next message
Ben is currently offline BenFriend
Messages: 46
Registered: July 2009
Member
Ed,

The schema that I am using to generate my ecore model does not have any
xmi:ids declared. I just edit the created ecore model and set the ID
property to true for the EAttribute that I want to make sure is unique.

So, does it mean that EMF will not populate either intrinsicIDToEObjectMap
or the idToEObjectMap when the resource is loaded? If that is the case,
then will it make any different if I use
ResourceImpl::setIntrinsicIDToEObjectMap or XMLResourceImpl::setID()?

Thanks again Ed.
Re: XMLResource.setID [message #422181 is a reply to message #422180] Mon, 25 August 2008 05:34 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040200060408020509000909
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Ben,

Comments below.

Ben wrote:
> Ed,
>
> The schema that I am using to generate my ecore model does not have
> any xmi:ids declared. I just edit the created ecore model and set the
> ID property to true for the EAttribute that I want to make sure is
> unique.
>
> So, does it mean that EMF will not populate either
> intrinsicIDToEObjectMap or the idToEObjectMap when the resource is
> loaded?
You have to set a map for that map to be populated.
> If that is the case, then will it make any different if I use
> ResourceImpl::setIntrinsicIDToEObjectMap or XMLResourceImpl::setID()?
If you have a model with IDs you shouldn't need to do anything, other
than set this map if you want mapped lookup...

/**
* Sets the map used to cache the EObject identified by the value
of its ID feature.
* This cache is only activated if the map is not <code>null</code>.
* The map will be lazily loaded by the {@link
#getEObjectByID(String) getEObjectByID} method.
* It is up to the client to clear the cache when it becomes invalid,
* e.g., when the ID of a previously mapped EObject is changed.
* @param intrinsicIDToEObjectMap the new map or <code>null</code>.
* @see #getIntrinsicIDToEObjectMap
*/

You should always be able to call Resource.getEObject with your ID and
expect the object with that ID to be returned...
>
> Thanks again Ed.
>

--------------040200060408020509000909
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ben,<br>
<br>
Comments below.<br>
<br>
Ben wrote:
<blockquote
cite="mid:7c214782f53abf555c76872bcc366775$1@www.eclipse.org"
type="cite">Ed,
<br>
<br>
The schema that I am using to generate my ecore model does not have any
xmi:ids declared.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Registering the EValidator Implementation
Next Topic:Package with uri 'null' not found
Goto Forum:
  


Current Time: Fri Apr 26 14:40:37 GMT 2024

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

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

Back to the top