Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » problem with Map data type
problem with Map data type [message #52748] Tue, 17 July 2007 18:24 Go to next message
Eclipse UserFriend
Originally posted by: adilanwar10.yahoo.fr

Hi all,

i need to check if two class have the same list of attributes, i
write this code but it didn't work .

the map is still empty !!



helper context UML!Class def : match(p : UML!Class) : Boolean =

self.isAbstract = p.isAbstract and

self.ownedAttribute->size()= p.ownedAttribute->size() and

self.ownedAttribute->iterate(i ; attr : UML!Property = self.ownedAttribute |

if not thisModule.AttrMap.getKeys().isEmpty()

then

thisModule.AttrMap.containsKey(i.name)and
thisModule.AttrMap.get(i).name = i.type.name

else false

endif) ;

helper def : AttrMap : Map(String, UML!DataType) = Map{};

rule setAttrMap(c : UML!Class) {

do{

for (a in c.ownedAttribute){

thisModule.AttrMap <-
thisModule.AttrMap->including(a.name,a.type);

}

}

}

Best regards,
Adil
Re: problem with Map data type [message #53003 is a reply to message #52748] Wed, 18 July 2007 13:37 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

I do not see where you call setAttrMap.


Regards,

Frédéric Jouault


Adil Anwar wrote:
> Hi all,
>
> i need to check if two class have the same list of attributes, i
> write this code but it didn't work .
>
> the map is still empty !!
>
>
>
> helper context UML!Class def : match(p : UML!Class) : Boolean =
>
> self.isAbstract = p.isAbstract and
>
> self.ownedAttribute->size()= p.ownedAttribute->size() and
>
> self.ownedAttribute->iterate(i ; attr : UML!Property = self.ownedAttribute |
>
> if not thisModule.AttrMap.getKeys().isEmpty()
>
> then
>
> thisModule.AttrMap.containsKey(i.name)and
> thisModule.AttrMap.get(i).name = i.type.name
>
> else false
>
> endif) ;
>
> helper def : AttrMap : Map(String, UML!DataType) = Map{};
>
> rule setAttrMap(c : UML!Class) {
>
> do{
>
> for (a in c.ownedAttribute){
>
> thisModule.AttrMap <-
> thisModule.AttrMap->including(a.name,a.type);
>
> }
>
> }
>
> }
>
> Best regards,
> Adil
>
>
Re: [ATL] problem with Map data type [message #53028 is a reply to message #53003] Wed, 18 July 2007 13:39 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello again,

Please, remember to prefix the subject of your ATL-related posts with
[ATL], as I did in this message.

See the M2M wiki page for more information on this scheme:
http://wiki.eclipse.org/M2M


Regards,

Frédéric Jouault


Frédéric Jouault wrote:
> Hello,
>
> I do not see where you call setAttrMap.
>
>
> Regards,
>
> Frédéric Jouault
>
>
> Adil Anwar wrote:
>> Hi all,
>>
>> i need to check if two class have the same list of
>> attributes, i write this code but it didn't work .
>>
>> the map is still empty !!
>>
>>
>>
>> helper context UML!Class def : match(p : UML!Class) : Boolean =
>>
>> self.isAbstract = p.isAbstract and
>>
>> self.ownedAttribute->size()= p.ownedAttribute->size() and
>>
>> self.ownedAttribute->iterate(i ; attr : UML!Property =
>> self.ownedAttribute |
>>
>> if not thisModule.AttrMap.getKeys().isEmpty()
>>
>> then
>>
>> thisModule.AttrMap.containsKey(i.name)and
>> thisModule.AttrMap.get(i).name = i.type.name
>>
>> else false
>>
>> endif) ;
>>
>> helper def : AttrMap : Map(String, UML!DataType) = Map{};
>>
>> rule setAttrMap(c : UML!Class) {
>>
>> do{
>>
>> for (a in c.ownedAttribute){
>>
>> thisModule.AttrMap <-
>> thisModule.AttrMap->including(a.name,a.type);
>>
>> }
>>
>> }
>>
>> }
>>
>> Best regards,
>> Adil
>>
>>
Re: [ATL]problem with Map data type [message #53130 is a reply to message #53003] Wed, 18 July 2007 14:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adilanwar10.yahoo.fr

hello,
thanks for your respone, well i call setAttrMap in this rule
rule ClassConformityRule extends ModelElementMatchingRule{

from e1 : UML!Class, e2 : UML!Class

(thisModule.setAttrMap(e2)and e1.match(e2))

to r : MMC!ConformityRelationship


}

i want to fill the Map before checking the guard condition with the helper
match, is that possible in ATL ??

Regards,

Adil

"Fr
Re: [ATL]problem with Map data type [message #53233 is a reply to message #53130] Wed, 18 July 2007 16:44 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

You call an imperative rule from declarative code. This cannot work.
Don't you get an execution error?

Anyway, as usual, I would advise to use only declarative construct, like:

helper context UML!Class def: AttrMap : Map(String, UML!DataType) =
e.ownedAttribute->iterate(e; acc : Map(String, UML!Class) = Map{} |
acc->including(e.name, e.type)
);


Regards,

Frédéric Jouault


Adil Anwar wrote:
> hello,
> thanks for your respone, well i call setAttrMap in this rule
> rule ClassConformityRule extends ModelElementMatchingRule{
>
> from e1 : UML!Class, e2 : UML!Class
>
> (thisModule.setAttrMap(e2)and e1.match(e2))
>
> to r : MMC!ConformityRelationship
>
>
> }
>
> i want to fill the Map before checking the guard condition with the helper
> match, is that possible in ATL ??
>
> Regards,
>
> Adil
>
> "Frédéric Jouault" <frederic.jouault@univ-nantes.fr> a écrit dans le message
> de news: f7l53c$ik$1@build.eclipse.org...
>> Hello,
>>
>> I do not see where you call setAttrMap.
>>
>>
>> Regards,
>>
>> Frédéric Jouault
>>
>>
>> Adil Anwar wrote:
>>> Hi all,
>>>
>>> i need to check if two class have the same list of
>>> attributes, i write this code but it didn't work .
>>>
>>> the map is still empty !!
>>>
>>>
>>>
>>> helper context UML!Class def : match(p : UML!Class) : Boolean =
>>>
>>> self.isAbstract = p.isAbstract and
>>>
>>> self.ownedAttribute->size()= p.ownedAttribute->size() and
>>>
>>> self.ownedAttribute->iterate(i ; attr : UML!Property =
>>> self.ownedAttribute |
>>>
>>> if not thisModule.AttrMap.getKeys().isEmpty()
>>>
>>> then
>>>
>>> thisModule.AttrMap.containsKey(i.name)and
>>> thisModule.AttrMap.get(i).name = i.type.name
>>>
>>> else false
>>>
>>> endif) ;
>>>
>>> helper def : AttrMap : Map(String, UML!DataType) = Map{};
>>>
>>> rule setAttrMap(c : UML!Class) {
>>>
>>> do{
>>>
>>> for (a in c.ownedAttribute){
>>>
>>> thisModule.AttrMap <-
>>> thisModule.AttrMap->including(a.name,a.type);
>>>
>>> }
>>>
>>> }
>>>
>>> }
>>>
>>> Best regards,
>>> Adil
>>>
>
Re: [ATL]problem with Map data type [message #53569 is a reply to message #53233] Thu, 19 July 2007 15:38 Go to previous message
Eclipse UserFriend
Originally posted by: adilanwar10.yahoo.fr

Hi,

thanks for your help,

I'm not get an execution error when i used the imperative role. I think that
ATL engine evaluate the result of the setAttrMap in True,

but now i use the declarative construct as you suggest,

the problem was in the instruction : thisModule.AttrMap.get(i).name , the
value in key i was OclUndefined.
Regards
Adil

"Fr
Previous Topic:Re: [ATL] Charging models dynamically in an ATL transformation
Next Topic:[atl]: list of publications about ATL
Goto Forum:
  


Current Time: Thu Apr 25 00:09:00 GMT 2024

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

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

Back to the top