Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » EOL: Loading model from a ResourceSet
EOL: Loading model from a ResourceSet [message #1334198] Mon, 05 May 2014 12:53 Go to next message
Mario Bauer is currently offline Mario BauerFriend
Messages: 21
Registered: May 2014
Junior Member
Hi,

I want to use the Epsilon Object language to query data from an EMF ResourceSet in a Standalone Application.

In the example I only found a way to load a model from file.
https://dev.eclipse.org/svnroot/modeling/org.eclipse.epsilon/trunk/examples/org.eclipse.epsilon.examples.standalone/src/org/eclipse/epsilon/examples/standalone/eol/

Is it also possible to load a model from a ResourceSet?

Thanks for help
Mario
Re: EOL: Loading model from a ResourceSet [message #1335041 is a reply to message #1334198] Mon, 05 May 2014 21:37 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi,

Yes. You can use Epsilion's InMemoryEmfModel [1] to do this and pass in its constructor one of the resources of the ResourceSet (it should pick up the rest automatically).

Cheers,
Dimitris

[1] http://download.eclipse.org/epsilon/javadoc/org/eclipse/epsilon/emc/emf/InMemoryEmfModel.html
Re: EOL: Loading model from a ResourceSet [message #1338532 is a reply to message #1335041] Wed, 07 May 2014 08:58 Go to previous messageGo to next message
Mario Bauer is currently offline Mario BauerFriend
Messages: 21
Registered: May 2014
Junior Member
Thanks Dimitris!

If somebody other had the same problem, here is the code.

ResourceSet model = ...
InMemoryEmfModel emfModel = new InMemoryEmfModel(model.getResources().get(0));
emfModel.setName("daten");

String allTypes = "operation allTypes() : Collection {"
		+ "var alletypen = daten!ConcreteClassifier.all();"
		+ "var anonyme = daten!AnonymousClass.all();"
		+ "alletypen.addAll(anonyme);"
		+ "return alletypen.select(iterator | iterator.eResource().getURI().toString().startsWith('file:/'));"
		+ "}";

IEolExecutableModule module = new EolModule();
module.parse(allTypes);
module.getContext().getModelRepository().addModel(emfModel);
EolOperations declaredOperations = module.getDeclaredOperations();
EolOperation operation = declaredOperations.getOperation("allTypes");
ArrayList<Object> parameters = new ArrayList<Object>();
Object result = operation.execute(null, parameters, module.getContext());
Re: EOL: Loading model from a ResourceSet [message #1338956 is a reply to message #1338532] Wed, 07 May 2014 12:55 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Mario,

I'm glad this helped. Thanks for sharing your solution!

Cheers,
Dimitris
Previous Topic:[EMC] CSV driver not writing rows
Next Topic:Using [ETL] or [Flock] with files from different xtext grammars
Goto Forum:
  


Current Time: Thu Apr 25 05:55:58 GMT 2024

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

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

Back to the top