Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » issue with applicable and applied stereotypes?
issue with applicable and applied stereotypes? [message #1451011] Thu, 23 October 2014 07:43 Go to next message
Raphael Faudou is currently offline Raphael FaudouFriend
Messages: 105
Registered: July 2009
Senior Member
Hi all,
I tried to list applied stereotypes on a SysML model just created with Papyrus and I'm surprised as I can see "applied profiles" but "applicable stereotypes" is an empty list. Same for appliedStereotypes whereas I explicitely put some stereotypes to my model element.
After investigation in debug, profiles loaded are almost empty. Is it something known? shall I open a bug?

Here is the code and console outputs below:

public Model loadModel (String modelPath) {

System.out.println("trying to load model from file " + modelPath);
final ResourceSet resourceSet = new ResourceSetImpl();

UMLResourcesUtil.init(resourceSet);

// Create the output resource and add our model package to it.
Resource resource = resourceSet.getResource(URI.createFileURI(modelPath), true);

// model is the main content of resource
final Model model = (Model) resource.getContents().get(0);
System.out.println("mode loaded has name = " + model.getName());

System.out.println("Profiles applied to the model :");
System.out.println("-> " + model.getAppliedProfiles());

System.out.println("stereotypes applicable to the model :");
System.out.println("-> " + model.getApplicableStereotypes());

System.out.println("stereotypes applied to the model :");
System.out.println("-> " + model.getAppliedStereotypes());

return model;

}

console outputs:
trying to load model from file model/test1.uml
mode loaded has name = SysMLmodel
Profiles applied to the model :
-> [org.eclipse.uml2.uml.internal.impl.ProfileImpl@33fba86 (eProxyURI: pathmap://SysML_PROFILES/SysML.profile.uml#_fSw28LX7EduFmqQsrNB9lw), org.eclipse.uml2.uml.internal.impl.ProfileImpl@15ecd501 (eProxyURI: pathmap://SysML_PROFILES/SysML.profile.uml#_TZ_nULU5EduiKqCzJMWbGw), org.eclipse.uml2.uml.internal.impl.ProfileImpl@6d3c3df3 (eProxyURI: pathmap://SysML_PROFILES/SysML.profile.uml#_Gx8MgLX7EduFmqQsrNB9lw), org.eclipse.uml2.uml.internal.impl.ProfileImpl@4bb25b81 (eProxyURI: pathmap://SysML_PROFILES/SysML.profile.uml#_rpx28LX7EduFmqQsrNB9lw), org.eclipse.uml2.uml.internal.impl.ProfileImpl@436e5aed (eProxyURI: pathmap://SysML_PROFILES/SysML.profile.uml#_5WYJ0LX7EduFmqQsrNB9lw), org.eclipse.uml2.uml.internal.impl.ProfileImpl@5679f207 (eProxyURI: pathmap://SysML_PROFILES/SysML.profile.uml#_C2zXMLX8EduFmqQsrNB9lw), org.eclipse.uml2.uml.internal.impl.ProfileImpl@56dc688a (eProxyURI: pathmap://SysML_PROFILES/SysML.profile.uml#_NxdG4LX8EduFmqQsrNB9lw), org.eclipse.uml2.uml.internal.impl.ProfileImpl@43f69b79 (eProxyURI: pathmap://SysML_PROFILES/SysML.profile.uml#_OOJC4LX8EduFmqQsrNB9lw), org.eclipse.uml2.uml.internal.impl.ProfileImpl@6a7859ef (eProxyURI: pathmap://SysML_PROFILES/SysML.profile.uml#_meOioLX8EduFmqQsrNB9lw), org.eclipse.uml2.uml.internal.impl.ProfileImpl@2b780d7a (eProxyURI: pathmap://SysML_PROFILES/SysML.profile.uml#_nAF5kLX8EduFmqQsrNB9lw), org.eclipse.uml2.uml.internal.impl.ProfileImpl@8c61644 (eProxyURI: pathmap://SysML_PROFILES/SysML.profile.uml#_neZmMLX8EduFmqQsrNB9lw), org.eclipse.uml2.uml.internal.impl.ProfileImpl@799bb43f (eProxyURI: model.profile.uml#_JA3QAFqGEeSZBdgQcmtAeQ)]
stereotypes applicable to the model :
-> []
stereotypes applied to the model :
-> []

Re: issue with applicable and applied stereotypes? [message #1451018 is a reply to message #1451011] Thu, 23 October 2014 07:50 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 926
Registered: February 2011
Senior Member
Hi Raphael,

The issue is here:

(eProxyURI: pathmap://SysML_PROFILES/...


The "eProxyURI" means that the profile can't be resolved (or hasn't been, for any reason). UMLResource.init() initializes standard UML resources, but not Papyrus ones (i.e. not SysML). Papyrus is not designed to be ran standalone, so there is a lot of manual initialization stuff to do if you want to achieve that. Especially, you need to declare the SysML profile (Papyrus does it through extension points, but extension points are not loaded in standalone Java applications)

Regards,
Camille


Camille Letavernier
Re: issue with applicable and applied stereotypes? [message #1451091 is a reply to message #1451011] Thu, 23 October 2014 10:16 Go to previous messageGo to next message
Raphael Faudou is currently offline Raphael FaudouFriend
Messages: 105
Registered: July 2009
Senior Member
Thanks Camille for pointing that (eProxy).
I have added more stuff and now my profiles seem to be the true profiles as I can use them to find stereotypes.
Profiles applied to the model :
-> [org.eclipse.uml2.uml.internal.impl.ProfileImpl@1e9420f9 (name: Blocks, visibility: <unset>) (URI: http://www.eclipse.org/papyrus/0.7.0/SysML/Blocks),...

But applicableStereotypes still returns an empty list and I cannot apply "view" on a model.

stereotype "SysML::ModelElements::View" is not applicable to Model

I investigated in Debug on applyStereotype and found that I get a null eClassifier in the method ElementOperations.getExtension(Element element, Stereotype stereotype)

org.eclipse.uml2.uml.internal.impl.ClassImpl@4199d4f9 (eProxyURI: pathmap://UML_METAMODELS/UML.metamodel.uml#Package)

Do you know what I can add to my intializations to avoid proxies?
Should I register my model.uml ? somthing like:
URI uri 2= URI.createFileURI("/Users/Documents/ws/loadModel/model/test1.uml");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri2.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri2.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri2.appendSegment("profiles").appendSegment(""));

and
EPackage.Registry.INSTANCE.put("/Users/Documents/ws/loadModel/model/test1.uml",UMLPackage.eINSTANCE);

Thanks for any clue
Re: issue with applicable and applied stereotypes? [message #1451202 is a reply to message #1451091] Thu, 23 October 2014 13:26 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 926
Registered: February 2011
Senior Member
Hi,

Your model doesn't need to be registered (And actually, the fragment of code you pasted would only make things worse, registering your model on standard UML Uris, i.e. pretending that your model is the UML Metamodel itself). However, the UML Metamodel should be registered. I know UML provides a static helper for doing standalone initialization (Registering the metamodel + standard profiles), but I don't know what exactly.

Camille


Camille Letavernier
Re: issue with applicable and applied stereotypes? [message #1451262 is a reply to message #1451202] Thu, 23 October 2014 15:10 Go to previous messageGo to next message
Raphael Faudou is currently offline Raphael FaudouFriend
Messages: 105
Registered: July 2009
Senior Member
Thanks.
I made some progress with appropriate registration of UML metamodels and now I can see applicable stereotypes and so I can apply stereotypes without error.

Last issue concerns applied Stereotypes : still empty.
And if I save my model it does not contain any applied stereotype (neither those already existing before model edition by code nor those applied by program).

here are below the elements that have disappeared.
Seems that there is missing mapping to registrer base_Class and base_package elements. A problem with eCore eAnnotations? something special to do for registration?

<ModelElements:View xmi:id="_hDVCUFq5EeS_CrUFoLv7RA" base_Package="_QkWYYFn-EeS1RLEAMjdO1w"/>
<Blocks:Block xmi:id="_ILH9MFq6EeS_CrUFoLv7RA" base_Class="_ILHWIFq6EeS_CrUFoLv7RA"/>
<Blocks:Block xmi:id="_IgdUAFq6EeS_CrUFoLv7RA" base_Class="_Igcs8Fq6EeS_CrUFoLv7RA"/>
<Blocks:Block xmi:id="_I1P4QFq6EeS_CrUFoLv7RA" base_Class="_I1PRMFq6EeS_CrUFoLv7RA"/>

Re: issue with applicable and applied stereotypes? [message #1451276 is a reply to message #1451262] Thu, 23 October 2014 15:45 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 926
Registered: February 2011
Senior Member
The SysML profile is a static profile, so the Ecore Metamodel is stored outside the UML Profile model. You may need to declare it separately (For each subprofile)

The idea is that each contribution from oep.syml/plugin.xml should be translated into plain Java when using SysML standalone. This includes:

- The Profile mapping (uml2.uml.generated_package)
- The Ecore mapping (emf.ecore.generated_package)
- The URI Mapping (emf.ecore.uri_mapping)

Papyrus extensions are not required for standalone applications (papyrus.uml.extensionpoints.*)


Camille Letavernier
Re: issue with applicable and applied stereotypes? [message #1451342 is a reply to message #1451276] Thu, 23 October 2014 17:38 Go to previous messageGo to next message
Raphael Faudou is currently offline Raphael FaudouFriend
Messages: 105
Registered: July 2009
Senior Member
Thanks again.
I have looked at plugin.xml and translated each line into mappings:

For profile mapping I get following initialization code (I know, I should not address UUID directly but it is another task: I will do it when it works):

private static void initURI2ProfileMap() {
		UMLPlugin.getEPackageNsURIToProfileLocationMap().put(SysmlPackage.eNS_URI, 
				URI.createURI(SysmlResource.SYSML_PROFILE_URI+"#_TZ_nULU5EduiKqCzJMWbGw"));	
		UMLPlugin.getEPackageNsURIToProfileLocationMap().put(BlocksPackage.eNS_URI, 
				URI.createURI(SysmlResource.SYSML_PROFILE_URI+"#_fSw28LX7EduFmqQsrNB9lw"));		
		UMLPlugin.getEPackageNsURIToProfileLocationMap().put(ModelelementsPackage.eNS_URI, 
				URI.createURI(SysmlResource.SYSML_PROFILE_URI+"#Gx8MgLX7EduFmqQsrNB9lw"));		
		UMLPlugin.getEPackageNsURIToProfileLocationMap().put(PortandflowsPackage.eNS_URI, 
				URI.createURI(SysmlResource.SYSML_PROFILE_URI+"#_rpx28LX7EduFmqQsrNB9lw"));	
		// and so on ...
		
                System.out.println("UMLPlugin.getEPackageNsURIToProfileLocationMap() : "
				+ UMLPlugin.getEPackageNsURIToProfileLocationMap());
	}


For Ecore mapping I get this code:

Quote:
private static void initPackageRegistry(final EPackage.Registry packageRegistry) {
packageRegistry.put(SysmlPackage.eNS_URI, SysmlPackage.eINSTANCE);
packageRegistry.put(BlocksPackage.eNS_URI, BlocksPackage.eINSTANCE);
packageRegistry.put(RequirementsPackage.eNS_URI, RequirementsPackage.eINSTANCE);
packageRegistry.put(ModelelementsPackage.eNS_URI, ModelelementsPackage.eINSTANCE);

// and so on...

}


And for URI Mapping I get:

Quote:
private static void initURIConverterURIMap( final Map<URI, URI> uriMap) {

RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFactoryMap().
put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
URI uri1 = URI.createURI("jar:file:/applications/EclipseLMSR1/plugins/org.eclipse.uml2.uml.resources_5.0.0.v20140910-1354.jar!/");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri1.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri1.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri1.appendSegment("profiles").appendSegment(""));

String baseUri = "jar:file:/applications/EclipseLMSR1/plugins/org.eclipse.papyrus.sysml_1.0.1.v201409170932.jar!/";
URI uri = URI.createURI(baseUri+"model/SysML.profile.uml");
uriMap.put(URI.createURI(SysmlResource.SYSML_PROFILE_URI), uri);
URI uriPrimitivesTypes = URI.createURI(baseUri+"libraries/SysMLPrimitiveTypes.uml");
uriMap.put(URI.createURI(SysmlResource.SYSML_PRIMITIVE_TYPES_LIBRARY_URI), uriPrimitivesTypes);

URI uriSysMLPlugin = URI.createURI(baseUri);

uriMap.put(URI.createURI(SysmlResource.LIBRARIES_PATHMAP), uriSysMLPlugin.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(SysmlResource.PROFILES_PATHMAP), uriSysMLPlugin.appendSegment("model").appendSegment(""));

System.out.println("initURIConverterURIMap :: "+ uriMap);

}



Did I forget something?
I stil can not see applied stereotypes...

I have seen sysml.ecore in sysML plugin but no reference in plugin.xml. Should I map it too somewhere?

Thanks
Raphaƫl
Re: issue with applicable and applied stereotypes? [message #1451728 is a reply to message #1451342] Fri, 24 October 2014 07:46 Go to previous message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 926
Registered: February 2011
Senior Member
sysml.ecore is transformed to SysMLPackage.eINSTANCE (and others) via the Genmodel, so it doesn't need to be registered.

Everything looks good now, so I can't really tell. I guess the Java Debugger can help you now, but I don't really know what you should check. If the resource is properly populated, then the resource.save() should work seamlessly. Well, this probably means that you should check the Resource's contents.


Camille Letavernier
Previous Topic:Xtext integration into Papyrus PopupEditor
Next Topic:Converting RSA-RTE models to Papyrus models
Goto Forum:
  


Current Time: Sat Aug 08 06:56:53 GMT 2020

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

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

Back to the top