Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [Epsilon] Standalone: execution details(calls to the execute method and info about the returned object)
icon5.gif  [Epsilon] Standalone: execution details [message #666313] Tue, 19 April 2011 20:51 Go to next message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 242
Registered: October 2009
Location: Mexico
Senior Member

Hello,

Is there any place to get information about the details of the execution of epsilon modules, specifically what does exactly does
module.execute() 
does and what is contained in the returned object.

Also, can you tell me why in one of the eol standalone example the above call is replaced by a call to the execution of a specific rule? i.e.:

@Override
	protected Object execute(IEolExecutableModule module)
			throws EolRuntimeException {
		EolOperation operation = module.getDeclaredOperations().get(0);
		return operation.execute(null, Collections.EMPTY_LIST, module.getContext());
	}


I have made a test with an eol source and the two methods and I only get rule execution with the latter. But what if I have several rules in my eol source?

Thanks,

Horacio


Horacio Hoyos Rodriguez
Kinori Tech
Need professional support for Epsilon, EMF?
Go to: https://kinori.tech
Re: [Epsilon] Standalone: execution details [message #666324 is a reply to message #666313] Tue, 19 April 2011 21:50 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Hi Horacio,

If I recall correctly, calling the execute() method in an EolModule will parse the module and run the statements at the global level. For instance, this will print "Hello world", but it will neither run f() nor print "Bye cruel world", as we only run the sentences before all operations:

"Hello world".println();

operation f() {
  -* lots of code *-
}

"Bye cruel world".println();


This would print both lines *and* run f():

"Hello world".println();
"Bye cruel world".println();
f();

operation f() {
  -* lots of code *-
}


The second fragment you mention is very different. It's running a specific operation in an EOL module through the API. If you want to run an operation in an EOL module like that, I would follow these steps:


  1. Parse the module and run the statements at the global scope with the execute method of EolModule.
  2. Pick the desired EolOperation.
  3. Run the EolOperation through its execute method.


However, you're using the term "rule" instead of "operation". Are you writing EOL code, or are you using something like ETL? EOL operations are like functions: if you don't call them explicitly, they won't run. EOL is an imperative language: for declarative model transformations, you should use ETL.

Cheers,
Antonio
Re: [Epsilon] Standalone: execution details [message #666325 is a reply to message #666313] Tue, 19 April 2011 21:51 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 242
Registered: October 2009
Location: Mexico
Senior Member

Hello,

@Antonio: seems we where writting at the same time. Your answer fits my findings. =D

So I have continued doing tests. First of all I just want to say that (silly me) I "just" understood how eol is a "general-purpose standalone modeling language", so that made things a little bit more clear, specially in the eol examples.

Whit this in mind I now understand that an eol file can contain several statements and operations and that executing an eolmodule executes that file over the specified models. Operations will be called if they are invoked within the statements, as in the initial add example of the EOL chpater in the epsilon book. Still, I want to know what is the returned object if a module execution.

Now, invoking a specific operation with the
operation.execute()
method calls a specific operation to be executed. Caution must be taken as the rest of the file is not executed. Hence, you should only use this method to execute "context-less" operations as the self variable will be null.

We should do a more complete tutorial/example on this. Maybe a new chapter in the book?

Regards,

Horacio


Horacio Hoyos Rodriguez
Kinori Tech
Need professional support for Epsilon, EMF?
Go to: https://kinori.tech

[Updated on: Tue, 19 April 2011 21:53]

Report message to a moderator

Re: [Epsilon] Standalone: execution details [message #666350 is a reply to message #666325] Wed, 20 April 2011 05:22 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 242
Registered: October 2009
Location: Mexico
Senior Member

Hello,

I have continued doing some tests in standalone mode. I am running an evl source that has two input models. For what I can tell (print commands and execution result) it seems as executing an evl module (possibly any module) with more than one model runs the evl source on each of the models, in my case I have two modules and the evl source is being run twice.

I could imagine this is the desired behavior if for example you want to run the same e?l source on different models. However, in my case I will prompt the user twice if there is a missed constraint, and it will be a "duplicated" prompt. If I am correct, can the execute method be modified as to receive an extra parameter that indicates a number of models that should be considered the input of the e?l source. For example:

module.execute(2);


This would tell the engine to group the models by two's and run the e?l source once for each group. So If I have previously loaded 2 models the source will be executed once; if I have loaded 6, then the source would be executed 3 times, and so on and so forth. If I had loaded 5, in the third run I will certainly get an exception as a model will be missing. For compatibility, a call with no parameter will behave as currently.

Regards,

Horacio


Horacio Hoyos Rodriguez
Kinori Tech
Need professional support for Epsilon, EMF?
Go to: https://kinori.tech
Re: [Epsilon] Standalone: execution details [message #666387 is a reply to message #666350] Wed, 20 April 2011 09:33 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Actually, you *can* pass arguments to an EolOperation and set the self variable from the execute() method. Let's go back to the example you mentioned before:

return operation.execute(null, Collections.EMPTY_LIST, module.getContext());


The first argument (if not null) is the value for the self variable, the second one is the List with the arguments for the EolOperation, and the third one is the EOL module's context (with the model repository and other important information). It all depends on how you call this method.

As for your duplicated prompt, I'm not sure what the problem is. Could you please describe your setup more in depth?

Running a certain EVL validation with different groups of models doesn't require modifying the execute() method. Just run it once with the first group of models, clear and set up the model repository in the EVL module's context for the next group, run it again, and keep going. Something like this (warning, untested):

final EvlModule m = new EvlModule();
final ModelRepository repo =
  m.getContext().getModuleRepository();

// Load the EVL module
m.parse(...);

// First group
repo.addModel(...);
repo.addModel(...);
m.execute();

// Second group
repo.clear();
repo.addModel(...);
repo.addModel(...);
m.execute();

// ... and so on

Re: [Epsilon] Standalone: execution details [message #667284 is a reply to message #666387] Wed, 27 April 2011 21:01 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 242
Registered: October 2009
Location: Mexico
Senior Member

Hello Antonio,

Thanks for your explanation. I got my own runtime classes almost ready. Regarding the Model Repository, what is the difference between the celar() and the dispose() methods? In you post you used the clear, but in the standalone example the execute method invokes the dispose method when finished.

Thanks,

Hoarcio


Horacio Hoyos Rodriguez
Kinori Tech
Need professional support for Epsilon, EMF?
Go to: https://kinori.tech
Re: [Epsilon] Standalone: execution details [message #667336 is a reply to message #667284] Thu, 28 April 2011 08:30 Go to previous message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Oops, that was a mistake on my part. Yes, you should definitely call dispose() rather than clear() in my previous example. clear() only removes the models without unloading them, and dispose() unloads the models and then removes the models from the repository.

You're welcome Smile.
Previous Topic:[Epsilon] Standalone
Next Topic:[Epsilon] Request: Ship Plugins with Source code
Goto Forum:
  


Current Time: Fri Apr 19 06:26:46 GMT 2024

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

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

Back to the top