Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] How to know type of a model element in condition of matched rule(I need know a eCore type of an attribute of a model element)
[ATL] How to know type of a model element in condition of matched rule [message #805115] Thu, 23 February 2012 10:52 Go to next message
_md2_ on Forum is currently offline _md2_ on ForumFriend
Messages: 9
Registered: February 2012
Location: L'Aquila
Junior Member
Hi all,
As the title suggests i need to know a type of a model element's field in a matched rule condition. I have 2 metatodel:
1 INPUT diff.ecore: is the metamodel of the models product with EMFCompare.
2 OUTPUT EcoreDiff: is a custom metamodel for rappresenting ModelDifference (deployed in Univeristy of L'Aquila)
At code.google.com/p/ecoredifftoemfcompare/ there is the shared code
I'm just beginning but I have some problems.
I'm try to know a dinamic type of a element.
As you can see the rule DiffGroup2ChangedPackage and DiffGroup2ChangedPackage in from field have commented on the condition. This condition is used to choose which of the two matched rule take based on the type of rightparent. They are commented out because they are never verified. The function sor.rightParent.eClass (). Name = '...' I used heavily in the earlier version and it returned the correct values​​, but as a helper instead that in the condition of a matched rule.

Sorry for my English
Regards

module Diff2EcoreDiff2; -- Module Template
create Out : EcoreDiff from In : diff;
--##regola che inizializza la trasformazione
rule Diff2Diff {
      from 
            s : diff!DiffModel
      to
            t : EcoreDiff!DifferenceModel
            (
                  differenceElements <- s.ownedElements.first().subDiffElements->collect(e | thisModule.resolveTemp(e,'element'))
            )     
}
--metodo per le aggiungere una changedPackage
rule DiffGroup2ChangedPackage {
      from 
            sor : diff!DiffGroup--(sor.rightParent.eClass().name='EPackage')
      to
            element : EcoreDiff!ChangedEPackage(
                  updatedElement <- sor.rightParent,
                  name <- sor.rightParent.name,
                  eStructuralFeatures <- sor.subDiffElements->collect(e | thisModule.resolveTemp(e,'element'))
            )     
}
--##metodo per le aggiungere una changedClass
rule DiffGroup2ChangedClass {
      from 
            s : diff!DiffGroup--(s.rightParent.eClass().name='EClass')
      to
            element : EcoreDiff!ChangedEClass(
                  updatedElement <- s.rightParent,
                  name <- s.rightParent.name,
                  eStructuralFeatures <- s.subDiffElements->collect(e | thisModule.resolveTemp(e,'element'))
            )     
}

Re: [ATL] How to know type of a model element in condition of matched rule [message #805381 is a reply to message #805115] Thu, 23 February 2012 17:43 Go to previous message
_md2_ on Forum is currently offline _md2_ on ForumFriend
Messages: 9
Registered: February 2012
Location: L'Aquila
Junior Member
I solved using as a condition oclIsTypeOf(Diff! myType) instead of eClass().name='MyType'.
If you have any suggestions they are welcome.
Thank you.
Previous Topic:[qvto]how to transform undefined attributes
Next Topic:[ATL] Ant Task classpath problem
Goto Forum:
  


Current Time: Fri Apr 26 20:11:16 GMT 2024

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

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

Back to the top