0

在 Eclipse 中,使用 Papyrus neon 和 Acceleo 3.7 for SysML 1.4 图表,getAppliedStereotype() 返回 null。这些模块是

[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')]

我在 generate.java 中添加了以下代码,但仍然无法工作

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(""));  

像 c.getAppliedStereotypes() 这样的代码返回 null。我想获取类似以下代码的需求信息,由于 getAppliedStereotype 操作,该代码不返回任何内容:

[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]
4

1 回答 1

0

好吧,如果您的模型元素都没有应用构造型,您将找不到类或对象。因此,当您尝试打印具有应用构造型的所有元素的应用构造型而不首先确保列表本身不为空时,您将失败。

于 2018-09-11T03:22:41.547 回答