Home » Modeling » Papyrus » applied stereotype from SysML not returned
| | |
Re: applied stereotype from SysML not returned [message #1170323 is a reply to message #1170306] |
Mon, 04 November 2013 15:10 |
Camille Letavernier Messages: 952 Registered: February 2011 |
Senior Member |
|
|
Hi,
Papyrus provides a "static" implementation of the SysML profile. "Static" means that it has been converted to Ecore, and Java code has been generated for all stereotypes.
So, registering the "SysML.profile.uml" is necessary, but not sufficient.
You should also register the EMF/Ecore EPackage in the Package registry. You can do it with:
EPackage.Registry.INSTANCE.put(SysmlPackage.eNS_URI, SysmlPackage.eINSTANCE);
EPackage.Registry.INSTANCE.put(BlocksPackage.eNS_URI, BlocksPackage.eINSTANCE);
EPackage.Registry.INSTANCE.put(RequirementsPackage.eNS_URI, RequirementsPackage.eINSTANCE);
...
...
UML also provides a specific extension point for UML generated packages, which is different from the standard EMF one. So you may need to do something for that too... I'm not sure.
Regards,
Camille
Camille Letavernier
|
|
|
Re: applied stereotype from SysML not returned [message #1170336 is a reply to message #1170323] |
Mon, 04 November 2013 15:20 |
|
Hi, Camille, jonas b,
Yes, indeed, UML has some extra registration steps for profiles. Have
a look at what the UMLResourceUtil API does in the
org.eclipse.uml2.uml.resources plug-in does for registration of the UML
standard profiles. You can do the same for your profiles.
http://git.eclipse.org/c/uml2/org.eclipse.uml2.git/tree/plugins/org.eclipse.uml2.uml.resources/src/org/eclipse/uml2/uml/resources/util/UMLResourcesUtil.java
HTH,
Christian
On 2013-11-04 15:10:15 +0000, Camille Letavernier said:
> Hi,
>
>
> Papyrus provides a "static" implementation of the SysML profile.
> "Static" means that it has been converted to Ecore, and Java code has
> been generated for all stereotypes.
>
> So, registering the "SysML.profile.uml" is necessary, but not sufficient.
>
> You should also register the EMF/Ecore EPackage in the Package
> registry. You can do it with:
>
> EPackage.Registry.INSTANCE.put(SysmlPackage.eNS_URI, SysmlPackage.eINSTANCE);
> EPackage.Registry.INSTANCE.put(BlocksPackage.eNS_URI, BlocksPackage.eINSTANCE);
> EPackage.Registry.INSTANCE.put(RequirementsPackage.eNS_URI,
> RequirementsPackage.eINSTANCE);
> ..
> ..
>
> UML also provides a specific extension point for UML generated
> packages, which is different from the standard EMF one. So you may need
> to do something for that too... I'm not sure.
>
>
> Regards,
> Camille
|
|
|
Re: applied stereotype from SysML not returned [message #1173889 is a reply to message #1170336] |
Wed, 06 November 2013 20:32 |
jonas b Messages: 23 Registered: July 2013 |
Junior Member |
|
|
Hi again,
Thank you for the hints. I rebuilt org.eclipse.uml2.uml.resources.util.UMLResourcesUtil.initGlobalRegistries() but to no effect yet.
public static void registerSysmlProfile() {
initPackageRegistry(EPackage.Registry.INSTANCE);
initURIConverterURIMap(URIConverter.URI_MAP);
UMLPlugin.getEPackageNsURIToProfileLocationMap().put(SysmlPackage.eNS_URI, URI.createURI(SysmlResource.SYSML_PROFILE_URI));
}
private static void initURIConverterURIMap(final Map<URI, URI> uriMap) {
final URI baseUri = getResourceURI("model/SysML.profile.uml");
//baseUri == jar:file:/C:/Users/jb/momut/libraries/org.eclipse.papyrus.sysml_0.10.0.v201306121352.jar!/
uriMap.put(URI.createURI(SysmlResource.PROFILES_PATHMAP), baseUri.appendSegment("model").appendSegment(""));
uriMap.put(URI.createURI(SysmlResource.LIBRARIES_PATHMAP), baseUri.appendSegment("libraries").appendSegment(""));
}
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(ActivitiesPackage.eNS_URI, ActivitiesPackage.eINSTANCE);
packageRegistry.put(AllocationsPackage.eNS_URI, AllocationsPackage.eINSTANCE);
packageRegistry.put(ConstraintsPackage.eNS_URI, ConstraintsPackage.eINSTANCE);
packageRegistry.put(InteractionsPackage.eNS_URI, InteractionsPackage.eINSTANCE);
packageRegistry.put(ModelelementsPackage.eNS_URI, ModelelementsPackage.eINSTANCE);
packageRegistry.put(PortandflowsPackage.eNS_URI, PortandflowsPackage.eINSTANCE);
packageRegistry.put(StatemachinesPackage.eNS_URI, StatemachinesPackage.eINSTANCE);
packageRegistry.put(UsecasesPackage.eNS_URI, UsecasesPackage.eINSTANCE);
}
I did not reproduce the methods
public static Resource.Factory.Registry initResourceFactoryRegistry(Resource.Factory.Registry resourceFactoryRegistry)
and
public static ContentHandler.Registry initContentHandlerRegistry(ContentHandler.Registry contentHandlerRegistry)
because I can't find equivalent Objects for Sysml.
So after all these registrations, here are the contents of the various maps:
UMLPlugin.getEPackageNsURIToProfileLocationMap():
[http://www.eclipse.org/uml2/schemas/Ecore/5=pathmap://UML_PROFILES/Ecore.profile.uml#_0,
http://www.eclipse.org/papyrus/0.7.0/SysML=pathmap://SysML_PROFILES/SysML.profile.uml, //does that even belong in here?
http://www.eclipse.org/uml2/4.0.0/UML/Profile/L3=pathmap://UML_PROFILES/StandardL3.profile.uml#_0,
http://www.eclipse.org/uml2/4.0.0/UML/Profile/L2=pathmap://UML_PROFILES/StandardL2.profile.uml#_0]
URIConverter.URI_MAP
[pathmap://UML_LIBRARIES/->jar:file:/C:/Users/jb/momut/libraries/org.eclipse.uml2.uml.resources_4.1.0.v20130610-0712.jar!/libraries/,
pathmap://UML_METAMODELS/->jar:file:/C:/Users/jb/momut/libraries/org.eclipse.uml2.uml.resources_4.1.0.v20130610-0712.jar!/metamodels/,
pathmap://UML_PROFILES/->jar:file:/C:/Users/jb/momut/libraries/org.eclipse.uml2.uml.resources_4.1.0.v20130610-0712.jar!/profiles/,
http://www.eclipse.org/ocl/1.1.0/oclstdlib.uml->jar:file:/C:/Users/jb/momut/libraries/org.eclipse.ocl.uml_4.0.100.v20130610-1317.jar!/model/oclstdlib.uml,
pathmap://SysML_PROFILES/->jar:file:/C:/Users/jb/momut/libraries/org.eclipse.papyrus.sysml_0.10.0.v201306121352.jar!/model/,
pathmap://SysML_LIBRARIES/->jar:file:/C:/Users/jb/momut/libraries/org.eclipse.papyrus.sysml_0.10.0.v201306121352.jar!/libraries/]
However, I still don't see the stereotypes applied.
|
|
|
Re: applied stereotype from SysML not returned [message #1176715 is a reply to message #1173889] |
Fri, 08 November 2013 14:03 |
|
Hi,
There is no SysML resource implementation; SysML is a profile of UML,
so it uses the UMLResource.
I would suggest at this point debugging the
ElementOperations::getAppliedStereotypes() method to see why you're not
getting the stereotypes that you expect.
cW
On 2013-11-06 20:32:10 +0000, jonas b said:
> Hi again,
>
> Thank you for the hints. I rebuilt
> org.eclipse.uml2.uml.resources.util.UMLResourcesUtil.initGlobalRegistries()
> but to no effect yet.
>
> public static void registerSysmlProfile() {
> initPackageRegistry(EPackage.Registry.INSTANCE);
> initURIConverterURIMap(URIConverter.URI_MAP);
>
> UMLPlugin.getEPackageNsURIToProfileLocationMap().put(SysmlPackage.eNS_URI,
> URI.createURI(SysmlResource.SYSML_PROFILE_URI));
> }
>
> private static void initURIConverterURIMap(final Map<URI, URI> uriMap) {
> final URI baseUri = getResourceURI("model/SysML.profile.uml");
> //baseUri ==
> jar:file:/C:/Users/jb/momut/libraries/org.eclipse.papyrus.sysml_0.10.0.v201306121352.jar!/
>
> uriMap.put(URI.createURI(SysmlResource.PROFILES_PATHMAP),
> baseUri.appendSegment("model").appendSegment(""));
> uriMap.put(URI.createURI(SysmlResource.LIBRARIES_PATHMAP),
> baseUri.appendSegment("libraries").appendSegment(""));
> }
>
> 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(ActivitiesPackage.eNS_URI, ActivitiesPackage.eINSTANCE);
> packageRegistry.put(AllocationsPackage.eNS_URI,
> AllocationsPackage.eINSTANCE);
> packageRegistry.put(ConstraintsPackage.eNS_URI,
> ConstraintsPackage.eINSTANCE);
> packageRegistry.put(InteractionsPackage.eNS_URI,
> InteractionsPackage.eINSTANCE);
> packageRegistry.put(ModelelementsPackage.eNS_URI,
> ModelelementsPackage.eINSTANCE);
> packageRegistry.put(PortandflowsPackage.eNS_URI,
> PortandflowsPackage.eINSTANCE);
> packageRegistry.put(StatemachinesPackage.eNS_URI,
> StatemachinesPackage.eINSTANCE);
> packageRegistry.put(UsecasesPackage.eNS_URI, UsecasesPackage.eINSTANCE);
> }
> I did not reproduce the methods public static Resource.Factory.Registry
> initResourceFactoryRegistry(Resource.Factory.Registry
> resourceFactoryRegistry)
> and public static ContentHandler.Registry
> initContentHandlerRegistry(ContentHandler.Registry
> contentHandlerRegistry)
> because I can't find equivalent Objects for Sysml.
>
> So after all these registrations, here are the contents of the various maps:
> UMLPlugin.getEPackageNsURIToProfileLocationMap():
> [http://www.eclipse.org/uml2/schemas/Ecore/5=pathmap://UML_PROFILES/Ecore.profile.uml#_0,
>
> http://www.eclipse.org/papyrus/0.7.0/SysML=pathmap://SysML_PROFILES/SysML.profile.uml,
> //does that even belong in here?
> http://www.eclipse.org/uml2/4.0.0/UML/Profile/L3=pathmap://UML_PROFILES/StandardL3.profile.uml#_0,
>
> http://www.eclipse.org/uml2/4.0.0/UML/Profile/L2=pathmap://UML_PROFILES/StandardL2.profile.uml#_0]
>
>
> URIConverter.URI_MAP
>
> [pathmap://UML_LIBRARIES/->jar:file:/C:/Users/jb/momut/libraries/org.eclipse.uml2.uml.resources_4.1.0.v20130610-0712.jar!/libraries/,
>
> pathmap://UML_METAMODELS/->jar:file:/C:/Users/jb/momut/libraries/org.eclipse.uml2.uml.resources_4.1.0.v20130610-0712.jar!/metamodels/,
> pathmap://UML_PROFILES/->jar:file:/C:/Users/jb/momut/libraries/org.eclipse.uml2.uml.resources_4.1.0.v20130610-0712.jar!/profiles/,
> http://www.eclipse.org/ocl/1.1.0/oclstdlib.uml->jar:file:/C:/Users/jb/momut/libraries/org.eclipse.ocl.uml_4.0.100.v20130610-1317.jar!/model/oclstdlib.uml,
> pathmap://SysML_PROFILES/->jar:file:/C:/Users/jb/momut/libraries/org.eclipse.papyrus.sysml_0.10.0.v201306121352.jar!/model/,
> pathmap://SysML_LIBRARIES/->jar:file:/C:/Users/jb/momut/libraries/org.eclipse.papyrus.sysml_0.10.0.v201306121352.jar!/libraries/]
>
>
> However, I still don't see the stereotypes applied.
|
|
| |
Re: applied stereotype from SysML not returned [message #1181605 is a reply to message #1181453] |
Mon, 11 November 2013 18:14 |
|
Hi, Tomas,
You don't have to hard-code this. You can use the
EcoreUtil.getURI(EObject) API to get the URI of profile and register
that.
This is beside the fact that the profile's ID will only change if it is
destroyed and created anew.
HTH,
Christian
On 2013-11-11 16:09:48 +0000, jonas b said:
> Hi,
>
> Thank you for pointing me in the right direction!
>
> The thing I missed was to add Requirement package's NS URI to the map:
> UMLPlugin.getEPackageNsURIToProfileLocationMap().put(RequirementsPackage.eNS_URI,
> URI.createURI(SysmlResource.SYSML_PROFILE_URI+"#_OOJC4LX8EduFmqQsrNB9lw"));Although
> I'm glad it finally works, I expect there must be a better solution.
> The hardcoded fragment #_OOJC4LX8EduFmqQsrNB9lw will most likely break
> it as soon as we update SysML in our library.
|
|
| |
Re: applied stereotype from SysML not returned [message #1186091 is a reply to message #1185330] |
Thu, 14 November 2013 13:24 |
|
Hi,
If SysML is subdivided into nested profiles (as MARTE is; sorry, I know
nothing about SysML) then you can recursively scan its
getNestedPackages(), collecting those that are Profiles. So, your
start is a good one, you just need to dig deeper into the profile
structure.
And I'm very sorry to have accidentally addressed you as Tomas in my
previous reply. I conflated this conversation with another!
cW
On 2013-11-14 02:02:12 +0000, jonas b said:
> Thanks for the hint. But how do I obtain an instance of Profile at that
> point? The only Profile I can access is SysML itself. I can do this by
> creating a ResourceSetImpl, then using it to load a resource with
> URI.createURI(SysmlResource.SYSML_PROFILE_URI)) and then iterating
> through the contents until I hit a Profile. But then this profile is
> SysML, not SysML::Requirements.
|
|
| |
Goto Forum:
Current Time: Tue Sep 24 10:25:36 GMT 2024
Powered by FUDForum. Page generated in 0.04422 seconds
|