Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Checking whether ATL module may be used for given target MM and model
Checking whether ATL module may be used for given target MM and model [message #1713058] Fri, 30 October 2015 13:09 Go to next message
Dmitry Tatarinov is currently offline Dmitry TatarinovFriend
Messages: 5
Registered: October 2015
Junior Member
Hi.

We are developing a project with use of EMF, where we have one main metamodel (MM1) and a number of 'small' metamodels that are a 'subset' of MM1. Each of this small metamodels needs its own set of tools (parsers, analyzers, configuration generators), and we do not want to work with MM1 while developing them, as MM1 is redundunt. So, we need to transforms models.

We are currently using ATL/EMFTVM and for some reason allow users to transforms instances of MM1 to instance of any other metamodel with any ATL module. Instances of MM1 consist of a big number of 'components' and each also can be transformed using our wizard (we run emftvm programatically).

The problem is that there is a great total number of components that can be transformed, while only few the potentially may be used with given ATL module. So we need to filter models that can be IN models for some module. The obvious way to do it is just to run a module under each of these models and accept those, which do not fail (throw exceptions), but it may be time consuming and 'not academic'.

So the question is, aren't there any tools or ATL/EMFTVM SDK support for checking these condtions?
Re: Checking whether ATL module may be used for given target MM and model [message #1713527 is a reply to message #1713058] Wed, 04 November 2015 20:06 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 351
Registered: September 2012
Location: Belgium
Senior Member

It depends what exactly you mean with "these conditions". The general problem of determining whether a transformation is going to throw an error is undecidable, just like determining whether or not it terminates. If it is a simple matter of checking that only a subset of MM1 metaclasses is used in the input model, things are much easier. The way to do it is to develop an extra "well-formedness check" ATL query that validates the input model, and returns "true" when it passes. I can see a few ways of implementing such a query:


  1. Write a separate validation query for each transformation module. Only the original input model is required as validation input.
  2. Write a single, reflective validation query that checks if the input model uses only metaclasses that occur in the output metamodel. This validation query requires the original input model as well as the targeted output metamodel.
  3. Write a single, reflective validation query that checks if the input model uses only metaclasses that are specified in the transformation module. This validation query requires the original input model as well as the transformation module EMFTVM bytecode (=model).



Cheers,
Dennis
Re: Checking whether ATL module may be used for given target MM and model [message #1714571 is a reply to message #1713527] Fri, 13 November 2015 15:55 Go to previous messageGo to next message
Dmitry Tatarinov is currently offline Dmitry TatarinovFriend
Messages: 5
Registered: October 2015
Junior Member
Thanks.

The question now is how to write these queries. Say, firstly I want to check, whether all metaclasses used in ATL module (as input elements) are a subset of MM1 metaclasses. Should I write this query in Java code, e.g.?

Module module = env.loadModule(moduleResolver, name);
for (Rule rule : m.getRules()) {
for (InputRuleElement element : rule.getInputElements()) {
// check
}
}

If yes, is it possible to do this by registering only source MM and the module?

If no, what to use to write such queries?
Re: Checking whether ATL module may be used for given target MM and model [message #1715172 is a reply to message #1714571] Thu, 19 November 2015 19:46 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 351
Registered: September 2012
Location: Belgium
Senior Member

You could write the query code in Java, but you can also write an ATL query (https://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Language#ATL_Queries). When executing a query, the ExecEnv.run() method returns the value of the evaluated OCL expression, which you can use to determine whether or not to allow the transformation on the selected input model. The query could take the EMFTVM model (module.eResource()) and MM1 as input models.

Cheers,
Dennis
Re: Checking whether ATL module may be used for given target MM and model [message #1716504 is a reply to message #1715172] Fri, 04 December 2015 12:54 Go to previous messageGo to next message
Dmitry Tatarinov is currently offline Dmitry TatarinovFriend
Messages: 5
Registered: October 2015
Junior Member
Thanks, Dennis.

We've implemented some obvious 'checks', that emftvm module may be used with given MM (whether IN or OUT). We check, whether each rule of module uses only metaclasses, specified in MM. Another question is now how to check it in more academic way, as we just compare type literals, which may be unreliable.

The problem now is to think of a way to filter models (EObjects), that may be used with given IN MM, OUT MM and emftvm module (given that model conforms to IN MM). Is it appropriate to check for example that at least one rule of module will be executed? By 'executed' I mean, that input model (EObject) has in its content all the elements, specified in the FROM clause of module. Here we assume, that if no rule may be matched, the transformation has no semantic sense, despite technically it may be legal. Are there some other checks of this kind?
Re: Checking whether ATL module may be used for given target MM and model [message #1716738 is a reply to message #1716504] Mon, 07 December 2015 21:34 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 351
Registered: September 2012
Location: Belgium
Senior Member

Dmitry Tatarinov wrote on Fri, 04 December 2015 13:54

We've implemented some obvious 'checks', that emftvm module may be used with given MM (whether IN or OUT). We check, whether each rule of module uses only metaclasses, specified in MM. Another question is now how to check it in more academic way, as we just compare type literals, which may be unreliable.


EMFTVM only links its modules against real metamodels at load-time, which is why the .emftvm files only contain lexical references to metaclasses. When loading an EMFTVM module into an ExecEnv instance, the actual metaclasses will be resolved against the registered metamodels, and the "eType" property of the various typed elements will have been filled in. Using such a loaded EMFTVM module should allow you to check - using the actual EMFTVM type resolver algorithm - whether the exact same metaclasses of the MM are also used in the EMFTVM module.

Dmitry Tatarinov wrote on Fri, 04 December 2015 13:54

The problem now is to think of a way to filter models (EObjects), that may be used with given IN MM, OUT MM and emftvm module (given that model conforms to IN MM). Is it appropriate to check for example that at least one rule of module will be executed? By 'executed' I mean, that input model (EObject) has in its content all the elements, specified in the FROM clause of module. Here we assume, that if no rule may be matched, the transformation has no semantic sense, despite technically it may be legal. Are there some other checks of this kind?


You may check whether the intersection of metaclasses referenced by the input model and the InputRuleElement instances of "#automaticSingle" Rules in the EMFTVM model is non-empty. That means that there are ATL matched rules that take instances of those metaclasses as input. Keep in mind that this approach ignores any OCL filter expression used on the rule's "from" part, however, and the actual rule may still not trigger due to the filter expression evaluating to"false".


Cheers,
Dennis
Re: Checking whether ATL module may be used for given target MM and model [message #1717271 is a reply to message #1716738] Fri, 11 December 2015 10:06 Go to previous messageGo to next message
Dmitry Tatarinov is currently offline Dmitry TatarinovFriend
Messages: 5
Registered: October 2015
Junior Member
Dennis Wagelaar wrote on Mon, 07 December 2015 21:34

You may check whether the intersection of metaclasses referenced by the input model and the InputRuleElement instances of "#automaticSingle" Rules in the EMFTVM model is non-empty. That means that there are ATL matched rules that take instances of those metaclasses as input. Keep in mind that this approach ignores any OCL filter expression used on the rule's "from" part, however, and the actual rule may still not trigger due to the filter expression evaluating to"false".


My English is rather poor, but it seems, that I had meant exactly what you've suggested: check, whether for at least one automaticSingle rule all the InputRuleElements are referenced as metaclasses in contens of EObject.

As you mentioned, the only other idea to filter raw EObjects may be to somehow evaluate the OCL expression in matcher block; is there any smart way to deal with these expressions (without reimplementing the whole engine =))?

Re: Checking whether ATL module may be used for given target MM and model [message #1717340 is a reply to message #1717271] Fri, 11 December 2015 22:02 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 351
Registered: September 2012
Location: Belgium
Senior Member

Dmitry Tatarinov wrote on Fri, 11 December 2015 11:06

As you mentioned, the only other idea to filter raw EObjects may be to somehow evaluate the OCL expression in matcher block; is there any smart way to deal with these expressions (without reimplementing the whole engine =))?


If you could "pause" EMFTVM between the matching phase and the applying phase, you could introspect the matches model (ExecEnv.getMatches()) to see if any rule matched. After the user chooses to apply the transformation, you can simply resume the transformation with the existing matches.

With the current API, this is not possible: ExecEnv.run() will execute a transformation in its entirety. It is definitely possible to add API that enables the above scenario. Is this something you would be interested in? N.B. you need to consider that matching is often half the transformation execution time!


Cheers,
Dennis
Re: Checking whether ATL module may be used for given target MM and model [message #1717436 is a reply to message #1717340] Sun, 13 December 2015 18:43 Go to previous message
Dmitry Tatarinov is currently offline Dmitry TatarinovFriend
Messages: 5
Registered: October 2015
Junior Member
Dennis Wagelaar wrote on Fri, 11 December 2015 22:02

With the current API, this is not possible: ExecEnv.run() will execute a transformation in its entirety. It is definitely possible to add API that enables the above scenario. Is this something you would be interested in? N.B. you need to consider that matching is often half the transformation execution time!


As I'm dealing with this problem due to my bachelor's degree diploma project, it will be at least a chance to add some 'scientific component' to the work Smile However, in real scenario this feature may be not very useful, as in our domain-specific transformations only a very small subset of EObjects will pass the first check (referencing all metaclasses for InputRuleElements of at least one rule) and will not pass the second (filtering), while this second check seems to be time consuming.

Thanks!
Previous Topic:EMFTVM Documentation Issues
Next Topic:Add-Delet-Class
Goto Forum:
  


Current Time: Sun Nov 19 05:13:49 GMT 2017

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

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