Problems with flow port stereotype with Luna and Acceleo [message #1684920] |
Wed, 18 March 2015 16:31 |
Thomas Bardot 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 |
Frank W. 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 #1693765 is a reply to message #1690270] |
Tue, 28 April 2015 09:01 |
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.08073 seconds