Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » accessing uml attributes from queries
accessing uml attributes from queries [message #42037] Wed, 31 October 2007 08:08 Go to next message
Eclipse UserFriend
Originally posted by: krzysztof_kaczmarski.o2.pl

Hi All,

I have a question concerning the OCL standard.
If there is a UML class like:
class Person {
name : String[1..1];
dogs : Dog[0..*];
}

and I want to access these attributes from OCL then
'dogs' are treated like a Collection type... but I noticed in OCL
Console example that 'name' is also treated as a collection.
Am I right?

If it is true, are the flags {ordered} and {unique} taken into
consideration when particular collection type is used resulting in
proper Set, or OrderedSet.. etc types?

Thanks in advance,
Krzysztof
Re: accessing uml attributes from queries [message #42131 is a reply to message #42037] Wed, 31 October 2007 12:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Krzysztof,

Person::name in OCL would have a scalar type, not a collection. I think
this works OK in the MDT OCL implementation. What are you seeing in the
interactive console example that suggests it is a collection type? If you
are navigating to Person through some other association, you may be have an
implicit "collect" iterator that results in a collection. For example,

self.dog.owner.name

might be a collection if the association between the "self" type and Dog is
multivalued.

The {ordered} and {unique} flags determine the collection type for
multiplicity-many features, yes (in the MDT OCL implementation).

Cheers,

Christian


Krzysztof Kaczmarski wrote:

> Hi All,
>
> I have a question concerning the OCL standard.
> If there is a UML class like:
> class Person {
> name : String[1..1];
> dogs : Dog[0..*];
> }
>
> and I want to access these attributes from OCL then
> 'dogs' are treated like a Collection type... but I noticed in OCL
> Console example that 'name' is also treated as a collection.
> Am I right?
>
> If it is true, are the flags {ordered} and {unique} taken into
> consideration when particular collection type is used resulting in
> proper Set, or OrderedSet.. etc types?
>
> Thanks in advance,
> Krzysztof
Re: accessing uml attributes from queries [message #42336 is a reply to message #42131] Wed, 31 October 2007 21:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: krzysztof_kaczmarski.o2.pl

Hi Christian,

maybe this is just my misunderstanding of the suggestions tool.
The class is like:

class A
{
z : Integer[1..1];
}

I open it in a model, set focus to the class A,
select UML and M1.
Now I write 'z.' and I get suggestions connected to Integer type (abs,
etc).
When I write 'z->' I get suggestions as if z is a collection (collect,
sellect, isEmpty, etc.)
And when I write 'z->isEmpty()' I even get 'successfully parsed' message.

Cheers,
Krzysztof


Christian W. Damus wrote:
> Hi, Krzysztof,
>
> Person::name in OCL would have a scalar type, not a collection. I think
> this works OK in the MDT OCL implementation. What are you seeing in the
> interactive console example that suggests it is a collection type? If you
> are navigating to Person through some other association, you may be have an
> implicit "collect" iterator that results in a collection. For example,
>
> self.dog.owner.name
>
> might be a collection if the association between the "self" type and Dog is
> multivalued.
>
> The {ordered} and {unique} flags determine the collection type for
> multiplicity-many features, yes (in the MDT OCL implementation).
>
> Cheers,
>
> Christian
>
>
> Krzysztof Kaczmarski wrote:
>
>> Hi All,
>>
>> I have a question concerning the OCL standard.
>> If there is a UML class like:
>> class Person {
>> name : String[1..1];
>> dogs : Dog[0..*];
>> }
>>
>> and I want to access these attributes from OCL then
>> 'dogs' are treated like a Collection type... but I noticed in OCL
>> Console example that 'name' is also treated as a collection.
>> Am I right?
>>
>> If it is true, are the flags {ordered} and {unique} taken into
>> consideration when particular collection type is used resulting in
>> proper Set, or OrderedSet.. etc types?
>>
>> Thanks in advance,
>> Krzysztof
>
Re: accessing uml attributes from queries [message #42602 is a reply to message #42336] Thu, 01 November 2007 14:38 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Krzysztof,

The -> operator, when applied to a scalar property, coerces it to a Set
type. In the case that 'z' is undefined (null), the result is an empty
set. Otherwise, it is a Set containing the single value of 'z'.

Cheers,

Christian


Krzysztof Kaczmarski wrote:

> Hi Christian,
>
> maybe this is just my misunderstanding of the suggestions tool.
> The class is like:
>
> class A
> {
> z : Integer[1..1];
> }
>
> I open it in a model, set focus to the class A,
> select UML and M1.
> Now I write 'z.' and I get suggestions connected to Integer type (abs,
> etc).
> When I write 'z->' I get suggestions as if z is a collection (collect,
> sellect, isEmpty, etc.)
> And when I write 'z->isEmpty()' I even get 'successfully parsed' message.
>
> Cheers,
> Krzysztof


-----8<-----
Previous Topic:OCL expr as an initializer
Next Topic:[Announce] MDT OCL 1.2.0 I200711021618 is available
Goto Forum:
  


Current Time: Thu Mar 28 13:03:07 GMT 2024

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

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

Back to the top