Bug 521173 - Precondition on link mapping are not called, but are validated
Summary: Precondition on link mapping are not called, but are validated
Status: UNCONFIRMED
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 4.1.1   Edit
Hardware: PC Windows 10
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2017-08-21 05:17 EDT by Jerome Pequery CLA
Modified: 2017-10-17 10:32 EDT (History)
2 users (show)

See Also:


Attachments
Screenshot of the diagram having the defect (13.53 KB, image/png)
2017-08-21 05:17 EDT, Jerome Pequery CLA
no flags Details
The tool declaration (51.21 KB, image/png)
2017-08-21 05:19 EDT, Jerome Pequery CLA
no flags Details
The declaration of the link mapping (39.02 KB, image/png)
2017-08-21 05:23 EDT, Jerome Pequery CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jerome Pequery CLA 2017-08-21 05:17:11 EDT
Created attachment 269908 [details]
Screenshot of the diagram having the defect

In MelodyCCM, there is a link connection tool about connecting a BorderNode to another Node. When I use this tool, preconditions are not called : 

It's a "provides" tool between a component and an interface (see screenshot). As a source, I can clic on the port or the component (extramapping), and as target, on the interface. 
But I Can also clic on the interface as a source. This check is done in preconditions, and those preconditions are not called by sirius during runtime.

I checked SiriusGraphicalNodeEditPolicy.getConnectionCreateCommand, and the behavior seems correct, it returns null as a Command at the end. The canCreate varialbe is set to false from the beginning, it's correct after mapping checking, so he doesn't call the precondition : it's logical. But at the end, it doesn't invalidate the link creation tool. 

I try to isolate this issue in a smaller sample, but I wasn't able : in all reproduction cases, the problem doesn't occurs. It might be an combinaison of many things for reproduction.
Comment 1 Jerome Pequery CLA 2017-08-21 05:19:47 EDT
Created attachment 269909 [details]
The tool declaration

all other declarations are not specific
Comment 2 Jerome Pequery CLA 2017-08-21 05:23:39 EDT
Created attachment 269910 [details]
The declaration of the link mapping
Comment 3 Julien Dupont CLA 2017-08-21 09:59:10 EDT
I can't reproduce the problem with Sirius.
I try to reproduce the problem with ecore example that contains extra mapping as explain in ticket. I try too, with a not synchronized diagram.
In all cases the précondition is evaluated and the result correspond as expected.
Comment 4 Maxime Porhel CLA 2017-10-17 10:32:32 EDT
Julien, did you try with a 4.1.x version of Sirius ? Could you attach you sample on ecore ? It seems you forgot the precondition/sourceFinderPrecondition/targetFinderPrecondition in your VSM to mimic Jérôme use case.

Jérôme, as currently implemented, there is not checks of the mapping preconditions during mappings/extra mappings analysis for an EdgeCreationTool, see org.eclipse.sirius.diagram.business.api.query.EdgeCreationDescriptionQuery.isValidAsSourceElement(DMappingBased) (+ target variant), the check is done on the mapping, extra mapping their domain class.

You should update your tool to complete the "Connection Complete Precondition"/"Connection Start Precondition" attributes of your tool. (you might also extract the common part of mapping/tool preconditions in java service to ease the maintenance)

IMO (to confirm with Pierre-Charles), the evaluation of all mappings preconditions is not done at command building step of the tool, as it would be evaluated on each source/target changes while hoovering the diagram and this might cause performance drawbacks.