Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] GetNameFromSource exception
[ATL] GetNameFromSource exception [message #66504] Tue, 20 November 2007 16:09 Go to next message
Guillaume Gauffre is currently offline Guillaume GauffreFriend
Messages: 65
Registered: July 2009
Member
Hi,

I use some rules to generate a model based on two input models :
I've got two rule like the rule AOut2AOut which use a lazy rule during
the matching of the target element "aIL".
In the imperative section, I try to use the resolveTemp function to get
the element created by the lazy rule but in all cases, an exception is
fired with the message
"could not find operation getNamedTargetFromSource on Void having
supertypes: [OclAny]"
The variable used, "ap" in the resolveTemp call, is always containing a
correct element.
Is it the use of the lazy rule which is not correct or something else ?
Please, if anybody has an idea about this problem and how to solve it...

Thank you


I put the code of all variables used but maybe it is not important
considering my problem, sorry for the length of the code section.

----
rule AOut2AOut {
from
a : mmA!AOut( not
a.rsrc->select(r|r.oclIsKindOf(mmA!DEx))->collect(r|r.LF)- >forAll(e
|e.oclIsUndefined() or e = ''))

using {
l : Set(String) =
a.rsrc->select(r|r.oclIsKindOf(asur!DEx))->collect(r|r.LF)- >asSet();

t : OrderedSet(owl!OWLClass) =
owl!OWLClass.allInstances()->select(e|e.localName=a.PS.toString())- >first().subClass
->select(e|l->one(i|i=e.localName));

tA : Sequence(Sequence(owl!Individual)) =
t->collect(i|i.instance->select(elt|elt.isAnAP())->collect(elt|elt.getAllAp()));

tD : Sequence(Set(owl!Individual)) =
t->collect(i|i.instance->select(elt|elt.RDFType->one(type|type=thisModule.getDType()))
->union(tA->collect(path|path->collect(e|e->last().getDRelated()))- >flatten()->flatten()->asSet()));

dC : owl!Individual =
tD->flatten()->select(elt|tD->flatten()->count(elt)=tD->size())- >first();

aC : Sequence(owl!Individual) =
tA->collect(path|path->any(e|e->last().getDRelated() = dC));

noAp : Boolean = aC->flatten()->flatten()->forAll(e|e.oclIsUndefined());

}
to
aIL : mmB!A_Out (
Name <- a.Name,
d <- outdIL,
ap <- if (not noAp) then
thisModule.reorgAp(aC)->flatten()->collect(e|thisModule.oAPIs(e)) else
Set{} endif,
T <- t->iterate(type ; str : String = '' | str.concat('|'+type.localName))
),

idev : mmB!In_port (
Name <- if (dC.oclIsUndefined()) then 'i+D_'+a.Name else
'i+'+dC.localName endif,
type <- if (dC.oclIsUndefined()) then Set{} else
thisModule.makeDT(dC.getDUsed()) endif
),

dev : mmB!A_Device (
Name <- if (dC.oclIsUndefined()) then 'D_'+a.Name else dC.localName endif,
in_p <- idev
)
do {
for (ap in thisModule.reorgAp(aC)->last()) {
thisModule.resolveTemp(ap,'oap').type <- idev.type;
thisModule.model.communications <-
thisModule.ACom(thisModule.resolveTemp(ap,'oap'),idev);
}
}

----
lazy rule oAPIs {
from
ap : owl!Individual
to
oapis : mmB!A_API (
Name <- ap.localName,
in_ports <- iap,
out_ports <- oap
),
oap : asurIL!Out_port (
Name <- 'o+'+ap.localName
),
iap : asurIL!In_port (
Name <- 'i+'+ap.localName,
type <- thisModule.makeDT(ap.getDUsed())
)
}
Re: [ATL] GetNameFromSource exception [message #66770 is a reply to message #66504] Mon, 26 November 2007 10:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Hugo.Bruneliere.univ-nantes.fr

> Hi,

Hi Guillaume,

>
> I use some rules to generate a model based on two input models :
> I've got two rule like the rule AOut2AOut which use a lazy rule during
> the matching of the target element "aIL".
> In the imperative section, I try to use the resolveTemp function to get
> the element created by the lazy rule but in all cases, an exception is
> fired with the message
> "could not find operation getNamedTargetFromSource on Void having
> supertypes: [OclAny]"
> The variable used, "ap" in the resolveTemp call, is always containing a
> correct element.
> Is it the use of the lazy rule which is not correct or something else ?
> Please, if anybody has an idea about this problem and how to solve it...
>
> Thank you
>
>
> I put the code of all variables used but maybe it is not important
> considering my problem, sorry for the length of the code section.
>
> ----
> rule AOut2AOut {
> from
> a : mmA!AOut( not
> a.rsrc->select(r|r.oclIsKindOf(mmA!DEx))->collect(r|r.LF)- >forAll(e
> |e.oclIsUndefined() or e = ''))
>
> using {
> l : Set(String) =
> a.rsrc->select(r|r.oclIsKindOf(asur!DEx))->collect(r|r.LF)- >asSet();
>
> t : OrderedSet(owl!OWLClass) =
> owl!OWLClass.allInstances()->select(e|e.localName=a.PS.toString())- >first().subClass
>
> ->select(e|l->one(i|i=e.localName));
>
> tA : Sequence(Sequence(owl!Individual)) =
> t->collect(i|i.instance->select(elt|elt.isAnAP())->collect(elt|elt.getAllAp()));
>
>
> tD : Sequence(Set(owl!Individual)) =
> t->collect(i|i.instance->select(elt|elt.RDFType->one(type|type=thisModule.getDType()))
>
> ->union(tA->collect(path|path->collect(e|e->last().getDRelated()))- >flatten()->flatten()->asSet()));
>
>
> dC : owl!Individual =
> tD->flatten()->select(elt|tD->flatten()->count(elt)=tD->size())- >first();
>
> aC : Sequence(owl!Individual) =
> tA->collect(path|path->any(e|e->last().getDRelated() = dC));
>
> noAp : Boolean =
> aC->flatten()->flatten()->forAll(e|e.oclIsUndefined());
>
> }
> to
> aIL : mmB!A_Out (
> Name <- a.Name,
> d <- outdIL,
> ap <- if (not noAp) then
> thisModule.reorgAp(aC)->flatten()->collect(e|thisModule.oAPIs(e)) else
> Set{} endif,
> T <- t->iterate(type ; str : String = '' |
> str.concat('|'+type.localName))
> ),
>
> idev : mmB!In_port (
> Name <- if (dC.oclIsUndefined()) then 'i+D_'+a.Name else
> 'i+'+dC.localName endif,
> type <- if (dC.oclIsUndefined()) then Set{} else
> thisModule.makeDT(dC.getDUsed()) endif
> ),
>
> dev : mmB!A_Device (
> Name <- if (dC.oclIsUndefined()) then 'D_'+a.Name else dC.localName
> endif,
> in_p <- idev
> )
> do {
> for (ap in thisModule.reorgAp(aC)->last()) {
> thisModule.resolveTemp(ap,'oap').type <- idev.type;

The attributes of a given model element have to be set in the rule which
creates it: the "type" attributes should be set in the oAPIs rule.

> thisModule.model.communications <-
> thisModule.ACom(thisModule.resolveTemp(ap,'oap'),idev);

The principle of a lazy rule is that it is matched only if you
explicitly call it. In many cases, the use of lazy rules replace calls
to the "resolveTemp" method. So you should have written something like
this: "thisModule.oAPIs(ap)" instead of
"thisModule.resolveTemp(ap,'oap')" (because as oAPIs is a lazy rule
which is never called in your Atl program, the rule is never matched).

Note that the model element which is returned by a lazy rule is the
first mentioned in the "to" section of the rule. So in your case, I
think you should first put the "oap : asurIL!Out_port" element in the
"to" section of your lazy rule.

> }
> }
>
> ----
> lazy rule oAPIs {
> from
> ap : owl!Individual
> to
> oapis : mmB!A_API (
> Name <- ap.localName,
> in_ports <- iap,
> out_ports <- oap
> ),
> oap : asurIL!Out_port (
> Name <- 'o+'+ap.localName
> ),
> iap : asurIL!In_port (
> Name <- 'i+'+ap.localName,
> type <- thisModule.makeDT(ap.getDUsed())
> )
> }

Best regards,

Hugo

--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
Re: [ATL] GetNameFromSource exception [message #66832 is a reply to message #66770] Tue, 27 November 2007 07:57 Go to previous messageGo to next message
Guillaume Gauffre is currently offline Guillaume GauffreFriend
Messages: 65
Registered: July 2009
Member
Thanks hugo for your response.

Ok for the definition of the attribute 'type', unfortunately, I think I
can determine it only into the 'do' section, but I will see this problem
later.
About the lazy rule, you told me that I never call it, in fact I call it
in the 'to' section (the amount of code surrely hide it :-)
<<<<<ap <- if (not noAp) then
thisModule.reorgAp(aC)->flatten()->collect(e|thisModule.oAPIs(e)) else
Set{} endif,>>>>>>
I try to put the 'oap' element at the beginning of the 'to' section of
my lazy rule, but nothing change ...

But ... yes finally I found a solution :
I put the attribute 'unique' to my lazy rule and use in the imperative
section the call to it to get the element 'ap' instead of using the
'resolveTemp' call, and it works, I can either define the attribute
'type' !!!!

for (ap in thisModule.reorgAp(aC)->last()) {
thisModule.outAPIs(ap).out_ports->first().type <- idev.type;
thisModule.model.communications <-
thisModule.ACom(thisModule.outAPIs(ap).out_ports->first(),idev);
}

If somebody knows the difference between the two calls : unique lazy
rule or resolveTemp, it would be great.
Now I will never use resolveTemp again !!!!!

Thanks Hugo

Regards,

Guillaume

Hugo Bruneliere a écrit :
>> Hi,
>
> Hi Guillaume,
>
>>
>> I use some rules to generate a model based on two input models :
>> I've got two rule like the rule AOut2AOut which use a lazy rule during
>> the matching of the target element "aIL".
>> In the imperative section, I try to use the resolveTemp function to
>> get the element created by the lazy rule but in all cases, an
>> exception is fired with the message
>> "could not find operation getNamedTargetFromSource on Void having
>> supertypes: [OclAny]"
>> The variable used, "ap" in the resolveTemp call, is always containing
>> a correct element.
>> Is it the use of the lazy rule which is not correct or something else ?
>> Please, if anybody has an idea about this problem and how to solve it...
>>
>> Thank you
>>
>>
>> I put the code of all variables used but maybe it is not important
>> considering my problem, sorry for the length of the code section.
>>
>> ----
>> rule AOut2AOut {
>> from
>> a : mmA!AOut( not
>> a.rsrc->select(r|r.oclIsKindOf(mmA!DEx))->collect(r|r.LF)- >forAll(e
>> |e.oclIsUndefined() or e = ''))
>>
>> using {
>> l : Set(String) =
>> a.rsrc->select(r|r.oclIsKindOf(asur!DEx))->collect(r|r.LF)- >asSet();
>>
>> t : OrderedSet(owl!OWLClass) =
>> owl!OWLClass.allInstances()->select(e|e.localName=a.PS.toString())- >first().subClass
>>
>> ->select(e|l->one(i|i=e.localName));
>>
>> tA : Sequence(Sequence(owl!Individual)) =
>> t->collect(i|i.instance->select(elt|elt.isAnAP())->collect(elt|elt.getAllAp()));
>>
>>
>> tD : Sequence(Set(owl!Individual)) =
>> t->collect(i|i.instance->select(elt|elt.RDFType->one(type|type=thisModule.getDType()))
>>
>> ->union(tA->collect(path|path->collect(e|e->last().getDRelated()))- >flatten()->flatten()->asSet()));
>>
>>
>> dC : owl!Individual =
>> tD->flatten()->select(elt|tD->flatten()->count(elt)=tD->size())- >first();
>> aC : Sequence(owl!Individual) =
>> tA->collect(path|path->any(e|e->last().getDRelated() = dC));
>>
>> noAp : Boolean =
>> aC->flatten()->flatten()->forAll(e|e.oclIsUndefined());
>>
>> }
>> to
>> aIL : mmB!A_Out (
>> Name <- a.Name,
>> d <- outdIL,
>> ap <- if (not noAp) then
>> thisModule.reorgAp(aC)->flatten()->collect(e|thisModule.oAPIs(e)) else
>> Set{} endif,
>> T <- t->iterate(type ; str : String = '' |
>> str.concat('|'+type.localName))
>> ),
>>
>> idev : mmB!In_port (
>> Name <- if (dC.oclIsUndefined()) then 'i+D_'+a.Name else
>> 'i+'+dC.localName endif,
>> type <- if (dC.oclIsUndefined()) then Set{} else
>> thisModule.makeDT(dC.getDUsed()) endif
>> ),
>>
>> dev : mmB!A_Device (
>> Name <- if (dC.oclIsUndefined()) then 'D_'+a.Name else
>> dC.localName endif,
>> in_p <- idev
>> )
>> do {
>> for (ap in thisModule.reorgAp(aC)->last()) {
>> thisModule.resolveTemp(ap,'oap').type <- idev.type;
>
> The attributes of a given model element have to be set in the rule which
> creates it: the "type" attributes should be set in the oAPIs rule.
>
>> thisModule.model.communications <-
>> thisModule.ACom(thisModule.resolveTemp(ap,'oap'),idev);
>
> The principle of a lazy rule is that it is matched only if you
> explicitly call it. In many cases, the use of lazy rules replace calls
> to the "resolveTemp" method. So you should have written something like
> this: "thisModule.oAPIs(ap)" instead of
> "thisModule.resolveTemp(ap,'oap')" (because as oAPIs is a lazy rule
> which is never called in your Atl program, the rule is never matched).
>
> Note that the model element which is returned by a lazy rule is the
> first mentioned in the "to" section of the rule. So in your case, I
> think you should first put the "oap : asurIL!Out_port" element in the
> "to" section of your lazy rule.
>
>> }
>> }
>>
>> ----
>> lazy rule oAPIs {
>> from
>> ap : owl!Individual
>> to
>> oapis : mmB!A_API (
>> Name <- ap.localName,
>> in_ports <- iap,
>> out_ports <- oap
>> ),
>> oap : asurIL!Out_port (
>> Name <- 'o+'+ap.localName
>> ),
>> iap : asurIL!In_port (
>> Name <- 'i+'+ap.localName,
>> type <- thisModule.makeDT(ap.getDUsed())
>> )
>> }
>
> Best regards,
>
> Hugo
>
Re: [ATL] GetNameFromSource exception [message #66833 is a reply to message #66832] Tue, 27 November 2007 13:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Hugo.Bruneliere.univ-nantes.fr

Dear Guillaume,

Guillaume Gauffre a écrit :
> Thanks hugo for your response.
>
> Ok for the definition of the attribute 'type', unfortunately, I think I
> can determine it only into the 'do' section, but I will see this problem
> later.
> About the lazy rule, you told me that I never call it, in fact I call it
> in the 'to' section (the amount of code surrely hide it :-)
> <<<<<ap <- if (not noAp) then
> thisModule.reorgAp(aC)->flatten()->collect(e|thisModule.oAPIs(e)) else
> Set{} endif,>>>>>>
> I try to put the 'oap' element at the beginning of the 'to' section of
> my lazy rule, but nothing change ...
>
> But ... yes finally I found a solution :
> I put the attribute 'unique' to my lazy rule and use in the imperative
> section the call to it to get the element 'ap' instead of using the
> 'resolveTemp' call, and it works, I can either define the attribute
> 'type' !!!!
>
> for (ap in thisModule.reorgAp(aC)->last()) {
> thisModule.outAPIs(ap).out_ports->first().type <- idev.type;
> thisModule.model.communications <-
> thisModule.ACom(thisModule.outAPIs(ap).out_ports->first(),idev);
> }
>
> If somebody knows the difference between the two calls : unique lazy
> rule or resolveTemp, it would be great.

By writing your lazy rule as "unique", you specify that it will be only
executed once (the first time it will be explicitly called) and so will
always return a reference to the same created model element.

> Now I will never use resolveTemp again !!!!!
>
> Thanks Hugo
>
> Regards,
>
> Guillaume
>
> Hugo Bruneliere a écrit :
>>> Hi,
>>
>> Hi Guillaume,
>>
>>>
>>> I use some rules to generate a model based on two input models :
>>> I've got two rule like the rule AOut2AOut which use a lazy rule
>>> during the matching of the target element "aIL".
>>> In the imperative section, I try to use the resolveTemp function to
>>> get the element created by the lazy rule but in all cases, an
>>> exception is fired with the message
>>> "could not find operation getNamedTargetFromSource on Void having
>>> supertypes: [OclAny]"
>>> The variable used, "ap" in the resolveTemp call, is always containing
>>> a correct element.
>>> Is it the use of the lazy rule which is not correct or something else ?
>>> Please, if anybody has an idea about this problem and how to solve it...
>>>
>>> Thank you
>>>
>>>
>>> I put the code of all variables used but maybe it is not important
>>> considering my problem, sorry for the length of the code section.
>>>
>>> ----
>>> rule AOut2AOut {
>>> from
>>> a : mmA!AOut( not
>>> a.rsrc->select(r|r.oclIsKindOf(mmA!DEx))->collect(r|r.LF)- >forAll(e
>>> |e.oclIsUndefined() or e = ''))
>>>
>>> using {
>>> l : Set(String) =
>>> a.rsrc->select(r|r.oclIsKindOf(asur!DEx))->collect(r|r.LF)- >asSet();
>>>
>>> t : OrderedSet(owl!OWLClass) =
>>> owl!OWLClass.allInstances()->select(e|e.localName=a.PS.toString())- >first().subClass
>>>
>>> ->select(e|l->one(i|i=e.localName));
>>>
>>> tA : Sequence(Sequence(owl!Individual)) =
>>> t->collect(i|i.instance->select(elt|elt.isAnAP())->collect(elt|elt.getAllAp()));
>>>
>>>
>>> tD : Sequence(Set(owl!Individual)) =
>>> t->collect(i|i.instance->select(elt|elt.RDFType->one(type|type=thisModule.getDType()))
>>>
>>> ->union(tA->collect(path|path->collect(e|e->last().getDRelated()))- >flatten()->flatten()->asSet()));
>>>
>>>
>>> dC : owl!Individual =
>>> tD->flatten()->select(elt|tD->flatten()->count(elt)=tD->size())- >first();
>>>
>>> aC : Sequence(owl!Individual) =
>>> tA->collect(path|path->any(e|e->last().getDRelated() = dC));
>>>
>>> noAp : Boolean =
>>> aC->flatten()->flatten()->forAll(e|e.oclIsUndefined());
>>>
>>> }
>>> to
>>> aIL : mmB!A_Out (
>>> Name <- a.Name,
>>> d <- outdIL,
>>> ap <- if (not noAp) then
>>> thisModule.reorgAp(aC)->flatten()->collect(e|thisModule.oAPIs(e))
>>> else Set{} endif,
>>> T <- t->iterate(type ; str : String = '' |
>>> str.concat('|'+type.localName))
>>> ),
>>>
>>> idev : mmB!In_port (
>>> Name <- if (dC.oclIsUndefined()) then 'i+D_'+a.Name else
>>> 'i+'+dC.localName endif,
>>> type <- if (dC.oclIsUndefined()) then Set{} else
>>> thisModule.makeDT(dC.getDUsed()) endif
>>> ),
>>>
>>> dev : mmB!A_Device (
>>> Name <- if (dC.oclIsUndefined()) then 'D_'+a.Name else
>>> dC.localName endif,
>>> in_p <- idev
>>> )
>>> do {
>>> for (ap in thisModule.reorgAp(aC)->last()) {
>>> thisModule.resolveTemp(ap,'oap').type <- idev.type;
>>
>> The attributes of a given model element have to be set in the rule
>> which creates it: the "type" attributes should be set in the oAPIs rule.
>>
>>> thisModule.model.communications <-
>>> thisModule.ACom(thisModule.resolveTemp(ap,'oap'),idev);
>>
>> The principle of a lazy rule is that it is matched only if you
>> explicitly call it. In many cases, the use of lazy rules replace calls
>> to the "resolveTemp" method. So you should have written something like
>> this: "thisModule.oAPIs(ap)" instead of
>> "thisModule.resolveTemp(ap,'oap')" (because as oAPIs is a lazy rule
>> which is never called in your Atl program, the rule is never matched).
>>
>> Note that the model element which is returned by a lazy rule is the
>> first mentioned in the "to" section of the rule. So in your case, I
>> think you should first put the "oap : asurIL!Out_port" element in the
>> "to" section of your lazy rule.
>>
>>> }
>>> }
>>>
>>> ----
>>> lazy rule oAPIs {
>>> from
>>> ap : owl!Individual
>>> to
>>> oapis : mmB!A_API (
>>> Name <- ap.localName,
>>> in_ports <- iap,
>>> out_ports <- oap
>>> ),
>>> oap : asurIL!Out_port (
>>> Name <- 'o+'+ap.localName
>>> ),
>>> iap : asurIL!In_port (
>>> Name <- 'i+'+ap.localName,
>>> type <- thisModule.makeDT(ap.getDUsed())
>>> )
>>> }
>>
>> Best regards,
>>
>> Hugo
>>


Best regards,

Hugo

--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
Re: [ATL] GetNameFromSource exception [message #67775 is a reply to message #66833] Thu, 29 November 2007 23:52 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

Hugo is right.

To complete his answer to your question: if you used a standard rule +
resolveTemp the target elements would always be created. With a unique
lazy rule, the target elements will only be created if you actually
refer to the rule.

This may for instance be handy if you refer to the unique lazy rule from
within an if-then-else-endif OCL expression, or from an if-else statement.


Regards,

Frédéric Jouault


Hugo Bruneliere wrote:
> Dear Guillaume,
>
> Guillaume Gauffre a écrit :
>> Thanks hugo for your response.
>>
>> Ok for the definition of the attribute 'type', unfortunately, I think
>> I can determine it only into the 'do' section, but I will see this
>> problem later.
>> About the lazy rule, you told me that I never call it, in fact I call
>> it in the 'to' section (the amount of code surrely hide it :-)
>> <<<<<ap <- if (not noAp) then
>> thisModule.reorgAp(aC)->flatten()->collect(e|thisModule.oAPIs(e)) else
>> Set{} endif,>>>>>>
>> I try to put the 'oap' element at the beginning of the 'to' section of
>> my lazy rule, but nothing change ...
>>
>> But ... yes finally I found a solution :
>> I put the attribute 'unique' to my lazy rule and use in the imperative
>> section the call to it to get the element 'ap' instead of using the
>> 'resolveTemp' call, and it works, I can either define the attribute
>> 'type' !!!!
>>
>> for (ap in thisModule.reorgAp(aC)->last()) {
>> thisModule.outAPIs(ap).out_ports->first().type <- idev.type;
>> thisModule.model.communications <-
>> thisModule.ACom(thisModule.outAPIs(ap).out_ports->first(),idev);
>> }
>>
>> If somebody knows the difference between the two calls : unique lazy
>> rule or resolveTemp, it would be great.
>
> By writing your lazy rule as "unique", you specify that it will be only
> executed once (the first time it will be explicitly called) and so will
> always return a reference to the same created model element.
>
>> Now I will never use resolveTemp again !!!!!
>>
>> Thanks Hugo
>>
>> Regards,
>>
>> Guillaume
>>
>> Hugo Bruneliere a écrit :
>>>> Hi,
>>>
>>> Hi Guillaume,
>>>
>>>>
>>>> I use some rules to generate a model based on two input models :
>>>> I've got two rule like the rule AOut2AOut which use a lazy rule
>>>> during the matching of the target element "aIL".
>>>> In the imperative section, I try to use the resolveTemp function to
>>>> get the element created by the lazy rule but in all cases, an
>>>> exception is fired with the message
>>>> "could not find operation getNamedTargetFromSource on Void having
>>>> supertypes: [OclAny]"
>>>> The variable used, "ap" in the resolveTemp call, is always
>>>> containing a correct element.
>>>> Is it the use of the lazy rule which is not correct or something else ?
>>>> Please, if anybody has an idea about this problem and how to solve
>>>> it...
>>>>
>>>> Thank you
>>>>
>>>>
>>>> I put the code of all variables used but maybe it is not important
>>>> considering my problem, sorry for the length of the code section.
>>>>
>>>> ----
>>>> rule AOut2AOut {
>>>> from
>>>> a : mmA!AOut( not
>>>> a.rsrc->select(r|r.oclIsKindOf(mmA!DEx))->collect(r|r.LF)- >forAll(e
>>>> |e.oclIsUndefined() or e = ''))
>>>>
>>>> using {
>>>> l : Set(String) =
>>>> a.rsrc->select(r|r.oclIsKindOf(asur!DEx))->collect(r|r.LF)- >asSet();
>>>>
>>>> t : OrderedSet(owl!OWLClass) =
>>>> owl!OWLClass.allInstances()->select(e|e.localName=a.PS.toString())- >first().subClass
>>>>
>>>> ->select(e|l->one(i|i=e.localName));
>>>>
>>>> tA : Sequence(Sequence(owl!Individual)) =
>>>> t->collect(i|i.instance->select(elt|elt.isAnAP())->collect(elt|elt.getAllAp()));
>>>>
>>>>
>>>> tD : Sequence(Set(owl!Individual)) =
>>>> t->collect(i|i.instance->select(elt|elt.RDFType->one(type|type=thisModule.getDType()))
>>>>
>>>> ->union(tA->collect(path|path->collect(e|e->last().getDRelated()))- >flatten()->flatten()->asSet()));
>>>>
>>>>
>>>> dC : owl!Individual =
>>>> tD->flatten()->select(elt|tD->flatten()->count(elt)=tD->size())- >first();
>>>>
>>>> aC : Sequence(owl!Individual) =
>>>> tA->collect(path|path->any(e|e->last().getDRelated() = dC));
>>>>
>>>> noAp : Boolean =
>>>> aC->flatten()->flatten()->forAll(e|e.oclIsUndefined());
>>>>
>>>> }
>>>> to
>>>> aIL : mmB!A_Out (
>>>> Name <- a.Name,
>>>> d <- outdIL,
>>>> ap <- if (not noAp) then
>>>> thisModule.reorgAp(aC)->flatten()->collect(e|thisModule.oAPIs(e))
>>>> else Set{} endif,
>>>> T <- t->iterate(type ; str : String = '' |
>>>> str.concat('|'+type.localName))
>>>> ),
>>>>
>>>> idev : mmB!In_port (
>>>> Name <- if (dC.oclIsUndefined()) then 'i+D_'+a.Name else
>>>> 'i+'+dC.localName endif,
>>>> type <- if (dC.oclIsUndefined()) then Set{} else
>>>> thisModule.makeDT(dC.getDUsed()) endif
>>>> ),
>>>>
>>>> dev : mmB!A_Device (
>>>> Name <- if (dC.oclIsUndefined()) then 'D_'+a.Name else
>>>> dC.localName endif,
>>>> in_p <- idev
>>>> )
>>>> do {
>>>> for (ap in thisModule.reorgAp(aC)->last()) {
>>>> thisModule.resolveTemp(ap,'oap').type <- idev.type;
>>>
>>> The attributes of a given model element have to be set in the rule
>>> which creates it: the "type" attributes should be set in the oAPIs rule.
>>>
>>>> thisModule.model.communications <-
>>>> thisModule.ACom(thisModule.resolveTemp(ap,'oap'),idev);
>>>
>>> The principle of a lazy rule is that it is matched only if you
>>> explicitly call it. In many cases, the use of lazy rules replace
>>> calls to the "resolveTemp" method. So you should have written
>>> something like this: "thisModule.oAPIs(ap)" instead of
>>> "thisModule.resolveTemp(ap,'oap')" (because as oAPIs is a lazy rule
>>> which is never called in your Atl program, the rule is never matched).
>>>
>>> Note that the model element which is returned by a lazy rule is the
>>> first mentioned in the "to" section of the rule. So in your case, I
>>> think you should first put the "oap : asurIL!Out_port" element in the
>>> "to" section of your lazy rule.
>>>
>>>> }
>>>> }
>>>>
>>>> ----
>>>> lazy rule oAPIs {
>>>> from
>>>> ap : owl!Individual
>>>> to
>>>> oapis : mmB!A_API (
>>>> Name <- ap.localName,
>>>> in_ports <- iap,
>>>> out_ports <- oap
>>>> ),
>>>> oap : asurIL!Out_port (
>>>> Name <- 'o+'+ap.localName
>>>> ),
>>>> iap : asurIL!In_port (
>>>> Name <- 'i+'+ap.localName,
>>>> type <- thisModule.makeDT(ap.getDUsed())
>>>> )
>>>> }
>>>
>>> Best regards,
>>>
>>> Hugo
>>>
>
>
> Best regards,
>
> Hugo
>
Previous Topic:[ATL] Problem with UML-Reference
Next Topic:classes hidden in trasformation
Goto Forum:
  


Current Time: Sat May 08 20:22:12 GMT 2021

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

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

Back to the top