OCLs for abstract classes and children [message #652744] |
Sun, 06 February 2011 00:20  |
Eclipse User |
|
|
|
Hi, I have a metamodel which has a Metaclass named "Model" this class is going to be the root of everything. Then I have another metaclass called "NamedElement" this class is going to compose the "Model". "NamedElement"that its an Abstract Class and is father of all the rest of metaclasses In the model.
import ecore_0 : 'http://www.eclipse.org/emf/2002/Ecore#/';
package MAS : MAS = 'http://MAS/1.0'
{
class MASModel
{
property Elements#MAS : MASNamedElement[*] { composes };
}
class MASNamedElement { abstract }
{
attribute name : String[?];
property MAS#Elements : MASModel[1];
-- invariant UniqueName:
-- Achieves.allInstances()or Agent.allInstances() or Capabilities.allInstances()or
-- Goal.allInstances() or Possesses.allInstances() or Requires.allInstances() or Role.allInstances()->isUnique(name) ;
}
class MASElement extends MASNamedElement { abstract };
class MASRelation extends MASNamedElement { abstract }
{
property source : MASElement[?];
property target : MASElement[?];
}
class Requires extends MASRelation
{
invariant RequiresDestinationType:
self.target->forAll(a|a.oclIsKindOf(Capabilities));
invariant RequiresSourceType:
self.source->forAll(a|a.oclIsKindOf(Role));
}
class ScoredRelation extends MASRelation { abstract }
{
attribute score : ecore_0::EFloat[?] = '0' { transient };
}
class Achieves extends ScoredRelation
{
invariant AchievesDestinationType:
self.target->forAll(a|a.oclIsKindOf(Goal));
invariant AchievesSourceType:
self.source->forAll(a|a.oclIsKindOf(Role));
}
class Possesses extends ScoredRelation
{
invariant PossessesDestinationType:
self.target->forAll(a|a.oclIsKindOf(Capabilities));
invariant PossessesSourceType:
self.source->forAll(a|a.oclIsKindOf(Agent));
}
class Role extends MASElement;
class Goal extends MASElement;
class Agent extends MASElement;
class Capabilities extends MASElement;
}
What I want is to write an OCL that checks for repeated names... normally it wold be like:
self.AllInstances->IsUnique(name); also I tried another thing where the OCL comments are...but doesn't work.
But I want to check for all the children of NamedElement(from Elements and Relations untill the end of file), and also there are no instances of NamedElement, so I'm having trouble defining this constraint for the ecore file and for the Audits in GMF.
Thanks in advance...
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02759 seconds