unable get SysML stereotypes [message #1768125] |
Thu, 13 July 2017 18:45  |
Eclipse User |
|
|
|
In Eclipse, Using Papyrus neon and Acceleo 3.7 for SysML 1.4 diagram, the getAppliedStereotype()returns null. The modules are
[module generate('http://www.eclipse.org/uml2/5.0.0/UML',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/Blocks',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/Activities',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/Requirements',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/ModelElements')]
I have added the following code in the generate.java but still cannot work
Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
// UML2 profiles
URI uri = URI.createURI("platform:/plugin/org.eclipse.uml2.uml.resources");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));
// SysML profiles
uri = URI.createURI("platform:/plugin/org.eclipse.papyrus.sysml14");
uriMap.put(URI.createURI(SysMLResource.LIBRARIES_PATHMAP), uri.appendSegment("librairies").appendSegment(""));
uriMap.put(URI.createURI("pathmap://SysML14_PROFILES/"), uri.appendSegment("model").appendSegment(""));
The code like c.getAppliedStereotypes() returns null. I want to get the information of a requirement like the following code which returns nothing because of the getAppliedStereotype operation:
[for (re : uml::Class | uml::Class.allInstances()->select(cl : uml::Class | cl.getAppliedStereotype('SysML::Requirements::Requirement') <> null))]
--[re.name/]
Modellpfad : [re.qualifiedName/]
Id : [re.getValue(re.getAppliedStereotype('SysML::Requirements::Requirement'), 'id')/]
Text : [re.getValue(re.getAppliedStereotype('SysML::Requirements::Requirement'), 'text')/]
[/for]
|
|
|
Re: unable get SysML stereotypes [message #1768151 is a reply to message #1768125] |
Fri, 14 July 2017 07:42   |
Eclipse User |
|
|
|
Hi
Do not attempt to recode UMLResourcesUtil.init use it and if necessary report any problems as a bug.
Similarly there should be a SysMLResourcesUtil.init. If there isn't raise a bug.
"librairies" looks smelly.
Regards
Ed Willink
|
|
|
Re: unable get SysML stereotypes [message #1768173 is a reply to message #1768151] |
Fri, 14 July 2017 10:29   |
Eclipse User |
|
|
|
Ed Willink wrote on Fri, 14 July 2017 07:42Hi
Do not attempt to recode UMLResourcesUtil.init use it and if necessary report any problems as a bug.
Similarly there should be a SysMLResourcesUtil.init. If there isn't raise a bug.
"librairies" looks smelly.
Regards
Ed Willink
Hi
What else can I do to use the getappliedstereotypes operation? I delete the code in java file.
|
|
|
|
Re: unable get SysML stereotypes [message #1768179 is a reply to message #1768175] |
Fri, 14 July 2017 11:44   |
Eclipse User |
|
|
|
Ed Willink wrote on Fri, 14 July 2017 10:39Hi
No idea. Your comment seems to make very little sense and to completely ignore my earlier reply.
Regards
Ed Willink
Hi
Thank you for your replying. Do you mean the following code is not necessary? I added this because some solutions said this like in https://www.eclipse.org/forums/index.php/t/1060450/
Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
// UML2 profiles
URI uri = URI.createURI("platform:/plugin/org.eclipse.uml2.uml.resources");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));
// SysML profiles
uri = URI.createURI("platform:/plugin/org.eclipse.papyrus.sysml14");
uriMap.put(URI.createURI(SysMLResource.LIBRARIES_PATHMAP), uri.appendSegment("librairies").appendSegment(""));
uriMap.put(URI.createURI("pathmap://SysML14_PROFILES/"), uri.appendSegment("model").appendSegment(""));
|
|
|
Re: unable get SysML stereotypes [message #1768181 is a reply to message #1768179] |
Fri, 14 July 2017 11:53   |
Eclipse User |
|
|
|
Hi
Your code is very undesirable since correct and complete initialization of UML (and presumably SysML) is really hard., which is why I promoted the use of UMLResourcesUtil.init() that does the job correctly and portably. So make sure that UMLResourcesUtil.init() is called.
I know very little about SysML, but any failure to provide a SysMLResourcesUtil.init() or equivalent for you to call is a SysML bug.
The message you quote perhaps predates the widespread availability of UMLResourcesUtil.init().
Regards
Ed Willink
|
|
|
Re: unable get SysML stereotypes [message #1768385 is a reply to message #1768181] |
Tue, 18 July 2017 08:33   |
Eclipse User |
|
|
|
Hi Jiaan,
If I am not mistaken, you should not be using the "http://www.eclipse.org/papyrus/sysml/1.4/SysML" & co urls in your module declaration since I'm pretty sure this declaration conflicts with how the model themselves refer to the SysML profiles (they likely use a "pathmap" url internally).
You should remove the code you're using for UML profiles and call UMLResourcesUtil.init(resourceSet) instead. This will remove the risk of bad registration from the UML side of things. As for SysML, Papyrus doesn't provide a proper setup API for it so you do need to implement it yourself, but you're probably better off asking on the papyrus forum for that. This question, though old, seem to correspond and it looks like there is quite a lot of things to register for the proper function of SysML...
As Ed mentions though, "librairies" is most likely false.
Laurent Goubet
Obeo
[Updated on: Tue, 18 July 2017 08:34] by Moderator Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04050 seconds