Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » qualified association returns object instead of collection
qualified association returns object instead of collection [message #1267146] Sat, 08 March 2014 14:40 Go to next message
Pieter Martin is currently offline Pieter MartinFriend
Messages: 37
Registered: July 2013
Member
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 #1271325 is a reply to message #1267146] Fri, 14 March 2014 21:03 Go to previous messageGo to next message
Pieter Martin is currently offline Pieter MartinFriend
Messages: 37
Registered: July 2013
Member
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



Re: qualified association returns object instead of collection [message #1271511 is a reply to message #1271325] Sat, 15 March 2014 10:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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
>
>
>
>
Re: qualified association returns object instead of collection [message #1271528 is a reply to message #1271511] Sat, 15 March 2014 11:53 Go to previous message
Pieter Martin is currently offline Pieter MartinFriend
Messages: 37
Registered: July 2013
Member
Hi,

Done https://bugs.eclipse.org/bugs/show_bug.cgi?id=430439

Regards
Pieter
Previous Topic:Is nsURI for Pivot Package elements mandatory?
Next Topic:ocl for reflexive associationclass navigation bug
Goto Forum:
  


Current Time: Tue Mar 19 02:37:11 GMT 2024

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

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

Back to the top