Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » check an attribute
check an attribute [message #37377] Wed, 19 September 2007 15:32 Go to next message
Eclipse UserFriend
Originally posted by: briandwilliam.hotmail.com

hi,
I will like to initialize a label with the string ' emmetteur' or '
receveur' by testing the value of an attribute.
Class : Port Attribute : Direction .
If Direction = ' IN' the label takes the value ' receveur'
If Direction = ' OUT' the label takes the value ' emmetteur'
thank you
Re: check an attribute [message #37411 is a reply to message #37377] Wed, 19 September 2007 16:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Briand,

Sorry, what is your question?

You want to do something with a label, but I don't know what a label is or
how OCL is supposed to fit into this picture. Are you looking to do
something like:

context Port::label : String
init: if self.Direction = ' IN' then ' receveur' else ' emmetter' endif

assuming that the Direction may only have one of these two values. However,
this sounds like a case where a derived attribute is more useful:

context Port::label : String
derive: if self.Direction = ' IN' then ' receveur' else ' emmetter' endif

Cheers,

Christian


briand wrote:

> hi,
> I will like to initialize a label with the string ' emmetteur' or '
> receveur' by testing the value of an attribute.
> Class : Port Attribute : Direction .
> If Direction = ' IN' the label takes the value ' receveur'
> If Direction = ' OUT' the label takes the value ' emmetteur'
> thank you
Re: check an attribute [message #37445 is a reply to message #37411] Thu, 20 September 2007 09:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: briandwilliam.hotmail.com

hi,
here a little more explanations ! to see the drawing
The ExtremiteConnRepresentation class represents a connection between nodes
(diagram gmf) and ExtremiteConnexion.role is a label.
when I create my connection, I want to initialize my ExtremiteConnexion.role
with 'emetteur' or ' receveur' according to InterfaceSimple.direction ! if
direction='IN' then role='receveur' else role='emetteur'
I try this :
context ExtremiteConnRepresentation
if
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
Syn.redefinitionRefDescSyn.direction='IN' then self.role='receveur' else
self.role='emetteur' endif
and I had this error message :
Invalid expression body 'if
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
Syn.redefinitionRefDescSyn.direction='IN' then self.role='receveur' else
self.role='emetteur' endif'. Cause: Invalid expression body 'if
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
Syn.redefinitionRefDescSyn.direction='IN' then self.role='receveur' else
self.role='emetteur' endif'. Cause: ERROR in (operationCallExpCS): (Cannot
find operation (=(String)) for the type (Sequence(Direction)))
thank you very much !!!

"Christian W. Damus" <cdamus@ca.ibm.com> a
  • Attachment: model.jpeg
    (Size: 75.33KB, Downloaded 310 times)
Re: check an attribute [message #37479 is a reply to message #37445] Thu, 20 September 2007 14:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Briand,

I see. "Direction" is an enumeration type, so you need to reference its
literal values by name:

if
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePortSyn.redefinitionRefDescSyn.direction=Directi on::IN
then
self.role='receveur'
else
self.role='emetteur'
endif

HTH,

Christian

briand wrote:

> hi,
> here a little more explanations ! to see the drawing
> The ExtremiteConnRepresentation class represents a connection between
> nodes (diagram gmf) and ExtremiteConnexion.role is a label.
> when I create my connection, I want to initialize my
> ExtremiteConnexion.role with 'emetteur' or ' receveur' according to
> InterfaceSimple.direction ! if direction='IN' then role='receveur' else
> role='emetteur' I try this :
> context ExtremiteConnRepresentation
> if
>
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
> Syn.redefinitionRefDescSyn.direction='IN' then self.role='receveur' else
> self.role='emetteur' endif
> and I had this error message :
> Invalid expression body 'if
>
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
> Syn.redefinitionRefDescSyn.direction='IN' then self.role='receveur' else
> self.role='emetteur' endif'. Cause: Invalid expression body 'if
>
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
> Syn.redefinitionRefDescSyn.direction='IN' then self.role='receveur' else
> self.role='emetteur' endif'. Cause: ERROR in (operationCallExpCS): (Cannot
> find operation (=(String)) for the type (Sequence(Direction)))
> thank you very much !!!
>
> "Christian W. Damus" <cdamus@ca.ibm.com> a �rit dans le message de
> news:fcrism$bc$1@build.eclipse.org...
>> Hi, Briand,
>>
>> Sorry, what is your question?
>>
>> You want to do something with a label, but I don't know what a label is
>> or
>> how OCL is supposed to fit into this picture. Are you looking to do
>> something like:
>>
>> context Port::label : String
>> init: if self.Direction = ' IN' then ' receveur' else ' emmetter'
>> endif
>>
>> assuming that the Direction may only have one of these two values.
> However,
>> this sounds like a case where a derived attribute is more useful:
>>
>> context Port::label : String
>> derive: if self.Direction = ' IN' then ' receveur' else ' emmetter'
> endif
>>
>> Cheers,
>>
>> Christian
>>
>>
>> briand wrote:
>>
>> > hi,
>> > I will like to initialize a label with the string ' emmetteur' or '
>> > receveur' by testing the value of an attribute.
>> > Class : Port Attribute : Direction .
>> > If Direction = ' IN' the label takes the value ' receveur'
>> > If Direction = ' OUT' the label takes the value ' emmetteur'
>> > thank you
>>
Re: check an attribute [message #37514 is a reply to message #37479] Thu, 20 September 2007 20:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: briandwilliam.hotmail.com

thank you for your assistance but it always has an error !

error :

Invalid expression body 'if
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
Syn.redefinitionRefDescSyn.direction=Direction::IN then self.role='receveur'
else self.role='emetteur' endif
'. Cause: Invalid expression body 'if
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
Syn.redefinitionRefDescSyn.direction=Direction::IN then self.role='receveur'
else self.role='emetteur' endif
'. Cause: ERROR in (operationCallExpCS): (Cannot find operation
(=(Direction)) for the type (Sequence(Direction)))




"Christian W. Damus" <cdamus@ca.ibm.com> a
Re: check an attribute [message #37545 is a reply to message #37514] Thu, 20 September 2007 21:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Briand,

Right. The problem is, that (evidently) the following expression results in
a collection of Direction values:

self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePortSyn.redefinitionRefDescSyn.direction

because at least one of the following properties has multiplicity many (is
collection-valued):

- redefinitionAccrochePort
- contenu
- redefinitionDescripteurDeReferencePortSyn
- redefinitionRefDescSyn

Apply the "." operator to navigate the property of a collection value
implicitly iterates the collection using the "collect" iterator, so that
the result is another collection.

You will need to do either:

self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePortSyn.redefinitionRefDescSyn.direction- >forAll(d
| d = Direction::IN)

to assert that all directions are "in" or, if you expect that there will
only be one direction in the collection value:

self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePortSyn.redefinitionRefDescSyn.direction- >first()
= Direction::IN

HTH,

Christian


briand wrote:

> thank you for your assistance but it always has an error !
>
> error :
>
> Invalid expression body 'if
>
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
> Syn.redefinitionRefDescSyn.direction=Direction::IN then
> self.role='receveur' else self.role='emetteur' endif
> '. Cause: Invalid expression body 'if
>
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
> Syn.redefinitionRefDescSyn.direction=Direction::IN then
> self.role='receveur' else self.role='emetteur' endif
> '. Cause: ERROR in (operationCallExpCS): (Cannot find operation
> (=(Direction)) for the type (Sequence(Direction)))
>

------8<------
Re: check an attribute [message #37632 is a reply to message #37545] Sat, 22 September 2007 09:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: briandwilliam.hotmail.com

thank you the constraint is now valid ! I start to understand the mechanism
of ocl ...
this constraint is defined on a connection (ExtremiteConnRepresentation),
my connection does not appear on the diagram !
however it appears in the model !!! and the role property is not defined
????
I manage to go up the ascent of associations ! so it would seem that all is
correct !?

how can I solve the problem ??? with the debbugger ? while checking
point-to-point ?
thanks

Christian W. Damus" <cdamus@ca.ibm.com> a
Re: check an attribute [message #37940 is a reply to message #37632] Mon, 24 September 2007 14:03 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Briand,

If you are having trouble with specifying connections in your UML model, you
might rather try asking about that in the UML newsgroup
(eclipse.modeling.mdt.uml2). If it is a problem of the UML2 Tools diagram
editor not creating your connections correctly, then you should ask about
it in that newsgroup (eclipse.modeling.mdt.uml2tools).

Otherwise, the MDT OCL component doesn't offer any debugging support beyond
what JDT provides. Debugging aids are in the scope of the OCL Tools
component, but the only such aid available there (perhaps soon) is Miguel's
AST View.

Cheers,

Christian


briand wrote:

> thank you the constraint is now valid ! I start to understand the
> mechanism of ocl ...
> this constraint is defined on a connection (ExtremiteConnRepresentation),
> my connection does not appear on the diagram !
> however it appears in the model !!! and the role property is not defined
> ????
> I manage to go up the ascent of associations ! so it would seem that all
> is correct !?
>
> how can I solve the problem ??? with the debbugger ? while checking
> point-to-point ?
> thanks
>
> Christian W. Damus" <cdamus@ca.ibm.com> a �rit dans le message de
> news:fcup7m$lvs$1@build.eclipse.org...
>> Hi, Briand,
>>
>> Right. The problem is, that (evidently) the following expression results
> in
>> a collection of Direction values:
>>
>>
>
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
> Syn.redefinitionRefDescSyn.direction
>>
>> because at least one of the following properties has multiplicity many
>> (is collection-valued):
>>
>> - redefinitionAccrochePort
>> - contenu
>> - redefinitionDescripteurDeReferencePortSyn
>> - redefinitionRefDescSyn
>>
>> Apply the "." operator to navigate the property of a collection value
>> implicitly iterates the collection using the "collect" iterator, so that
>> the result is another collection.
>>
>> You will need to do either:
>>
>>
>
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
> Syn.redefinitionRefDescSyn.direction->forAll(d
>> | d = Direction::IN)
>>
>> to assert that all directions are "in" or, if you expect that there will
>> only be one direction in the collection value:
>>
>>
>
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
> Syn.redefinitionRefDescSyn.direction->first()
>> = Direction::IN
>>
>> HTH,
>>
>> Christian
>>
>>
>> briand wrote:
>>
>> > thank you for your assistance but it always has an error !
>> >
>> > error :
>> >
>> > Invalid expression body 'if
>> >
>>
>
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
>> > Syn.redefinitionRefDescSyn.direction=Direction::IN then
>> > self.role='receveur' else self.role='emetteur' endif
>> > '. Cause: Invalid expression body 'if
>> >
>>
>
self.redefinitionAccrochePort.contenu.redefinitionDescripteu rDeReferencePort
>> > Syn.redefinitionRefDescSyn.direction=Direction::IN then
>> > self.role='receveur' else self.role='emetteur' endif
>> > '. Cause: ERROR in (operationCallExpCS): (Cannot find operation
>> > (=(Direction)) for the type (Sequence(Direction)))
>> >
>>
>> ------8<------
Previous Topic:VariableExp and "UMLVariable"
Next Topic:beginner questions: what is best practice to implement EMF derived methods with OCL
Goto Forum:
  


Current Time: Wed Sep 18 19:27:02 GMT 2024

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

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

Back to the top