Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread


By: Matthew Campbell
RE: Instantiating a .ecore file [ reply ]  
2010-03-20 11:23
Thanks so much for the reply and the pointer on where to start looking - I've been busy since the holidays and had to set my RGen project aside for a little bit but I'm hoping to get back into it soon. I'll take a look and see what I can do to help on the find_reference() thing.

On the UML 2.x metamodel, I was wondering if someone could take the UML 2.x profile form the Eclipse UML Tools project (which is in ecore format) and do a reverse transformation to get the RGen metamodel out of it. I don't know what the license issues would be, but it seems a shame to have to recreate the wheel when there's already an active community maintaining a UML 2.x metamodel somewhere. Anyways, thanks again for an awesome project and I'm looking forward to working with it some more.

By: Martin Thiede
RE: Instantiating a .ecore file [ reply ]  
2010-03-19 21:30
Hello Markus,

you are right, integrating the UML2.0 metamodel is not a big issue technically. You could type in the metamodel manually. Or you could convert it from an ECore or maybe UML class model.

If someone wants to contribute the UML2.0 metamodel I would be grateful.

Otherwise, you could just use a local copy of the metamodel without publishing it.


By: Martin Thiede
RE: Instantiating a .ecore file [ reply ]  
2010-03-19 21:23
Hello Matthew,

the way you are instantiating the .ecore file is right. However, the ECoreXMLInstantiator is not very sophisticated yet. It can not resolve references to elements which are not within the same .ecore file and in your case the attribute types (EInt, EString, etc.) are probably such external elements.

The spot to look at is ecore_xml_instantiator.rb, method find_referenced(). Here I do not take care about references like "";. What would be required here is a piece of code recognizing the standard ECore datatypes (EInt, EString, ...) in the standard location ( This code should then create either new instances of EDatatype with the given name or - maybe the better solution - just create references to the existing instances in the RGen::ECore package/module: RGen::ECore::EInt, RGen::ECore::EString, etc.

If you or someone wants to try this, I would appreciate your patch.


By: Markus Klotzbuecher
RE: Instantiating a .ecore file [ reply ]  
2009-12-15 14:13
Dear Matthew,

AFAIK there is no UML 2.0 meta model yet, but I believe it shouldn't
be too hard to create it starting from the existing UML1.3 one
(checkout lib/metamodels/uml13_metamodel.rb in the rgen sources).

I found Martins' slides and the state machine examples quite useful
for getting into rgen.

Not sure about your problem with eAttributes. Maybe Martin can help

Best regards

By: Matthew Campbell
Instantiating a .ecore file [ reply ]  
2009-12-07 05:20
I've been playing around with RGen over the weekend with the ultimate goal of generating some code off of an ECore model. I'm working in Eclipse 3.5 and I created the ECore model/diagram from the New File wizard. I added some test classes and I'm set.

I've been using the following snippet from my generate.rb script to read the .ecore file and run it through some templates:

# instantiate the ecore file
envECore =
inst = { |f|

# get the root EPackage from the instantiated ecore,
# works as expected so the model looks like it loaded fine
root = envECore.find({:class => RGen::ECore::EPackage})[0]

# generate code
tc =, targetDir)

I've been looking around in the source and what documentation is available, and my main point of trouble has been figuring out what versions of what formats are supported (for instance, I haven't seen anything available yet to instantiate/serialize UML2 models). Is loading an .ecore file currently supported, and is that code the correct way to do so?

I have some templates that expand on things like ":for => eAttributes" and everything seems to work until I find that my EAttribute's eType field is nil. There's definitely an eType defined in the ECore file. I thought to try eAttributeType instead, but it's marked as derived in RGen::ECore and throws an error when accessing it since there doesn't seem to be a eAttributeType_derived defined in the EAttribute class definition. All of this makes me thing I'm not loading the file correctly, so I thought I'd see if I could get some expert opinion.

I've used openArchitectureWare on a few other projects and have enjoyed working on the model-driven level, but I have to say one of the biggest issues for me was their choice to create several external DSLs for the job. I love what I've seen of RGen so far, so thanks a bunch.