Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Validation Problems of OCL Constraints contained in a static UML Profile
Validation Problems of OCL Constraints contained in a static UML Profile [message #1755250] Wed, 01 March 2017 16:43 Go to next message
Alexander Kraas is currently offline Alexander KraasFriend
Messages: 9
Registered: March 2015
Junior Member
Dear community,

at the moment, I always run into a validation problem for UML model that has applied a "static" UML Profile applied. The UML Profile contains many OCL constraints that make use of the implicit defined associations (base_MetaclassName or extension_StereotypeName) between Stereotype and UML element instances. The vaildation is realized with ValidationDelegates of OCL Pivot.

For instance, when I use the XTextConsole to validate the OCL Expression below, I get the expected result.
self.extension_TestStereotype.taggedValue->notEmpty() 


But, when this expression is used to define a OCL Constraint for a Stereotype contained in a "static" UML Profile, the validation fails with the following exception:
org.eclipse.ocl.pivot.internal.delegate.OCLDelegateException: The 'TestStereotype::Constraint_1' constraint result is invalid for 'TestStereotype'
 - Unable to resolve stereotype TestProfile::TestStereotype
	at org.eclipse.ocl.pivot.internal.delegate.OCLValidationDelegate$CheckingConstraintEvaluator.handleInvalidResult(OCLValidationDelegate.java:116)...


Due to the raised exception, I assume that a problem concerning the "extension_xxx" navigation to Stereotype instances may exist in the ValidationDelegate of OCL Pivot. I am wondering if someone else had a similar problem and could provide a hint for avoiding this problem. For testing purposes, I have attached a small example including a "static" UML Profile that contains only one Stereotype.

Thank you in advance,
Alexander

[Updated on: Wed, 01 March 2017 16:45]

Report message to a moderator

Re: Validation Problems of OCL Constraints contained in a static UML Profile [message #1755259 is a reply to message #1755250] Wed, 01 March 2017 17:44 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5834
Registered: July 2009
Senior Member
Hi

Thanks for the repro. It's always nice to see the problem without a game of ping pong.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=512910 raised

Looks like a new configuration path bug. Only workaround I can suggest is to not use a static profile.

Regards

Ed Willink
Re: Validation Problems of OCL Constraints contained in a static UML Profile [message #1755321 is a reply to message #1755259] Thu, 02 March 2017 10:41 Go to previous messageGo to next message
Alexander Kraas is currently offline Alexander KraasFriend
Messages: 9
Registered: March 2015
Junior Member
Hi Ed,

thank you for the quick feedback. According to your given advice to use a "dynamic" UML Profile, I conclude that a bug fix for the raised issue is a little bit more complex. Since I have also to add a small number of Java-defined Operations to my UML Profile, the "dynamic" variant is no good solution. However, as far as I have understood the concept of Pivot OCL, I should also have the ability to use a "custom" stdlib that extends the existing stdlib. Due to the limited documentation concerning this extension mechanism, I am wondering if a clean way to implement and to deploy my own "custom" lib exists. In other words; Is it possible to implement a "custom" lib as a dedicated Eclipse plugin, without altering the "org.eclipse.ocl.pivot" plugin?

Best regards,
Alexander
Re: Validation Problems of OCL Constraints contained in a static UML Profile [message #1755324 is a reply to message #1755321] Thu, 02 March 2017 10:50 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5834
Registered: July 2009
Senior Member
Hi

I don't think the fix is too hard. I had an initial look, but need to progress an ICMT submission first. Might get a fix done today. Main challenge is resolving whether there are other places awaiting the same bug discovery / fix.

A custom stdlib is an option, but when I started writing a tutorial demonstrating a math.oclstdlib, I found too many bugs to be able to promote this as a working functionality.

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

Regards

Ed Willink
Re: Validation Problems of OCL Constraints contained in a static UML Profile [message #1755336 is a reply to message #1755324] Thu, 02 March 2017 12:28 Go to previous messageGo to next message
Alexander Kraas is currently offline Alexander KraasFriend
Messages: 9
Registered: March 2015
Junior Member
Hi Ed,

due to your given response, meanwhile I have found a "quick-fix" solution that works for me at the moment, although this is not a perfect solution Wink However, just for your Information, I have attached the inserted code snipped below.

Thank you for your support!

Best regards,
Alexander

BTW: Interesting to know that also the Deadline for the ICMT conference is postponed untill 5th March.

public static @Nullable Object /*UMLElementExtension*/ getUMLElementExtension(@NonNull Stereotype staticType, org.eclipse.uml2.uml.@NonNull Element umlElement) {
	EObject eTarget = staticType.getESObject();

	// Begin of inserted code
	if ( !(eTarget instanceof org.eclipse.uml2.uml.Stereotype)) {
		ResourceSet rset = umlElement.eResource().getResourceSet();
		String qualifiedName = staticType.getOwningPackage().getName() +"::"+staticType.getName();

		for (org.eclipse.uml2.uml.NamedElement newTarget : UMLUtil.findNamedElements(rset, qualifiedName)) {
			if (newTarget instanceof org.eclipse.uml2.uml.Stereotype)
				eTarget = newTarget;
				break;
		}
	}
	// End of insertion
	if (eTarget instanceof org.eclipse.uml2.uml.Stereotype) {
	....
Re: Validation Problems of OCL Constraints contained in a static UML Profile [message #1755337 is a reply to message #1755336] Thu, 02 March 2017 12:56 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5834
Registered: July 2009
Senior Member
Hi

Good that you have a fix. It's something like what I was thinking of, but when working with a static profile, is it correct to load the dynamic UML in order to understand the static functionality? The Pivot Stereotype that is getUMLElementExtension's first argument is created without relying on any UML model.

Given that in

self.base_Class.extension_TestStereotype.taggedValue.oclAsSet()->notEmpty()

self.base_Class.extension_TestStereotype just does a safe cast of self, you might find that something like

self.oclAsType(testprofile::TestStereotype).taggedValue.oclAsSet()->notEmpty()

also works. I don't think the cast is needed at all.

self.taggedValue <> null

might also be better.

Regards

Ed Willink
Re: Validation Problems of OCL Constraints contained in a static UML Profile [message #1755343 is a reply to message #1755337] Thu, 02 March 2017 13:35 Go to previous messageGo to next message
Alexander Kraas is currently offline Alexander KraasFriend
Messages: 9
Registered: March 2015
Junior Member
Hi Ed,

thank you for the comments concerning my OCL example provided yesterday. You are right that a navigation like "self.base_Class.extension_TestStereotype" makes no sense, but in the case of my example Constraint, it was the easiest way to reproduce the raised issue. Of course, when directly accessing the "taggedValue" attribute of a stereotype instance, then your last mentioned variant "self.taggedValue <> null" is the cleanest way. There is no need for a type-cast at all.

In order to keep track of any changes concerning bug 512910, I have registered me in the "CC List". I hope this is fine for you.

Best regards,
Alexander
Re: Validation Problems of OCL Constraints contained in a static UML Profile [message #1755348 is a reply to message #1755343] Thu, 02 March 2017 14:07 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5834
Registered: July 2009
Senior Member
Hi

Ok, thanks for the clarification and simple repro. I was about to dismiss the problem as too perverse to merit fixing any time soon. Unfortunately extension_TestStereotype is an unnavigable opposite so there will be no alternative to a one-off model search to find all TestStereotype instances and then filter to the one that is an opposite. The code is already there; just needs activating in this UML scenario. One day there could be a more optimized ModelManager.

Regards

Ed Willink
Re: Validation Problems of OCL Constraints contained in a static UML Profile [message #1755424 is a reply to message #1755348] Fri, 03 March 2017 08:59 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5834
Registered: July 2009
Senior Member
Hi

Fixed in http://www.eclipse.org/modeling/download.php?file=/modeling/mdt/ocl/downloads/drops/6.3.0/N201703021118/mdt-ocl-Update-N201703021118.zip

I doubt that there will be another I-build before M6 in two weeks.

Regards

Ed Willink
Re: Validation Problems of OCL Constraints contained in a static UML Profile [message #1755446 is a reply to message #1755424] Fri, 03 March 2017 12:20 Go to previous message
Alexander Kraas is currently offline Alexander KraasFriend
Messages: 9
Registered: March 2015
Junior Member
Hi Ed,

I have successfully tested the new version just before. Your bug-fix works perfect for me.
Thank you for your support.

Best regards,
Alexander
Previous Topic:The 'Property::CompatibleDefaultExpression' constraint is violated for xxxxx
Next Topic:Help with this example?
Goto Forum:
  


Current Time: Thu Apr 19 21:44:24 GMT 2018

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

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