Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Problems with flow port stereotype with Luna and Acceleo(How to know if a port has the flow port stereotype and which direction it has)
Problems with flow port stereotype with Luna and Acceleo [message #1684920] Wed, 18 March 2015 16:31 Go to next message
Thomas Bardot is currently offline Thomas BardotFriend
Messages: 5
Registered: January 2014
Junior Member
Hello

Since I upgrade to Luna, with Acceleo 3.5.1 and Papyrus 1.0.2, I am not able to test if a port has the stereotype "Flow Port" and to get its direction value.

I use two java services in order to do that :
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) {
	        return result;
	    }

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


If "aPort" is a port with the Flow Port stereotype the result of the following test is always false :
[ aPort.hasStereotype('SysML::PortAndFlows::FlowPort')/]


With the previous versions of Acceleo and Papyrus on Kepler, it works fine.

How can I fix this problem and test if a port has the Flow Port stereotype?

Thanks

[Updated on: Thu, 19 March 2015 16:48]

Report message to a moderator

Re: Problems with flow port stereotype with Luna and Acceleo [message #1690186 is a reply to message #1684920] Wed, 25 March 2015 15:20 Go to previous messageGo to next message
Frank W. is currently offline Frank W.Friend
Messages: 10
Registered: March 2015
Junior Member
Hi,

I have the same version of Acceleo and Eclipse.

[aPort.hasStereotype('FlowPort')/]


should work. So you have just to use the name and not the qualified name

you can then access the stereotype direction with
[aPort.getStereotypeValue('SysML::PortAndFlows::FlowPort', 'direction')/]

So here you need the qualified name.

No Java Script needed, just two queries. Like described elsewhere:

[query public hasStereotype( e : uml::Element, value: String) : Boolean = not e.getAppliedStereotypes()->select(e : uml::Stereotype | e.name = value) -> isEmpty()/]
[query public getStereotypeValue(e : uml::Element, st_name : String, propertyname : String) : String = e.getValue(e.getAppliedStereotype(st_name), propertyname) /]

[Updated on: Wed, 25 March 2015 15:21]

Report message to a moderator

Re: Problems with flow port stereotype with Luna and Acceleo [message #1690270 is a reply to message #1690186] Thu, 26 March 2015 09:24 Go to previous messageGo to next message
Thomas Bardot is currently offline Thomas BardotFriend
Messages: 5
Registered: January 2014
Junior Member
Thank you for your help Frank.

Unfortunately, these queries don't work with my tool chain.
[aPort.hasStereotype('FlowPort')/]

or
[aPort.hasStereotype('SysML::PortAndFlows::FlowPort')/]


always return 'false' value.

On Kepler version, everything work fine. But if these queries work fine with your version of Luna, it's still encouraging even if I don't understand why it does not work for me. Any idea?

[Updated on: Thu, 26 March 2015 09:25]

Report message to a moderator

Re: Problems with flow port stereotype with Luna and Acceleo [message #1693765 is a reply to message #1690270] Tue, 28 April 2015 09:01 Go to previous message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

I have tested your example and they indeed do not work on Acceleo on Luna. I have opened your UML model and it uses two UML profiles. They are using the following URIs:
- pathmap://UML_PROFILES/Ecore.profile.uml
- pathmap://SysML_PROFILES/SysML.profile.uml

EMF does not know how to load those models since it does not understand those URIs. Someone has to tell EMF how to convert those URIs. I don't know who is supposed to do this job or why this job is not done anymore, maybe the plugin in charge of this is not installed on your configuration. Acceleo being a generic tool, it is not aware of your UML or SysML profiles since this is an UML issue but it can let you tell EMF how to find them. For that you have to use the URI map of the resource set used in order to add a mapping between the URI of your profile and its real URI.

pathmap://SysML_PROFILES/ -> platform:/plugin/org.eclipse.papyrus.sysml/model/

It can be done by using the code available in the Acceleo FAQ in the method registerPackages of your Java launcher. Do not forget to change the Javadoc of the method registerPackages to use "@generated NOT" instead of "@generated".

 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.sysml");
 uriMap.put(URI.createURI(SysmlResource.LIBRARIES_PATHMAP), uri.appendSegment("librairies").appendSegment(""));
 uriMap.put(URI.createURI("pathmap://SysML_PROFILES/"), uri.appendSegment("model").appendSegment(""));  


Regards,

Stephane Bégaudeau, Obeo
Previous Topic:[XPAND] java.net.MalformedURLException: unknown protocol: ar
Next Topic:OCL Constraint to java code
Goto Forum:
  


Current Time: Sat Apr 20 03:59:55 GMT 2024

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

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

Back to the top