[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmf] Re: GMF mapping Audit Rules

Hi, Achilleas,

You can, in the context of any classifier, use allInstances() to access all instances of any other classifier. So, for example:

  context Class1
  inv:
    Class2.allInstances()->forAll(c2 | self.value1 <> c2.value2)

However, this may be over-constrained. I see from your sketch of your model that Class1 and Class2 are aggregated in a root. So, you might rather do:

  context Root
  inv:
    classes1->product(classes2)->forAll(pair |
        pair.first.value1 <> pair.second.value2)

which would scope the constraint to the context of each individual Root element.

HTH,

Christian


Achilleas wrote:
Hi,

I will like to ask if it is possible to compare two attributes using one audit rule;one constraint.

For instance if i have the following metamodel

     Root (aggregates classes1,classes2)
Class1(includes EAttribute value1) Class2(includes EAttribute value2)

Usually when a constraint is written it will be of the form:

Domain Element Target: |Class1::EClass
Class1.allInstances()->forAll( c1, c2 | c1 <> c2 implies c1.value1 <> c2.value1 )



What if I want to compare the values of instances of the Class1 with instances of the Class2? Is there a way to define two Domain Element Targets? Could it be done directly from the Root class specifying this as the Domain Element Target?


Thanks,

Achilleas