Home » Archived » M2M (model-to-model transformation) » problem with Map data type
problem with Map data type [message #52748] |
Tue, 17 July 2007 14:24  |
Eclipse User |
|
|
|
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: [ATL] problem with Map data type [message #53028 is a reply to message #53003] |
Wed, 18 July 2007 09:39   |
Eclipse User |
|
|
|
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 #53233 is a reply to message #53130] |
Wed, 18 July 2007 12:44   |
Eclipse User |
|
|
|
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 11:38  |
Eclipse User |
|
|
|
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
|
|
|
Goto Forum:
Current Time: Mon May 12 16:17:49 EDT 2025
Powered by FUDForum. Page generated in 0.03634 seconds
|