Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Mixed types collection operations
[ATL] Mixed types collection operations [message #93360] Tue, 28 October 2008 10:06 Go to next message
Skander TURKI is currently offline Skander TURKIFriend
Messages: 130
Registered: July 2009
Senior Member
Hi,
i have a little problem when using a collection with mixed types inside.
For instance, i have a collection (that is the UML2
package.packagedElement collection) that contains uml2 classes, packages,
associations and other stuff...

The problem is thet i want to write this:

myPublicMemoryTypes: distinct AAXL!MemoryType
foreach (e in s.packagedElement->select(h | h.oclIsTypeOf(UML2!Class)
and
h.isAbstract=true and h.visibility=#public ) (
name <- e.name
)

The problem here is when the iterator "h" is a package i get this error
:"isAbstract does not exist on UML2!Package" !

So i want to test on isAbstract only when the type is a UML2!Class.
Does anybody have an idea of how to do such things?!!
Re: [ATL] Mixed types collection operations [message #93382 is a reply to message #93360] Tue, 28 October 2008 10:48 Go to previous messageGo to next message
Andy Carpenter is currently offline Andy CarpenterFriend
Messages: 145
Registered: July 2009
Senior Member
Skander,

Suggestion below. However, this feels like you should have a rule
for dealing with classes and other rules for the different types of
packaged elements (each rule needs the appropriate guard
condition).

Andy.

"Skander " <skander.turki@gmail.com> wrote in message
news:ca7f59a660579de39852492ee6216b55$1@www.eclipse.org...
> Hi,
> i have a little problem when using a collection with mixed types inside.
> For instance, i have a collection (that is the UML2
> package.packagedElement collection) that contains uml2 classes, packages,
> associations and other stuff...
>
> The problem is thet i want to write this:
>
> myPublicMemoryTypes: distinct AAXL!MemoryType foreach (e in
> s.packagedElement->select(h | h.oclIsTypeOf(UML2!Class) and
> h.isAbstract=true and h.visibility=#public ) (
> name <- e.name
> )
>

foreach(e in s.packagedElement->select(h | if h.oclIsTypeOf(UML!Class then
h.isAbstract= true and h.visibility=#public)
else
false
endif) (
name <- e.name
)

> The problem here is when the iterator "h" is a package i get this error
> :"isAbstract does not exist on UML2!Package" !
> So i want to test on isAbstract only when the type is a UML2!Class.
> Does anybody have an idea of how to do such things?!!
>
Re: [ATL] Mixed types collection operations [message #93394 is a reply to message #93360] Tue, 28 October 2008 10:56 Go to previous messageGo to next message
Freddy Allilaire is currently offline Freddy AllilaireFriend
Messages: 130
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020008040907050507050000
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi,

Maybe you can write something like this (with an helper) to solve your
problem:

myPublicMemoryTypes: distinct AAXL!MemoryType foreach (e in
s.packagedElement->select(h | h.isClassAbstractAndPublic()) (
name <- e.name
)

helper context UML2!PackagedElement -- Not sure if it's the good type ;)
def : isClassAbstractAndPublic() : Boolean =
if self.oclIsTypeOf(UML2!Class) then
if (self.isAbstract=true and self.visibility=#public) then
true
else
false
endif
else
false
endif;

I also advised you to replace distinct-foreach by lazy rules if it is
possible
( http://www.eclipse.org/m2m/atl/basicExamples_Patterns/articl e.php?file=Port/index.html)

Regards,
Freddy.


Skander a
Re: [ATL] Mixed types collection operations [message #93408 is a reply to message #93394] Tue, 28 October 2008 12:56 Go to previous message
Skander TURKI is currently offline Skander TURKIFriend
Messages: 130
Registered: July 2009
Senior Member
thanks for all, the lazy rule is what i was looking for!
but i didn't find anything about it in the ATL User GUIDE. The example you
gave (freddy) is clear enough.
Hope this user guide will be updated soon, it will be good for the
beginners (like me).
Previous Topic:A weird result
Next Topic:[ATL]How to get an attribute which is defined in another file
Goto Forum:
  


Current Time: Fri Apr 19 00:13:28 GMT 2024

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

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

Back to the top