Home » Modeling » Papyrus » issue with applicable and applied stereotypes?
issue with applicable and applied stereotypes? [message #1451011] |
Thu, 23 October 2014 07:43 |
|
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 #1451091 is a reply to message #1451011] |
Thu, 23 October 2014 10:16 |
|
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 #1451262 is a reply to message #1451202] |
Thu, 23 October 2014 15:10 |
|
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 #1451342 is a reply to message #1451276] |
Thu, 23 October 2014 17:38 |
|
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 |
Camille Letavernier Messages: 952 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
|
|
|
Goto Forum:
Current Time: Mon Sep 23 06:21:13 GMT 2024
Powered by FUDForum. Page generated in 0.04067 seconds
|