|
Re: OCLs for abstract classes and children [message #652745 is a reply to message #652744] |
Sun, 06 February 2011 07:00 |
|
Perhaps it's related to https://bugs.eclipse.org/bugs/show_bug.cgi?id=329389 ?
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Am 06.02.2011 06:22, schrieb Oscar Andres Fajardo F.:
> 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...
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03070 seconds