Converting a UML class diagram created using Papyrus into an .ecore file

断了今生、忘了曾经 提交于 2019-12-07 17:40:52

问题


Here is what I do using eclipse :

  1. Create a new Papyrus project
  2. Create a class diagram in Papyrus
  3. Create a new EMF empty project
  4. Use the EMF Generator Model to convert my .uml file (created with Papyrus) into an .ecore file

Now i would like to do that in Java. I found a post here where someone is doing it from XSD. I would like to do the same thing but from UML. User565300 is using something called Xsd2Ecore but I couldn't find a Uml2Ecore. Do you guys know what eclipse is using to convert UML file ?


回答1:


I happened to bump into this problem very recently and found an easy solution so thought I would share.

In addition to Papyrus, I have the Obeo UML Designer 6.1 plugin installed.

1) UML Designer adds a concept of a "Modeling Project". Create one from the File->New submenu.

2) Find the Papyrus model you want to convert to ECore. Under its root node you will generally see two children labeled "notation" and "uml". The node labeled "uml" corresponds to a file called "model.uml". Click it and copy the file path to the clipboard.

3) Return to your Modeling Project. Paste your clipboard into it, and you should see "model .uml" appear. Open it.

4) Open the "root resource node" and select its single child, which will be referred to below as the "root model node". -- This should be a UML model object representing the root of the model you are porting. -- If you see something else, check whether you failed to overwrite a pre-existing file or copied the wrong model source .

5) Make sure you are on the Modeling perspective and see the "UML Editor" menu. With the root model node still highlighted, navigate to "Convert To" -> "Ecore Model..."

6) Complete the wizard. Correct any errors and reepat if necessary.

The Obeo Designer is an open source project available on GitHub, so I imagine its possible to pick apart the Manifest file to identify the menu contribution for "To Ecore..." and then locate the actual source code through GitHub.




回答2:


Papyrus is an UML Editor which requires other plugins. You need to use another plugin such as accelero in order to generate code but to be honest it seems that since Eclipse 3.5 this plugin is not really working with the latest releases. The best would be to swap to Topcased which is modeling development environment including code generation. The only problem is that Topcased has been abandoned in order to be merged inside Papurus MDT so it is better not to invest in this tool today and stick to Papyrus MDT.

Creating ecore model from papyrus is impossible because it works with a GMF model and not directly from an Ecore model. GMF being also abandoned since Eclipse 3.5 I don't know what to say ... Good luck,



来源:https://stackoverflow.com/questions/6082765/converting-a-uml-class-diagram-created-using-papyrus-into-an-ecore-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!