Adding a Semantic Resource to the Session (SOLVED) [message #1818519] |
Wed, 18 December 2019 11:48 |
Neeraj Bhusare Messages: 177 Registered: July 2009 Location: Canada |
Senior Member |
|
|
Hi All,
I use the following code to add a semantic-resource to the Session instance.
final AddSemanticResourceCommand command = new AddSemanticResourceCommand(session, resource.getURI(), monitor);
session.getTransactionalEditingDomain().getCommandStack().execute(command);
The constructor takes the resource URI as an input parameter. After the command is executed, the semantic-resource "instance" loaded in the session is not the same as the one used to get the URI (resource.getURI()). As a side-effect, I see the following error when I try to perform the save operation - Impossible to find an interpreter - Could not find a session for the model element...
As a workaround, I get hold of the semantic-resource from the session using the resource URI and replace the model element in the resource with the one passed as the parameter to the service method. The hack works.
Is there a better way to deal with the above?
Out of curiosity, why is it that the `AddSemanticResourceCommand` constructor takes a resource URI and not a resource as a parameter?
Please comment.
Thanks in advance.
Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj
[Updated on: Wed, 18 December 2019 15:02] Report message to a moderator
|
|
|
Re: Adding a Semantic Resource to the Session [message #1818523 is a reply to message #1818519] |
Wed, 18 December 2019 14:08 |
|
Hello,
Yes, this is expected to happen if your resource was loaded in a different editing domain and resource set than from the session. This is why the constructor takes a resource URI, because it will load the resource with the editing domain of the session.
You can use the command, but it will be simpler in your code to directly call addSemanticResource(URI, IProgressMonitor) from your session.
Best regards,
Steve
Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
Powered by
FUDForum. Page generated in 0.02710 seconds