Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » How to convert the .uml generated from Magic draw to .ecore using UML2EcoreConverter
How to convert the .uml generated from Magic draw to .ecore using UML2EcoreConverter [message #1722895] Wed, 10 February 2016 07:43 Go to next message
Zille Huma is currently offline Zille HumaFriend
Messages: 6
Registered: February 2016
Junior Member
I have created my UML model in magic draw and generated its .uml files. Along with the .uml file for my model, there are also .uml files for the profiles used. I have converted it to corresponding .ecore using the 'import uml model' through EMF project wizard and it converts correctly. Now i want to convert my model .uml to corresponding .ecore programatically. How can i do it? from different resources, i read that UML2EcoreConverter.convert() can be used for this purpose but i am not sure how will the uml input be passed as an input parameter to this convert method. I also looked it UMLUtil.convertToEcore() but as i understood it takes a package as input and converts it. However, in my case, i have my uml model with different comprising packages so i dont think I can somehow pass my complete model to UMLUtil.convertToEcore() to convert it. Can somebody help me in this regard.
Re: How to convert the .uml generated from Magic draw to .ecore using UML2EcoreConverter [message #1722905 is a reply to message #1722895] Wed, 10 February 2016 09:19 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

UML2Ecore is not relevant to your problem; it is part of the process of
converting your UML model into executable Java code.

Magic Draw UML should just load. But we cannot help with a "doesn't
work" description. You might find that

https://wiki.eclipse.org/OCL/ForumNetiquette

motivates a more productive form of communication.

Regards

Ed Willink

On 10/02/2016 07:43, Zille Huma wrote:
> I have created my UML model in magic draw and generated its .uml
> files. Along with the .uml file for my model, there are also .uml
> files for the profiles used. I have converted it to corresponding
> .ecore using the 'import uml model' through EMF project wizard and it
> converts correctly. Now i want to convert my model .uml to
> corresponding .ecore programatically. How can i do it? from different
> resources, i read that UML2EcoreConverter.convert() can be used for
> this purpose but i am not sure how will the uml input be passed as an
> input parameter to this convert method. I also looked it
> UMLUtil.convertToEcore() but as i understood it takes a package as
> input and converts it. However, in my case, i have my uml model with
> different comprising packages so i dont think I can somehow pass my
> complete model to UMLUtil.convertToEcore() to convert it. Can somebody
> help me in this regard.
Re: How to convert the .uml generated from Magic draw to .ecore using UML2EcoreConverter [message #1722908 is a reply to message #1722905] Wed, 10 February 2016 09:32 Go to previous messageGo to next message
Zille Huma is currently offline Zille HumaFriend
Messages: 6
Registered: February 2016
Junior Member
Hi Ed,

thanks for the prompt reply and further guiding references.

I would try to explain my problem in more detail. At the moment, I have my .uml generated through magic draw. My goal is to generate its corresponding .xsd programmatically. First i tested it with EMF project wizard. Here, I created a project and imported this .uml as uml model. This step generated an EMF project with corresponding .ecore and .genmodel. Later i exported the .genmodel by the option 'Export model' and exported to it corresponding .xsd.

Now, when i am trying to do it programmatically, I assume that i have to carry out in similar steps, i.e., .uml--> .ecore --> .xsd. What is your opinion in this regard? I do not have to convert the .uml to .ecore before converting it to .xsd? can i do this conversion directly?

THanks in advance.
Re: How to convert the .uml generated from Magic draw to .ecore using UML2EcoreConverter [message #1722912 is a reply to message #1722908] Wed, 10 February 2016 09:45 Go to previous messageGo to next message
Zille Huma is currently offline Zille HumaFriend
Messages: 6
Registered: February 2016
Junior Member
Further, the snippet of the code so far is as follows(it uses the ideas fromhttps://www.eclipse.org/forums/index.php/t/151754/ to register packages, extensions and pathmaps):
ResourceSet set = new ResourceSetImpl();


// register extensions
this.registerExtensions();

// registering packages
this.registerPackages(set);

//register pathmaps
this.registerPathmaps(umlResourcePluginPath);

//get model
Resource res = set.getResource(URI.createFileURI(fileToOpen), true);

EList<Resource> resources = set.getResources();
EcoreUtil.resolveAll(resources.get(0));
Model model = (Model) EcoreUtil.getObjectByType(resources.get(0).getContents(), UMLPackage.Literals.MODEL);
Collection<EPackage> result= UMLUtil.convertToEcore(model, null);

Regards.
Re: How to convert the .uml generated from Magic draw to .ecore using UML2EcoreConverter [message #1722951 is a reply to message #1722908] Wed, 10 February 2016 13:07 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If you want to convert UML to XSD once , yes, go via Ecore, manually.

If you want to convert UML to XSD many times, reconsider, use of XSD is
unnecessary and arguably unhelpful for modeling purposes.

All the UML facilities should work programmatically; you just need to
get your initialization correct.

Regards

Ed Willink


On 10/02/2016 09:32, Zille Huma wrote:
> Hi Ed,
>
> thanks for the prompt reply and further guiding references.
>
> I would try to explain my problem in more detail. At the moment, I
> have my .uml generated through magic draw. My goal is to generate its
> corresponding .xsd programmatically. First i tested it with EMF
> project wizard. Here, I created a project and imported this .uml as
> uml model. This step generated an EMF project with corresponding
> .ecore and .genmodel. Later i exported the .genmodel by the option
> 'Export model' and exported to it corresponding .xsd.
> Now, when i am trying to do it programmatically, I assume that i have
> to carry out in similar steps, i.e., .uml--> .ecore --> .xsd. What is
> your opinion in this regard? I do not have to convert the .uml to
> .ecore before converting it to .xsd? can i do this conversion directly?
>
> THanks in advance.
Previous Topic:Re: [EMF] Loading UML Magicdraw models
Next Topic:how to setValue() of a stereotype property that refers to another stereotype
Goto Forum:
  


Current Time: Wed Apr 24 18:47:57 GMT 2024

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

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

Back to the top