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 12:21  |
Eclipse User |
|
|
|
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 16:40   |
Eclipse User |
|
|
|
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 05:21   |
Eclipse User |
|
|
|
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 07:10   |
Eclipse User |
|
|
|
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 #94116 is a reply to message #94087] |
Thu, 30 October 2008 19:17   |
Eclipse User |
|
|
|
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 #94185 is a reply to message #94154] |
Fri, 31 October 2008 06:44  |
Eclipse User |
|
|
|
"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!
>
|
|
|
Goto Forum:
Current Time: Sun Jul 27 18:08:27 EDT 2025
Powered by FUDForum. Page generated in 0.13148 seconds
|