Home » Modeling » OCL » OCLInEcore recursive operations
OCLInEcore recursive operations [message #786086] |
Sun, 29 January 2012 19:55  |
Eclipse User |
|
|
|
Hello
I'm trying to make an recursive operation with OCLInEcore, but it's thrown an error that the operation was not found. Is there any solution to this problem? Does OCLInEcore does not support recursive functions? I'm doing something like this:
operation rec(n: Type1): Type2
{
body: if self = n then 0
else n.childs->iterate(e: Type3; acc:Integer=0 | if e.rev() > acc then e.DIT() else acc endif) endif;
}
|
|
| | |
Re: OCLInEcore recursive operations [message #786566 is a reply to message #786296] |
Mon, 30 January 2012 10:34   |
Eclipse User |
|
|
|
I'm using Eclipse Modeling Tools Version: Indigo Service Release 1 Build id: 20110916-0149.
That was a simple example I came with at the moment. My problem is in a larger scale. Anyway where it is, maybe you can see any error that I'm not seeing right.
package KAOSStandard : kaos = 'kaos'
{
class KAOS
{
property hasCompartmentNode : CompartmentNode[*] { ordered composes };
property hasNodes : Nodes[*] { ordered composes };
property hasLinks : Links[*] { ordered composes };
property root : Goal[1] { ordered };
operation modelDepth() : ecore::EIntegerObject[1]
{
body:
self.goalsDistanceToRoot(self.root, Set{0}, 0)->iterate(i : Integer ; m : Integer = - 1 | if m = - 1 then i else m.max(i) endif);
}
operation goalsDistanceToRoot(n : Nodes[1], dist : ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
ecore::EIntegerObject[*]
{
body:
if n.oclIsKindOf(Goal) then
self.depthOfGoal(n.oclAsType(Goal), dist, last)
else
if n.oclIsKindOf(Obstacle) then
self.depthOfObstacle(n.oclAsType(Obstacle), dist, last)
else
dist
endif
endif;
}
operation depthOfGoal(g : Goal[1], dist : ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
ecore::EIntegerObject[*]
{
body:
if g.isLeafGoal() then
self.depthOfLeafGoal(g, dist, last)
else
self.union(g.goalIsAndRef->collect(andRefToOtherGoal)->union(g.goalIsOrRef->collect(orRefToOtherGoal))->asSet(), g.goalHasObstacle->collect(obstacle)->asSet())->collect(n : Nodes | self.goalsDistanceToRoot(n, dist->including(last + 1), last + 1))->asSet()
endif;
}
operation union(s1 : Goal[*], s2 : Nodes[*]) : Nodes[*]
{
body: let s : Set(Nodes) = Set{} in s->union(s1)->union(s2);
}
operation depthOfLeafGoal(g : Goal[1], dist : ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
ecore::EIntegerObject[*]
{
body:
let s : Sequence(Obstacle) = g.goalHasObstacle->collect(obstacle) in
if s->notEmpty() then
s->collect(o : Obstacle | self.goalsDistanceToRoot(o.oclAsType(Nodes), dist->including(last + 1), last + 1))->asSet()
else
dist
endif;
}
operation depthOfObstacle(o : Obstacle[1], dist : ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
ecore::EIntegerObject[*]
{
body:
if self.isLeafObstacle(o) then
self.depthOfLeafObstacle(o, dist, last)
else
self.obstacleRefinement(o)->collect(o : Obstacle | self.goalsDistanceToRoot(o.oclAsType(Nodes), dist->including(last + 1), last + 1))->asSet()
endif;
}
operation obstacleRefinement(o : Obstacle[1]) : Obstacle[*]
{
body:
self.hasLinks->select(l : Links | l.oclIsKindOf(ObstacleRefinement) and l.oclAsType(ObstacleRefinement).obstToObstRef = o)->collect(oclAsType(ObstacleRefinement))->collect(obstRefToObst);
}
operation depthOfLeafObstacle(o : Obstacle[1], dist : ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
ecore::EIntegerObject[*]
{
body:
let s : Sequence(Goal) = o.solution->collect(obstacleHasSolution) in
if s->notEmpty() then
s->collect(g : Goal | self.goalsDistanceToRoot(g.oclAsType(Nodes), dist->including(last + 1), last + 1))->asSet()
else
dist
endif;
}
operation isLeafObstacle(o : Obstacle[1]) : Boolean[1]
{
body:
not self.hasLinks->exists(l : Links | (l.oclIsKindOf(ObstacleRefinement) and l.oclAsType(ObstacleRefinement).obstToObstRef = o));
}
annotation _'gmf.diagram'
(
foo = 'bar'
);
}
....
abstract class Nodes
{
attribute name : String[?] { ordered };
attribute TransformationSource : String[?] { ordered };
attribute IstarActorContainer : String[?] { ordered };
annotation _'gmf.node'
(
label = 'name',
_'label.placement' = 'external'
);
}
class Goal extends Nodes
{
attribute formalDef : String[?] { ordered };
attribute informalDef : String[?] { ordered };
property goalIsOrRef#orRefToGoal : OrRefinement[*] { ordered };
property otherGoalIsOrRef#orRefToOtherGoal : OrRefinement[*] { ordered };
property goalIsAndRef#andRefToGoal : AndRefinement[*] { ordered };
property otherGoalIsAndRef#andRefToOtherGoal : AndRefinement[*] { ordered };
property goalHasObstacle#obstacleToGoal : ObstructionLink[*] { ordered };
property solutionIsGoal#obstacleHasSolution : SolutionLink[*] { ordered };
property goalToOperatLink#operatLinkToGoal : OperationalizationLink[*] { ordered };
property goalConcerns#concernedByGoal : ConcernsLink[*] { ordered };
property goalHasDomProp#DomPropLinkToGoal : DomainPropLink[*] { ordered };
operation isLeafGoal() : Boolean[1]
{
body: self.goalIsAndRef->isEmpty() and self.goalIsOrRef->isEmpty();
}
annotation _'gmf.node'
(
color = '0,191,255',
_'border.color' = '0,191,255',
size = '80,50',
figure = 'polygon',
_'polygon.x' = '30 70 50 10',
_'polygon.y' = '10 10 40 40',
_'tool.description' = 'Create new Goal'
);
}
...
class Obstacle extends Nodes
{
property obstacleObstruction#obstacle : ObstructionLink[*] { ordered };
property solution#obstacleSolution : SolutionLink[*] { ordered };
annotation _'gmf.node'
(
color = '255,140,0',
_'border.color' = '255,140,0',
size = '80,50',
figure = 'polygon',
_'polygon.x' = '10 50 70 30',
_'polygon.y' = '10 10 40 40',
_'tool.description' = 'Create new Obstacle'
);
}
...
abstract class Links
{
attribute TransformationSource : String[?] { ordered };
attribute name : String[?] { ordered };
attribute Source : String[?] { ordered };
attribute Target : String[?] { ordered };
}
class OrRefinement extends Links
{
invariant linkToHimself('Goal ' + orRefToGoal.name + ' can not be a refinement of himself.'):
orRefToGoal <> orRefToOtherGoal;
property orRefToGoal#goalIsOrRef : Goal[1] { ordered };
property orRefToOtherGoal#otherGoalIsOrRef : Goal[1] { ordered };
annotation _'gmf.link'
(
source = 'orRefToGoal',
target = 'orRefToOtherGoal',
color = '0,0,255',
_'target.decoration' = 'arrow',
width = '2',
style = 'dash',
_'tool.description' = 'Create new OrRefinement between Goal, Requirement or Expectation'
);
}
class AndRefinement extends Links
{
invariant linkToHimself('Goal ' + andRefToGoal.name + ' can not be a refinement of himself.'):
andRefToGoal <> andRefToOtherGoal;
property andRefToGoal#goalIsAndRef : Goal[1] { ordered };
property andRefToOtherGoal#otherGoalIsAndRef : Goal[1] { ordered };
annotation _'gmf.link'
(
source = 'andRefToGoal',
target = 'andRefToOtherGoal',
color = '0,0,255',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new AndRefinement between Goal, Requirement or Expectation'
);
}
class ObstacleRefinement extends Links
{
invariant linkToHimself('Obstacle ' + obstRefToObst.name + ' can not be a refinement of himself.'):
obstRefToObst <> obstToObstRef;
property obstRefToObst : Obstacle[1] { ordered };
property obstToObstRef : Obstacle[1] { ordered };
annotation _'gmf.link'
(
source = 'obstRefToObst',
target = 'obstToObstRef',
color = '255,140,0',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new ObstacleRefinement between Obstacles'
);
}
class ObstructionLink extends Links
{
property obstacle#obstacleObstruction : Obstacle[1] { ordered };
property obstacleToGoal#goalHasObstacle : Goal[1] { ordered };
annotation _'gmf.link'
(
source = 'obstacle',
target = 'obstacleToGoal',
color = '255,165,0',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new ObstructionLink between an Obstacle and a Goal, Requirement or Expectation'
);
}
class SolutionLink extends Links
{
property obstacleHasSolution#solutionIsGoal : Goal[1] { ordered };
property obstacleSolution#solution : Obstacle[1] { ordered };
annotation _'gmf.link'
(
source = 'obstacleHasSolution',
target = 'obstacleSolution',
color = '0,139,0',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new SolutionLink between an Obstacle and a Goal, Requirement or Expectation'
);
}
...
|
|
|
Re: OCLInEcore recursive operations [message #786632 is a reply to message #786566] |
Mon, 30 January 2012 12:00   |
Eclipse User |
|
|
|
Hi
Your example has many "..." ellisions and no CompartmentNode, so I
cannot comment on what real problems exist.
Regards
Ed Willink
On 30/01/2012 15:34, Patricia Espada wrote:
> I'm using Eclipse Modeling Tools Version: Indigo Service Release 1
> Build id: 20110916-0149.
>
> That was a simple example I came with at the moment. My problem is in
> a larger scale. Anyway where it is, maybe you can see any error that
> I'm not seeing right.
>
>
> package KAOSStandard : kaos = 'kaos'
> {
> class KAOS
> {
> property hasCompartmentNode : CompartmentNode[*] { ordered
> composes };
> property hasNodes : Nodes[*] { ordered composes };
> property hasLinks : Links[*] { ordered composes };
> property root : Goal[1] { ordered };
> operation modelDepth() : ecore::EIntegerObject[1]
> {
> body:
> self.goalsDistanceToRoot(self.root, Set{0},
> 0)->iterate(i : Integer ; m : Integer = - 1 | if m = - 1 then i else
> m.max(i) endif);
> }
> operation goalsDistanceToRoot(n : Nodes[1], dist :
> ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
> ecore::EIntegerObject[*]
> {
> body:
> if n.oclIsKindOf(Goal) then
> self.depthOfGoal(n.oclAsType(Goal), dist, last) else
> if n.oclIsKindOf(Obstacle) then
> self.depthOfObstacle(n.oclAsType(Obstacle),
> dist, last) else dist
> endif endif;
> }
> operation depthOfGoal(g : Goal[1], dist :
> ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
> ecore::EIntegerObject[*]
> {
> body:
> if g.isLeafGoal() then
> self.depthOfLeafGoal(g, dist, last) else
>
> self.union(g.goalIsAndRef->collect(andRefToOtherGoal)->union(g.goalIsOrRef->collect(orRefToOtherGoal))->asSet(),
> g.goalHasObstacle->collect(obstacle)->asSet())->collect(n : Nodes |
> self.goalsDistanceToRoot(n, dist->including(last + 1), last +
> 1))->asSet() endif;
> }
> operation union(s1 : Goal[*], s2 : Nodes[*]) : Nodes[*]
> {
> body: let s : Set(Nodes) = Set{} in s->union(s1)->union(s2);
> }
> operation depthOfLeafGoal(g : Goal[1], dist :
> ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
> ecore::EIntegerObject[*]
> {
> body:
> let s : Sequence(Obstacle) =
> g.goalHasObstacle->collect(obstacle) in if
> s->notEmpty() then s->collect(o : Obstacle |
> self.goalsDistanceToRoot(o.oclAsType(Nodes), dist->including(last +
> 1), last + 1))->asSet() else
> dist endif;
> }
> operation depthOfObstacle(o : Obstacle[1], dist :
> ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
> ecore::EIntegerObject[*]
> {
> body:
> if self.isLeafObstacle(o) then
> self.depthOfLeafObstacle(o, dist, last) else
> self.obstacleRefinement(o)->collect(o : Obstacle |
> self.goalsDistanceToRoot(o.oclAsType(Nodes), dist->including(last +
> 1), last + 1))->asSet() endif;
> }
> operation obstacleRefinement(o : Obstacle[1]) : Obstacle[*]
> {
> body:
> self.hasLinks->select(l : Links |
> l.oclIsKindOf(ObstacleRefinement) and
> l.oclAsType(ObstacleRefinement).obstToObstRef =
> o)->collect(oclAsType(ObstacleRefinement))->collect(obstRefToObst);
> }
> operation depthOfLeafObstacle(o : Obstacle[1], dist :
> ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
> ecore::EIntegerObject[*]
> {
> body:
> let s : Sequence(Goal) =
> o.solution->collect(obstacleHasSolution) in if
> s->notEmpty() then s->collect(g : Goal |
> self.goalsDistanceToRoot(g.oclAsType(Nodes), dist->including(last +
> 1), last + 1))->asSet() else
> dist endif;
> }
> operation isLeafObstacle(o : Obstacle[1]) : Boolean[1]
> {
> body:
> not self.hasLinks->exists(l : Links |
> (l.oclIsKindOf(ObstacleRefinement) and
> l.oclAsType(ObstacleRefinement).obstToObstRef = o));
> }
> annotation _'gmf.diagram'
> (
> foo = 'bar'
> );
> }
> ...
> abstract class Nodes
> {
> attribute name : String[?] { ordered };
> attribute TransformationSource : String[?] { ordered };
> attribute IstarActorContainer : String[?] { ordered };
> annotation _'gmf.node'
> (
> label = 'name',
> _'label.placement' = 'external'
> );
> }
> class Goal extends Nodes
> {
> attribute formalDef : String[?] { ordered };
> attribute informalDef : String[?] { ordered };
> property goalIsOrRef#orRefToGoal : OrRefinement[*] { ordered };
> property otherGoalIsOrRef#orRefToOtherGoal : OrRefinement[*] {
> ordered };
> property goalIsAndRef#andRefToGoal : AndRefinement[*] {
> ordered };
> property otherGoalIsAndRef#andRefToOtherGoal :
> AndRefinement[*] { ordered };
> property goalHasObstacle#obstacleToGoal : ObstructionLink[*] {
> ordered };
> property solutionIsGoal#obstacleHasSolution : SolutionLink[*]
> { ordered };
> property goalToOperatLink#operatLinkToGoal :
> OperationalizationLink[*] { ordered };
> property goalConcerns#concernedByGoal : ConcernsLink[*] {
> ordered };
> property goalHasDomProp#DomPropLinkToGoal : DomainPropLink[*]
> { ordered };
> operation isLeafGoal() : Boolean[1]
> {
> body: self.goalIsAndRef->isEmpty() and
> self.goalIsOrRef->isEmpty();
> }
> annotation _'gmf.node'
> (
> color = '0,191,255',
> _'border.color' = '0,191,255',
> size = '80,50',
> figure = 'polygon',
> _'polygon.x' = '30 70 50 10',
> _'polygon.y' = '10 10 40 40',
> _'tool.description' = 'Create new Goal'
> );
> }
> ..
> class Obstacle extends Nodes
> {
> property obstacleObstruction#obstacle : ObstructionLink[*] {
> ordered };
> property solution#obstacleSolution : SolutionLink[*] { ordered };
> annotation _'gmf.node'
> (
> color = '255,140,0',
> _'border.color' = '255,140,0',
> size = '80,50',
> figure = 'polygon',
> _'polygon.x' = '10 50 70 30',
> _'polygon.y' = '10 10 40 40',
> _'tool.description' = 'Create new Obstacle'
> );
> }
> ..
> abstract class Links
> {
> attribute TransformationSource : String[?] { ordered };
> attribute name : String[?] { ordered };
> attribute Source : String[?] { ordered };
> attribute Target : String[?] { ordered };
> }
> class OrRefinement extends Links
> {
> invariant linkToHimself('Goal ' + orRefToGoal.name + ' can not
> be a refinement of himself.'):
> orRefToGoal <> orRefToOtherGoal;
> property orRefToGoal#goalIsOrRef : Goal[1] { ordered };
> property orRefToOtherGoal#otherGoalIsOrRef : Goal[1] { ordered };
> annotation _'gmf.link'
> (
> source = 'orRefToGoal',
> target = 'orRefToOtherGoal',
> color = '0,0,255',
> _'target.decoration' = 'arrow',
> width = '2',
> style = 'dash',
> _'tool.description' = 'Create new OrRefinement between
> Goal, Requirement or Expectation'
> );
> }
> class AndRefinement extends Links
> {
> invariant linkToHimself('Goal ' + andRefToGoal.name + ' can
> not be a refinement of himself.'):
> andRefToGoal <> andRefToOtherGoal;
> property andRefToGoal#goalIsAndRef : Goal[1] { ordered };
> property andRefToOtherGoal#otherGoalIsAndRef : Goal[1] {
> ordered };
> annotation _'gmf.link'
> (
> source = 'andRefToGoal',
> target = 'andRefToOtherGoal',
> color = '0,0,255',
> _'target.decoration' = 'arrow',
> width = '2',
> _'tool.description' = 'Create new AndRefinement between
> Goal, Requirement or Expectation'
> );
> }
> class ObstacleRefinement extends Links
> {
> invariant linkToHimself('Obstacle ' + obstRefToObst.name + '
> can not be a refinement of himself.'):
> obstRefToObst <> obstToObstRef;
> property obstRefToObst : Obstacle[1] { ordered };
> property obstToObstRef : Obstacle[1] { ordered };
> annotation _'gmf.link'
> (
> source = 'obstRefToObst',
> target = 'obstToObstRef',
> color = '255,140,0',
> _'target.decoration' = 'arrow',
> width = '2',
> _'tool.description' = 'Create new ObstacleRefinement
> between Obstacles'
> );
> }
> class ObstructionLink extends Links
> {
> property obstacle#obstacleObstruction : Obstacle[1] { ordered };
> property obstacleToGoal#goalHasObstacle : Goal[1] { ordered };
> annotation _'gmf.link'
> (
> source = 'obstacle',
> target = 'obstacleToGoal',
> color = '255,165,0',
> _'target.decoration' = 'arrow',
> width = '2',
> _'tool.description' = 'Create new ObstructionLink between
> an Obstacle and a Goal, Requirement or Expectation'
> );
> }
> class SolutionLink extends Links
> {
> property obstacleHasSolution#solutionIsGoal : Goal[1] {
> ordered };
> property obstacleSolution#solution : Obstacle[1] { ordered };
> annotation _'gmf.link'
> (
> source = 'obstacleHasSolution',
> target = 'obstacleSolution',
> color = '0,139,0',
> _'target.decoration' = 'arrow',
> width = '2',
> _'tool.description' = 'Create new SolutionLink between an
> Obstacle and a Goal, Requirement or Expectation'
> );
> }
> ..
>
|
|
|
Re: OCLInEcore recursive operations [message #786659 is a reply to message #786632] |
Mon, 30 January 2012 12:28  |
Eclipse User |
|
|
|
I though what it was more simple if a do not put the entire example. Anyway here it is:
module _'KAOS.ecore'
import ecore : 'http://www.eclipse.org/emf/2002/Ecore#/';
package KAOSStandard : kaos = 'kaos'
{
class KAOS
{
property hasCompartmentNode : CompartmentNode[*] { ordered composes };
property hasNodes : Nodes[*] { ordered composes };
property hasLinks : Links[*] { ordered composes };
property root : Goal[1] { ordered };
operation numLeafGoals() : ecore::EIntegerObject[?]
{
body: self.hasNodes->select(n : Nodes | n.oclIsKindOf(Goal) and n.oclAsType(Goal).isLeafGoal())->size();
}
operation numLeafGoalsWithAgents() : ecore::EIntegerObject[?]
{
body:
self.hasNodes->select(n : Nodes | n.oclIsKindOf(Goal) and n.oclAsType(Goal).isLeafGoal() and n.oclAsType(Goal).goalNumberOfAgents() > 0)->size();
}
operation numLeafGoalsWithObjects() : ecore::EIntegerObject[?]
{
body:
self.hasNodes->select(n : Nodes | n.oclIsKindOf(Goal) and n.oclAsType(Goal).isLeafGoal() and n.oclAsType(Goal).goalNumberOfObjects() > 0)->size();
}
operation numLeafObstacles() : ecore::EIntegerObject[?]
{
body:
self.hasNodes->select(n : Nodes | n.oclIsKindOf(Obstacle) and not self.hasLinks->exists(l : Links | (l.oclIsKindOf(ObstacleRefinement) and l.oclAsType(ObstacleRefinement).obstToObstRef = n.oclAsType(Obstacle))))->size();
}
operation numLeafGoalsWithOperations() : ecore::EIntegerObject[?]
{
body:
self.hasNodes->select(n : Nodes | n.oclIsKindOf(Goal) and n.oclAsType(Goal).isLeafGoal() and n.oclAsType(Goal).goalNumberOfOperations() > 0)->size();
}
operation numOperations() : ecore::EIntegerObject[?]
{
body: self.hasNodes->select(n : Nodes | n.oclIsKindOf(OperationNode))->size();
}
operation numOperationsWithAgents() : ecore::EIntegerObject[?]
{
body:
self.hasNodes->select(n : Nodes | n.oclIsKindOf(OperationNode) and n.oclAsType(OperationNode).operationNumberOfAgents() > 0)->size();
}
operation numAgents() : ecore::EIntegerObject[?]
{
body: self.hasNodes->select(n : Nodes | n.oclIsKindOf(Agent))->size();
}
operation numLeafGoalsWithConcerns() : ecore::EIntegerObject[?]
{
body:
self.hasLinks->select(l : Links | l.oclIsKindOf(ConcernsLink) and l.oclAsType(ConcernsLink).concernedByGoal.isLeafGoal())->size();
}
operation modelDepth() : ecore::EIntegerObject[1]
{
body:
self.goalsDistanceToRoot(self.root, Set{0}, 0)->iterate(i : Integer ; m : Integer = - 1 | if m = - 1 then i else m.max(i) endif);
}
operation goalsDistanceToRoot(n : Nodes[1], dist : ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
ecore::EIntegerObject[*]
{
body:
if n.oclIsKindOf(Goal) then self.depthOfGoal(n.oclAsType(Goal), dist, last) else if n.oclIsKindOf(Obstacle) then self.depthOfObstacle(n.oclAsType(Obstacle), dist, last) else dist endif endif;
}
operation depthOfGoal(g : Goal[1], dist : ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
ecore::EIntegerObject[*]
{
body:
if g.isLeafGoal() then self.depthOfLeafGoal(g, dist, last) else self.union(g.goalIsAndRef->collect(andRefToOtherGoal)->union(g.goalIsOrRef->collect(orRefToOtherGoal))->asSet(), g.goalHasObstacle->collect(obstacle)->asSet())->collect(n : Nodes | self.goalsDistanceToRoot(n, dist->including(last + 1), last + 1))->asSet() endif;
}
operation union(s1 : Goal[*], s2 : Nodes[*]) : Nodes[*]
{
body: let s : Set(Nodes) = Set{} in s->union(s1)->union(s2);
}
operation depthOfLeafGoal(g : Goal[1], dist : ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
ecore::EIntegerObject[*]
{
body:
let s : Sequence(Obstacle) = g.goalHasObstacle->collect(obstacle) in if s->notEmpty() then s->collect(o : Obstacle | self.goalsDistanceToRoot(o.oclAsType(Nodes), dist->including(last + 1), last + 1))->asSet() else dist endif;
}
operation depthOfObstacle(o : Obstacle[1], dist : ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
ecore::EIntegerObject[*]
{
body:
if self.isLeafObstacle(o) then self.depthOfLeafObstacle(o, dist, last) else self.obstacleRefinement(o)->collect(o : Obstacle | self.goalsDistanceToRoot(o.oclAsType(Nodes), dist->including(last + 1), last + 1))->asSet() endif;
}
operation obstacleRefinement(o : Obstacle[1]) : Obstacle[*]
{
body:
self.hasLinks->select(l : Links | l.oclIsKindOf(ObstacleRefinement) and l.oclAsType(ObstacleRefinement).obstToObstRef = o)->collect(oclAsType(ObstacleRefinement))->collect(obstRefToObst);
}
operation depthOfLeafObstacle(o : Obstacle[1], dist : ecore::EIntegerObject[*], last : ecore::EIntegerObject[1]) :
ecore::EIntegerObject[*]
{
body:
let s : Sequence(Goal) = o.solution->collect(obstacleHasSolution) in if s->notEmpty() then s->collect(g : Goal | self.goalsDistanceToRoot(g.oclAsType(Nodes), dist->including(last + 1), last + 1))->asSet() else dist endif;
}
operation isLeafObstacle(o : Obstacle[1]) : Boolean[1]
{
body:
not self.hasLinks->exists(l : Links | (l.oclIsKindOf(ObstacleRefinement) and l.oclAsType(ObstacleRefinement).obstToObstRef = o));
}
operation depth() : ecore::EIntegerObject[1]
{
body:
let s : OrderedSet(Nodes) = OrderedSet{self.root.oclAsType(Goal)} in s->iterate(n : Nodes ; i : Integer = 0 | s = s->union(n.oclAsType(Goal).goalIsAndRef->collect(andRefToOtherGoal)->asOrderedSet())->excluding(n) and i = i + 1);
}
operation modelDit() : ecore::EIntegerObject[1]
{
body:
self.hasNodes->iterate(n : Nodes ; i : Integer = 0 | if n.oclIsKindOf(Goal) and n.oclAsType(Goal).dit(self.root) > i then n.oclAsType(Goal).dit(self.root) else i endif);
}
annotation _'gmf.diagram'
(
foo = 'bar'
);
}
abstract class CompartmentNode
{
attribute name : String[?] { ordered };
}
class GoalCompartmentNode extends CompartmentNode
{
property compHasGoals : Goal[*] { ordered composes }
{
annotation _'gmf.compartment'
(
layout = 'free'
);
}
annotation _'gmf.node'
(
label = 'name',
_'border.color' = '0,0,255',
size = '200,100',
_'border.width' = '2',
_'tool.description' =
'Create new GoalCompartmentNode for inserting Goals, Requirements and Expectations in the diagram'
);
}
class SoftgoalCompartmentNode extends CompartmentNode
{
property softgoalCompHasSoftgoals : Softgoal[*] { ordered composes }
{
annotation _'gmf.compartment'
(
layout = 'free'
);
}
annotation _'gmf.node'
(
label = 'name',
_'border.color' = '0,100,0',
size = '200,100',
_'border.width' = '2',
_'tool.description' = 'Create new SoftgoalCompartmentNode for inserting Softgoals in the diagram'
);
}
class ObstacleCompartmentNode extends CompartmentNode
{
property obstCompNodeHasObstacle : Obstacle[*] { ordered composes }
{
annotation _'gmf.compartment'
(
layout = 'free'
);
}
annotation _'gmf.node'
(
label = 'name',
_'border.color' = '255,165,0',
size = '200,100',
_'border.width' = '2',
_'tool.description' = 'Create new ObstacleCompartmentNode for inserting Obstacles in the diagram'
);
}
class DomainPropertiesCompartmentNode extends CompartmentNode
{
property domProCompNodeHasDomProp : DomainProperties[*] { ordered composes }
{
annotation _'gmf.compartment'
(
layout = 'free'
);
}
annotation _'gmf.node'
(
label = 'name',
_'border.color' = '148,0,211',
size = '200,100',
_'border.width' = '2',
_'tool.description' =
'Create new DomainPropertiesCompartmentNode for inserting Domain Invariants and Domain Hipothesis in the diagram'
);
}
class AgentCompartmentNode extends CompartmentNode
{
property agentCompHasAgent : Agent[*] { ordered composes }
{
annotation _'gmf.compartment'
(
layout = 'free'
);
}
annotation _'gmf.node'
(
label = 'name',
_'border.color' = '255,105,180',
size = '200,100',
_'border.width' = '2',
_'tool.description' =
'Create new AgentCompartmentNode for inserting System Agents and Environment Agents in the diagram'
);
}
class ObjectCompartmentNode extends CompartmentNode
{
property objCompHasObjects : Object[*] { ordered }
{
annotation _'gmf.compartment'
(
layout = 'free'
);
}
annotation _'gmf.node'
(
label = 'name',
_'border.color' = '165,42,42',
size = '200,100',
_'border.width' = '2',
_'tool.description' = 'Create new ObjectCompartmentNode for creating Entities and Events in the diagram'
);
}
class OperationCompartmentNode extends CompartmentNode
{
property hasOperationNodes : OperationNode[*] { ordered }
{
annotation _'gmf.compartment'
(
layout = 'free'
);
}
annotation _'gmf.node'
(
label = 'name',
size = '200,100',
_'border.width' = '2',
_'tool.description' = 'Create new OperationCompartmentNode for inserting Operations in the diagram'
);
}
abstract class Nodes
{
attribute name : String[?] { ordered };
attribute TransformationSource : String[?] { ordered };
attribute IstarActorContainer : String[?] { ordered };
annotation _'gmf.node'
(
label = 'name',
_'label.placement' = 'external'
);
}
class Goal extends Nodes
{
attribute formalDef : String[?] { ordered };
attribute informalDef : String[?] { ordered };
property goalIsOrRef#orRefToGoal : OrRefinement[*] { ordered };
property otherGoalIsOrRef#orRefToOtherGoal : OrRefinement[*] { ordered };
property goalIsAndRef#andRefToGoal : AndRefinement[*] { ordered };
property otherGoalIsAndRef#andRefToOtherGoal : AndRefinement[*] { ordered };
property goalHasObstacle#obstacleToGoal : ObstructionLink[*] { ordered };
property solutionIsGoal#obstacleHasSolution : SolutionLink[*] { ordered };
property goalToOperatLink#operatLinkToGoal : OperationalizationLink[*] { ordered };
property goalConcerns#concernedByGoal : ConcernsLink[*] { ordered };
property goalHasDomProp#DomPropLinkToGoal : DomainPropLink[*] { ordered };
operation isLeafGoal() : Boolean[1]
{
body: self.goalIsAndRef->isEmpty() and self.goalIsOrRef->isEmpty();
}
operation goalAgents() : Agent[*]
{
body:
let s : Sequence(Agent) = if self.oclIsKindOf(Expectation) then self.oclAsType(Expectation).expToAgentExpLink->collect(expLinkToAgent) else if self.oclIsKindOf(Requirement) then self.oclAsType(Requirement).ReqToAgentReqLink->collect(ReqToAgentLink) else Sequence{} endif endif in s->union(self.otherGoalIsOrRef->collect(orRefToGoal)->union(self.otherGoalIsAndRef->collect(andRefToGoal))->collect(g : Goal | g.goalAgents()));
}
operation goalNumberOfAgents() : ecore::EIntegerObject[?]
{
body: self.goalAgents()->size();
}
operation goalNumberOfObjects() : ecore::EIntegerObject[?]
{
body: self.goalConcerns->collect(concernsObject)->size();
}
operation goalNumberOfOperations() : ecore::EIntegerObject[?]
{
body: self.goalToOperatLink->collect(operatLinkToOperationNode)->size();
}
annotation _'gmf.node'
(
color = '0,191,255',
_'border.color' = '0,191,255',
size = '80,50',
figure = 'polygon',
_'polygon.x' = '30 70 50 10',
_'polygon.y' = '10 10 40 40',
_'tool.description' = 'Create new Goal'
);
}
class Requirement extends Goal
{
property ReqToAgentReqLink#agentReqLinkToReq : AgentReqLink[+] { ordered };
annotation _'gmf.node'
(
color = '0,191,255',
_'border.color' = '0,0,0',
_'border.width' = '2',
size = '80,50',
figure = 'polygon',
_'polygon.x' = '30 70 50 10',
_'polygon.y' = '10 10 40 40',
_'tool.description' = 'Create new Requirement'
);
}
class Expectation extends Goal
{
property expToAgentExpLink#agentExpLinkToExp : AgentExpLink[+] { ordered };
annotation _'gmf.node'
(
color = '255,215,0',
_'border.color' = '255,215,0',
size = '80,50',
figure = 'polygon',
_'polygon.x' = '30 70 50 10',
_'polygon.y' = '10 10 40 40',
_'tool.description' = 'Create new Expectation'
);
}
class Softgoal extends Goal
{
annotation _'gmf.node'
(
color = '50,205,50',
_'border.color' = '50,205,50',
size = '40,40',
figure = 'ellipse',
_'tool.description' = 'Create new Softgoal'
);
}
class Obstacle extends Nodes
{
property obstacleObstruction#obstacle : ObstructionLink[*] { ordered };
property solution#obstacleSolution : SolutionLink[*] { ordered };
operation obstacleNumberOfSolutions() : ecore::EIntegerObject[?]
{
body: self.solution->size();
}
annotation _'gmf.node'
(
color = '255,140,0',
_'border.color' = '255,140,0',
size = '80,50',
figure = 'polygon',
_'polygon.x' = '10 50 70 30',
_'polygon.y' = '10 10 40 40',
_'tool.description' = 'Create new Obstacle'
);
}
abstract class DomainProperties extends Nodes
{
attribute formalDef : String[?] { ordered };
attribute informalDef : String[?] { ordered };
property domPropToGoal#goalToDomProp : DomainPropLink[+] { ordered };
}
class DomainInvariant extends DomainProperties
{
annotation _'gmf.node'
(
color = '221,160,221',
_'border.color' = '221,160,221',
size = '80,50',
figure = 'polygon',
_'polygon.x' = '10 40 70 70 10',
_'polygon.y' = '20 10 20 40 40',
_'tool.description' = 'Create new DomainInvariant'
);
}
class DomainHyphothesis extends DomainProperties
{
annotation _'gmf.node'
(
color = '147,112,219',
_'border.color' = '147,112,219',
size = '80,50',
figure = 'polygon',
_'polygon.x' = '10 40 70 70 10',
_'polygon.y' = '20 10 20 40 40',
_'tool.description' = 'Create new DomainHyphothesis'
);
}
abstract class Object extends Nodes
{
attribute informalDef : String[?] { ordered };
property objToInhLink#inhLinkToObject : InheritanceLink[*] { ordered };
property otherObjToInhLink#inhLinkToOtherObj : InheritanceLink[*] { ordered };
property objToAggLink#aggLinkToObject : AggregationLink[*] { ordered };
property otherObjToAggLink#aggLinkToOtherObject : AggregationLink[*] { ordered };
property objToCardLink#cardLinkToObject : CardinalityLink[*] { ordered };
property otherObjToCardLink#cardLinkToOtherObject : CardinalityLink[*] { ordered };
property objIsMonitored#monLinkToObject : MonitorsLink[*] { ordered };
property objIsControlled#contLinkToObject : ControlsLink[*] { ordered };
property objectIsConcerned#concernsObject : ConcernsLink[*] { ordered };
}
abstract class Agent extends Object
{
property agentMonitors#monLinkToAgent : MonitorsLink[*] { ordered };
property agentControls#contLinkToAgent : ControlsLink[*] { ordered };
property agentPerforms#perLinkToAgent : PerformsLink[*] { ordered };
operation agentNumberOfLeafGoals() : ecore::EIntegerObject[?]
{
body:
if self.oclIsKindOf(EnvironmentAgent) then self.oclAsType(EnvironmentAgent).numLeafGoals() else if self.oclIsKindOf(SystemAgent) then self.oclAsType(SystemAgent).numLeafGoals() else 0 endif endif;
}
}
class SystemAgent extends Agent
{
property agentToReqLink#ReqToAgentLink : AgentReqLink[+] { ordered };
operation numLeafGoals() : ecore::EIntegerObject[?]
{
body: self.agentToReqLink->collect(agentReqLinkToReq)->size();
}
annotation _'gmf.node'
(
color = '255,160,122',
_'border.color' = '255,160,122',
size = '80,50',
figure = 'polygon',
_'polygon.x' = '10 20 60 70 60 20',
_'polygon.y' = '25 40 40 25 10 10',
_'tool.description' = 'Create new SystemAgent'
);
}
class EnvironmentAgent extends Agent
{
property agentToExpLink#expLinkToAgent : AgentExpLink[+] { ordered };
operation numLeafGoals() : ecore::EIntegerObject[?]
{
body: self.agentToExpLink->collect(agentExpLinkToExp)->size();
}
annotation _'gmf.node'
(
color = '255,182,193',
_'border.color' = '255,182,193',
size = '80,50',
figure = 'polygon',
_'polygon.x' = '10 20 60 70 60 20',
_'polygon.y' = '25 40 40 25 10 10',
_'tool.description' = 'Create new EnvironmentAgent'
);
}
class Event extends Object
{
attribute frequency : ecore::EInt[?] { ordered };
annotation _'gmf.node'
(
color = '189,183,107',
_'border.color' = '189,183,107',
size = '80,50',
figure = 'polygon',
_'polygon.x' = '10 10 60 70 60',
_'polygon.y' = '10 40 40 25 10',
_'tool.description' = 'Create new Event'
);
}
class Entity extends Object
{
annotation _'gmf.node'
(
color = '143,188,143',
_'border.color' = '143,188,143',
size = '60,30',
figure = 'rectangle',
_'tool.description' = 'Create new Entity'
);
}
class Relationship extends Object
{
property relationConnObject : Object[1] { ordered };
property objectIsConnByRelation : Object[1] { ordered };
annotation _'gmf.link'
(
label = 'name',
source = 'relationConnObject',
target = 'objectIsConnByRelation',
color = '255,127,80',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new Relationship between two Objects'
);
}
class OperationNode extends Nodes
{
property operationNodeToOperatLink#operatLinkToOperationNode : OperationalizationLink[*] { ordered };
property operationIsPerformed#perLinkToOperationNode : PerformsLink[*] { ordered };
operation operationNumberOfAgents() : ecore::EIntegerObject[?]
{
body: self.operationIsPerformed->collect(perLinkToAgent)->size();
}
annotation _'gmf.node'
(
color = '211,211,211',
_'border.color' = '211,211,211',
size = '60,30',
figure = 'ellipse',
_'tool.description' = 'Create new OperationNode'
);
}
abstract class Links
{
attribute TransformationSource : String[?] { ordered };
attribute name : String[?] { ordered };
attribute Source : String[?] { ordered };
attribute Target : String[?] { ordered };
}
class OrRefinement extends Links
{
invariant linkToHimself('Goal ' + orRefToGoal.name + ' can not be a refinement of himself.'):
orRefToGoal <> orRefToOtherGoal;
property orRefToGoal#goalIsOrRef : Goal[1] { ordered };
property orRefToOtherGoal#otherGoalIsOrRef : Goal[1] { ordered };
annotation _'gmf.link'
(
source = 'orRefToGoal',
target = 'orRefToOtherGoal',
color = '0,0,255',
_'target.decoration' = 'arrow',
width = '2',
style = 'dash',
_'tool.description' = 'Create new OrRefinement between Goal, Requirement or Expectation'
);
}
class AndRefinement extends Links
{
invariant linkToHimself('Goal ' + andRefToGoal.name + ' can not be a refinement of himself.'):
andRefToGoal <> andRefToOtherGoal;
property andRefToGoal#goalIsAndRef : Goal[1] { ordered };
property andRefToOtherGoal#otherGoalIsAndRef : Goal[1] { ordered };
annotation _'gmf.link'
(
source = 'andRefToGoal',
target = 'andRefToOtherGoal',
color = '0,0,255',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new AndRefinement between Goal, Requirement or Expectation'
);
}
class ObstacleRefinement extends Links
{
invariant linkToHimself('Obstacle ' + obstRefToObst.name + ' can not be a refinement of himself.'):
obstRefToObst <> obstToObstRef;
property obstRefToObst : Obstacle[1] { ordered };
property obstToObstRef : Obstacle[1] { ordered };
annotation _'gmf.link'
(
source = 'obstRefToObst',
target = 'obstToObstRef',
color = '255,140,0',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new ObstacleRefinement between Obstacles'
);
}
class ObstructionLink extends Links
{
property obstacle#obstacleObstruction : Obstacle[1] { ordered };
property obstacleToGoal#goalHasObstacle : Goal[1] { ordered };
annotation _'gmf.link'
(
source = 'obstacle',
target = 'obstacleToGoal',
color = '255,165,0',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new ObstructionLink between an Obstacle and a Goal, Requirement or Expectation'
);
}
class SolutionLink extends Links
{
property obstacleHasSolution#solutionIsGoal : Goal[1] { ordered };
property obstacleSolution#solution : Obstacle[1] { ordered };
annotation _'gmf.link'
(
source = 'obstacleHasSolution',
target = 'obstacleSolution',
color = '0,139,0',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new SolutionLink between an Obstacle and a Goal, Requirement or Expectation'
);
}
class OperationalizationLink extends Links
{
attribute label : String[1] = 'Operationalization' { ordered readonly };
property operatLinkToGoal#goalToOperatLink : Goal[1] { ordered };
property operatLinkToOperationNode#operationNodeToOperatLink : OperationNode[1] { ordered };
annotation _'gmf.link'
(
label = 'label',
source = 'operatLinkToGoal',
target = 'operatLinkToOperationNode',
color = '105,105,105',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new OperationalizationLink between an Operation and a Goal'
);
}
class ConcernsLink extends Links
{
attribute label : String[1] = 'Concerns' { ordered readonly };
property concernedByGoal#goalConcerns : Goal[1] { ordered };
property concernsObject#objectIsConcerned : Object[1] { ordered };
annotation _'gmf.link'
(
label = 'label',
source = 'concernedByGoal',
target = 'concernsObject',
color = '205,133,63',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new ConcernsLink between a Goal, Requirement or Expectation and an Object'
);
}
class DomainPropLink extends Links
{
property DomPropLinkToGoal#goalHasDomProp : Goal[1] { ordered };
property goalToDomProp#domPropToGoal : DomainProperties[1] { ordered };
annotation _'gmf.link'
(
source = 'DomPropLinkToGoal',
target = 'goalToDomProp',
color = '148,0,211',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' =
'Create new DomainPropLink between Goal, Requirement or Expectation and Domain Invariant or Domain Hipothesis'
);
}
class AgentReqLink extends Links
{
property ReqToAgentLink#agentToReqLink : SystemAgent[1] { ordered };
property agentReqLinkToReq#ReqToAgentReqLink : Requirement[1] { ordered };
annotation _'gmf.link'
(
source = 'ReqToAgentLink',
target = 'agentReqLinkToReq',
color = '233,150,122',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new AgentReqLink for connecting a System Agent to a Requirement'
);
}
class AgentExpLink extends Links
{
property expLinkToAgent#agentToExpLink : EnvironmentAgent[1] { ordered };
property agentExpLinkToExp#expToAgentExpLink : Expectation[1] { ordered };
annotation _'gmf.link'
(
source = 'expLinkToAgent',
target = 'agentExpLinkToExp',
color = '176,48,96',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new AgentExpLink for connecting an Environment Agent to an Expectation'
);
}
class InheritanceLink extends Links
{
invariant linkToHimself('Object ' + inhLinkToObject.name + ' can not be a refinement of himself.'):
inhLinkToObject <> inhLinkToOtherObj;
property inhLinkToObject#objToInhLink : Object[1] { ordered };
property inhLinkToOtherObj#otherObjToInhLink : Object[1] { ordered };
annotation _'gmf.link'
(
source = 'inhLinkToObject',
target = 'inhLinkToOtherObj',
_'target.decoration' = 'closedarrow',
width = '2',
_'tool.description' = 'Create new InheritanceLink between Entities'
);
}
class AggregationLink extends Links
{
invariant linkToHimself('Object ' + aggLinkToObject.name + ' can not be a refinement of himself.'):
aggLinkToObject <> aggLinkToOtherObject;
property aggLinkToObject#objToAggLink : Object[1] { ordered };
property aggLinkToOtherObject#otherObjToAggLink : Object[1] { ordered };
annotation _'gmf.link'
(
source = 'aggLinkToObject',
target = 'aggLinkToOtherObject',
_'target.decoration' = 'filledrhomb',
width = '2',
_'tool.description' = 'Create new AggregationLink between Entities'
);
}
class CardinalityLink extends Links
{
attribute firstEnd : String[1] { ordered };
attribute secondEnd : String[1] { ordered };
property cardLinkToObject#objToCardLink : Object[1] { ordered };
property cardLinkToOtherObject#otherObjToCardLink : Object[1] { ordered };
annotation _'gmf.link'
(
source = 'cardLinkToObject',
target = 'cardLinkToOtherObject',
width = '2',
_'tool.description' = 'Create new CardinalityLink between Entities'
);
}
class MonitorsLink extends Links
{
attribute label : String[1] = 'Monitors' { ordered readonly };
property monLinkToAgent#agentMonitors : Agent[1] { ordered };
property monLinkToObject#objIsMonitored : Object[1] { ordered };
annotation _'gmf.link'
(
label = 'label',
source = 'monLinkToAgent',
target = 'monLinkToObject',
color = '102,205,170',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new MonitorsLink between an Object and an Agent'
);
}
class ControlsLink extends Links
{
attribute label : String[1] = 'Controls' { ordered readonly };
property contLinkToAgent#agentControls : Agent[1] { ordered };
property contLinkToObject#objIsControlled : Object[1] { ordered };
annotation _'gmf.link'
(
label = 'label',
source = 'contLinkToAgent',
target = 'contLinkToObject',
color = '34,139,34',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new ControlsLink between an Object and an Agent'
);
}
class PerformsLink extends Links
{
attribute label : String[1] = 'Performs' { ordered readonly };
property perLinkToAgent#agentPerforms : Agent[1] { ordered };
property perLinkToOperationNode#operationIsPerformed : OperationNode[1] { ordered };
annotation _'gmf.link'
(
label = 'label',
source = 'perLinkToAgent',
target = 'perLinkToOperationNode',
color = '0,0,0',
_'target.decoration' = 'arrow',
width = '2',
_'tool.description' = 'Create new PerformsLink between an Agent and an Operation'
);
}
class Conflict extends Links
{
invariant linkToHimself('Goal ' + conflictBtwnGoals.name + ' can not be a refinement of himself.'):
conflictBtwnGoals <> goalHasConflict;
attribute label : String[1] = 'Conflict' { ordered readonly };
property conflictBtwnGoals : Goal[1] { ordered };
property goalHasConflict : Goal[1] { ordered };
annotation _'gmf.link'
(
label = 'label',
source = 'conflictBtwnGoals',
target = 'goalHasConflict',
color = '205,0,0',
_'source.decoration' = 'arrow',
_'target.decoration' = 'arrow',
width = '2',
style = 'dash',
_'tool.description' = 'Create new Conflict between Goals'
);
}
annotation gmf
(
foo = 'bar'
);
}
and the problem is with the operation modelDepth
|
|
|
Goto Forum:
Current Time: Tue Jul 22 19:27:12 EDT 2025
Powered by FUDForum. Page generated in 0.05324 seconds
|