Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Cannot apply SysML stereotype
Cannot apply SysML stereotype [message #1696820] Thu, 28 May 2015 18:01 Go to next message
Sylvere Krima is currently offline Sylvere KrimaFriend
Messages: 1
Registered: May 2015
Junior Member
Hi all,

I am getting an IllegalArgumentException when applying a stereotype from the SysML (papyrus) profile.

My configuration is as follow:
- this is a standalone application
- I use the UML2 API v4.1.2
- I use the SysML API v0.10.2

I have been able to register all my packages/profiles/metamodels properly using the following code:
		resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
		resourceSet.getPackageRegistry().put(SysmlPackage.eNS_URI, SysmlPackage.eINSTANCE);
		resourceSet.getPackageRegistry().put(BlocksPackage.eNS_URI, BlocksPackage.eINSTANCE);
		resourceSet.getPackageRegistry().put(RequirementsPackage.eNS_URI, RequirementsPackage.eINSTANCE);
		resourceSet.getPackageRegistry().put(ActivitiesPackage.eNS_URI, ActivitiesPackage.eINSTANCE);
		resourceSet.getPackageRegistry().put(AllocationsPackage.eNS_URI, AllocationsPackage.eINSTANCE);
		resourceSet.getPackageRegistry().put(ConstraintsPackage.eNS_URI, ConstraintsPackage.eINSTANCE);
		resourceSet.getPackageRegistry().put(InteractionsPackage.eNS_URI, InteractionsPackage.eINSTANCE);
		resourceSet.getPackageRegistry().put(ModelelementsPackage.eNS_URI, ModelelementsPackage.eINSTANCE);
		resourceSet.getPackageRegistry().put(PortandflowsPackage.eNS_URI, PortandflowsPackage.eINSTANCE);
		resourceSet.getPackageRegistry().put(StatemachinesPackage.eNS_URI, StatemachinesPackage.eINSTANCE);
		resourceSet.getPackageRegistry().put(UsecasesPackage.eNS_URI, UsecasesPackage.eINSTANCE);		
		resourceSet.getURIConverter().getURIMap().put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), umlbaseUri.appendSegment("libraries").appendSegment(""));
		resourceSet.getURIConverter().getURIMap().put(URI.createURI(UMLResource.METAMODELS_PATHMAP), umlbaseUri.appendSegment("metamodels").appendSegment(""));
		resourceSet.getURIConverter().getURIMap().put(URI.createURI(UMLResource.PROFILES_PATHMAP), umlbaseUri.appendSegment("profiles").appendSegment(""));
		
		resourceSet.getURIConverter().getURIMap().put(URI.createURI(SysmlResource.PROFILES_PATHMAP), sysmlbaseUri.appendSegment("model").appendSegment(""));
		resourceSet.getURIConverter().getURIMap().put(URI.createURI(SysmlResource.LIBRARIES_PATHMAP), sysmlbaseUri.appendSegment("libraries").appendSegment(""));
		
		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
		
		
		UMLPlugin.getEPackageNsURIToProfileLocationMap().put(SysmlPackage.eNS_URI, URI.createURI(SysmlResource.SYSML_PROFILE_URI));
		
		resourceSet.getResource(URI.createURI(SysmlResource.SYSML_PROFILE_URI), true);


I then:
- create my model, a package, and some elements
- retrieve the SysML and Blocks profiles
- apply them to my package
- retrieve the NestedConnectorEnd stereotype
- and finally try to apply it to an instance of ConnectorEnd

Unfortunately I get an IllegalArgumentException on that line where I apply the stereotype. Any idea why? Or what to check?

I also get that same exception thrown whenever I try to apply a stereotype, such as a Block on a Class ...

Thanks for you help and ideas Smile
Re: Cannot apply SysML stereotype [message #1696921 is a reply to message #1696820] Fri, 29 May 2015 11:59 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi,

First, I woud suggest using the UMLResourcesUtil API to initialize your
resource set for stand-alone usage, then add the registrations needed
for SysML. I would also suggest raising an enhancement on Papyrus to
add an analogous SysMLResourcesUtil if it doesn't already exist (it
should delegate to UMLResourcesUtil and add its own stuff).

The SysML profile is statically generated, so UML2 will expect to be
able to find the Ecore EClasses corresponding to its UML Stereotypes in
the package registry, but there's an additional registry provided by
UML2 that provides this linkage. I don't see your code snippet
manipulating that registry.

You will need to fill the
UMLPlugin.getEPackageNsURIToProfileLocationMap() with the same mappings
that the plugin.xml of the SysML plug-in declares on the
org.eclipse.uml2.uml.generated_package extension point.

If that doesn't solve your problem, then you'll have to debug the
ElementOperations.applyStereotype(...) method to see which of the many
possible issues you're facing.

HTH,

Christian


On 2015-05-28 18:42:12 +0000, Sylvere Krima said:

> Hi all,
>
> I am getting an IllegalArgumentException when applying a stereotype
> from the SysML (papyrus) profile.
>
> My configuration is as follow:
> - this is a standalone application
> - I use the UML2 API v4.1.2
> - I use the SysML API v0.10.2
>
> I have been able to register all my packages/profiles/metamodels
> properly using the following code:
>
> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(SysmlPackage.eNS_URI,
> SysmlPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(BlocksPackage.eNS_URI,
> BlocksPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(RequirementsPackage.eNS_URI,
> RequirementsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ActivitiesPackage.eNS_URI,
> ActivitiesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(AllocationsPackage.eNS_URI,
> AllocationsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ConstraintsPackage.eNS_URI,
> ConstraintsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(InteractionsPackage.eNS_URI,
> InteractionsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(ModelelementsPackage.eNS_URI,
> ModelelementsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(PortandflowsPackage.eNS_URI,
> PortandflowsPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(StatemachinesPackage.eNS_URI,
> StatemachinesPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(UsecasesPackage.eNS_URI,
> UsecasesPackage.eINSTANCE);
>
> resourceSet.getURIConverter().getURIMap().put(URI.createURI(UMLResource.LIBRARIES_PATHMAP),
> umlbaseUri.appendSegment("libraries").appendSegment(""));
>
> resourceSet.getURIConverter().getURIMap().put(URI.createURI(UMLResource.METAMODELS_PATHMAP),
> umlbaseUri.appendSegment("metamodels").appendSegment(""));
>
> resourceSet.getURIConverter().getURIMap().put(URI.createURI(UMLResource.PROFILES_PATHMAP),
> umlbaseUri.appendSegment("profiles").appendSegment(""));
>
>
> resourceSet.getURIConverter().getURIMap().put(URI.createURI(SysmlResource.PROFILES_PATHMAP),
> sysmlbaseUri.appendSegment("model").appendSegment(""));
>
> resourceSet.getURIConverter().getURIMap().put(URI.createURI(SysmlResource.LIBRARIES_PATHMAP),
> sysmlbaseUri.appendSegment("libraries").appendSegment(""));
>
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
>
>
>
> UMLPlugin.getEPackageNsURIToProfileLocationMap().put(SysmlPackage.eNS_URI,
> URI.createURI(SysmlResource.SYSML_PROFILE_URI));
>
>
> resourceSet.getResource(URI.createURI(SysmlResource.SYSML_PROFILE_URI),
> true);
>
>
> I then:
> - create my model, a package, and some elements
> - retrieve the SysML and Blocks profiles
> - apply them to my package
> - retrieve the NestedConnectorEnd stereotype
> - and finally try to apply it to an instance of ConnectorEnd
>
> Unfortunately I get an IllegalArgumentException on that line where I
> apply the stereotype. Any idea why? Or what to check?
>
> I also get that same exception thrown whenever I try to apply a
> stereotype, such as a Block on a Class ...
>
> Thanks for you help and ideas :)
Re: Cannot apply SysML stereotype [message #1696947 is a reply to message #1696921] Fri, 29 May 2015 16:12 Go to previous message
Raphael B is currently offline Raphael BFriend
Messages: 14
Registered: April 2013
Junior Member
As a side note, shouldn't it be possible to use the SysML model dynamically?

The approach I suggested was to
- open the "SysML.profile.uml",
- call the "define" method on every Profile found,
- register the definition of each profile in the package registry and in the profile location map

But that approach didn't seem to work with the SysML profile provided by Papyrus, although it works with some other profiles I'm working on.
Previous Topic:UML2 jars in maven repositories
Next Topic:Listen for (re)application of a profile
Goto Forum:
  


Current Time: Fri Mar 29 05:36:55 GMT 2024

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

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

Back to the top