Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » accessing runtime models with reflection
accessing runtime models with reflection [message #1837041] Thu, 21 January 2021 10:26 Go to next message
Ludovico Iovino is currently offline Ludovico IovinoFriend
Messages: 33
Registered: July 2019
Member
Hi all, I have a doubt for which I couldn't find a solution. I have an EOL script that I launch programmatically with java standalone code. I set up the runtime config with java code in which I load models dynamically... I load all the models in a specific project folder. Now I have to access to these models in the eol script, but I only know how to use the models as variables... so If i have model1...modelk I can use them as variables but I think it would be nice to use reflection so I can access to these models with the string name.
Hope I have been clear.thanks
Re: accessing runtime models with reflection [message #1837046 is a reply to message #1837041] Thu, 21 January 2021 11:45 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Ludovico,

The following should do the trick.

for (m in System.context.modelRepository.models) {
  m.println();
  m.getAllOfType("Task").println();
}


Thanks,
Dimitris
Re: accessing runtime models with reflection [message #1837048 is a reply to message #1837046] Thu, 21 January 2021 11:50 Go to previous messageGo to next message
Ludovico Iovino is currently offline Ludovico IovinoFriend
Messages: 33
Registered: July 2019
Member
Perfect and thanks a lot!
Cheers
Re: accessing runtime models with reflection [message #1837201 is a reply to message #1837048] Sun, 24 January 2021 22:00 Go to previous messageGo to next message
Ludovico Iovino is currently offline Ludovico IovinoFriend
Messages: 33
Registered: July 2019
Member
Another quick question related to the same category. If the eol is executed programmatically the eol program does not resolve the external references I guess. In fact if I execute the same program with runtime config it returns the external refs. I can't find the property to be set programmatically when the model is loaded. I guessed it was EXPAND to be set to true but the result does not change...is there a way to resolve it from the java launcher ? Otherswise I guess I should use ecoreutil to resolve the proxy from eol...what do you guys suggest?

thanks a lot
Re: accessing runtime models with reflection [message #1837214 is a reply to message #1837201] Mon, 25 January 2021 09:08 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

The expand property should do the trick indeed; this is the property that the Eclipse-based development tools also use (see line 208 of EmfModelConfigurationDialog).

One reason why resolution may fail is if cross-references make use of platform:/ URLs, which are meaningless outside Eclipse/OSGi. Could this be the case? If not, please share a minimal example and I will investigate further.

Thanks,
Dimitris
Re: accessing runtime models with reflection [message #1837242 is a reply to message #1837214] Mon, 25 January 2021 21:54 Go to previous messageGo to next message
Ludovico Iovino is currently offline Ludovico IovinoFriend
Messages: 33
Registered: July 2019
Member
I think you're right... i see the platform:/ url . I'll pack an example. Thanks
Re: accessing runtime models with reflection [message #1838266 is a reply to message #1837242] Fri, 19 February 2021 20:36 Go to previous messageGo to next message
Ludovico Iovino is currently offline Ludovico IovinoFriend
Messages: 33
Registered: July 2019
Member
I created a minimal example with a standalone launcher ...the problem I still have is related to proxyuri that it is returned in standalone launcher but not using the runtimeconfig. Launching the eol from the runtime config I get the external reference resolved and printed correctly. On the other side I receive the proxyuri and i can't resolve it. The EXPAND prop is set to true...

project zip here: https://www.dropbox.com/s/r5v467njsdxcbgg/EXPAND-prop.zip?dl=0
thanks a lot for your help.
Re: accessing runtime models with reflection [message #1838280 is a reply to message #1838266] Sat, 20 February 2021 12:29 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Ludovico,

Replacing "model/qualitydef.model" in your Evaluation class with the following seems to be doing the trick.

 
URI.createFileURI(new File("model/qualitydef.model").getAbsolutePath()).toString()


Thanks,
Dimitris
Re: accessing runtime models with reflection [message #1838286 is a reply to message #1838280] Sat, 20 February 2021 14:10 Go to previous message
Ludovico Iovino is currently offline Ludovico IovinoFriend
Messages: 33
Registered: July 2019
Member
This is really a magic trick :) it worked like a charm. thank you Dimitris
Previous Topic:Using reflection
Next Topic:Xtext integration with GMF
Goto Forum:
  


Current Time: Fri Apr 26 21:30:32 GMT 2024

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

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

Back to the top