Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Helper Not producing desired result
[ATL] Helper Not producing desired result [message #93852] Wed, 29 October 2008 16:21 Go to next message
Skander TURKI is currently offline Skander TURKIFriend
Messages: 130
Registered: July 2009
Senior Member
The problem i have is this helper that does not work:

(Thanks alfons laarman for your answer I am trying the solution you
suggested)
This helper must do a filtering on a collection
(UML2!Package.packagedElement) before launching a lazy rule on this
collection:

helper context Sequence(UML2!packageableElement)
def : Filtering
(collectionElementsType : String,
isAbstract : Boolean,
visibility : String,
appliedStereotype : String)
: Sequence (UML2!Class) = self->select(h |
h.oclIsTypeOf(collectionElementsType))
->select(z | z.isAbstract=isAbstract
and z.visibility=visibility
and z.isStereotypeApplied(appliedStereotype))
;

..and The call is here:

rule Packages {
from s : UML2!Package (not s.oclIsTypeOf(UML2!Model))
to p: MM!Package
(
packagedElements <- s.packagedElement->Filtering('UML2!Class',
true,
'#public', 'stereotypeName')->collect(e |
thisModule.myLazyRule(e))

..the Lazy rule is here:

lazy rule myLazyRule {
from s : UML2!Class
to t : MM!Class (
name <- s.name
)
}

The helper named 'Filtering' is not working, i have no errors, ATL runs
but nothing is produced.
Re: [ATL] Helper Not producing desired result [message #93895 is a reply to message #93852] Wed, 29 October 2008 20:40 Go to previous messageGo to next message
Alfons Laarman is currently offline Alfons LaarmanFriend
Messages: 71
Registered: July 2009
Member
Hi,

Awnsers below:

"Skander " <skander.turki@gmail.com> schreef in bericht
news:bdf58fdfa711956e493e8e0cc312df38$1@www.eclipse.org...
> The problem i have is this helper that does not work:
....
> helper context Sequence(UML2!packageableElement) def : Filtering
> (collectionElementsType : String, isAbstract : Boolean, visibility :
> String, appliedStereotype : String) : Sequence (UML2!Class) =
> self->select(h | h.oclIsTypeOf(collectionElementsType))
> ->select(z | z.isAbstract=isAbstract and z.visibility=visibility and
> z.isStereotypeApplied(appliedStereotype))
> ;

Usually we write functions starting with a lower case letter. filtering.
The parameter of oclIsTypeOf is OclType not String. Here actually we can
also blame ATL's primitive type-system (wow here i recognize that the
concatenation of words in for example the German language can be useful to
prevent ambiguities. I do not mean primitive-type system) for not providing
any feedback on this.
Anyway if you change in function signature and call, than it should work.
However the same thing might fly for the visibility check, in this case
maybe you can use toString and do a string comparison. Alternatively you
could pass the argument as an Enum literal, I do not know the type of that
but you can use OclAny.

> .and The call is here:
>
> rule Packages { from s : UML2!Package (not
> s.oclIsTypeOf(UML2!Model))
> to p: MM!Package
> (
> packagedElements <- s.packagedElement->Filtering('UML2!Class',
> true,
> '#public', 'stereotypeName')->collect(e |
> thisModule.myLazyRule(e))
>
> .the Lazy rule is here:
>
> lazy rule myLazyRule {
> from s : UML2!Class
> to t : MM!Class (
> name <- s.name
> )
> }
>
> The helper named 'Filtering' is not working, i have no errors, ATL runs
> but nothing is produced.
>
Re: [ATL] Helper Not producing desired result [message #94000 is a reply to message #93895] Thu, 30 October 2008 09:21 Go to previous messageGo to next message
Skander TURKI is currently offline Skander TURKIFriend
Messages: 130
Registered: July 2009
Senior Member
Thanks alfons,
I changed the type to OclANy but it did not work either i have this error
message:
could not find operation filtering on Sequence(OclAny) having supertypes:
[Collection(OclAny)]

The helper i wrote:

helper context Sequence(UML2!PackageableElement)
def : filtering ##notice the lower case function name ;)
(collectionElementsType : OclType, isAbstract : Boolean,
visibility : String, appliedStereotype : String)
: Sequence (UML2!Class) = self->select(h |
h.oclIsTypeOf(collectionElementsType))
->select(z | z.isAbstract=isAbstract
and z.visibility.toString()=visibility
and z.isStereotypeApplied(appliedStereotype)
);
...and the call:

packagedElements <- s.packagedElement->filtering(UML2!Class, true,
'public', 'stereotypeName')->collect(e | thisModule.myMemoryTypes(e))

I don't understand what is wrong, looks like he didn't find the function
with the appropriate signature!!


Alfons Laarman wrote:

> Hi,

> Awnsers below:

> "Skander " <skander.turki@gmail.com> schreef in bericht
> news:bdf58fdfa711956e493e8e0cc312df38$1@www.eclipse.org...
>> The problem i have is this helper that does not work:
> ....
>> helper context Sequence(UML2!packageableElement) def : Filtering
>> (collectionElementsType : String, isAbstract : Boolean, visibility :
>> String, appliedStereotype : String) : Sequence (UML2!Class) =
>> self->select(h | h.oclIsTypeOf(collectionElementsType))
>> ->select(z | z.isAbstract=isAbstract and z.visibility=visibility and
>> z.isStereotypeApplied(appliedStereotype))
>> ;

> Usually we write functions starting with a lower case letter. filtering.
> The parameter of oclIsTypeOf is OclType not String. Here actually we can
> also blame ATL's primitive type-system (wow here i recognize that the
> concatenation of words in for example the German language can be useful to
> prevent ambiguities. I do not mean primitive-type system) for not providing
> any feedback on this.
> Anyway if you change in function signature and call, than it should work.
> However the same thing might fly for the visibility check, in this case
> maybe you can use toString and do a string comparison. Alternatively you
> could pass the argument as an Enum literal, I do not know the type of that
> but you can use OclAny.

>> .and The call is here:
>>
>> rule Packages { from s : UML2!Package (not
>> s.oclIsTypeOf(UML2!Model))
>> to p: MM!Package
>> (
>> packagedElements <- s.packagedElement->Filtering('UML2!Class',
>> true,
>> '#public', 'stereotypeName')->collect(e |
>> thisModule.myLazyRule(e))
>>
>> .the Lazy rule is here:
>>
>> lazy rule myLazyRule {
>> from s : UML2!Class
>> to t : MM!Class (
>> name <- s.name
>> )
>> }
>>
>> The helper named 'Filtering' is not working, i have no errors, ATL runs
>> but nothing is produced.
>>
Re: [ATL] Helper Not producing desired result [message #94014 is a reply to message #94000] Thu, 30 October 2008 11:10 Go to previous messageGo to next message
Alfons Laarman is currently offline Alfons LaarmanFriend
Messages: 71
Registered: July 2009
Member
And if you change the right arrow (->) to a dot (.).
Did you define the helper in the same file? I once noticed that helpers on
primitive types are not imported from libraries. Don;t know if this is the
case for collection types.


Regards,

Alfons


"Skander " <skander.turki@gmail.com> schreef in bericht
news:6a76270d19101e5a63f6a25b1f1da4e2$1@www.eclipse.org...
> Thanks alfons,
> I changed the type to OclANy but it did not work either i have this error
> message:
> could not find operation filtering on Sequence(OclAny) having supertypes:
> [Collection(OclAny)]
>
> The helper i wrote:
>
> helper context Sequence(UML2!PackageableElement) def : filtering
> ##notice the lower case function name ;)
> (collectionElementsType : OclType, isAbstract : Boolean, visibility :
> String, appliedStereotype : String) : Sequence (UML2!Class) =
> self->select(h | h.oclIsTypeOf(collectionElementsType))
> ->select(z | z.isAbstract=isAbstract and
> z.visibility.toString()=visibility and
> z.isStereotypeApplied(appliedStereotype)
> );
> ...and the call:
>
> packagedElements <- s.packagedElement->filtering(UML2!Class, true,
> 'public', 'stereotypeName')->collect(e | thisModule.myMemoryTypes(e))
>
> I don't understand what is wrong, looks like he didn't find the function
> with the appropriate signature!!
>
>
> Alfons Laarman wrote:
>
>> Hi,
>
>> Awnsers below:
>
>> "Skander " <skander.turki@gmail.com> schreef in bericht
>> news:bdf58fdfa711956e493e8e0cc312df38$1@www.eclipse.org...
>>> The problem i have is this helper that does not work:
>> ....
>>> helper context Sequence(UML2!packageableElement) def : Filtering
>>> (collectionElementsType : String, isAbstract : Boolean, visibility :
>>> String, appliedStereotype : String) : Sequence (UML2!Class) =
>>> self->select(h | h.oclIsTypeOf(collectionElementsType))
>>> ->select(z | z.isAbstract=isAbstract and z.visibility=visibility and
>>> z.isStereotypeApplied(appliedStereotype))
>>> ;
>
>> Usually we write functions starting with a lower case letter. filtering.
>> The parameter of oclIsTypeOf is OclType not String. Here actually we can
>> also blame ATL's primitive type-system (wow here i recognize that the
>> concatenation of words in for example the German language can be useful
>> to prevent ambiguities. I do not mean primitive-type system) for not
>> providing any feedback on this.
>> Anyway if you change in function signature and call, than it should work.
>> However the same thing might fly for the visibility check, in this case
>> maybe you can use toString and do a string comparison. Alternatively you
>> could pass the argument as an Enum literal, I do not know the type of
>> that but you can use OclAny.
>
>>> .and The call is here:
>>>
>>> rule Packages { from s : UML2!Package (not
>>> s.oclIsTypeOf(UML2!Model))
>>> to p: MM!Package
>>> (
>>> packagedElements <- s.packagedElement->Filtering('UML2!Class',
>>> true,
>>> '#public', 'stereotypeName')->collect(e |
>>> thisModule.myLazyRule(e))
>>>
>>> .the Lazy rule is here:
>>>
>>> lazy rule myLazyRule {
>>> from s : UML2!Class
>>> to t : MM!Class (
>>> name <- s.name
>>> )
>>> }
>>>
>>> The helper named 'Filtering' is not working, i have no errors, ATL runs
>>> but nothing is produced.
>>>
>
>
Re: [ATL] Helper Not producing desired result [message #94073 is a reply to message #94014] Thu, 30 October 2008 13:45 Go to previous messageGo to next message
Skander TURKI is currently offline Skander TURKIFriend
Messages: 130
Registered: July 2009
Senior Member
thanks alfons for all,
i changed the -> notation to the dot notation,
now i have this error:

****** BEGIN Stack Trace
message: ERROR: could not find operation filtering on Sequence(OclAny)
having supertypes: [Collection(OclAny)]
A.main() : ??#24 null

it looks like he cannot cast the Sequence(OclAny) type to the
Collection(OclAny) type!
Re: [ATL] Helper Not producing desired result [message #94087 is a reply to message #94073] Thu, 30 October 2008 14:32 Go to previous messageGo to next message
Skander TURKI is currently offline Skander TURKIFriend
Messages: 130
Registered: July 2009
Senior Member
finally it worked for me when i used all the package as the context of the
helper , like this:

helper context UML2!Package
def : filtering
(collectionElementsType : OclAny,
isAbstract : Boolean,
visibility : String,
appliedStereotype : String)
: Sequence (UML2!Class) = self.packagedElement->select(h |
h.oclIsTypeOf(collectionElementsType))
->select(z | z.isAbstract=isAbstract
and z.visibility.toString()=visibility
and z.isStereotypeApplied(appliedStereotype)
)
;

...and wiht this call:

packagedElement <- s.filtering(UML2!Class,true,'public',
'StereotypeName')->collect(e | thisModule.myLazyRule(e)),

Thanks for all alfons!!
Re: [ATL] Helper Not producing desired result [message #94116 is a reply to message #94087] Thu, 30 October 2008 23:17 Go to previous messageGo to next message
Alfons Laarman is currently offline Alfons LaarmanFriend
Messages: 71
Registered: July 2009
Member
Good work Skander.
Now I remember, you cannot define operations on sequences. This probably is
somewhere in the documentation.

Doesnt it give a warning?
In ATL code i see this:
if(signature.matches("^(Q|G|C|E|O|N).*$")) {

// Sequence, Bag, Collection, Set, OrderedSet, Native type

logger.warning("Unsupported registration: " + signature);



I'm glad it works for you.



Regards,



Alfons




"Skander " <skander.turki@gmail.com> schreef in bericht
news:c22930ba9b09220aebdc6201659b7169$1@www.eclipse.org...
> finally it worked for me when i used all the package as the context of the
> helper , like this:
>
> helper context UML2!Package def : filtering
> (collectionElementsType : OclAny, isAbstract : Boolean,
> visibility : String, appliedStereotype : String) : Sequence (UML2!Class) =
> self.packagedElement->select(h | h.oclIsTypeOf(collectionElementsType))
> ->select(z | z.isAbstract=isAbstract and
> z.visibility.toString()=visibility and
> z.isStereotypeApplied(appliedStereotype)
> )
> ;
>
> ..and wiht this call:
>
> packagedElement <- s.filtering(UML2!Class,true,'public',
> 'StereotypeName')->collect(e | thisModule.myLazyRule(e)),
>
> Thanks for all alfons!!
>
>
Re: [ATL] Helper Not producing desired result [message #94154 is a reply to message #94116] Fri, 31 October 2008 08:18 Go to previous messageGo to next message
Skander TURKI is currently offline Skander TURKIFriend
Messages: 130
Registered: July 2009
Senior Member
thanks alfons,
in fact i got the message :

Unsupported registration: QMUML2!Package;

But the word QMUML2 did not mean too much for me!
this was when i have the signature:
helper context Sequence(UML2!Package) def : filtering

And when i changed it to:
helper context Set(UML2!Package) def : filtering

I got the same message but with the type EMUML2!Package :
Unsupported registration: EMUML2!Package;

I think they should change the error message to something like:
"Unsupported registration of EMUML2!Package, Collections not supported in
signatures!!"

This could be more helpful to newbies like me!
Re: [ATL] Helper Not producing desired result [message #94185 is a reply to message #94154] Fri, 31 October 2008 10:44 Go to previous message
Alfons Laarman is currently offline Alfons LaarmanFriend
Messages: 71
Registered: July 2009
Member
"Skander " <skander.turki@gmail.com> schreef in bericht
news:fe77fe81fc09f3cc9240022e8fe61a84$1@www.eclipse.org...
> thanks alfons,
> in fact i got the message :
>
> Unsupported registration: QMUML2!Package;
>
> But the word QMUML2 did not mean too much for me!
> this was when i have the signature:
> helper context Sequence(UML2!Package) def : filtering

ATL type system converts types to string. Q stands for seQuence, which is a
parameterized type. In you case the type parameter is a Modelelement which
is encoded as MUML!Package
The details are in the ATL virtual machine documentation for those
interested.

> And when i changed it to:
> helper context Set(UML2!Package) def : filtering
>
> I got the same message but with the type EMUML2!Package :
> Unsupported registration: EMUML2!Package;
>
> I think they should change the error message to something like:
> "Unsupported registration of EMUML2!Package, Collections not supported in
> signatures!!"
>
> This could be more helpful to newbies like me!
>
Previous Topic:compile-time certification of m2m transformations
Next Topic:[ATL] How to write a standalone Java application for model tranformation?
Goto Forum:
  


Current Time: Fri Apr 26 09:24:08 GMT 2024

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

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

Back to the top