Accessing Model Repository Data [message #1842090] |
Tue, 08 June 2021 23:28 |
|
We are developing an Ant task that runs inside a build that contains EOL tasks which load, and ultimately save model data.
During the run, we need access to EMF models that have been loaded by EOL.
We find that the models only persist on the shutdown of the build.
This prevents our code from reading the file, as it is not stored at this time.
Hence, we have a first question:
What is the recommended way to force EOL during the run of the build to persist a model to disk? Does one exist?
Further, we have discovered that we can obtain a reference to the EOL model repository that is stored in the references of the Ant project.
However, all the contents are wrapped in EOL wrappers. This leads to our second question:
How can one obtain a reference to the underlying EMF model of a org.eclipse.epsilon.emc.emf.EmfModel?
Technical details of the last item:
We have the model repository as an object from which an IModel can be found by name .getModelByName(name)). This [font=Courier]IModel[/code] is of the type org.eclipse.epsilon.emc.emf.EmfModel.
The meta-model has generated Model code that is accessible to the task.
|
|
|
Re: Accessing Model Repository Data [message #1842096 is a reply to message #1842090] |
Wed, 09 June 2021 06:45 |
|
Hi Jörn,
> What is the recommended way to force EOL during the run of the build to persist a model to disk? Does one exist?
If your model is named M, you can call M.store() to save it.
> How can one obtain a reference to the underlying EMF model of a org.eclipse.epsilon.emc.emf.EmfModel?
M.getTarget() should do the trick.
Best,
Dimitris
|
|
|
Re: Accessing Model Repository Data [message #1842131 is a reply to message #1842096] |
Wed, 09 June 2021 21:57 |
|
Thanks! And sorry for asking. There was information on the forum already.
To force a sync in a build for external use:
- Call <epsilon.storeModel model="ModelName"/> to sync the file to disk.
- For EMFModels this calls EMFModel.store(), which calls
- org.eclipse.emf.ecore.resource.Resource.save().
After that, the model can be loaded and manipulated externally.
Note: After the manipulation the file has to be explicitly loaded again for Epsilon using <epsilon.loadModel/>
A direct access to the repository is not possible, AFAIK.
|
|
|
|
Re: Accessing Model Repository Data [message #1842136 is a reply to message #1842132] |
Thu, 10 June 2021 04:25 |
|
Apologies - I seem to have misread your message. getResource() returns the underlying EMF resource as shown below.
<project default="main">
<target name="main">
<epsilon.emf.loadModel name="M" .../>
<epsilon.eol>
// M is a ReflectiveModelReference
M.println();
// M.getTarget() returns the underlying EMF model
M.getTarget().println();
// .getResource() returns the EMF model's
// underlying resource
M.getTarget().getResource().println();
<model ref="M"/>
</epsilon.eol>
</target>
</project>
Best,
Dimitris
[Updated on: Thu, 10 June 2021 04:26] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03914 seconds