qualified association returns object instead of collection [message #1267146] |
Sat, 08 March 2014 09:40  |
Eclipse User |
|
|
|
Hi,
I have a qualified association Bank [idNumber]<---->[0..1]Customer
The customer property on Bank is qualified by idNumber.
The modelled multiplicity is [0..1] as that is the multiplicity of the qualified association.
However as per the spec,
"The multiplicity of a qualifier is given assuming that the qualifier value is supplied. The "raw" multiplicity without the
qualifier is assumed to be 0..*."
So the unqualified multiplicity of Bank.customer is many.
I expect on context Bank that the ocl expression "self.customer" should return a collection of some type.
However it returns a Customer object instead as tho the multiplicity is 1,
Is this a bug or am I missing something.
This is using the old ocl parser. i.e. not xtext's parsers.
Thanks
Pieter
|
|
|
|
Re: qualified association returns object instead of collection [message #1271511 is a reply to message #1271325] |
Sat, 15 March 2014 06:39   |
Eclipse User |
|
|
|
Hi
Unfortunately the UML tooling for qualified associations is poor.
Neither the old UML2 Tools nor the new papyrus support them, so creating
them is a bit hard.
I don't fully understand the model staructures. Providing a first class
Map syntax in OCLinEcore has been planned for a long time, but ... not
enough roundtuits.
You may well be right that the test example is wrong. But it seems that
you can at least fudge it for now with a wrong multiplicity. (This
almost certainly does not work at all yet with the PIvot OCL.) Please
raise a Bugzilla so that I eventually get round to studying it.
Regards
Ed Willink
On 14/03/2014 21:03, Pieter Martin wrote:
> Hi,
>
> I had a look at the test cases for this.
>
> In particular in AssociationTest
>
>
> /**
> * Tests that the result of qualifying an association navigation is a
> * scalar value (not a collection).
> */
> public void test_qualifiedAssociation_scalar_133435() {
> // unqualified navigation
> OCLExpression<Classifier> expr = parse(
> "package ocltest context Forest " +
> "inv: self.trees" +
> " endpackage");
>
> assertTrue(expr.getType() instanceof CollectionType);
> CollectionType collType = (CollectionType) expr.getType();
> assertSame(tree, collType.getElementType());
>
> // qualified navigation
> expr = parse(
> "package ocltest context Forest " +
> "inv: self.trees['foo', 3]" +
> " endpackage");
>
> assertSame(tree, expr.getType());
> }
>
>
> This tests exactly the issue I was trying to convey.
> And the test passes, however I noticed that the qualified property
> ocltest::Forest::trees has a multiplicity of [0..*]
>
> My understanding is that its multiplicity should be [0..1]. From the
> UML 2.4.1 spec it says
> Quote:
>> Given a qualified object and a qualifier instance, the number of
>> objects at the other end of the
>> association is constrained by the declared multiplicity. In the
>> common case in which the multiplicity is 0..1, the qualifier
>> value is unique with respect to the qualified object, and designates
>> at most one associated object.
>
>
> So does this mean the multiplicity in the OCLTest.uml Forest::trees
> should be [0..1] or have a missed something?
>
> Thanks
> Pieter
>
>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.04768 seconds