0

Can not get the Requirement from the model. I have tried getAppliedStereotypes() but it still not works. The code is as the following:

 [comment encoding = UTF-8 /]
[module maintest('http://www.eclipse.org/papyrus/sysml/1.4/SysML',
 'http://www.eclipse.org/papyrus/sysml/1.4/SysML/Activities',
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/Requirements', 
'http://www.eclipse.org/uml2/5.0.0/UML')/]

[template public maintestClass(aPackage : Package)]
 [comment @main /]
[file ((aPackage.name+'.m'), false, 'UTF-8')]
0000
 [for (r : Requirements::Requirement| aPackage.packagedElement->filter(Requirements::Requirement))]
11111   
 [/for]
[/file]
[/template]

Also, from this page http://techqa.info/programming/question/35093700/cannot-access-sysml-stereotypes-and-their-properties-in-acceleo , I can get Requirement just by generate(re : Requirements::Requirement) but it can not meet the needs since I have to put some node values in model to the document, but this template cannot get the model information. Or maybe any solutions about getting the nodes information in model which only get the Requirement?

lucia
  • 1
  • 2

1 Answers1

0

I had a very similar problem and to solve this I crossed this question here for which I now believe to have found the answer. I run through my SysML model's Classes and decide if they are Blocks or Requirements. Depending on that I call different imported templates:

[comment encoding = UTF-8 /]
[module main('http://www.eclipse.org/papyrus/sysml/1.4/SysML', 'http://www.eclipse.org/uml2/5.0.0/UML')]

[import MULTIC_TOOLING_GenSystemC::files::modRequirement /]
[import MULTIC_TOOLING_GenSystemC::files::modBlock /]

[template public mainTemplate(aClass : Class)]

    [comment @main/]
    [if (aClass.getAppliedStereotype('SysML::Blocks::Block')->notEmpty())]
        [let aBlock : Block = aClass.getStereotypeApplication(aClass.getAppliedStereotype('SysML::Blocks::Block'))]
        [tempBlock(aBlock)/]
        [/let]
    [/if]
    [if (aClass.getAppliedStereotype('SysML::Requirements::Requirement')->notEmpty())]
        [let aRequirement : Requirement = aClass.getStereotypeApplication(aClass.getAppliedStereotype('SysML::Requirements::Requirement'))]
            [tempRequirement(aRequirement)/]
        [/let]
    [/if]

[/template]
pipsoft
  • 21
  • 3