Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » how to detect cycle in OCL
how to detect cycle in OCL [message #58162] Wed, 11 June 2008 03:32 Go to next message
Eclipse User
Originally posted by: asma.charfi.com

Hi,
I want to code in OCL a constraint that detect a cycle in a component.
a cycle is a path that contains the same parts twice or more.
I use component and part part
connection between part is done used port
port have direction IN or Out
a part 1 is connected with part 2 , means that there is a connecotor linking
one Out port of part 1 with an IN Port of part 2

I tried to divide my constraint as follows.
- recover ports of direction IN in the main component :

Contexte component
self.ownedPort->select(let p : GCM::FlowPort =
getStereotypeApplication(getAppliedStereotype('GCM::FlowPort ')).oclAsType
(GCM::FlowPort) in p.direction <> GCM::DirectionKind::out)


- recover part directly linked to this component (there is a connector that
connects the port INof the component with a port IN of the part) :



Contexte Port (direction IN)

self.end-> select(e|e.owner.owner=self.owner).owner.oclAsType(Connector ).end- >
select(p|not (p.oclAsType(ConnectorEnd).partWithPort.oclIsUndefined())).
partWithPort.type




I want now to get all parts in connection with my part (to check if the list
of parts contains double)


did so have an idea about how to get list of parts that are connected ?

thank you
Re: how to detect cycle in OCL [message #58187 is a reply to message #58162] Wed, 11 June 2008 02:16 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.zeligsoft.com

--=-Aw8Knelv38k0oqiggDu2
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Asma,

Which version of the MDT OCL component are you using? If 1.1or greater,
you should be able to use the UML metamodel binding's capability of
navigating non-navigable association ends to more concisely express
constraints involving stereotypes.

context Component
def: inPorts : Collection(Port) = self.ownedPort->select(p : Port |
p.extension_FlowPort <> null and
p.extension_FlowPort.direction <> GCM::DirectionKind::out) in

Regarding finding all parts connected to some part, you may find MDT
OCL's custom closure() iterator to be of use. For example, to find all
of the supertypes of a classifier (pretending that
Classifier::allParents() query doesn't exist):

context Classifier
def: allSupers() : Collection(Classifier) = general->closure(general)

or, the closure of all associated classifiers to which a classifier can
navigate via associations:

context Classifier
def: reachable() : Collection(Classifier) =
self->closure(ownedAttribute->select(association <> null).type)

Your component-model scenario is just too complex for my little
brain ;-)

HTH,

Christian

On Tue, 2008-06-10 at 20:32 -0700, charfi asma wrote:

> Hi,
> I want to code in OCL a constraint that detect a cycle in a component.
> a cycle is a path that contains the same parts twice or more.
> I use component and part part
> connection between part is done used port
> port have direction IN or Out
> a part 1 is connected with part 2 , means that there is a connecotor linking
> one Out port of part 1 with an IN Port of part 2
>
> I tried to divide my constraint as follows.
> - recover ports of direction IN in the main component :
>
> Contexte component
> self.ownedPort->select(let p : GCM::FlowPort =
> getStereotypeApplication(getAppliedStereotype('GCM::FlowPort ')).oclAsType
> (GCM::FlowPort) in p.direction <> GCM::DirectionKind::out)
>
>
> - recover part directly linked to this component (there is a connector that
> connects the port INof the component with a port IN of the part) :
>
>
>
> Contexte Port (direction IN)
>
> self.end-> select(e|e.owner.owner=self.owner).owner.oclAsType(Connector ).end- >
> select(p|not (p.oclAsType(ConnectorEnd).partWithPort.oclIsUndefined())).
> partWithPort.type
>
>
>
>
> I want now to get all parts in connection with my part (to check if the list
> of parts contains double)
>
>
> did so have an idea about how to get list of parts that are connected ?
>
> thank you
>
>

--=-Aw8Knelv38k0oqiggDu2
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, Asma,<BR>
<BR>
Which version of the MDT OCL component are you using?&nbsp; If 1.1or greater, you should be able to use the UML metamodel binding's capability of navigating non-navigable association ends to more concisely express constraints involving stereotypes.<BR>
<BR>
context Component<BR>
def:&nbsp; inPorts : Collection(Port) = self.ownedPort-&gt;select(p : Port |<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; p.extension_FlowPort &lt;&gt; null and<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; p.extension_FlowPort.direction &lt;&gt; GCM::DirectionKind::out) in<BR>
<BR>
Regarding finding all parts connected to some part, you may find MDT OCL's custom closure() iterator to be of use. For example, to find all of the supertypes of a classifier (pretending that Classifier::allParents() query doesn't exist):<BR>
<BR>
context Classifier<BR>
def: allSupers() : Collection(Classifier) = general-&gt;closure(general)<BR>
<BR>
or, the closure of all associated classifiers to which a classifier can navigate via associations:<BR>
<BR>
context Classifier<BR>
def:&nbsp; reachable() : Collection(Classifier) =<BR>
&nbsp;&nbsp;&nbsp; self-&gt;closure(ownedAttribute-&gt;select(associati on &lt;&gt; null).type)<BR>
<BR>
Your component-model scenario is just too complex for my little brain ;-)<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
On Tue, 2008-06-10 at 20:32 -0700, charfi asma wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Hi,</FONT>
<FONT COLOR="#000000">I want to code in OCL a constraint that detect a cycle in a component.</FONT>
<FONT COLOR="#000000">a cycle is a path that contains the same parts twice or more.</FONT>
<FONT COLOR="#000000">I use component and part part</FONT>
<FONT COLOR="#000000">connection between part is done used port</FONT>
<FONT COLOR="#000000">port have direction IN or Out</FONT>
<FONT COLOR="#000000">a part 1 is connected with part 2 , means that there is a connecotor linking </FONT>
<FONT COLOR="#000000">one Out port of part 1 with an IN Port of part 2</FONT>

<FONT COLOR="#000000">I tried to divide my constraint as follows.</FONT>
<FONT COLOR="#000000">- recover ports of direction IN in the main component :</FONT>

<FONT COLOR="#000000">Contexte component</FONT>
<FONT COLOR="#000000">self.ownedPort-&gt;select(let p : GCM::FlowPort = </FONT>
<FONT COLOR="#000000"> getStereotypeApplication(getAppliedStereotype('GCM::FlowPort ')).oclAsType </FONT>
<FONT COLOR="#000000">(GCM::FlowPort) in p.direction &lt;&gt; GCM::DirectionKind::out)</FONT>


<FONT COLOR="#000000">- recover part directly linked to this component (there is a connector that </FONT>
<FONT COLOR="#000000">connects the port INof the component with a port IN of the part) :</FONT>



<FONT COLOR="#000000">Contexte Port (direction IN)</FONT>

<FONT COLOR="#000000"> self.end-&gt;select(e|e.owner.owner=self.owner).owner.oc lAsType(Connector).end-&gt; </FONT>
<FONT COLOR="#000000">select(p|not (p.oclAsType(ConnectorEnd).partWithPort.oclIsUndefined())). </FONT>
<FONT COLOR="#000000">partWithPort.type</FONT>




<FONT COLOR="#000000">I want now to get all parts in connection with my part (to check if the list </FONT>
<FONT COLOR="#000000">of parts contains double)</FONT>


<FONT COLOR="#000000">did so have an idea about how to get list of parts that are connected ?</FONT>

<FONT COLOR="#000000">thank you </FONT>


</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-Aw8Knelv38k0oqiggDu2--
Re: how to detect cycle in OCL [message #58212 is a reply to message #58187] Wed, 11 June 2008 19:42 Go to previous message
Eclipse User
Originally posted by: asma.charfi.com

This is a multi-part message in MIME format.

------=_NextPart_000_000D_01C8CBC0.A558D1C0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable

thank you christian.
custom closure() iterator seems to be usefull, but I did not understand =
its meannig
can you explain more your example (using closure instead of allparents() =
to get all classifer) ?
your constraint is too difficult to understand :)
( def: allSupers() : Collection(Classifier) =3D =
general->closure(general))
I tried to use closure to get parts that are connected with one (any()) =
but it always return all the parts=20
closure(exp: OclExpression) what should we put as oclExpression ?
I understand that when we write self->closure() the type of exp must be =
the same as self

thank you for your help=20

Asma




"Christian W. Damus" <cdamus@zeligsoft.com> a =C3=A9crit dans le =
message de news: 1213150614.7176.21.camel@cwdlappy...
Hi, Asma,

Which version of the MDT OCL component are you using? If 1.1or =
greater, you should be able to use the UML metamodel binding's =
capability of navigating non-navigable association ends to more =
concisely express constraints involving stereotypes.

context Component
def: inPorts : Collection(Port) =3D self.ownedPort->select(p : Port |
p.extension_FlowPort <> null and
p.extension_FlowPort.direction <> GCM::DirectionKind::out) in

Regarding finding all parts connected to some part, you may find MDT =
OCL's custom closure() iterator to be of use. For example, to find all =
of the supertypes of a classifier (pretending that =
Classifier::allParents() query doesn't exist):

context Classifier
def: allSupers() : Collection(Classifier) =3D =
general->closure(general)

or, the closure of all associated classifiers to which a classifier =
can navigate via associations:

context Classifier
def: reachable() : Collection(Classifier) =3D
self->closure(ownedAttribute->select(association <> null).type)

Your component-model scenario is just too complex for my little brain =
;-)

HTH,

Christian

On Tue, 2008-06-10 at 20:32 -0700, charfi asma wrote:=20
Hi,
I want to code in OCL a constraint that detect a cycle in a component.
a cycle is a path that contains the same parts twice or more.
I use component and part part
connection between part is done used port
port have direction IN or Out
a part 1 is connected with part 2 , means that there is a connecotor =
linking=20
one Out port of part 1 with an IN Port of part 2

I tried to divide my constraint as follows.
- recover ports of direction IN in the main component :

Contexte component
self.ownedPort->select(let p : GCM::FlowPort =3D=20
getStereotypeApplication(getAppliedStereotype('GCM::FlowPort ')).oclAsType=
=20
(GCM::FlowPort) in p.direction <> GCM::DirectionKind::out)


- recover part directly linked to this component (there is a connector =
that=20
connects the port INof the component with a port IN of the part) :



Contexte Port (direction IN)

self.end-> select(e|e.owner.owner=3Dself.owner).owner.oclAsType(Connect or)=
..end->=20
select(p|not (p.oclAsType(ConnectorEnd).partWithPort.oclIsUndefined())). =

partWithPort.type




I want now to get all parts in connection with my part (to check if the =
list=20
of parts contains double)


did so have an idea about how to get list of parts that are connected ?

thank you=20



------=_NextPart_000_000D_01C8CBC0.A558D1C0
Content-Type: text/html;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable

=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; CHARSET=3DUTF-8">
<META content=3D"MSHTML 6.00.6000.20772" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>thank you christian.</FONT></DIV>
<DIV>custom closure() iterator seems to be usefull, but I did not =
understand its=20
meannig</DIV>
<DIV><FONT face=3DArial size=3D2>can you explain more your example =
(using closure=20
instead of allparents() to get all classifer) ?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>your constraint is too difficult to =
understand=20
:)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>( <FONT face=3D"Times New Roman" =
size=3D3>def:=20
allSupers() : Collection(Classifier) =3D=20
general-&gt;closure(general))</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman" =
size=3D3>I tried to use=20
closure to get parts that are connected with one (any()) but it always =
return=20
all the parts </FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman" =
size=3D3><FONT=20
size=3D1>closure(exp: OclExpression) what should we put as oclExpression =

?</FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman" =
size=3D3><FONT size=3D1>I=20
understand that when we write self-&gt;closure() the type of exp must be =
the=20
same as self</FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman" =
size=3D3><FONT=20
size=3D1></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman" =
size=3D3><FONT=20
size=3D1><FONT face=3DArial size=3D2>thank you for your help=20
</FONT></FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman" =
size=3D3><FONT=20
size=3D1><FONT face=3DArial =
size=3D2></FONT></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman" =
size=3D3><FONT=20
size=3D1><FONT face=3DArial =
size=3D2>Asma</FONT></DIV></FONT></FONT></FONT>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman" =
size=3D3></FONT><FONT=20
face=3D"Times New Roman" size=3D3></FONT><BR>&nbsp;</DIV></FONT>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Christian W. Damus" &lt;<A=20
href=3D"mailto:cdamus@zeligsoft.com">cdamus@zeligsoft.com</A>&gt; a =
=C3=A9crit dans=20
le message de news: <A=20
=
href=3D"mailto:1213150614.7176.21.camel@cwdlappy">1213150614.7176.21.came=
l@cwdlappy</A>...</DIV>Hi,=20
Asma,<BR><BR>Which version of the MDT OCL component are you =
using?&nbsp; If=20
1.1or greater, you should be able to use the UML metamodel binding's=20
capability of navigating non-navigable association ends to more =
concisely=20
express constraints involving stereotypes.<BR><BR>context=20
Component<BR>def:&nbsp; inPorts : Collection(Port) =3D=20
self.ownedPort-&gt;select(p : Port=20
|<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; p.extension_FlowPort =
&lt;&gt;=20
null and<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
p.extension_FlowPort.direction &lt;&gt; GCM::DirectionKind::out)=20
in<BR><BR>Regarding finding all parts connected to some part, you may =
find MDT=20
OCL's custom closure() iterator to be of use. For example, to find all =
of the=20
supertypes of a classifier (pretending that Classifier::allParents() =
query=20
doesn't exist):<BR><BR>context Classifier<BR>def: allSupers() :=20
Collection(Classifier) =3D general-&gt;closure(general)<BR><BR>or, the =
closure=20
of all associated classifiers to which a classifier can navigate via=20
associations:<BR><BR>context Classifier<BR>def:&nbsp; reachable() :=20
Collection(Classifier) =3D<BR>&nbsp;&nbsp;&nbsp;=20
self-&gt;closure(ownedAttribute-&gt;select(associati on &lt;&gt;=20
null).type)<BR><BR>Your component-model scenario is just too complex =
for my=20
little brain ;-)<BR><BR>HTH,<BR><BR>Christian<BR><BR>On Tue, =
2008-06-10 at=20
20:32 -0700, charfi asma wrote:=20
<BLOCKQUOTE TYPE=3D"CITE"><PRE><FONT color=3D#000000>Hi,</FONT>
<FONT color=3D#000000>I want to code in OCL a constraint that detect a =
cycle in a component.</FONT>
<FONT color=3D#000000>a cycle is a path that contains the same parts =
twice or more.</FONT>
<FONT color=3D#000000>I use component and part part</FONT>
<FONT color=3D#000000>connection between part is done used port</FONT>
<FONT color=3D#000000>port have direction IN or Out</FONT>
<FONT color=3D#000000>a part 1 is connected with part 2 , means that =
there is a connecotor linking </FONT>
<FONT color=3D#000000>one Out port of part 1 with an IN Port of part =
2</FONT>

<FONT color=3D#000000>I tried to divide my constraint as follows.</FONT>
<FONT color=3D#000000>- recover ports of direction IN in the main =
component :</FONT>

<FONT color=3D#000000>Contexte component</FONT>
<FONT color=3D#000000>self.ownedPort-&gt;select(let p : GCM::FlowPort =
=3D </FONT>
<FONT =
color=3D#000000>getStereotypeApplication(getAppliedStereotype('GCM::FlowP=
ort')).oclAsType </FONT>
<FONT color=3D#000000>(GCM::FlowPort) in p.direction &lt;&gt; =
GCM::DirectionKind::out)</FONT>


<FONT color=3D#000000>- recover part directly linked to this component =
(there is a connector that </FONT>
<FONT color=3D#000000>connects the port INof the component with a port =
IN of the part) :</FONT>



<FONT color=3D#000000>Contexte Port (direction IN)</FONT>

<FONT =
color=3D#000000> self.end-&gt;select(e|e.owner.owner=3Dself.owner).owner. o=
clAsType(Connector).end-&gt; </FONT>
<FONT color=3D#000000>select(p|not =
(p.oclAsType(ConnectorEnd).partWithPort.oclIsUndefined())). </FONT>
<FONT color=3D#000000>partWithPort.type</FONT>




<FONT color=3D#000000>I want now to get all parts in connection with my =
part (to check if the list </FONT>
<FONT color=3D#000000>of parts contains double)</FONT>


<FONT color=3D#000000>did so have an idea about how to get list of parts =
that are connected ?</FONT>

<FONT color=3D#000000>thank you </FONT>


</PRE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_000D_01C8CBC0.A558D1C0--
Re: how to detect cycle in OCL [message #58288 is a reply to message #58212] Wed, 11 June 2008 13:25 Go to previous message
Eclipse User
Originally posted by: cdamus.zeligsoft.com

--=-y5BM7FaYjASHPYv+MmJO
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi, Asma,

Yes, the closure body expression type must conform to the source
collection type. This is because the body expression is recursively
evaluated on its own results until no more results are obtained, taking
care to account for cycles.

Thus, my example expression finds the closure of classifiers that are
connected by the "general" property, navigating in the direction from
specific to general classifier. It really is intended to be a
directed-graph closure.

HTH,

Christian


On Wed, 2008-06-11 at 12:42 -0700, charfi asma wrote:

> =EF=BB=BF=20
>=20
> thank you christian.
> custom closure() iterator seems to be usefull, but I did not
> understand its meannig
> can you explain more your example (using closure instead of
> allparents() to get all classifer) ?
> your constraint is too difficult to understand :)
> ( def: allSupers() : Collection(Classifier) =3D
> general->closure(general))
> I tried to use closure to get parts that are connected with one
> (any()) but it always return all the parts=20
> closure(exp: OclExpression) what should we put as oclExpression ?
> I understand that when we write self->closure() the type of exp must
> be the same as self
> =20
> thank you for your help=20
> =20
> Asma
> =20
>=20
> =20
> =20
> "Christian W. Damus" <cdamus@zeligsoft.com> a =C3=A9crit dans le
> message de news: 1213150614.7176.21.camel@cwdlappy...
> =20
> Hi, Asma,
> =20
> Which version of the MDT OCL component are you using? If
> 1.1or greater, you should be able to use the UML metamodel
> binding's capability of navigating non-navigable association
> ends to more concisely express constraints involving
> stereotypes.
> =20
> context Component
> def: inPorts : Collection(Port) =3D self.ownedPort->select(p :
> Port |
> p.extension_FlowPort <> null and
> p.extension_FlowPort.direction <>
> GCM::DirectionKind::out) in
> =20
> Regarding finding all parts connected to some part, you may
> find MDT OCL's custom closure() iterator to be of use. For
> example, to find all of the supertypes of a classifier
> (pretending that Classifier::allParents() query doesn't
> exist):
> =20
> context Classifier
> def: allSupers() : Collection(Classifier) =3D
> general->closure(general)
> =20
> or, the closure of all associated classifiers to which a
> classifier can navigate via associations:
> =20
> context Classifier
> def: reachable() : Collection(Classifier) =3D
> self->closure(ownedAttribute->select(association <>
> null).type)
> =20
> Your component-model scenario is just too complex for my
> little brain ;-)
> =20
> HTH,
> =20
> Christian
> =20
> On Tue, 2008-06-10 at 20:32 -0700, charfi asma wrote:=20
> =20
> > Hi,
> > I want to code in OCL a constraint that detect a cycle in a com=
ponent.
> > a cycle is a path that contains the same parts twice or more.
> > I use component and part part
> > connection between part is done used port
> > port have direction IN or Out
> > a part 1 is connected with part 2 , means that there is a conne=
cotor linking=20
> > one Out port of part 1 with an IN Port of part 2
> >=20
> > I tried to divide my constraint as follows.
> > - recover ports of direction IN in the main component :
> >=20
> > Contexte component
> > self.ownedPort->select(let p : GCM::FlowPort =3D=20
> > getStereotypeApplication(getAppliedStereotype('GCM::FlowPort '))=
..oclAsType=20
> > (GCM::FlowPort) in p.direction <> GCM::DirectionKind::out)
> >=20
> >=20
> > - recover part directly linked to this component (there is a co=
nnector that=20
> > connects the port INof the component with a port IN of the part=
) :
> >=20
> >=20
> >=20
> > Contexte Port (direction IN)
> >=20
> > self.end->select(e|e.owner.owner=3Dself.owner).owner.oclAsType(=
Connector).end->=20
> > select(p|not (p.oclAsType(ConnectorEnd).partWithPort.oclIsUndef=
ined())).=20
> > partWithPort.type
> >=20
> >=20
> >=20
> >=20
> > I want now to get all parts in connection with my part (to chec=
k if the list=20
> > of parts contains double)
> >=20
> >=20
> > did so have an idea about how to get list of parts that are con=
nected ?
> >=20
> > thank you=20
> >=20
> >=20

--=-y5BM7FaYjASHPYv+MmJO
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY BGCOLOR="#ffffff">
Hi, Asma,<BR>
<BR>
Yes, the closure body expression type must conform to the source collection type.&nbsp; This is because the body expression is recursively evaluated on its own results until no more results are obtained, taking care to account for cycles.<BR>
<BR>
Thus, my example expression finds the closure of classifiers that are connected by the &quot;general&quot; property, navigating in the direction from specific to general classifier.&nbsp; It really is intended to be a directed-graph closure.<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Wed, 2008-06-11 at 12:42 -0700, charfi asma wrote:<BR>
<BLOCKQUOTE TYPE=CITE>
<FONT COLOR="#000000">&#65279; </FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT SIZE="2"><FONT COLOR="#000000">thank you christian.</FONT></FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT COLOR="#000000">custom closure() iterator seems to be usefull, but I did not understand its meannig</FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT SIZE="2"><FONT COLOR="#000000">can you explain more your example (using closure instead of allparents() to get all classifer) ?</FONT></FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT SIZE="2"><FONT COLOR="#000000">your constraint is too difficult to understand :)</FONT></FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT SIZE="2"><FONT COLOR="#000000">( </FONT></FONT><FONT COLOR="#000000">def: allSupers() : Collection(Classifier) = general-&gt;closure(general))</FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT COLOR="#000000">I tried to use closure to get parts that are connected with one (any()) but it always return all the parts </FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT SIZE="1"><FONT COLOR="#000000">closure(exp: OclExpression) what should we put as oclExpression ?</FONT></FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT SIZE="1"><FONT COLOR="#000000">I understand that when we write self-&gt;closure() the type of exp must be the same as self</FONT></FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT COLOR="#000000">&nbsp;</FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT SIZE="2"><FONT COLOR="#000000">thank you for your help </FONT></FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT COLOR="#000000">&nbsp;</FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT SIZE="2"><FONT COLOR="#000000">Asma</FONT></FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT COLOR="#000000">&nbsp;</FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BR>
<FONT SIZE="2"><FONT COLOR="#000000">&nbsp;</FONT></FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<FONT COLOR="#000000">&nbsp;</FONT>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BLOCKQUOTE>
<FONT COLOR="#000000">&quot;Christian W. Damus&quot; &lt;<A HREF="mailto:cdamus@zeligsoft.com">cdamus@zeligsoft.com</A>&gt; a &#233;crit dans le message de news: <A HREF="mailto:1213150614.7176.21.camel@cwdlappy">1213150614.7176.21.camel@cwdlappy</A>...</FONT>
</BLOCKQUOTE>
</BLOCKQUOTE>
<BLOCKQUOTE TYPE=CITE>
<BLOCKQUOTE>
<FONT COLOR="#000000">Hi, Asma,</FONT><BR>
<BR>
<FONT COLOR="#000000">Which version of the MDT OCL component are you using?&nbsp; If 1.1or greater, you should be able to use the UML metamodel binding's capability of navigating non-navigable association ends to more concisely express constraints involving stereotypes.</FONT><BR>
<BR>
<FONT COLOR="#000000">context Component</FONT><BR>
<FONT COLOR="#000000">def:&nbsp; inPorts : Collection(Port) = self.ownedPort-&gt;select(p : Port |</FONT><BR>
<FONT COLOR="#000000"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; p.extension_FlowPort &lt;&gt; null and</FONT><BR>
<FONT COLOR="#000000"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; p.extension_FlowPort.direction &lt;&gt; GCM::DirectionKind::out) in</FONT><BR>
<BR>
<FONT COLOR="#000000">Regarding finding all parts connected to some part, you may find MDT OCL's custom closure() iterator to be of use. For example, to find all of the supertypes of a classifier (pretending that Classifier::allParents() query doesn't exist):</FONT><BR>
<BR>
<FONT COLOR="#000000">context Classifier</FONT><BR>
<FONT COLOR="#000000">def: allSupers() : Collection(Classifier) = general-&gt;closure(general)</FONT><BR>
<BR>
<FONT COLOR="#000000">or, the closure of all associated classifiers to which a classifier can navigate via associations:</FONT><BR>
<BR>
<FONT COLOR="#000000">context Classifier</FONT><BR>
<FONT COLOR="#000000">def:&nbsp; reachable() : Collection(Classifier) =</FONT><BR>
<FONT COLOR="#000000">&nbsp;&nbsp;&nbsp; self-&gt;closure(ownedAttribute-&gt;select(associati on &lt;&gt; null).type)</FONT><BR>
<BR>
<FONT COLOR="#000000">Your component-model scenario is just too complex for my little brain ;-)</FONT><BR>
<BR>
<FONT COLOR="#000000">HTH,</FONT><BR>
<BR>
<FONT COLOR="#000000">Christian</FONT><BR>
<BR>
<FONT COLOR="#000000">On Tue, 2008-06-10 at 20:32 -0700, charfi asma wrote: </FONT>
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Hi,</FONT>
<FONT COLOR="#000000">I want to code in OCL a constraint that detect a cycle in a component.</FONT>
<FONT COLOR="#000000">a cycle is a path that contains the same parts twice or more.</FONT>
<FONT COLOR="#000000">I use component and part part</FONT>
<FONT COLOR="#000000">connection between part is done used port</FONT>
<FONT COLOR="#000000">port have direction IN or Out</FONT>
<FONT COLOR="#000000">a part 1 is connected with part 2 , means that there is a connecotor linking </FONT>
<FONT COLOR="#000000">one Out port of part 1 with an IN Port of part 2</FONT>

<FONT COLOR="#000000">I tried to divide my constraint as follows.</FONT>
<FONT COLOR="#000000">- recover ports of direction IN in the main component :</FONT>

<FONT COLOR="#000000">Contexte component</FONT>
<FONT COLOR="#000000">self.ownedPort-&gt;select(let p : GCM::FlowPort = </FONT>
<FONT COLOR="#000000"> getStereotypeApplication(getAppliedStereotype('GCM::FlowPort ')).oclAsType </FONT>
<FONT COLOR="#000000">(GCM::FlowPort) in p.direction &lt;&gt; GCM::DirectionKind::out)</FONT>


<FONT COLOR="#000000">- recover part directly linked to this component (there is a connector that </FONT>
<FONT COLOR="#000000">connects the port INof the component with a port IN of the part) :</FONT>



<FONT COLOR="#000000">Contexte Port (direction IN)</FONT>

<FONT COLOR="#000000"> self.end-&gt;select(e|e.owner.owner=self.owner).owner.oc lAsType(Connector).end-&gt; </FONT>
<FONT COLOR="#000000">select(p|not (p.oclAsType(ConnectorEnd).partWithPort.oclIsUndefined())). </FONT>
<FONT COLOR="#000000">partWithPort.type</FONT>




<FONT COLOR="#000000">I want now to get all parts in connection with my part (to check if the list </FONT>
<FONT COLOR="#000000">of parts contains double)</FONT>


<FONT COLOR="#000000">did so have an idea about how to get list of parts that are connected ?</FONT>

<FONT COLOR="#000000">thank you </FONT>


</PRE>
</BLOCKQUOTE>
</BLOCKQUOTE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-y5BM7FaYjASHPYv+MmJO--
Previous Topic:getStereotypeApplication()
Next Topic:deleteElement when variables and operations have the same names
Goto Forum:
  


Current Time: Tue Oct 21 13:39:35 GMT 2014

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

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