Home » Archived » M2M (model-to-model transformation) » [ATL] Helper Not producing desired result
|
Re: [ATL] Helper Not producing desired result [message #93895 is a reply to message #93852] |
Wed, 29 October 2008 20:40 |
Alfons Laarman 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 |
Skander TURKI 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 |
Alfons Laarman 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 #94116 is a reply to message #94087] |
Thu, 30 October 2008 23:17 |
Alfons Laarman 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!!
>
>
|
|
| | |
Goto Forum:
Current Time: Fri Apr 26 09:24:08 GMT 2024
Powered by FUDForum. Page generated in 0.04218 seconds
|