Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Update aird file when change the uri of sementic resource
Update aird file when change the uri of sementic resource [message #1799398] Thu, 06 December 2018 08:29 Go to next message
Stéphanie Piccin is currently offline Stéphanie PiccinFriend
Messages: 4
Registered: June 2018
Junior Member
Hello,

I want to change the uri of semantic resource via the method :

resource.setURI(<NewUri>);

I save my resource but the aird file is not updated and it contains the old uri of my resource. So my project is inconsistent.

I tried by using the following method :
session.addSemanticResource(<NewUri>, new NullProgressMonitor())

but it is not working.

Can you help me to update the aird file when i change the uri of semantic resource

Thanks
Re: Update aird file when change the uri of sementic resource [message #1800162 is a reply to message #1799398] Thu, 20 December 2018 17:19 Go to previous message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 432
Registered: May 2011
Senior Member
Hello,

The issue with changing the URI of a resource with resource.setURI is that incoming reference from other resource will not be updated.

I think you will have less trouble, by moving the resource content. The approach I would recommand is the following:
- First, create the new resource:
	Resource newSemanticResource =resourceSet().createResource(newSemanticResourceURI);
    newSemanticResource.save(null);


- Next, Add the resource to the session
session.getTransactionalEditingDomain().getCommandStack().execute(new RecordingCommand(session.getTransactionalEditingDomain()) {

	@Override
	protected void doExecute() {
		session.addSemanticResource(semanticResource4uri, new NullProgressMonitor());
	}
});


- Finally, move the resource root to the new resource and save
EObject toMove = semanticResource3.getContents().get(0);
session.getTransactionalEditingDomain().getCommandStack().execute(new RecordingCommand(session.getTransactionalEditingDomain()) {

	@Override
	protected void doExecute() {
		semanticResource4.getContents().add(toMove);
	}
});
        session.save(new NullProgressMonitor());


I checked with a JUnit where I had a model A with a model element referencing a model element from model B. I moved this model element from B to a new resource C. In model A, the reference was updated to model C automatically.

Regards,
Steve


Steve Monnier - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:How to perform operation only for disabled cells in Sirius table
Next Topic:Is Sirius supports only for EObjects.
Goto Forum:
  


Current Time: Tue Oct 15 20:56:26 GMT 2019

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

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

Back to the top