possible side effect of getAppliedStereotype [message #1767765] |
Mon, 10 July 2017 21:12  |
Eclipse User |
|
|
|
Hi again,
I went through a :Cannot find operation (getAppliedStereotype(String)) for the type (Requirement) error with the following code...
[for (re:uml::Class | r->select(c:uml::Class | getValue(getAppliedStereotype('SysML::Requirements::Requirement'),'derived')->flatten()->notEmpty()))] <drop/>
[for (e:Requirement | re.getValue(getAppliedStereotype('SysML::Requirements::Requirement'),'derived')->flatten())] <drop/>
[for (x:Element | re.getValue(getAppliedStereotype('SysML::Requirements::Requirement'),'verifiedBy')->flatten())] <drop/>
Found a verification item linked to a Requirement : [x.toString().clean()/]
[/for] <drop/>
[/for] <drop/>
[for (t:Element | re.getValue(getAppliedStereotype('SysML::Requirements::Requirement'),'verifiedBy')->flatten())] <drop/>
Found a verification item linked to a Requirement : [t.toString().clean()/]
[/for] <drop/>
[/for] <drop/>
By removing the
[for (x:Element | re.getValue(getAppliedStereotype('SysML::Requirements::Requirement'),'verifiedBy')->flatten())] <drop/>
Found a verification item linked to a Requirement : [x.toString().clean()/]
[/for] <drop/>
I don't have this issue, and the code is the same as in the second part : I don't understand from where comes this issue. Is this a possible side effect ?
Samuel
|
|
|
Re: possible side effect of getAppliedStereotype [message #1767781 is a reply to message #1767765] |
Tue, 11 July 2017 06:14   |
Eclipse User |
|
|
|
in my opinion the problem is maybe due to implicit variable
when you use re.getValue(getAppliedStereotype('SysML::Requirements::Requirement')) it is not clear on which object you are calling getAppliedStereotype
can you force the caller, for instance :
re.getValue(re.getAppliedStereotype('SysML::Requirements::Requirement')) ?
|
|
|
Re: possible side effect of getAppliedStereotype [message #1767783 is a reply to message #1767765] |
Tue, 11 July 2017 06:22   |
Eclipse User |
|
|
|
Hi Samuel,
The point is that you attempt to call getAppliedStereotype on something (a SysML::Requirement) that is a stereotype. The operation getAppliedStereotype is not defined for stereotypes since it is not possible to apply a stereotype on a stereotype.
You should always make clear the element on which an operation call is made because the default one is not always obvious. ;-)
|
|
|
|
Re: possible side effect of getAppliedStereotype [message #1767815 is a reply to message #1767786] |
Tue, 11 July 2017 11:43   |
Eclipse User |
|
|
|
hi,
I have some trouble in getAppliedStereotype. I use papyrus neon and sysml1.4, the following code:
[c.getAppliedStereotype('SysML::Requirements::Requirement')/]
[c.getAppliedStereotypes()/]
returns nothing, c is the model. I search and add the following code in java but it 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("profiles").appendSegment(""));
Also, 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 want to know why it cannot work??
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03574 seconds