Home » Modeling » Epsilon » [ETL] Accessing specific output of a transformation rule(Is it possible to use .equivalent() in a similar kind of way as ATL's resolveTemp())
[ETL] Accessing specific output of a transformation rule [message #1843021] |
Mon, 12 July 2021 08:37 |
Guillaume Dupont Messages: 21 Registered: April 2017 |
Junior Member |
|
|
Hello,
I have two metamodels. One called SimplePDL:
The other called PetriNet:
I want to transform a model of SimplePDL to PetriNet; to do so, there exist the following "informal" rules:
- we can transform a WorkDefinition to a fragment of Petri net as so:
- we can transform a WorkSequence using two arrows between the corresponding fragments of the WorkDefinitions, as so:
To transform WorkDefinition, I can write the following piece of ETL:
rule WorkDefinition2PetriNet
transform wd : simplepdl!WorkDefinition
to p_ready : petrinet!Place,
p_started : petrinet!Place,
p_running : petrinet!Place,
p_finished : petrinet!Place,
t_start : petrinet!Transition,
t_finish : petrinet!Transition,
a_ready_start : petrinet!Arc,
a_start_started : petrinet!Arc,
a_start_running : petrinet!Arc,
a_running_finish : petrinet!Arc,
a_finish_finished : petrinet!Arc extends Process2PetriNet {
p_ready.name = wd.name + "_ready";
p_ready.marking = 1;
p_started.name = wd.name + "_started";
// Etc.
}
But to transform the WorkSequence, I need to make reference to a specific output of the WorkDefinition2PetriNet rule... For instance, if we say I only transform start2finish type WorkSequences, I have:
rule WorkSequence2PetrInet
transform ws : simplepdl!WorkSequence
to arc_1 : petrinet!Arc,
arc_2 : petrinet!Arc {
arc_1.source = ???; // output 'p_started' of rule 'WorkDefinition2PetriNet' applied to 'ws.predecessor'...
...
How do I do that? I understand that there is the .equivalent() method, but I do not feel like it allows to filter which element we retrieve; i.e.: if I write ws.predecessor.equivalent(), what element will I get? Probably not the element I want, right?
For the record, there is something in ATL to do exactly that, called .resolveTemp(). It works like so:
object.resolveTemp('<rule name>', '<output variable name>');
This retrieves the result of applying the given rule to the given object and select the given output variable. For instance, in the example I have, I would write:
arc_1.source = ws.predecessor.resolveTemp('WorkDefinition2PetriNet', 'p_started');
(This is not proper ATL this is just for the example)
Is there an equivalent in ETL? Or is there another "conventional" way specific to it?
Thank you very much for your help.
G.
|
|
| | | | |
Re: [ETL] Accessing specific output of a transformation rule [message #1843028 is a reply to message #1843027] |
Mon, 12 July 2021 13:59 |
|
Hi Guillaume,
> My guess is that, if I reorganize slightly the output of the rule I break my script completely; this also means the output of the rule has a sense of absolute, non-deterministic ordering.
This could be brittle indeed so better have some unit tests in this case (which is a good idea for any non-trivial transformation anyway). Not sure what you mean by "absolute, non-deterministic ordering".
> Also, what happens if there are several rules that may produce a place? I saw that .equivalents() could take as optional argument the name of the rule (but I haven't seen it used in any example).
I've put together an example demonstrating equivalents() with multiple rules that produce multiple elements each in https://www.eclipse.org/epsilon/live/?e69a6cf6
Best,
Dimitris
|
|
|
Re: [ETL] Accessing specific output of a transformation rule [message #1843032 is a reply to message #1843028] |
Mon, 12 July 2021 15:10 |
Guillaume Dupont Messages: 21 Registered: April 2017 |
Junior Member |
|
|
Hello Dimitris,
You are right, unit testing is always a good (if not mandatory) thing to have!
I said "non-deterministic" but I meant "deterministic" (sorry, doing several things simultaneously...). What I mean is that the order shall always be the same, no matter the version of Epsilon and the backend for executing the rules (I do not know how much this is a reasonable assumption). Typically, in ATL, we never know in which order rules will be executed, as it is a purely declarative language with an optimized scheduler.
Thank you very much for your example playground; this is very instructive!
I guess there exists the possibility to have one rule per output element you need and then select the desired object using rules (rather than variables).
Also, I was wondering, maybe there is a possibility to declare and manage several global associative array/map variables in an ETL script? They would link an input object to an output object for each of the needed concept (this is how resolveTemp works essentially).
For example, we would have "map_readies", "map_finished", "map_finish" and "map_start", each of type "Map(WorkDefinition,Node)", that are being populated in the WorkDefinition2PetriNet rule.
The problem is that we do not know when the rules are actually executed, so there is a slight possibility we could try to access objects resulting from the transformation of a WorkDefinition that has not been executed yet...
Thanks,
G.
|
|
| | | |
Goto Forum:
Current Time: Sat Apr 27 06:56:47 GMT 2024
Powered by FUDForum. Page generated in 0.04482 seconds
|