Bug 481849 - Make metamodel registration in VSMs mandatory (or at least highly encouraged)
Summary: Make metamodel registration in VSMs mandatory (or at least highly encouraged)
Status: ASSIGNED
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 3.1.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on: 487999 488094 488299 489842 493331 493330
Blocks:
  Show dependency tree
 
Reported: 2015-11-10 09:29 EST by Pierre-Charles David CLA
Modified: 2017-02-21 05:14 EST (History)
4 users (show)

See Also:


Attachments
Ecore Editor ui to load EPackage since EMF 2.9 (12.35 KB, image/png)
2015-11-10 10:42 EST, Cedric Brun CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre-Charles David CLA 2015-11-10 09:29:21 EST
We know that several features related to interpreted expression do not work very well when Sirius has to guess which user metamodels should be considered (see for example AQL expressions validation/interpretation). In general, everything is much easier for Sirius and much more stable (and less confusing) for end-users if the metamodels are properly registered in the VSMs.

We should make it mandatory (as much as possible) for all the metamodels referenced in a VSM to be registered. This includes at least all the domain classes and all the type literals in all the interpreted expressions in the VSM. Given only the metamodels explicitly registered in the VSM, we should be able to resolve all of these types. If the VSM is inside a plug-in project, we should also make sure the project has dependencies (directly or indirectly) on plug-ins which provide said metamodels).
Comment 1 Maxime Porhel CLA 2015-11-10 10:17:29 EST
Additional use case: 
 . Metamodel plugins in the workspace (and non-deployed)
 . VSM plugin in the workspace
 . We currently register the platform:/resource uri of the ecore file. 
-> Once deployed, Sirius will not be able to retrieve it. 

We might need something like an element with two attribute: the nsUri and some optional location (to be able to compute and retrieve the platform:/resource uri to ease the completion, validation and other VSM editor features).
Comment 2 Cedric Brun CLA 2015-11-10 10:42:04 EST
Created attachment 257858 [details]
Ecore Editor ui to load EPackage since EMF 2.9
Comment 3 Cedric Brun CLA 2015-11-10 10:42:41 EST
(In reply to Maxime Porhel from comment #1)
> Additional use case: 
>  . Metamodel plugins in the workspace (and non-deployed)
>  . VSM plugin in the workspace
>  . We currently register the platform:/resource uri of the ecore file. 
> -> Once deployed, Sirius will not be able to retrieve it. 
> 
> We might need something like an element with two attribute: the nsUri and
> some optional location (to be able to compute and retrieve the
> platform:/resource uri to ease the completion, validation and other VSM
> editor features).


I think the right answer is simpler than that.

We should rely on the target-platform support EMF core brings with 
org.eclipse.emf.ecore.plugin.EcorePlugin.computePlatformURIMap(true) 

(since EMF 2.9) and update the UI accordingly based on what has been done in EMF itself (see attachment). We could even consider not even proposing an alternative solution to the "Browse Target Platform Packages" button as any other solution might work "by chance" but is quite unreliable.
Comment 4 Eclipse Genie CLA 2016-02-09 05:29:07 EST
New Gerrit change created: https://git.eclipse.org/r/66188
Comment 5 Laurent Fasani CLA 2016-02-23 11:46:14 EST
The MM_registration_in_VSM_spec.textile specification has been added in previous gerrit which covers many aspects about using declared MM only. It covers validation, completion and run-time and also UI aspects.

The scope of this ticket is about validation described below:

only RepresentationDescription meta-models in the scope of validation. That bug handle part of the validation aspects ensuring that meta-models are correctly declared and also that Domain class is part of the declared Meta-modes

Below is an extract of the MM_registration_in_VSM_spec.textile that corresponds to what is done in the scopr of this ticket

*RepresentationDescription metamodels*
The validation on odesign should provides an error in the following cases:
* if there is no registered meta-models on RepresentationDescription
* if registered meta-models are not among VSP dependencies and its transitive dependencies. This rule is only if the odesign is owned by a VSP. (We consider that a VSP is a plugin which contains an extension to org.eclipse.sirius.componentization)
* when the RepresentationDescription does not register the MM used for :
[...]
** a non null Domain Class
Comment 6 Eclipse Genie CLA 2016-02-24 05:10:40 EST
New Gerrit change created: https://git.eclipse.org/r/67215
Comment 7 Eclipse Genie CLA 2016-02-24 05:10:44 EST
New Gerrit change created: https://git.eclipse.org/r/67214
Comment 8 Pierre-Charles David CLA 2016-03-04 04:12:23 EST
As part of this ticket, or maybe bug #487999, we should add the same "Browse Target Platform Packages" as present in recent versions of EMF, see org.eclipse.emf.ecore.presentation.EcoreActionBarContributor.ExtendedLoadResourceDialog.
Comment 9 Pierre-Charles David CLA 2016-05-10 09:06:46 EDT
Moving this top-level ticket to 4.1. More disucssion is needed around this whole issue of "which metamodels are visible/registered at any point in time/in the code".

For 4.0 we'll only do two things:
* Add a VSM validation rule that raises a warning if any RepresentationDescription defined inside lacks explicit metamodels.
* Add an "Add from Target Platform" button along with the exising "from Registry", "from workspace" and "from filesystem" in RepresentationDescriptionMetamodelPropertySectionSpec.

I'll create two separate tickets for these specific issues.
Comment 10 Laurent Redor CLA 2016-05-23 12:06:41 EDT
Warning: the metamodel should not be referenced through the current URI. For example if I add the metamodel 

> <metamodel href="http://www.eclipse.org/sirius/sample/basicfamily#/"/>

(like in https://git.eclipse.org/r/73413) for the "Persons diagram" diagram of the Basic Famly sample, and then open the VSM (with the MM not deployed, ie MM and VSP are in the same workspace), I have the exception:

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(Unknown Source)
	at org.eclipse.sirius.editor.properties.sections.description.representationdescription.RepresentationDescriptionMetamodelPropertySectionSpec.refresh(RepresentationDescriptionMetamodelPropertySectionSpec.java:225)
	at org.eclipse.ui.views.properties.tabbed.TabContents$6.run(TabContents.java:217)
...

when I clicked on the representation. The above gerrit was abandonned for this reason to avoid that end-user will be confronted to this problem with the basic family example.
Comment 11 Maxime Porhel CLA 2016-05-24 05:50:27 EDT
See: 
 . https://git.eclipse.org/r/#/c/67215
 . https://git.eclipse.org/r/#/c/72930

Those patch sets were initially proposed as draft for Bug 493330 which haas been resolved for Sirius 4.0.0. 
I move them here for the moment but they might later require the creation of specific bugzilla regarding the status of this one.