Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Parsing problem.
Parsing problem. [message #31769] Tue, 03 July 2007 13:30 Go to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
Hi all, I am working on some rules for a UML profile (constraints on
stereotypes), and can't seem to get this one right.

Let me explain the situation. The desired rule would be (in text):

"A component with this stereotype cannot use interfaces directly".

Ok, so, now in OCL. I will try to write it not so concise so that it can
be easily understood. Part A, B, and C are not in the code, I'm placing
them here so I can refer to each one independently. Context= the
stereotype applied to Component:

(Part A)
let d: Set(Dependency) = self.base_Component.clientDependency->select(e
| e.oclIsKindOf(Usage))

(Part B)
in let j: Set(Dependency) = d->select(supplier.oclIsKindOf(Interface))

(Part C)
in j->isEmpty()


That is one way of writing it, isn't it?, at least I thought it was.
However, I get a "Error... Iteration expression body must be a boolean
expresion..." (sorry I'm not thorough in the error message, but my IDE
doesn't let me copy it).

So, going through it piece by piece:
"Part A" is Ok, I think. At least it parses with no errors.
"Part C" is so simple, it can be wrong.
"Part B". Well, here is the problem. I get that
"supplier.oclIsKindOf(Interface)" is not a boolean expression!!.

Correct me if I'm wrong, but I am standing in a Set of Dependency, I get
each Dependency and ask if it's "supplier" role (an instance of
"NamedElement") is of the type or subtype of Interface, am I right?.

I don't see my mistake here. Perhaps I'm just too submerged on the
subject to see it.

I hope someone can enlighten me.
Thank you,
Juan Pedro
Re: Parsing problem. [message #31804 is a reply to message #31769] Tue, 03 July 2007 14:43 Go to previous messageGo to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
Sorry, I maid a mess. I should have said that LABELS "PartA", "Part B",
and "Part C" were not in the text.
The rest is fine.


Juan Pedro Silva escribió:
> Hi all, I am working on some rules for a UML profile (constraints on
> stereotypes), and can't seem to get this one right.
>
> Let me explain the situation. The desired rule would be (in text):
>
> "A component with this stereotype cannot use interfaces directly".
>
> Ok, so, now in OCL. I will try to write it not so concise so that it can
> be easily understood. Part A, B, and C are not in the code, I'm placing
> them here so I can refer to each one independently. Context= the
> stereotype applied to Component:
>
> (Part A)
> let d: Set(Dependency) = self.base_Component.clientDependency->select(e
> | e.oclIsKindOf(Usage))
>
> (Part B)
> in let j: Set(Dependency) = d->select(supplier.oclIsKindOf(Interface))
>
> (Part C)
> in j->isEmpty()
>
>
> That is one way of writing it, isn't it?, at least I thought it was.
> However, I get a "Error... Iteration expression body must be a boolean
> expresion..." (sorry I'm not thorough in the error message, but my IDE
> doesn't let me copy it).
>
> So, going through it piece by piece:
> "Part A" is Ok, I think. At least it parses with no errors.
> "Part C" is so simple, it can be wrong.
> "Part B". Well, here is the problem. I get that
> "supplier.oclIsKindOf(Interface)" is not a boolean expression!!.
>
> Correct me if I'm wrong, but I am standing in a Set of Dependency, I get
> each Dependency and ask if it's "supplier" role (an instance of
> "NamedElement") is of the type or subtype of Interface, am I right?.
>
> I don't see my mistake here. Perhaps I'm just too submerged on the
> subject to see it.
>
> I hope someone can enlighten me.
> Thank you,
> Juan Pedro
>
Re: Parsing problem. [message #31912 is a reply to message #31769] Wed, 04 July 2007 15:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Juan Pedro,

The problem with Part B is that the "supplier" property is multi-valued.
Thus,

supplier.oclIsKindOf(Interface)

is an abbreviation of

supplier->collect(e | e.oclIsKindOf(Interface))

which type is a collection of Booleans, not a Boolean.

Try this, instead:

in let j: Set(Dependency) = d->select(
supplier->exists(e | e.oclIsKindOf(Interface)))

HTH,

Christian


Juan Pedro Silva wrote:

> Hi all, I am working on some rules for a UML profile (constraints on
> stereotypes), and can't seem to get this one right.
>
> Let me explain the situation. The desired rule would be (in text):
>
> "A component with this stereotype cannot use interfaces directly".
>
> Ok, so, now in OCL. I will try to write it not so concise so that it can
> be easily understood. Part A, B, and C are not in the code, I'm placing
> them here so I can refer to each one independently. Context= the
> stereotype applied to Component:
>
> (Part A)
> let d: Set(Dependency) = self.base_Component.clientDependency->select(e
> | e.oclIsKindOf(Usage))
>
> (Part B)
> in let j: Set(Dependency) = d->select(supplier.oclIsKindOf(Interface))
>
> (Part C)
> in j->isEmpty()
>
>
> That is one way of writing it, isn't it?, at least I thought it was.
> However, I get a "Error... Iteration expression body must be a boolean
> expresion..." (sorry I'm not thorough in the error message, but my IDE
> doesn't let me copy it).
>
> So, going through it piece by piece:
> "Part A" is Ok, I think. At least it parses with no errors.
> "Part C" is so simple, it can be wrong.
> "Part B". Well, here is the problem. I get that
> "supplier.oclIsKindOf(Interface)" is not a boolean expression!!.
>
> Correct me if I'm wrong, but I am standing in a Set of Dependency, I get
> each Dependency and ask if it's "supplier" role (an instance of
> "NamedElement") is of the type or subtype of Interface, am I right?.
>
> I don't see my mistake here. Perhaps I'm just too submerged on the
> subject to see it.
>
> I hope someone can enlighten me.
> Thank you,
> Juan Pedro
Re: Parsing problem. [message #32017 is a reply to message #31912] Thu, 05 July 2007 15:06 Go to previous messageGo to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
Christian, as usual, you couldn't be more right.
And yes, I was just too submerged on the
subject to see it.. :-)
Thank you very much.
Regards,
Juan Pedro

Christian W. Damus escribió:
> Hi, Juan Pedro,
>
> The problem with Part B is that the "supplier" property is multi-valued.
> Thus,
>
> supplier.oclIsKindOf(Interface)
>
> is an abbreviation of
>
> supplier->collect(e | e.oclIsKindOf(Interface))
>
> which type is a collection of Booleans, not a Boolean.
>
> Try this, instead:
>
> in let j: Set(Dependency) = d->select(
> supplier->exists(e | e.oclIsKindOf(Interface)))
>
> HTH,
>
> Christian
>
>
> Juan Pedro Silva wrote:
>
>> Hi all, I am working on some rules for a UML profile (constraints on
>> stereotypes), and can't seem to get this one right.
>>
>> Let me explain the situation. The desired rule would be (in text):
>>
>> "A component with this stereotype cannot use interfaces directly".
>>
>> Ok, so, now in OCL. I will try to write it not so concise so that it can
>> be easily understood. Part A, B, and C are not in the code, I'm placing
>> them here so I can refer to each one independently. Context= the
>> stereotype applied to Component:
>>
>> (Part A)
>> let d: Set(Dependency) = self.base_Component.clientDependency->select(e
>> | e.oclIsKindOf(Usage))
>>
>> (Part B)
>> in let j: Set(Dependency) = d->select(supplier.oclIsKindOf(Interface))
>>
>> (Part C)
>> in j->isEmpty()
>>
>>
>> That is one way of writing it, isn't it?, at least I thought it was.
>> However, I get a "Error... Iteration expression body must be a boolean
>> expresion..." (sorry I'm not thorough in the error message, but my IDE
>> doesn't let me copy it).
>>
>> So, going through it piece by piece:
>> "Part A" is Ok, I think. At least it parses with no errors.
>> "Part C" is so simple, it can be wrong.
>> "Part B". Well, here is the problem. I get that
>> "supplier.oclIsKindOf(Interface)" is not a boolean expression!!.
>>
>> Correct me if I'm wrong, but I am standing in a Set of Dependency, I get
>> each Dependency and ask if it's "supplier" role (an instance of
>> "NamedElement") is of the type or subtype of Interface, am I right?.
>>
>> I don't see my mistake here. Perhaps I'm just too submerged on the
>> subject to see it.
>>
>> I hope someone can enlighten me.
>> Thank you,
>> Juan Pedro
>
Re: Parsing problem. [message #32052 is a reply to message #32017] Thu, 05 July 2007 16:02 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Juan Pedro Silva wrote:

> Christian, as usual, you couldn't be more right.

heh heh ... only because I happen to be very familiar with the UML metamodel
and have actually seen this problem before. :-)

> And yes, I was just too submerged on the
> subject to see it.. :-)
> Thank you very much.

You're most welcome.

cW

> Regards,
> Juan Pedro

<snip>
Previous Topic:problem with multiStatus
Next Topic:regex/ocl
Goto Forum:
  


Current Time: Sun Nov 23 21:35:55 GMT 2014

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

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