Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » syntax of this ocl expression
syntax of this ocl expression [message #66799] Mon, 09 February 2009 12:34 Go to next message
Eclipse UserFriend
Originally posted by: Sven.T.gmail.com

Hello,

I want to make sure that the parameters of an UML Operation is the same as
those defined in the UML ParameterNode of an UML Acitivity.

I am using OCL in conjunction with UML2. I attached this OCL constraint to
the UML model.
The context is UML Operation; it's an invariant, written in the body of an
Opaque Expression:

method [0..*] and nodes [0..*] are sets. I wrote the following expression:

ownedParameter = self.method->collect (act |
act.oclIsKindOf(Activity))->select (a | a.node)->select(b |
b.oclIsKindOf(ActivityParameterNode)).Parameter

But the OCL parser won't evaluate this expression. It also shows no error
message so I don't know where the error is actually located.

Hope, someone can help me out.


Regards,


Sven
Re: syntax of this ocl expression [message #67398 is a reply to message #66799] Mon, 09 February 2009 16:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Sven,

I don't know how you are parsing the expression, in particular what the
context classifier is or what UI component is doing the parsing, but you
can be certain that the OCL parser is producing a more-or-less useful
error message.

Probably the Activity property containing its parameters is not named
"Parameter" but rather "parameter". Another problem is that this
expression iterates all of the methods of the operation, so even if none
of the activities individually have all of the required parameters but
in combination all of the parameters are covered, then the constraint
will pass, though it shouldn't. Finally, I think the ownedParameter
collection is ordered, but the nodes of an activity are not, so the
collections aren't really comparable.

Try this, instead:

self.method->forAll(act | act.oclIsKindOf(Activity) implies
act.oclAsType(Activity).node->select(
oclIsKindOf(ActivityParameterNode))->collect(node |
node.oclAsType(ActivityParameterNode).parameter)->asBag() =
self.owedParameter->asBag())

This ensures that, regardless of ordering, every activity that is a
method of the operation has exactly one parameter node for each
operation parameter, no more and no less (the bag counts replication).

HTH,

Christian

Sven Trehner wrote:
> Hello,
>
> I want to make sure that the parameters of an UML Operation is the same
> as those defined in the UML ParameterNode of an UML Acitivity.
>
> I am using OCL in conjunction with UML2. I attached this OCL constraint
> to the UML model.
> The context is UML Operation; it's an invariant, written in the body of
> an Opaque Expression:
>
> method [0..*] and nodes [0..*] are sets. I wrote the following expression:
>
> ownedParameter = self.method->collect (act |
> act.oclIsKindOf(Activity))->select (a | a.node)->select(b |
> b.oclIsKindOf(ActivityParameterNode)).Parameter
>
> But the OCL parser won't evaluate this expression. It also shows no
> error message so I don't know where the error is actually located.
>
> Hope, someone can help me out.
>
>
> Regards,
>
>
> Sven
Re: syntax of this ocl expression [message #67478 is a reply to message #67398] Tue, 10 February 2009 12:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Sven.T.gmail.com

Hi Christian,

Comments below:


> I don't know how you are parsing the expression, in particular what the
> context classifier is or what UI component is doing the parsing, but you
> can be certain that the OCL parser is producing a more-or-less useful
> error message.

I am using OCL with UML2-codegen. I forgot to insert the Error view in my
new generated and extended uml2 editor. The error messages are being
displayed there.

> Try this, instead:
> ....node.oclAsType(ActivityParameterNode).parameter)->asBag() =
> self.owedParameter->asBag())

I had to insert "n" in ownedParameter but then it worked perfectly !

Thanks Christian for your explanations and corrected OCL Constraint!
The OCL constraint is exactly doing what I want.

Regards,

Sven
Re: syntax of this ocl expression [message #67498 is a reply to message #67478] Tue, 10 February 2009 14:36 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Sven,

Splendid! I'm glad it's working for you.

I guess you see how well I test that OCL snippets that I suggest in this
newsgroup! :-( I promise that I do better testing of the OCL code. :-D

cW

Sven Trehner wrote:
>
> Hi Christian,
>
> Comments below:
>
>
>> I don't know how you are parsing the expression, in particular what
>> the context classifier is or what UI component is doing the parsing,
>> but you can be certain that the OCL parser is producing a more-or-less
>> useful error message.
>
> I am using OCL with UML2-codegen. I forgot to insert the Error view in
> my new generated and extended uml2 editor. The error messages are being
> displayed there.
>
>> Try this, instead:
>> ....node.oclAsType(ActivityParameterNode).parameter)->asBag() =
>> self.owedParameter->asBag())
>
> I had to insert "n" in ownedParameter but then it worked perfectly !
>
> Thanks Christian for your explanations and corrected OCL Constraint!
> The OCL constraint is exactly doing what I want.
>
> Regards,
>
> Sven
>
>
>
>
Previous Topic:execute ocl query that is not boolean expression
Next Topic:[Announce] MDT OCL 1.2.3RC2 is available
Goto Forum:
  


Current Time: Fri Apr 19 03:03:33 GMT 2024

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

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

Back to the top