Home » Modeling » Epsilon » Loading models into IModel objects(Load a dynamically built model from memory, rather than from a file?)
Loading models into IModel objects [message #539413] |
Thu, 10 June 2010 16:07 |
Stephen Barrett Messages: 46 Registered: May 2010 |
Member |
|
|
Hello Epsilon Fans,
I've looked through the source, and don't see that what I want is provided for, but I thought I would ask anyway:
I am constructing UML2 models in Java which I want to manipulate with the Epsilon family of languages, also running in Java. Is it possible to load an IModel object directly with a UML2 model (or something similar)? Or maybe accomplish the same thing by specifying a URI scheme other than file:// for the PROPERTY_MODEL_FILE property?
This would save having to write a model out to an XMI file right after building it, only to turn around and read it back in again into an EmfModel. And it would also save having to unravel filesystem paths, permissions, etc., which is a consideration for standalone tools.
That being said, this is not a critical item, more of a "Wouldn't it be nice?" kind of thing.
Regards,
--Stephen
|
|
|
Re: Loading models into IModel objects [message #539428 is a reply to message #539413] |
Thu, 10 June 2010 17:03 |
Louis Rose Messages: 440 Registered: July 2009 Location: York, United Kingdom |
Senior Member |
|
|
Hi Stephen,
Thanks for the interest. Sure, I think InMemoryEmfModel is a perfect fit for this case.
Presuming that you're invoking Epsilon from Java, you can use code similar to this:
final InMemoryEmfModel model = new InMemoryEmfModel("NameOfYourModel", resource, UmlPackage.eINSTANCE);
where resource is an instance of EMF's Resource interface.
The in-memory model can then be used with Epsilon just like any other model. The following code, for example, could be use the in-memory model with EGL to generate some text:
final IEglContext context = new EglContext();
context.getModelRepository().addModel(model);
final EglFileGeneratingTemplateFactory factory = new EglFileGeneratingTemplateFactory(context);
final EglFileGeneratingTemplate template = factory.load(aUriOrFileToYourEglTemplate);
template.process();
// or use template.generate(...) if you want to
// store the results of the main template to disk
I hope this helps.
Cheers,
Louis.
[Updated on: Thu, 10 June 2010 17:04] Report message to a moderator
|
|
|
Re: Loading models into IModel objects [message #539430 is a reply to message #539413] |
Thu, 10 June 2010 17:01 |
Dimitrios Kolovos Messages: 1776 Registered: July 2009 |
Senior Member |
|
|
Hi Stephen,
You can use InMemoryEmfModel to access loaded EMF Resources from Epsilon
programs.
Cheers,
Dimitris
On 10/06/2010 19:07, Stephen Barrett wrote:
> Hello Epsilon Fans,
>
> I've looked through the source, and don't see that what I want is
> provided for, but I thought I would ask anyway:
>
> I am constructing UML2 models in Java which I want to manipulate with
> the Epsilon family of languages, also running in Java. Is it possible to
> load an IModel object directly with a UML2 model (or something similar)?
> Or maybe accomplish the same thing by specifying a URI scheme other than
> file:// for the PROPERTY_MODEL_FILE property?
>
> This would save having to write a model out to an XMI file right after
> building it, only to turn around and read it back in again into an
> EmfModel. And it would also save having to unravel filesystem paths,
> permissions, etc., which is a consideration for standalone tools.
>
> That being said, this is not a critical item, more of a "Wouldn't it be
> nice?" kind of thing.
>
> Regards,
> --Stephen
|
|
| | | | | | | | | | |
Re: Loading models into IModel objects [message #589980 is a reply to message #539413] |
Thu, 10 June 2010 17:01 |
Dimitrios Kolovos Messages: 1776 Registered: July 2009 |
Senior Member |
|
|
Hi Stephen,
You can use InMemoryEmfModel to access loaded EMF Resources from Epsilon
programs.
Cheers,
Dimitris
On 10/06/2010 19:07, Stephen Barrett wrote:
> Hello Epsilon Fans,
>
> I've looked through the source, and don't see that what I want is
> provided for, but I thought I would ask anyway:
>
> I am constructing UML2 models in Java which I want to manipulate with
> the Epsilon family of languages, also running in Java. Is it possible to
> load an IModel object directly with a UML2 model (or something similar)?
> Or maybe accomplish the same thing by specifying a URI scheme other than
> file:// for the PROPERTY_MODEL_FILE property?
>
> This would save having to write a model out to an XMI file right after
> building it, only to turn around and read it back in again into an
> EmfModel. And it would also save having to unravel filesystem paths,
> permissions, etc., which is a consideration for standalone tools.
>
> That being said, this is not a critical item, more of a "Wouldn't it be
> nice?" kind of thing.
>
> Regards,
> --Stephen
|
|
|
Re: Loading models into IModel objects [message #589995 is a reply to message #539413] |
Thu, 10 June 2010 17:03 |
Louis Rose Messages: 440 Registered: July 2009 Location: York, United Kingdom |
Senior Member |
|
|
Hi Stephen,
Thanks for the interest. Sure, I think InMemoryEmfModel is a perfect fit for this case.
Presuming that you're invoking Epsilon from Java, you can use code similar to this:
final InMemoryEmfModel model = new InMemoryEmfModel("NameOfYourModel", resource, UmlPackage.eINSTANCE);
where resource is an instance of EMF's Resource interface.
The in-memory model can then be used with Epsilon just like any other module. The following code, for example, could be use the in-memory model with EGL to generate some text:
final IEglContext context = new EglContext();
context.getModelRepository().addModel(model);
final EglFileGeneratingTemplateFactory factory = new EglFileGeneratingTemplateFactory(context);
final EglFileGeneratingTemplate template = factory.load(aUriOrFileToYourEglTemplate);
template.process();
// or use template.generate(...) if you want to
// store the results of the main template to disk
I hope this helps.
Cheers,
Louis.
|
|
| | | | | | | |
Goto Forum:
Current Time: Thu Sep 26 16:42:13 GMT 2024
Powered by FUDForum. Page generated in 0.05593 seconds
|