Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 Tools » genmodel for state machine diagram
genmodel for state machine diagram [message #476599] Mon, 20 July 2009 03:20 Go to next message
Eban Escott is currently offline Eban EscottFriend
Messages: 61
Registered: July 2009
Member
Hello,

First up, thanks guys for putting this great software together and the
potential is awesome!

I am trying to "Generate Model Code" from a .genmodel based on a "State
Machine Diagram" from the "UML 2.1 Diagrams" wizard. I am able to complete
this with code popping out in the src directory but it is incomplete, i.e.
the only .java file is the StateMachine name and none of the initial
states, transitions or simple state and final state can be found anywhere
in the generate model code.

Am I missing something or is there a simple example I can follow to get me
going? Or, is this one of those incubation features I need to be patient
on?

I have just downloaded the "Eclipse Modeling Tools" version of Eclipse so
I should have all the latest code and I know this includes incubation
projects and hence is not complete yet.

Thanks in advance
Eban
Re: genmodel for state machine diagram [message #476609 is a reply to message #476599] Thu, 23 July 2009 12:34 Go to previous messageGo to next message
Tatiana Fesenko is currently offline Tatiana FesenkoFriend
Messages: 530
Registered: July 2009
Senior Member
Hello Eban,

Thank you for the warm words.

You generate Java code using an approach described here - http://wiki.eclipse.org/MDT/UML2/FAQ#Can_I_generate_code_fro m_my_UML_.28.uml.29_model.3F
, don't you?
In that case the most relevant answer will be gotten in UML2 newsgroup. I
redirect your question there.

There are other approaches to generate code from UML diagrams. Some of them
are described here - news://news.eclipse.org/31c6fe66a4cc61648c68aef19f1af8ae$1@w ww.eclipse.org
..

Best wishes,
Tanya.


> Hello,
>
> First up, thanks guys for putting this great software together and the
> potential is awesome!
>
> I am trying to "Generate Model Code" from a .genmodel based on a
> "State Machine Diagram" from the "UML 2.1 Diagrams" wizard. I am able
> to complete this with code popping out in the src directory but it is
> incomplete, i.e. the only .java file is the StateMachine name and none
> of the initial states, transitions or simple state and final state can
> be found anywhere in the generate model code.
>
> Am I missing something or is there a simple example I can follow to
> get me going? Or, is this one of those incubation features I need to
> be patient on?
>
> I have just downloaded the "Eclipse Modeling Tools" version of Eclipse
> so I should have all the latest code and I know this includes
> incubation projects and hence is not complete yet.
>
> Thanks in advance Eban
>
Re: genmodel for state machine diagram [message #476614 is a reply to message #476609] Fri, 24 July 2009 07:19 Go to previous messageGo to next message
Eban Escott is currently offline Eban EscottFriend
Messages: 61
Registered: July 2009
Member
When I look at the .uml file it looks like:

...
<packagedElement xmi:type="uml:StateMachine"
xmi:id="_4QV5AHTSEd6tw7FQB0T26Q" name="Product">
<region xmi:id="_4QlwoHTSEd6tw7FQB0T26Q" name="Region">
<subvertex xmi:type="uml:Pseudostate"
xmi:id="_-7aC0HTSEd6tw7FQB0T26Q"/>
<subvertex xmi:type="uml:FinalState"
xmi:id="__kusoHTSEd6tw7FQB0T26Q"/>
<subvertex xmi:type="uml:State" xmi:id="_AdpRoHTTEd6tw7FQB0T26Q"
name="ProductList"/>
<transition xmi:id="_CciAMHTTEd6tw7FQB0T26Q"
source="_-7aC0HTSEd6tw7FQB0T26Q" target="_AdpRoHTTEd6tw7FQB0T26Q"/>
<transition xmi:id="_C9WOQHTTEd6tw7FQB0T26Q"
source="_AdpRoHTTEd6tw7FQB0T26Q" target="__kusoHTSEd6tw7FQB0T26Q"/>
</region>
</packagedElement>
</uml:Package>

So, the statemachine has a region and some states. All good until I create
an ecore model or genmodel from it but it seems to be missing everything
except the packageElement. Here is the .ecore file:

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="InputC"
nsURI="http:///InputC.ecore" nsPrefix="InputC">
<eClassifiers xsi:type="ecore:EClass" name="Product"/>
</ecore:EPackage>

Please help! :)
Re: genmodel for state machine diagram [message #476615 is a reply to message #476614] Fri, 24 July 2009 08:45 Go to previous messageGo to next message
Tas Frangoullides is currently offline Tas FrangoullidesFriend
Messages: 195
Registered: July 2009
Senior Member
Hi Eban,

I've not been keeping updated on what's happing in the UML2 project for a
little while but I don't beleive generation of code from StateMachines has
been implemented. I beleive the conversion from UML2 to Ecore is only for
the class modelling parts of UML where equivalent EMF metaclasses exists. I
think the only reason you are getting the "Product" come through is becuase
in UML a StateMachine is a type of Class and it's getting picked up by the
translater.

Implementing this type of generation isn't too hard once you are familar
with both UML2 and EMF and you can achieve a lot of control. I've done it
before so if you explain alittle more about what you are trying to achieve I
might be able to give you some ideas.

Tas




"Eban Escott" <eban.escott@uqconnect.edu.au> wrote in message
news:6f020c2cc5047138d4e51d4ac89073da$1@www.eclipse.org...
> When I look at the .uml file it looks like:
>
> ..
> <packagedElement xmi:type="uml:StateMachine"
> xmi:id="_4QV5AHTSEd6tw7FQB0T26Q" name="Product">
> <region xmi:id="_4QlwoHTSEd6tw7FQB0T26Q" name="Region">
> <subvertex xmi:type="uml:Pseudostate"
> xmi:id="_-7aC0HTSEd6tw7FQB0T26Q"/>
> <subvertex xmi:type="uml:FinalState"
> xmi:id="__kusoHTSEd6tw7FQB0T26Q"/>
> <subvertex xmi:type="uml:State" xmi:id="_AdpRoHTTEd6tw7FQB0T26Q"
> name="ProductList"/>
> <transition xmi:id="_CciAMHTTEd6tw7FQB0T26Q"
> source="_-7aC0HTSEd6tw7FQB0T26Q" target="_AdpRoHTTEd6tw7FQB0T26Q"/>
> <transition xmi:id="_C9WOQHTTEd6tw7FQB0T26Q"
> source="_AdpRoHTTEd6tw7FQB0T26Q" target="__kusoHTSEd6tw7FQB0T26Q"/>
> </region>
> </packagedElement>
> </uml:Package>
>
> So, the statemachine has a region and some states. All good until I create
> an ecore model or genmodel from it but it seems to be missing everything
> except the packageElement. Here is the .ecore file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="InputC"
> nsURI="http:///InputC.ecore" nsPrefix="InputC">
> <eClassifiers xsi:type="ecore:EClass" name="Product"/>
> </ecore:EPackage>
>
> Please help! :)
>
Re: genmodel for state machine diagram [message #476616 is a reply to message #476615] Fri, 24 July 2009 13:43 Go to previous messageGo to next message
Eban Escott is currently offline Eban EscottFriend
Messages: 61
Registered: July 2009
Member
Hey Tas, thanks for the heads up. I am trying to do some reflective
programming on a ecore model, or as it turns out now on a uml2 model? So,
i have been reading the EMF, 2nd edition book and I have got this working
on an ecore model fine:

InputCPackage inputCPackage = InputCPackage.eINSTANCE;
System.out.println(inputCPackage);
classifiers = inputCPackage.getEClassifiers();
for(EClassifier classifier: classifiers) {
System.out.println(classifier);
}

And from here I can reflectively traverse a meta-model combine that with
JET and out pops some code ... sweet. Having a guess, is this how
generators work?

Now, I want to do something similar again but on a state machine not a
class diagram. I have tried converting to ecore as you know but ran into
problems. How can I use reflection on a UML2 model?

Thanks, Eban
Re: genmodel for state machine diagram [message #476617 is a reply to message #476616] Fri, 24 July 2009 15:17 Go to previous messageGo to next message
Tas Frangoullides is currently offline Tas FrangoullidesFriend
Messages: 195
Registered: July 2009
Senior Member
Eban,

UML2 is implemented as instance of an ecore model, so you can instanciate
and manipulate it using the UML2 API. It's API is not as easy to understand
and EMF but that's just the way the UMl2 Spec is. You mgiht find the OMG
specification useful as the UML2 API is pretty much a mirror of it plus some
convenience methods.

You can do soemting allong the lines of

import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.UMLFactory;
import org.eclipse.uml2.uml.UMLPackage;

.....

Model model = UMLFactory.eINSTANCE.createModel();
Class personClass = model.createOwnedClass("Person", false);
Class addressClass = model.createOwnedClass("Address", false);
personClass.createOwnedAttribute("address", addressClass);

for (NamedElement namedElement: model.getOwnedMembers()) {
if (UMLPackage.Literals.CLASS.equals(namedElement.eClass())) {
Class umlClass = (Class) namedElement;
System.out.println(umlClass.getName());
}
}


In terms of going from a UML Statemachine I would approach it in a number of
steps which make it easier to build and test your generators

1. Using EMF define a simple StateMachine meta-model that describes the
semantics you are really interested in.
2. Develop a generators for generating code from instances of this simple
meta-model
3. Develop a transformation from UML2 StateMachine to your own StateMachine

To achieve step 2 you may find transforming to an ecore model and
customising the emf code generation tamplates helpful
The pure "modeling" approach to the transformations would be to use a proper
model transformation language but I have also found SwithUtil classes
pragmatic and easy to test.

Hope that helps,
Tas


"Eban Escott" <eban.escott@uqconnect.edu.au> wrote in message
news:1db3d97061ef7dcbb69e6494d701ad4a$1@www.eclipse.org...
> Hey Tas, thanks for the heads up. I am trying to do some reflective
> programming on a ecore model, or as it turns out now on a uml2 model? So,
> i have been reading the EMF, 2nd edition book and I have got this working
> on an ecore model fine:
>
> InputCPackage inputCPackage = InputCPackage.eINSTANCE;
> System.out.println(inputCPackage);
> classifiers = inputCPackage.getEClassifiers();
> for(EClassifier classifier: classifiers) {
> System.out.println(classifier);
> }
> And from here I can reflectively traverse a meta-model combine that with
> JET and out pops some code ... sweet. Having a guess, is this how
> generators work?
>
> Now, I want to do something similar again but on a state machine not a
> class diagram. I have tried converting to ecore as you know but ran into
> problems. How can I use reflection on a UML2 model?
>
> Thanks, Eban
>
Re: genmodel for state machine diagram [message #476620 is a reply to message #476617] Mon, 27 July 2009 03:08 Go to previous messageGo to next message
Eban Escott is currently offline Eban EscottFriend
Messages: 61
Registered: July 2009
Member
Hi Tas, I got the example code going that you included and I intend to
look at model transformational languages soon, thanks heaps for the tips!
For the moment, I am still trying to de-serialise the uml model as per:

http://wiki.eclipse.org/MDT/UML2/FAQ#What.27s_required_to_lo ad_a_UML_.28.uml.29_resource_from_a_standalone_application.3 F

I am getting an empty set and I have double checked the .uml file has in
it a statemachine and other elements. The code I have written is:

ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE); resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);

File file = new File("InputC.uml");
if(!file.exists()) {
System.out.println("Cannot find file.");
} else {
System.out.println("Found " + file.getCanonicalPath());
}

//URI uri = URI.createFileURI(file.getCanonicalPath());
//Resource resource = resourceSet.createResource(uri);
//System.out.println(resource.getContents().get(0));

Map uriMap = resourceSet.getURIConverter().getURIMap();
URI uri = URI.createFileURI(file.getCanonicalPath());
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(""));
Resource resource = resourceSet.createResource(uri);
System.out.println(resource.getContents());

I know I am close but can't seem to get it loading. Any ideas? Thanks, Eban
Re: genmodel for state machine diagram [message #476621 is a reply to message #476620] Mon, 27 July 2009 06:27 Go to previous message
Eban Escott is currently offline Eban EscottFriend
Messages: 61
Registered: July 2009
Member
Right got it. You have to

Resource resource = resourceSet.getResource(uri, true);

not create it. Thanks for the help :)
Re: genmodel for state machine diagram [message #624654 is a reply to message #476599] Thu, 23 July 2009 12:34 Go to previous message
Tatiana Fesenko is currently offline Tatiana FesenkoFriend
Messages: 530
Registered: July 2009
Senior Member
Hello Eban,

Thank you for the warm words.

You generate Java code using an approach described here - http://wiki.eclipse.org/MDT/UML2/FAQ#Can_I_generate_code_fro m_my_UML_.28.uml.29_model.3F
, don't you?
In that case the most relevant answer will be gotten in UML2 newsgroup. I
redirect your question there.

There are other approaches to generate code from UML diagrams. Some of them
are described here - news://news.eclipse.org/31c6fe66a4cc61648c68aef19f1af8ae$1@w ww.eclipse.org
..

Best wishes,
Tanya.


> Hello,
>
> First up, thanks guys for putting this great software together and the
> potential is awesome!
>
> I am trying to "Generate Model Code" from a .genmodel based on a
> "State Machine Diagram" from the "UML 2.1 Diagrams" wizard. I am able
> to complete this with code popping out in the src directory but it is
> incomplete, i.e. the only .java file is the StateMachine name and none
> of the initial states, transitions or simple state and final state can
> be found anywhere in the generate model code.
>
> Am I missing something or is there a simple example I can follow to
> get me going? Or, is this one of those incubation features I need to
> be patient on?
>
> I have just downloaded the "Eclipse Modeling Tools" version of Eclipse
> so I should have all the latest code and I know this includes
> incubation projects and hence is not complete yet.
>
> Thanks in advance Eban
>
Re: genmodel for state machine diagram [message #624659 is a reply to message #476609] Fri, 24 July 2009 07:19 Go to previous message
Eban Escott is currently offline Eban EscottFriend
Messages: 61
Registered: July 2009
Member
When I look at the .uml file it looks like:

...
<packagedElement xmi:type="uml:StateMachine"
xmi:id="_4QV5AHTSEd6tw7FQB0T26Q" name="Product">
<region xmi:id="_4QlwoHTSEd6tw7FQB0T26Q" name="Region">
<subvertex xmi:type="uml:Pseudostate"
xmi:id="_-7aC0HTSEd6tw7FQB0T26Q"/>
<subvertex xmi:type="uml:FinalState"
xmi:id="__kusoHTSEd6tw7FQB0T26Q"/>
<subvertex xmi:type="uml:State" xmi:id="_AdpRoHTTEd6tw7FQB0T26Q"
name="ProductList"/>
<transition xmi:id="_CciAMHTTEd6tw7FQB0T26Q"
source="_-7aC0HTSEd6tw7FQB0T26Q" target="_AdpRoHTTEd6tw7FQB0T26Q"/>
<transition xmi:id="_C9WOQHTTEd6tw7FQB0T26Q"
source="_AdpRoHTTEd6tw7FQB0T26Q" target="__kusoHTSEd6tw7FQB0T26Q"/>
</region>
</packagedElement>
</uml:Package>

So, the statemachine has a region and some states. All good until I create
an ecore model or genmodel from it but it seems to be missing everything
except the packageElement. Here is the .ecore file:

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="InputC"
nsURI="http:///InputC.ecore" nsPrefix="InputC">
<eClassifiers xsi:type="ecore:EClass" name="Product"/>
</ecore:EPackage>

Please help! :)
Re: genmodel for state machine diagram [message #624660 is a reply to message #476614] Fri, 24 July 2009 08:45 Go to previous message
Tas Frangoullides is currently offline Tas FrangoullidesFriend
Messages: 195
Registered: July 2009
Senior Member
Hi Eban,

I've not been keeping updated on what's happing in the UML2 project for a
little while but I don't beleive generation of code from StateMachines has
been implemented. I beleive the conversion from UML2 to Ecore is only for
the class modelling parts of UML where equivalent EMF metaclasses exists. I
think the only reason you are getting the "Product" come through is becuase
in UML a StateMachine is a type of Class and it's getting picked up by the
translater.

Implementing this type of generation isn't too hard once you are familar
with both UML2 and EMF and you can achieve a lot of control. I've done it
before so if you explain alittle more about what you are trying to achieve I
might be able to give you some ideas.

Tas




"Eban Escott" <eban.escott@uqconnect.edu.au> wrote in message
news:6f020c2cc5047138d4e51d4ac89073da$1@www.eclipse.org...
> When I look at the .uml file it looks like:
>
> ..
> <packagedElement xmi:type="uml:StateMachine"
> xmi:id="_4QV5AHTSEd6tw7FQB0T26Q" name="Product">
> <region xmi:id="_4QlwoHTSEd6tw7FQB0T26Q" name="Region">
> <subvertex xmi:type="uml:Pseudostate"
> xmi:id="_-7aC0HTSEd6tw7FQB0T26Q"/>
> <subvertex xmi:type="uml:FinalState"
> xmi:id="__kusoHTSEd6tw7FQB0T26Q"/>
> <subvertex xmi:type="uml:State" xmi:id="_AdpRoHTTEd6tw7FQB0T26Q"
> name="ProductList"/>
> <transition xmi:id="_CciAMHTTEd6tw7FQB0T26Q"
> source="_-7aC0HTSEd6tw7FQB0T26Q" target="_AdpRoHTTEd6tw7FQB0T26Q"/>
> <transition xmi:id="_C9WOQHTTEd6tw7FQB0T26Q"
> source="_AdpRoHTTEd6tw7FQB0T26Q" target="__kusoHTSEd6tw7FQB0T26Q"/>
> </region>
> </packagedElement>
> </uml:Package>
>
> So, the statemachine has a region and some states. All good until I create
> an ecore model or genmodel from it but it seems to be missing everything
> except the packageElement. Here is the .ecore file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="InputC"
> nsURI="http:///InputC.ecore" nsPrefix="InputC">
> <eClassifiers xsi:type="ecore:EClass" name="Product"/>
> </ecore:EPackage>
>
> Please help! :)
>
Re: genmodel for state machine diagram [message #624661 is a reply to message #476615] Fri, 24 July 2009 13:43 Go to previous message
Eban Escott is currently offline Eban EscottFriend
Messages: 61
Registered: July 2009
Member
Hey Tas, thanks for the heads up. I am trying to do some reflective
programming on a ecore model, or as it turns out now on a uml2 model? So,
i have been reading the EMF, 2nd edition book and I have got this working
on an ecore model fine:

InputCPackage inputCPackage = InputCPackage.eINSTANCE;
System.out.println(inputCPackage);
classifiers = inputCPackage.getEClassifiers();
for(EClassifier classifier: classifiers) {
System.out.println(classifier);
}

And from here I can reflectively traverse a meta-model combine that with
JET and out pops some code ... sweet. Having a guess, is this how
generators work?

Now, I want to do something similar again but on a state machine not a
class diagram. I have tried converting to ecore as you know but ran into
problems. How can I use reflection on a UML2 model?

Thanks, Eban
Re: genmodel for state machine diagram [message #624682 is a reply to message #476616] Fri, 24 July 2009 15:17 Go to previous message
Tas Frangoullides is currently offline Tas FrangoullidesFriend
Messages: 195
Registered: July 2009
Senior Member
Eban,

UML2 is implemented as instance of an ecore model, so you can instanciate
and manipulate it using the UML2 API. It's API is not as easy to understand
and EMF but that's just the way the UMl2 Spec is. You mgiht find the OMG
specification useful as the UML2 API is pretty much a mirror of it plus some
convenience methods.

You can do soemting allong the lines of

import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.UMLFactory;
import org.eclipse.uml2.uml.UMLPackage;

.....

Model model = UMLFactory.eINSTANCE.createModel();
Class personClass = model.createOwnedClass("Person", false);
Class addressClass = model.createOwnedClass("Address", false);
personClass.createOwnedAttribute("address", addressClass);

for (NamedElement namedElement: model.getOwnedMembers()) {
if (UMLPackage.Literals.CLASS.equals(namedElement.eClass())) {
Class umlClass = (Class) namedElement;
System.out.println(umlClass.getName());
}
}


In terms of going from a UML Statemachine I would approach it in a number of
steps which make it easier to build and test your generators

1. Using EMF define a simple StateMachine meta-model that describes the
semantics you are really interested in.
2. Develop a generators for generating code from instances of this simple
meta-model
3. Develop a transformation from UML2 StateMachine to your own StateMachine

To achieve step 2 you may find transforming to an ecore model and
customising the emf code generation tamplates helpful
The pure "modeling" approach to the transformations would be to use a proper
model transformation language but I have also found SwithUtil classes
pragmatic and easy to test.

Hope that helps,
Tas


"Eban Escott" <eban.escott@uqconnect.edu.au> wrote in message
news:1db3d97061ef7dcbb69e6494d701ad4a$1@www.eclipse.org...
> Hey Tas, thanks for the heads up. I am trying to do some reflective
> programming on a ecore model, or as it turns out now on a uml2 model? So,
> i have been reading the EMF, 2nd edition book and I have got this working
> on an ecore model fine:
>
> InputCPackage inputCPackage = InputCPackage.eINSTANCE;
> System.out.println(inputCPackage);
> classifiers = inputCPackage.getEClassifiers();
> for(EClassifier classifier: classifiers) {
> System.out.println(classifier);
> }
> And from here I can reflectively traverse a meta-model combine that with
> JET and out pops some code ... sweet. Having a guess, is this how
> generators work?
>
> Now, I want to do something similar again but on a state machine not a
> class diagram. I have tried converting to ecore as you know but ran into
> problems. How can I use reflection on a UML2 model?
>
> Thanks, Eban
>
Re: genmodel for state machine diagram [message #624685 is a reply to message #476617] Mon, 27 July 2009 03:08 Go to previous message
Eban Escott is currently offline Eban EscottFriend
Messages: 61
Registered: July 2009
Member
Hi Tas, I got the example code going that you included and I intend to
look at model transformational languages soon, thanks heaps for the tips!
For the moment, I am still trying to de-serialise the uml model as per:

http://wiki.eclipse.org/MDT/UML2/FAQ#What.27s_required_to_lo ad_a_UML_.28.uml.29_resource_from_a_standalone_application.3 F

I am getting an empty set and I have double checked the .uml file has in
it a statemachine and other elements. The code I have written is:

ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE); resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);

File file = new File("InputC.uml");
if(!file.exists()) {
System.out.println("Cannot find file.");
} else {
System.out.println("Found " + file.getCanonicalPath());
}

//URI uri = URI.createFileURI(file.getCanonicalPath());
//Resource resource = resourceSet.createResource(uri);
//System.out.println(resource.getContents().get(0));

Map uriMap = resourceSet.getURIConverter().getURIMap();
URI uri = URI.createFileURI(file.getCanonicalPath());
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(""));
Resource resource = resourceSet.createResource(uri);
System.out.println(resource.getContents());

I know I am close but can't seem to get it loading. Any ideas? Thanks, Eban
Re: genmodel for state machine diagram [message #624686 is a reply to message #476620] Mon, 27 July 2009 06:27 Go to previous message
Eban Escott is currently offline Eban EscottFriend
Messages: 61
Registered: July 2009
Member
Right got it. You have to

Resource resource = resourceSet.getResource(uri, true);

not create it. Thanks for the help :)
Previous Topic:UML2Tools Sequence Diagram
Next Topic:Unhandled loop exception when link Association Line on Composite Structure Diag
Goto Forum:
  


Current Time: Fri Apr 19 20:12:14 GMT 2024

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

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

Back to the top