|
Re: [Acceleo] how to get the ID of an EObject [message #761882 is a reply to message #761698] |
Wed, 07 December 2011 08:17 |
|
Hi,
There are two kind of "ID" for an EObject : the ID attribute, which can be retrieved with EcoreUtil.getID and corresponds to an attribute you've set as being the identifier of your object in the genmodel; or the XMI ID which appears in the serialized model as .
I believe what you seek is the second form, yet you're trying to access it through the first's accessor. Neither Acceleo nor EMF provide easy access to the XMI ID, you need a Java method that does the following :
public String getXMIID(EObject eObject) {
if (eObject.eResource() instanceof XMIResource) {
return ((XMIResource)eObject.eResource()).getID(eObject);
}
return "";
}
Laurent Goubet
Obeo
|
|
|
|
Powered by
FUDForum. Page generated in 0.03617 seconds