Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Create Ecore file programmatically with unique id for every elements
Create Ecore file programmatically with unique id for every elements [message #1446413] Thu, 16 October 2014 20:25 Go to next message
UmaShankar Subramani is currently offline UmaShankar SubramaniFriend
Messages: 194
Registered: December 2011
Location: SWEDEN
Senior Member
Hi all,

I am creating ecore file programmatically by using the code as follows. But I want to introduce unique ids for all the elements in the generated ecore file.

Currently, the file which I generated looks like the following ecore file.

ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put
("*", new XMIResourceFactoryImpl());

Resource resource = resourceSet.createResource(URI.createURI("file://D:/send.ecore"));

resource.add(eObject);


<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
<ecore:EOperation/>
<ecore:EOperation/>
<ecore:EAttribute/>
</xmi:XMI>

[Updated on: Thu, 16 October 2014 20:39]

Report message to a moderator

Re: Create Ecore file programmatically with unique id for every elements [message #1446631 is a reply to message #1446413] Fri, 17 October 2014 04:54 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
You'd need to to have a specialized factory that creates a specialized
XMIResourceImpl that overrides this method to return true.

protected boolean useUUIDs()
{
return false;
}


On 16/10/2014 10:25 PM, UmaShankar Subramani wrote:
> Hi all,
>
> I am creating ecore file programmatically by using the code as
> follows. But I want to introduce unique ids for all the elements in
> the generated ecore file. The id should be something similiar to the
> XMI ID .
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().put
> ("*", new XMIResourceFactoryImpl());
> Resource resource =
> resourceSet.createResource(URI.createURI("file://D:/send.ecore"));
>
> resource.add(eObject);
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
> <ecore:EOperation/>
> <ecore:EOperation/>
> <ecore:EAttribute/>
> </xmi:XMI>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:EMF help not part of official website
Next Topic:Adding Javadoc to the Model
Goto Forum:
  


Current Time: Tue Apr 16 10:46:35 GMT 2024

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

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

Back to the top