|
|
Re: qualified association returns object instead of collection [message #1271511 is a reply to message #1271325] |
Sat, 15 March 2014 10:39 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
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.06594 seconds