Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » ATL ignores elements inside a UML PackageImport(How can I get ATL to process the elements in a PackageImport)
ATL ignores elements inside a UML PackageImport [message #937066] Mon, 08 October 2012 16:21 Go to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi!
I have a UML model which imports packages from other UML models using the UML PackageImport element. My "top/main" rule is like the following...

rule ModelToB
{
from s: UML!Model(s.oclIsTypeOf(UML!Model))
to t : MB!B
(
a <- s.packagedElement->select(e|e.oclIsTypeOf(uml::Package))->union(s.packageImport->collect(e|e.importedPackage))->select(e|e.oclIsTypeOf(UML!Package))
)
}

This causes another rule PackageToC to fire later. However, only UML Packages from the s.packagedElement get processed. The UML Packages from s.packageImport don't get processed as they are not directly in the input model.

rule PackageToC
{
from s: UML!Package(s.oclIsTypeOf(UML!Package))
to t : MB!C()
}

I can get this to work if I change my rules to lazy rules and collect the packages and call them explicitly. I would like to avoid this as I have a very large number of rules that would require converting to lazy rules as every element in the UML PackageImport will require the same explicit treatment e.g. Classes, Datatypes etc.

Any way around this?

Thanks,
Ronan
Re: ATL ignores elements inside a UML PackageImport [message #937074 is a reply to message #937066] Mon, 08 October 2012 16:29 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Do you really mean oclIsTypeOf rather than oclIsKindOf? If ATL
approximates OCL reasonably, this will ignore all derived Packages such
as Model and Profile.

Regards

Ed Willink

On 08/10/2012 17:21, Ronan B wrote:
> Hi!
> I have a UML model which imports packages from other UML models using
> the UML PackageImport element. My "top/main" rule is like the
> following...
>
> rule ModelToB
> {
> from s: UML!Model(s.oclIsTypeOf(UML!Model))
> to t : MB!B
> (
> a <-
> s.packagedElement->select(e|e.oclIsTypeOf(uml::Package))->union(s.packageImport->collect(e|e.importedPackage))->select(e|e.oclIsTypeOf(UML!Package))
> )
> }
>
> This causes another rule PackageToC to fire later. However, only UML
> Packages from the s.packagedElement get processed. The UML Packages
> from s.packageImport don't get processed as they are not directly in
> the input model.
>
> rule PackageToC
> {
> from s: UML!Package(s.oclIsTypeOf(UML!Package))
> to t : MB!C()
> }
>
> I can get this to work if I change my rules to lazy rules and collect
> the packages and call them explicitly. I would like to avoid this as I
> have a very large number of rules that would require converting to
> lazy rules as every element in the UML PackageImport will require the
> same explicit treatment e.g. Classes, Datatypes etc.
>
> Any way around this?
>
> Thanks,
> Ronan
Re: ATL ignores elements inside a UML PackageImport [message #937083 is a reply to message #937074] Mon, 08 October 2012 16:42 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi Ed,
Yep it is as intended. I want to avoid UML model/UML profile instances going into the PackageToC rule.
Regards,
Ronan
Re: ATL ignores elements inside a UML PackageImport [message #937152 is a reply to message #937066] Mon, 08 October 2012 18:14 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

Op 08-10-12 18:21, Ronan B schreef:
> Hi!
> I have a UML model which imports packages from other UML models using the UML
> PackageImport element. My "top/main" rule is like the following...
>
> rule ModelToB
> {
> from s: UML!Model(s.oclIsTypeOf(UML!Model))
> to t : MB!B
> (
> a <-
> s.packagedElement->select(e|e.oclIsTypeOf(uml::Package))->union(s.packageImport->collect(e|e.importedPackage))->select(e|e.oclIsTypeOf(UML!Package))
>
> )
> }
>
> This causes another rule PackageToC to fire later. However, only UML Packages
> from the s.packagedElement get processed. The UML Packages from
> s.packageImport don't get processed as they are not directly in the input model.

Wait! Matched rules cannot be "caused to fire" explicitly. All matched rules
are matched up front, after which they are applied to their matches one by
one. If your ModelToB rule comes before your PackageToC rule, it is applied
before (but the application order is not guaranteed).

>
> rule PackageToC
> {
> from s: UML!Package(s.oclIsTypeOf(UML!Package))
> to t : MB!C()
> }
>
> I can get this to work if I change my rules to lazy rules and collect the
> packages and call them explicitly. I would like to avoid this as I have a very
> large number of rules that would require converting to lazy rules as every
> element in the UML PackageImport will require the same explicit treatment e.g.
> Classes, Datatypes etc.
>
> Any way around this?
>
> Thanks,
> Ronan

Your PackageToC rule will match all Package instances contained in one of the
declared input models. If your input model is not explicitly declared, a
matched rule won't try to match against it.

Lazy rules take explicit parameters, which allows you to go beyond the borders
of your declared input models.

The most straightforward way around this is to use a higher-order
transformation that collects all the imported models, and lists them
explicitly as input models.

Alternatively, the new EMFTVM (http://wiki.eclipse.org/ATL/EMFTVM) allows you
to specify additional input models dynamically. That way you can keep your
PackageToC rule, and you just need to add the imported UML models as extra
input models in the ATL EMFTVM launch config.

Regards,
Dennis


Cheers,
Dennis
Re: ATL ignores elements inside a UML PackageImport [message #937766 is a reply to message #937152] Tue, 09 October 2012 08:36 Go to previous message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi Dennis,

Dennis Wagelaar wrote on Mon, 08 October 2012 14:14
Op 08-10-12 18:21, Ronan B schreef:
> Hi!
> I have a UML model which imports packages from other UML models using the UML
> PackageImport element. My "top/main" rule is like the following...
>
> rule ModelToB
> {
> from s: UML!Model(s.oclIsTypeOf(UML!Model))
> to t : MB!B
> (
> a <-
> s.packagedElement->select(e|e.oclIsTypeOf(uml::Package))->union(s.packageImport->collect(e|e.importedPackage))->select(e|e.oclIsTypeOf(UML!Package))
>
> )
> }
>
> This causes another rule PackageToC to fire later. However, only UML Packages
> from the s.packagedElement get processed. The UML Packages from
> s.packageImport don't get processed as they are not directly in the input model.

Wait! Matched rules cannot be "caused to fire" explicitly. All matched rules
are matched up front, after which they are applied to their matches one by
one. If your ModelToB rule comes before your PackageToC rule, it is applied
before (but the application order is not guaranteed).

[Ronan] Yep I'm aware that I cannot control processing order. When I said "to fire" I meant by the rule engine not by any explicit call I would make. I think you took my use of the word "later" to meant that I wanted an explicit order. I meant it as "some other time". Perhaps that was not so clear, my bad Smile

>
> rule PackageToC
> {
> from s: UML!Package(s.oclIsTypeOf(UML!Package))
> to t : MB!C()
> }
>
> I can get this to work if I change my rules to lazy rules and collect the
> packages and call them explicitly. I would like to avoid this as I have a very
> large number of rules that would require converting to lazy rules as every
> element in the UML PackageImport will require the same explicit treatment e.g.
> Classes, Datatypes etc.
>
> Any way around this?
>
> Thanks,
> Ronan

Your PackageToC rule will match all Package instances contained in one of the
declared input models. If your input model is not explicitly declared, a
matched rule won't try to match against it.

[Ronan] Ah interesting I didn't know this about matched rules, I guess it makes sense. I also tried adding the imported model/package to the input list but then I'd have to encode explicitly in my ATL which is the "master model". By "master model" I mean the model that does the importing. This would mess up my very generic rules.

Lazy rules take explicit parameters, which allows you to go beyond the borders
of your declared input models.

[Ronan] Yep indeed. This works.

The most straightforward way around this is to use a higher-order
transformation that collects all the imported models, and lists them
explicitly as input models.

[Ronan] This sounds feasable but then i'll run into the same "master model" problem as above. I guess the HOT could be used to write this code too.

Alternatively, the new EMFTVM (http://wiki.eclipse.org/ATL/EMFTVM) allows you
to specify additional input models dynamically. That way you can keep your
PackageToC rule, and you just need to add the imported UML models as extra
input models in the ATL EMFTVM launch config.

[Ronan] This sounds very promising. I'll play around with this when I get a chance. For the moment I think i'll just convert the rules to lazy rules as it seems to be the only short term fix.

Regards,
Dennis


Thanks for the help!
Ronan
Previous Topic:[ATL] How to change ecoding
Next Topic:Stereotypes tag values: setValue to copy tag value
Goto Forum:
  


Current Time: Tue Apr 23 09:57:23 GMT 2024

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

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

Back to the top