Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Cannot Access SysML Sterotypes and their properties(I am unable to retrieve SysML sterotypes such as FlowPort and its direction property)
Cannot Access SysML Sterotypes and their properties [message #1721756] Fri, 29 January 2016 20:02 Go to next message
Yasir Hussain is currently offline Yasir HussainFriend
Messages: 1
Registered: January 2016
Junior Member
I am developing a M2T generator in Acceleo. The model is basically a UML model with SysML profile created in Papyrus. It includes Blocks and FlowPorts. I have to access these stereotypes but it seems that I cannot retrieve any SysML object even though they appear in list (code suggestion). Actually I have to access 'Direction' property of FlowPort associated with Port. I have already tried suggestions and answers from various forums (including this) but in vain.

The code is given below. I have created java services as suggested by this but port.hasStereotype('FlowPort') always return false. I have also tried 'SysML::PortAndFlows::FlowPort' instead of 'FlowPort'. I use Acceleo 3.6.2 on Eclipse Mars.

...
[template public generateElement(model : Model)]
[comment @main/]

[file ('created.txt', false, 'UTF-8')]
[for(port: Port | model.eAllContents(Port))]
	[if(port.hasStereotype('FlowPort'))]
		OK
	[else]
		NOT OK
	[/if]
[/for]
[/file]
[/template]


I include following metamodels in the Module at the time of creating the module:

http://www.eclipse.org/uml2/5.0.0/UML
http://www.eclipse.org/papyrus/0.7.0/SysML
http://www.eclipse.org/papyrus/0.7.0/SysML/Blocks
http://www.eclipse.org/papyrus/0.7.0/SysML/Constraints
http://www.eclipse.org/papyrus/0.7.0/SysML/PortAndFlows
http://www.eclipse.org/emf/2002/Ecore

Also I do register required packages including following as suggested by https://www.eclipse.org/forums/index.php?t=msg&th=1060450&goto=1693765& in registerPackages() of Generate.java

        // 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("SysML.profile.uml").appendSegment("")); 
        uriMap.put(URI.createURI("pathmap://SysML_PROFILES/"), uri.appendSegment("model").appendSegment(""));


Any sort of help is appreciated.
Re: Cannot Access SysML Sterotypes and their properties [message #1721780 is a reply to message #1721756] Sat, 30 January 2016 09:49 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7679
Registered: July 2009
Senior Member
Hi

I am sorry that Ihave not used UML with Acceleo so my advice is limited
however...

Provision of the UML registrations was always a pain and got worse after
the upgrade to UML 2.4 and then 2.5 support. A UMLResourcesUtil.init()
helper method was therefore provided. Any failure to use this method is
likely to encounter significant difficulties.

However Acceleo has unfortunately created unique challenges by trying to
fudge an equivalence between edit-time and run-time URIs and so what I
recommend may not be helpful. You need to check whether your style of
UML URI exposition is compatible with the fudge. When I was using
Acceleo for OCL, I needed to override some of the start up methods to
bypass the fudge.

[The "librairies" typo in:

uriMap.put(URI.createURI(SysmlResource.LIBRARIES_PATHMAP),
uri.appendSegment("librairies").appendSegment(""));

probably does not help. There should be a SysMLResourcesUtil.init() to
avoid such typos. Raise a Bugzilla.]

Regards

Ed Willink


On 29/01/2016 21:04, Yasir Hussain wrote:
> I am developing a M2T generator in Acceleo. The model is basically a
> UML model with SysML profile created in Papyrus. It includes Blocks
> and FlowPorts. I have to access these stereotypes but it seems that I
> cannot retrieve any SysML object even though they appear in list (code
> suggestion). Actually I have to access 'Direction' property of
> FlowPort associated with Port. I have already tried suggestions and
> answers from various forums (including
> https://www.eclipse.org/forums/index.php/t/452587/) but in vain.
> The code is given below. I have created java services as suggested by
> https://www.eclipse.org/forums/index.php?t=msg&th=1060450&goto=1693765&but
> port.hasStereotype('FlowPort') always return false. I have also tried
> 'SysML::PortAndFlows::FlowPort' instead of 'FlowPort'. I use Acceleo
> 3.6.2 on Eclipse Mars.
>
> ..
> [template public generateElement(model : Model)]
> [comment @main/]
>
> [file ('created.txt', false, 'UTF-8')]
> [for(port: Port | model.eAllContents(Port))]
> [if(port.hasStereotype('FlowPort'))]
> OK
> [else]
> NOT OK
> [/if]
> [/for]
> [/file]
> [/template]
>
> I include following metamodels in the Module at the time of creating
> the module:
>
> http://www.eclipse.org/uml2/5.0.0/UML
> http://www.eclipse.org/papyrus/0.7.0/SysML
> http://www.eclipse.org/papyrus/0.7.0/SysML/Blocks
> http://www.eclipse.org/papyrus/0.7.0/SysML/Constraints
> http://www.eclipse.org/papyrus/0.7.0/SysML/PortAndFlows
> http://www.eclipse.org/emf/2002/Ecore
>
> Also I do register required packages including following as suggested
> by
> https://www.eclipse.org/forums/index.php?t=msg&th=1060450&goto=1693765& in
> registerPackages() of Generate.java
>
> // 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("SysML.profile.uml").appendSegment(""));
> uriMap.put(URI.createURI("pathmap://SysML_PROFILES/"),
> uri.appendSegment("model").appendSegment(""));
>
> Any sort of help is appreciated.
>
Previous Topic:metamodel that reference other metamodels
Next Topic:Use of workspace-external template for EGL run Config
Goto Forum:
  


Current Time: Sat Nov 09 01:28:04 GMT 2024

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

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

Back to the top