eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

[pivot] A stereotype test case: #1015

Open eclipse-ocl-bot opened 2 weeks ago

eclipse-ocl-bot commented 2 weeks ago

| --- | --- | | Bugzilla Link | 398333 | | Status | NEW | | Importance | P3 normal | | Reported | Jan 16, 2013 16:13 EDT | | Modified | Jan 29, 2015 10:57 EDT | | Reporter | Ed Willink |

Description

From: Jeni Martin on the OCL newsgroup.

I am creating a profile, and my profile has three stereotypes. FR, NFR and Relation. FR and NFR are the extension of metaclass Class and Relation is the extension of metaclass Association. How can i define OCL constraints that says the Relation must be between FR and NFR? (each instance of FR is in relation with 0..* instance(s)of NFR.

eclipse-ocl-bot commented 2 weeks ago

By Ed Willink on Jan 31, 2013 10:53

Created attachment 226388 Demonstration of editab le constraints

Not yet executed.

:compression: Play2.zip

eclipse-ocl-bot commented 2 weeks ago

By Ed Willink on Sep 25, 2014 04:32

Created attachment 247358 Working solution

The attached works successfully in my current workspace, which is Mars M-ish but unlikely to differ significantly from Luna SR1.

The only surprise is that the constraint needs to be e.g.

self.base_Association.memberEnd.class->excluding(null)->exists(extension_FR<>null)

to accommodate Association-owned ends whose ".class" is null.

It would appear that null as an 'instance' of OclVoid conforms to everything and so has all possible stereotype extensions. This doesn't seem right.

Anyway ->excluding(null) is a workaround for now.

Needs resolving and converting to a JUnit test.

Exercising this in the OCL Console is made much harder by Bug 445052.

:compression: Bug398333.zip

eclipse-ocl-bot commented 2 weeks ago

By Rishi Kanth on Jan 29, 2015 10:23

Hi Ed,

The suggested solution works when the stereotype (FR, NFR) extend (using extension) the UML metaclass Class. Then, we have extension_FR and extension_NFR. However, if we define a stereotype, say NFR-Child, thats derived from NFR, then I dont see any extension_NFR-child. Who do we handle this situation ?

Thanks,\ Rishi

eclipse-ocl-bot commented 2 weeks ago

By Ed Willink on Jan 29, 2015 10:57

(In reply to Rishi Kanth from comment #3)

However, if we define a stereotype, say NFR-Child, thats derived from NFR, then I dont see any extension_NFR-child. Who do we handle this situation ?

This area is all at best underspecified and probably unspecified. I get the impression that with Eclipse OCL I am pioneering a typesafe implementation. So what you observe is an implementation design decision that may materialize as part of OCL 2.5.

Obviously NFR-child1 and NFR-child2 are derived from NFR so while extension_NFR can only navigate to one NFR, it may navigate to an unlimited number of different NFR-children stereotypes. This is surprising but unavoidable without severely crippling Stereotype inheritance. The multiplicity of extension_NFR is therefore determined at load-time according to whether there is more than one non-abstract derived NFR stereotype.

Since NFR-child is accessible via extension_NFR, I chose not to provide extension_NFR-child, you must instead do extension_NFR->selectByKind(NFR-child).