Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Validation of property access in post-conditions of UML static operations
Validation of property access in post-conditions of UML static operations [message #1747478] Tue, 15 November 2016 10:21 Go to next message
German Vega is currently offline German VegaFriend
Messages: 104
Registered: December 2015
Location: Grenoble, France
Senior Member
Hello

I am using OCL to specify post-conditions of UML operations declared static.

I would expect that in this case access to the self variable should not be allowed, and that I can only access static properties and operations (queries) using the qualified name syntax (class::property).

I have made a small test (attached) and noticed that these validations are not performed.

I don't know if these validations are explicitly specified in OCL, so I don't know if this is a bug or a Request For Enhancement.

In the meantime, I would like to know if it is possible to easily add (via an extension point, for instance) my own additional well-formedness rules to the OCL validation (the one invoked via the Papyrus menu Validation->Validate model)

Thanks

German Vega
  • Attachment: test.uml
    (Size: 3.02KB, Downloaded 369 times)
Re: Validation of property access in post-conditions of UML static operations [message #1747485 is a reply to message #1747478] Tue, 15 November 2016 11:04 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

"static" was added in OCL 2.2 as an intuitively obvious necessity for UML alignment, but without any consideration as to what it might mean in practice. e.g. is the PropertyCallExp source null or the class? How are ambiguous names resolved? Implementations are therefore also intuitive. Eclipse OCL has plausible "static" parsing but dubious evaluation that may improve if this thread provokes a sensible Bugzilla. A significant problem is that while UML and Java may support static concepts, Ecore does not and so the UML2Ecore2Java conversion that precedes evaluation loses "static".

NB the Eclipse OCL support for post-conditions is for parsing only. There is no evaluation support.

You should be able to extend the validation by loading a *.ocl document. See the Complete OCL tutorial.

Regards

Ed Willink
Re: Validation of property access in post-conditions of UML static operations [message #1747488 is a reply to message #1747485] Tue, 15 November 2016 12:10 Go to previous messageGo to next message
German Vega is currently offline German VegaFriend
Messages: 104
Registered: December 2015
Location: Grenoble, France
Senior Member
Hi

Thanks Ed for your prompt response, as always.

Quote:

Eclipse OCL has plausible "static" parsing but dubious evaluation that may improve if this thread provokes a sensible Bugzilla. A significant problem is that while UML and Java may support static concepts, Ecore does not and so the UML2Ecore2Java conversion that precedes evaluation loses "static".

NB the Eclipse OCL support for post-conditions is for parsing only. There is no evaluation support.


OK, I Understand. Actually I am just interested in parsing, not evaluation

Quote:

You should be able to extend the validation by loading a *.ocl document. See the Complete OCL tutorial.


Ok, I have managed to load a complete OCl document to add validations. I can navigate the UML model, but I don't know how to get the parsed OCl constraint.

Currently I have tried something like this

import uml:'http://www.eclipse.org/uml2/5.0.0/UML'


context uml::Operation

inv staticOperation: self.isStatic implies self.postcondition->forAll( c: Constraint |
	c.specification.oclAsType(OpaqueExpression)._'body' ????? don't know how to get the parsed constraint 
)


But the "body" of a OpaqueExpression is a String, and I need the parsed OCL expression, in order to check for PropertyCallExp expressions.

Is there a simple way to get to the parsed constraint?

Thanks

German
Re: Validation of property access in post-conditions of UML static operations [message #1747502 is a reply to message #1747488] Tue, 15 November 2016 13:59 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

In UML, you have "OpaqueExpression.body : String" and that's it.

In the Pivot OCL ExpressionInOCL extends OpaqueExpression and provides "ExpressionInOCL.ownedBody : OCLExpression", which is lazily initialized from the underlying string.

You will have to provide some kind of Java helper that uses MetamodelManager.getAsOf(...) to convert the UML string to the Pivot OCL tree. This could be generally useful but is perhaps the first challenge for 'how do we add OCL utility functions for use in UML?'. Alternatively we just have to add the "String::oclParse() : ExpressionInOCL" and/or "ExpressionInOCL::exec(args : Sequence(OclAny)) : OclAny" functions to the OCL standard library. Probably need to provide some inspection of an 'invalid' return to get at the error details.

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=507539, which I'm unlikely to look at any time soon. If you're interested, have a look at the implementation of OclAny::oclLog().

Regards

Ed Willink
Re: Validation of property access in post-conditions of UML static operations [message #1747504 is a reply to message #1747502] Tue, 15 November 2016 14:22 Go to previous messageGo to next message
German Vega is currently offline German VegaFriend
Messages: 104
Registered: December 2015
Location: Grenoble, France
Senior Member
Hello

Quote:

In UML, you have "OpaqueExpression.body : String" and that's it.


that's what I feared Sad

Quote:

You will have to provide some kind of Java helper that uses MetamodelManager.getAsOf(...) to convert the UML string to the Pivot OCL tree.


How do I invoke a Java helper method from OCL ?

Thanks

German vega
Re: Validation of property access in post-conditions of UML static operations [message #1747521 is a reply to message #1747504] Tue, 15 November 2016 15:45 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

https://bugs.eclipse.org/bugs/show_bug.cgi?id=394658, almost four years ago, was my original Bugzilla for a direct Java call. Still waiting for a round-tu-it.

In principle it should be easy to add a custom standard library and just before Neon, I started writing a tutorial to address https://bugs.eclipse.org/bugs/show_bug.cgi?id=415146 . My experiences were not satisfactory.

I would go with the oclParse() solution from https://bugs.eclipse.org/bugs/show_bug.cgi?id=507539 .

From Ecore, probably the easiest way is to just have a completely spurious generated class that you write custom methods in. Perhaps "null.oclAsType(CompletelySpurious).doSomethingUseful(withArg1)". Not sure that that extends to UML though.

Regards

Ed Willink

[Updated on: Tue, 15 November 2016 15:51]

Report message to a moderator

Re: Validation of property access in post-conditions of UML static operations [message #1747531 is a reply to message #1747521] Tue, 15 November 2016 16:47 Go to previous message
German Vega is currently offline German VegaFriend
Messages: 104
Registered: December 2015
Location: Grenoble, France
Senior Member
Hello

Well, all the alternatives seem to require a modified OCL standard library, and that is far beyond my reach by now.

As I have mentioned in previous posts, I work in a tool to transform UML constraints in OCL to some formal notation, so my original need was just simply to be sure to have a well-formed OCL constraint before applying the transformation. The tool is integrated with Papyrus, so that's why I asked you about extending the validation model menu.

I think for now I will just program my specific well-formedness rules in Java, and make a validation phase in the transformation that adds problem markers to the project (so that they show up in papyrus views). I should give a try to the OCL to Java generator

Anyway, thanks for the help, I have learnt a lot.

German Vega
Previous Topic:OCL in UML Profile
Next Topic:navigate from a UML class to a UML lifeline/message in an OCL constraint
Goto Forum:
  


Current Time: Fri Apr 19 03:45:15 GMT 2024

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

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

Back to the top