Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo/Papyrus] Problem with FlowPort direction
[Acceleo/Papyrus] Problem with FlowPort direction [message #696243] Wed, 13 July 2011 14:58 Go to next message
Gianmaria De Tommasi is currently offline Gianmaria De TommasiFriend
Messages: 2
Registered: July 2011
Junior Member

I'm trying to access to the "direction" attribute of a SysML FlowPort in my Papyrus model using Acceleo.

In my template I need to access to the 'direction' of the flow ports. That's what I'm trying to do

[template private generateHeaderFile(myGAM : Class)]


[for (p : Property | myGAM.getAllAttributes())]
[let fp : Stereotype = p.getApplicableStereotype('SysML::PortAndFlows::FlowPort')]
[if not fp->asBag()->isEmpty()]
/** [fp.getAllAttributes()->select(name='direction').toString()/] */



although the 'direction' attribute should be equal to 'in', 'out' or 'inout', I'm not able to retrieve it

Any hint ?

Re: [Acceleo/Papyrus] Problem with FlowPort direction [message #698296 is a reply to message #696243] Tue, 19 July 2011 08:26 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member

Retrieving an UML tagged value from Acceleo is quite tricky, and I strongly recommend that you use a Java service for that. Create a Java service with code such as this :

public boolean hasStereotype(Element element, String stereotypeName) {
    return element.getAppliedStereotype(stereotypeName) != null;

public List<Object> getTaggedValue(Element element, String stereotypeName, String property) {
    Stereotype stereotype = element.getAppliedStereotype(stereotypeName);
    List<Object> result = new ArrayList<Object>();
    if (stereotype == null) {

    Object value = element.getValue(stereotype, property);
    if (value instanceof Collection) {
    } else {
    return result;

Then either use the wizard "File > New > Other > Acceleo > Acceleo Module File" and make sure you select "create service wrapper" in the combo box "initialize contents". Select the Java file containing the method above and you'll get a new Acceleo module with the query corresponding to that java service (or watch the step by step

You'll then be able to call that service from your module (example if you've called the Acceleo module containing the service "acceleo::service::StereotypeUtils") :

[import acceleo::service::StereotypeUtils/]
[if (element.hasStereotype('SysML::PortAndFlows::FlowPort')]
    /** direction : getTaggedValue(element, 'SysML::PortAndFlows::FlowPort', 'direction') */

Laurent Goubet
Previous Topic:[Acceleo] Service class not found in the bundle containing module emtl
Next Topic:[XPand]trying to start Xpand from a plugin
Goto Forum:

Current Time: Tue May 21 01:08:54 GMT 2024

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

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

Back to the top