Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Deleting the root element from a child representation corrupts the session(The session is not recoverable)
Deleting the root element from a child representation corrupts the session [message #1768912] Mon, 24 July 2017 21:29 Go to next message
Chris Mamorella is currently offline Chris MamorellaFriend
Messages: 34
Registered: June 2013
Member
In my VSM I have:

Diagram type A: semantic root element = parent
Diagram type B: semantic root element = child

Diagram B can be created and navigated to from Diagram A if "parent" contains "child".

If I delete "child" from within diagram A without creating or navigating to Diagram B, the semantic model is updated appropriately and everything works as expected. If, however, I create/navigate to diagram B and then later delete the "child" from the semantic model (change is triggered from an another view), I get the following error:

java.lang.NullPointerException
	at org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer.getAllMandatoriesAdditionalLayers(DDiagramSynchronizer.java:343)
	at org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer.activateNewMandatoryAdditionalLayers(DDiagramSynchronizer.java:310)
	at org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer.refreshOperation(DDiagramSynchronizer.java:372)
	at org.eclipse.sirius.diagram.business.internal.experimental.sync.DDiagramSynchronizer.refresh(DDiagramSynchronizer.java:355)
	at org.eclipse.sirius.diagram.business.internal.sync.DDiagramSynchronizer.refresh(DDiagramSynchronizer.java:91)
	at org.eclipse.sirius.diagram.business.internal.dialect.DiagramDialectServices.refresh(DiagramDialectServices.java:254)
	at org.eclipse.sirius.business.internal.dialect.DialectManagerImpl.refresh(DialectManagerImpl.java:123)


In my experience this error indicates a decoupling between the session and its resources. But I don't understand why this happens when a nested representation is created under the parent representation. I assumed that deleting the child from the semantic model would be gracefully handled by Sirius when multiple representations exist because other model add or change events seem to be handled ok. Even worse - when this delete error occurs it is not recoverable and the only resort is to shut down and start a new session.

Is there a "delete representation" command that I need to be using? I catch the "delete child" notification and promptly close the diagram editor before this NPE error occurs, but the outcome is unchanged.

[Updated on: Mon, 24 July 2017 21:32]

Report message to a moderator

Re: Deleting the root element from a child representation corrupts the session [message #1768969 is a reply to message #1768912] Tue, 25 July 2017 09:14 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 470
Registered: May 2011
Senior Member
Hello,

In this scenario, where deleting a semantic element that is the root element of a different opened diagram, the expected behavior is to have a popup with the message "The root element has been deleted, the editor will close".

What version of Sirius are you using? The method where you have an exception does not exist anymore in Sirius 5.0. I tested in Sirius 4.1 where this method still existed and this scenario still works. Can you describe own the layers of your diagram description have been specified? Maybe there is an unexpected specification, but that seems unlikely.

Regards,
Steve


Steve Monnier - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Deleting the root element from a child representation corrupts the session [message #1768982 is a reply to message #1768969] Tue, 25 July 2017 12:13 Go to previous messageGo to next message
Chris Mamorella is currently offline Chris MamorellaFriend
Messages: 34
Registered: June 2013
Member
I am using Sirius 3.1.1.

My VSM is pretty straightforward.

The root of the semantic model is "parent" which can have multiple "child" objects. I have one diagram that represents the parent and its children. There is a second diagram that represents a child. Deleting a child from the semantic model creates a situation where a child representation's target becomes null.

Interestingly, I cam across a repair script that attempts to remedy the empty target situation.

There are other API methods available to delete a representation from a session (e.g. DiagramDialectServices#deleteRepresentation), but not sure if that's the direction to go in at this point or not. The only other thing worth mentioning is that the semantic model is shared by another editor/editing domain. The child element is removed by this other editing domain. The model changes are synchronized, although I am always getting exceptions in the logs from the sirius editing domain complaining about this. The exceptions are ignored and the model changes as expected so it amounts to white noise.

Re: Deleting the root element from a child representation corrupts the session [message #1768990 is a reply to message #1768982] Tue, 25 July 2017 13:33 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 470
Registered: May 2011
Senior Member
Hello,

Indeed, the fact that you remove the child element in another editing domain is important. I removed the element out of Eclipse, using a text editor, and the representation did not close by itself. Furthermore, if I refreshed the modeling project and switch back to the child representation it threw some exception but not like yours.
As a matter of fact, when you delete the child semantic element, even in the same editing domain, the child representation is not deleted, only closed. In your case, DiagramDialectServices#deleteRepresentation may do the trick, but you may need org.eclipse.sirius.ui.business.api.dialect.DialectUIServices.closeEditor(IEditorPart, boolean) instead.

Regards,
Steve


Steve Monnier - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Deleting the root element from a child representation corrupts the session [message #1769020 is a reply to message #1768990] Tue, 25 July 2017 18:12 Go to previous message
Chris Mamorella is currently offline Chris MamorellaFriend
Messages: 34
Registered: June 2013
Member
Steve,

Thanks for the added perspective. DialectUIManager.INSTANCE#closeEditor does close the affected editor, but there seems to be a problem with DialectManger.INSTANCE#deleteRepresentation which does not return successfully. This is verified when I iterate through the representations via DialectManager.INSTANCE.getAllRepresentations. The affected representation still exists with its semantic target, although now the semantic child is orphaned from its parent (e.g. the child container is null). Maybe the #deleteRepresentation fails when the semantic target of a representation cannot be linked back to the model?

At this point I am having better luck just not calling the #deleteRepresentation command. Upon saving and reopening the session, the "dangling" representation will still exist, but at least at this point its semantic target is now null, so saving and reloading seems to at least perform the necessary model cleanup. I might be able to get by with my workaround but I would much prefer to figure out why representations cannot be purged. Is there something else I can try? Perhaps the repair script that I linked to earlier?
Previous Topic:Validation Quick Fixes using external Java Actions
Next Topic:Error message after updating
Goto Forum:
  


Current Time: Thu Apr 02 23:24:30 GMT 2020

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

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

Back to the top