Bug 471456 - Sirius should not consider URI as unique ID
Summary: Sirius should not consider URI as unique ID
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.1.0   Edit
Assignee: Esteban DUGUEPEROUX CLA
QA Contact: Jessy Mallet CLA
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks: 471543
  Show dependency tree
 
Reported: 2015-06-30 11:13 EDT by Esteban DUGUEPEROUX CLA
Modified: 2015-10-16 09:11 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Esteban DUGUEPEROUX CLA 2015-06-30 11:13:26 EDT
In our Sirius based application in which we don't have workspace but instead have our models stored on a server, we use a InMemoryResourceImpl to store locally DRepresentations loaded from server.

By default in Sirius, with a workspace, a AirdResourceImpl is used which use UUID to have URI of object as unique ID but with InMemoryResourceImpl or even BinaryResourceImpl this is not the case, xpath based URI fragment is used in this case.

This has bad effect of don't opening the correct representation with the following scenario :
1. Have a session with a InMemoryResourceImpl as main sessionResource with URI "memory:data.togafin-memory.aird"
2. Load a DRepresentation r1 in this InMemoryResourceImpl, the URI of this DRepresentation will be "memory:data.togafin-memory.aird#//@ownedViews.0/@ownedRepresentations.0"
3. Open a Sirius editor on this DRepresentation r1
4. Load a DRepresentation r2 in this InMemoryResourceImpl, the URI of this DRepresentation will be "memory:data.togafin-memory.aird#//@ownedViews.0/@ownedRepresentations.1"
5. Open a Sirius editor on this DRepresentation r2
6. Open the Sirius editor of DRepresentation r1
7. Unload the DRepresentation r1 from the InMemoryResourceImpl, the URI of the DRepresentation r2 will become "memory:data.togafin-memory.aird#//@ownedViews.0/@ownedRepresentations.0"
8. Load again DRepresentation r1 in this InMemoryResourceImpl, the URI of this DRepresentation will be "memory:data.togafin-memory.aird#//@ownedViews.0/@ownedRepresentations.1"
9. Open a Sirius editor on this DRepresentation r1 => KO the editor is not opened, instead the editor of the second representation is shown.

It seems comes from use of URIEditorInput through SessionEditorInput, indeed the  URIEditorInput compare only URI. Then to fix that, SessionEditorInput should override URIEditorInput.equals() to test also input equality.
Comment 1 Eclipse Genie CLA 2015-06-30 11:42:18 EDT
New Gerrit change created: https://git.eclipse.org/r/51116
Comment 3 Esteban DUGUEPEROUX CLA 2015-07-08 04:32:48 EDT
Fixed through 3654fcc127fdc08cc639aa6cb58985c14d137da3.
Comment 4 Eclipse Genie CLA 2015-07-08 08:02:08 EDT
New Gerrit change created: https://git.eclipse.org/r/51572
Comment 5 Eclipse Genie CLA 2015-07-08 11:33:00 EDT
New Gerrit change created: https://git.eclipse.org/r/51602
Comment 7 Esteban DUGUEPEROUX CLA 2015-07-09 04:44:21 EDT
Reopened because of new test failures due to SessionEditorInput.exists()/equals() call while aird behind session doesn't exists anymore.
Comment 10 Esteban DUGUEPEROUX CLA 2015-07-10 03:39:34 EDT
Fixed with last commits.
Comment 11 Eclipse Genie CLA 2015-07-16 05:40:40 EDT
New Gerrit change created: https://git.eclipse.org/r/52057
Comment 13 Maxime Porhel CLA 2015-07-16 12:35:05 EDT
GoToMarkerTraceabilityWithUserInteractionTest fails since commit 55dfe4b7fe8eee9bc5594570d436d9b29e2bcfd4

The marker navigation service launch the diagram opening in a READ_ONLY transaction.
Before this commit, transaction was created on the "error editor"'s empty/temp session but now with the commit, a new valid session is created and opened during this error editor opening, when a temporary SessionEditorInput is created from the FileEditorInput  used by the marker service. 

Then the DDiagramEditor.gotoMarker was able to create a retrieve the right element and input and open the correct editor in a new session before closing the error editor (the user does not see the error editor except an error occurs during the opening of the valid editor).

With the last commit, the session is created as soon as we call getSession() on the temporary session editor input as a new sesison is created by Esteban's commit when the  known session is closed. 

Furthermore the current state seems to be able to reopen a previously closed session, IMO this is not safe on the existing code base.
Comment 14 Eclipse Genie CLA 2015-07-16 13:21:35 EDT
New Gerrit change created: https://git.eclipse.org/r/52101
Comment 16 Esteban DUGUEPEROUX CLA 2015-07-21 03:08:07 EDT
Fixed.
Comment 17 Esteban DUGUEPEROUX CLA 2015-08-31 08:31:56 EDT
Remains an issue, as the SessionEditorInput.uri field is not updated a SessionEditorInput.equals() can returns false instead of true.

This is the failing scenario :

Failing scenario with representations created in XPath based resource, InMemoryResourceImpl : 

1. Create 2 diagrams named '1' & '2'
2. Open '1'
3. Open '2'
4. Close '1'
5. Open '1'
6. Reopen '2' => KO : a new editor is opened while the existing one should be reopened.

We should override URIEditorInput.getURI() in SessionEditorInput to returns an updated uri.
Comment 18 Eclipse Genie CLA 2015-08-31 08:33:37 EDT
New Gerrit change created: https://git.eclipse.org/r/54885
Comment 20 Esteban DUGUEPEROUX CLA 2015-09-03 10:16:37 EDT
Fixed.
Comment 21 Eclipse Genie CLA 2015-09-07 03:35:08 EDT
New Gerrit change created: https://git.eclipse.org/r/55377
Comment 23 Jessy Mallet CLA 2015-09-29 03:30:07 EDT
Validated with Sirius 3.1.0.201509241504
Comment 24 Pierre-Charles David CLA 2015-10-16 09:11:55 EDT
Available in Sirius 3.1.0.