|
Re: [Epsilon] Standalone: execution details [message #666324 is a reply to message #666313] |
Tue, 19 April 2011 17:50   |
Eclipse User |
|
|
|
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:
- Parse the module and run the statements at the global scope with the execute method of EolModule.
- Pick the desired EolOperation.
- 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 17:51   |
Eclipse User |
|
|
|
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 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
[Updated on: Tue, 19 April 2011 17:53] by Moderator
|
|
|
Re: [Epsilon] Standalone: execution details [message #666350 is a reply to message #666325] |
Wed, 20 April 2011 01:22   |
Eclipse User |
|
|
|
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:
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
|
|
|
Re: [Epsilon] Standalone: execution details [message #666387 is a reply to message #666350] |
Wed, 20 April 2011 05:33   |
Eclipse User |
|
|
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05960 seconds