Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » applied stereotype from SysML not returned
applied stereotype from SysML not returned [message #1164145] Thu, 31 October 2013 13:11 Go to next message
jonas b is currently offline jonas bFriend
Messages: 23
Registered: July 2013
Junior Member
Hello!

I want to filter all elements which have applied stereotype Requirement.

I have a model which has applied profile SysML. In the model there are elements with applied stereotype Requirement from SysML::Requirements. I can see this in Papyrus Editor->Properties->Profile->Applied Stereotypes.

However, in code the stereotype doesn't show up. model.getAppliedProfiles() contains SysML, but element.getAppliedStereotypes() doesn't contain Requirement. Other stereotypes do get recognized however. For example stereotype Refine from StandardProfileL2 is recognized.

Please note that the model is not loaded within a plugin but from a standalone java application.

Why are SysML stereotype applications not recognized?
Re: applied stereotype from SysML not returned [message #1170139 is a reply to message #1164145] Mon, 04 November 2013 12:38 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi Jonas,


Papyrus contributes to Eclipse only via extension points, whereas EMF and UML can be used in standalone mode.

The Standard L2/L3 profiles are contributed by UML and should work in standalone.

SysML is contributed by Papyrus, and there is no standalone initialization helper for that. You need to setup SysML manually (i.e. register the SysML Profile and EPackage)

Papyrus has *not* been designed for standalone java applications.


Regards,
Camille


Camille Letavernier
Re: applied stereotype from SysML not returned [message #1170306 is a reply to message #1170139] Mon, 04 November 2013 14:55 Go to previous messageGo to next message
jonas b is currently offline jonas bFriend
Messages: 23
Registered: July 2013
Junior Member
Hello Camille,

Thank you for your reply.

Are you implying that setting up SysML is similar to setting up my own custom profile? Because this has already been done in my project, so I just need to reproduce that for SysML. Unfortunately I don't fully understand the process yet.

When I load my UML model which makes use of SysML profile, I have among the containing ResourceSet's resources: UMLResourceImpl@467924cb uri='pathmap://SysML_PROFILES/SysML.profile.uml'

I put org.eclipse.papyrus.sysml_0.10.0.v201306121352.jar on my buildpath. I find the profile in the jar in model/SysML.profile.uml

So I think in URIConverter.URI_MAP I need the following mapping: pathmap://SysML_PROFILES->jar:file:/C:/Users/jb/Desktop/demo/MoMuTUml_2013_2RC.jar!/model/

So that's where I am atm. I must be missing something more. What do you mean with registering the EPackage?
Re: applied stereotype from SysML not returned [message #1170323 is a reply to message #1170306] Mon, 04 November 2013 15:10 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
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 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

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 Go to previous messageGo to next message
jonas b is currently offline jonas bFriend
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 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

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 #1181453 is a reply to message #1176715] Mon, 11 November 2013 16:09 Go to previous messageGo to next message
jonas b is currently offline jonas bFriend
Messages: 23
Registered: July 2013
Junior Member
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 #1181605 is a reply to message #1181453] Mon, 11 November 2013 18:14 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

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 #1185330 is a reply to message #1181605] Thu, 14 November 2013 02:02 Go to previous messageGo to next message
jonas b is currently offline jonas bFriend
Messages: 23
Registered: July 2013
Junior Member
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.
Re: applied stereotype from SysML not returned [message #1186091 is a reply to message #1185330] Thu, 14 November 2013 13:24 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

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.
Re: applied stereotype from SysML not returned [message #1196759 is a reply to message #1186091] Tue, 19 November 2013 15:30 Go to previous message
jonas b is currently offline jonas bFriend
Messages: 23
Registered: July 2013
Junior Member
Works fine. Thanks!
Previous Topic:Send signal action defaults signal parameters to input pins...
Next Topic:Why show target object on send signal action...
Goto Forum:
  


Current Time: Thu Apr 25 21:04:47 GMT 2024

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

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

Back to the top