Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL with a profile applied to itself
OCL with a profile applied to itself [message #1772252] Thu, 07 September 2017 06:59 Go to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 152
Registered: July 2014
Senior Member
I'm working on specifying OCL statements for each constraint defined in the SysML profile (as far as I can, at least).
I use Papyrus together with its OCL integration for that purpose.

This is a very specific context since the SysML profile is applied to one of its own subpackage (SysML::Libraries). Papyrus supports this but it looks like the OCL engine is not that happy with it since it generates flows of errors each time I try to edit an OCL expression.

Errors raised are of the form:

org.eclipse.ocl.pivot.uml.internal.es2as.UML2AS - Missing package for stereotype application of xxx

Where "xxx" is either ValueType or Block (which are the two stereotypes used by the SysML::Libraries)

It's really painful since the Error Log window "pops up" each time and several clicks are required in order to get the focus back on the field where the OCL expression is edited.

How could I fix this?

My current configuration is:
Eclipse 4.6.3 - 20170314-1500
Papyrus v2.0.3.20103080851
OCL SDK v6.3.0. - 20170613-1432

The SysML.uml file I use is attached.
  • Attachment: SysML.uml
    (Size: 392.96KB, Downloaded 377 times)


Yves
Re: OCL with a profile applied to itself [message #1772255 is a reply to message #1772252] Thu, 07 September 2017 07:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Loading your model in the UML Model Editor and then invoking validate gives quite a few warnings which is not encouraging. The UML Model editor totally ignores OCL so the foregoing errors are UML problems which might be significant.

Using OCL->Validate and I get a stack trace including

Root exception:
java.lang.ClassCastException: org.eclipse.ocl.pivot.internal.ecore.es2as.Ecore2AS cannot be cast to org.eclipse.ocl.pivot.uml.internal.es2as.UML2AS
at org.eclipse.ocl.pivot.uml.internal.es2as.UML2AS.getAdapter(UML2AS.java:109)
at org.eclipse.ocl.pivot.uml.internal.validation.UMLOCLEValidator.validate(UMLOCLEValidator.java:261)
at org.eclipse.emf.ecore.util.Diagnostician.doValidate(Diagnostician.java:171)

which is probably closely related to your problem. My recollection is that "Missing package for" is usually the downstream consequence of an earlier loading failure. Did you get a fuller error message (hopefully with the above CCE)?

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

Regards

Ed Willink
Re: OCL with a profile applied to itself [message #1772257 is a reply to message #1772255] Thu, 07 September 2017 07:45 Go to previous messageGo to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 152
Registered: July 2014
Senior Member
Ed,

Thanks for your reply.

Unfortunately, no Exception stack is provided as part of the logged events. But I confirm that I can generate those errors by validating the model. This is the content I get with the "copy to clipboard" facility:

eclipse.buildId=4.6.3.M20170301-0400
java.version=1.8.0_91
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=fr_FR
Framework arguments: -product org.eclipse.epp.package.modeling.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.modeling.product

org.apache.log4j
Error
Thu Sep 07 09:26:09 CEST 2017
org.eclipse.ocl.pivot.uml.internal.es2as.UML2AS - Missing package for stereotype application of ValueType



Yves
Re: OCL with a profile applied to itself [message #1772261 is a reply to message #1772257] Thu, 07 September 2017 08:01 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=521974 identifies the modeling problem as a missing UML URI on the Blocks Package.

Ergonomic issues will be addressed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=521974

(Once your SysML.uml has an interesting amount of embedded OCL content, please attach to a Bugzilla so that I can incorporate it in the OCL regression tests.)

Regards

Ed Willink
Re: OCL with a profile applied to itself [message #1772266 is a reply to message #1772261] Thu, 07 September 2017 09:32 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Your SysML should not exhibit the UML behavior you expect since your nested profiles are Packages.

UML 2.5 12.3.3.3 "Applying a Profile means recursively applying all its nested and imported Profiles."

Regards

Ed Willink
Re: OCL with a profile applied to itself [message #1772298 is a reply to message #1772266] Thu, 07 September 2017 17:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Fixes available now from https://hudson.eclipse.org/ocl/job/buckminster-ocl-branch-tests/lastSuccessfulBuild/artifact/MDT-OCL.downloads/mdt-ocl-Update-201709071253.zip

Since you're developing some non-trivial OCL, I'm getting round to putting a UI on the CompleteOCLSplitter that will allow you to extract all the embedded OCL to a Complete OCL document where you can do normal text editor things.

Regards

Ed Willink

Re: OCL with a profile applied to itself [message #1772324 is a reply to message #1772298] Fri, 08 September 2017 06:16 Go to previous messageGo to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 152
Registered: July 2014
Senior Member
No Message Body

Yves

[Updated on: Fri, 08 September 2017 06:18]

Report message to a moderator

Re: OCL with a profile applied to itself [message #1772325 is a reply to message #1772298] Fri, 08 September 2017 06:17 Go to previous messageGo to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 152
Registered: July 2014
Senior Member
Ed,

You're really fast and efficient, thank you! :)

Regarding the extract of all those OCL constraints, I developed a GenDoc template that produces a DOCX file which facilitates reviews and comments but also the work progress follow-up. There is a OMG JIRA task about this work where I maintain an up-to-date version of this document and where people who are involved in the RTF can find it.

The point you raise about packages vs sub-profile is worth a discussion at the RTF level. As defined in the specification document today, there is no sub-profiles but actually packages. It's no clear to me whether this capability offered by Eclipse to apply only parts of the SysML profile is implementation side effect.

Adding URIs to the profile's packages can certainly be done anyway.

I'll try to switch to your new version soon and l will report here.

Thanks again.


Yves
Re: OCL with a profile applied to itself [message #1772330 is a reply to message #1772325] Fri, 08 September 2017 06:50 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The GenDoc template might be better at formatting comments; Xtext serialization is imperfect, but it won't allow give you a play area with syntax checking or validation. (If you maintain comments on your constraints, these can contribute to auto-generated specification text and tooling hovertext.)

The failure to apply sub-profiles seems like a clear Eclipse UML bug, though SysML seems like an interesting example. Do you really want to apply 10 sub-profiles mindlessly rather than one or two explicitly? (Actually I fail to see why a ProfileApplication is needed at all; if a Stereotype is referenced it is applied; it seems like a bloated import filtering mechanism that just causes UI / validation trouble.)

The failure to apply Packages as Profiles seems eminently sensible. Seems like a, probably Eclipse UML possibly Papyrus, bug that your use of sub-Packages rather than sub-Profiles has not been detected earlier.

Once the sub-profile fix is in place, the need for sub-URIs goes away but it is still a good idea to provide an explicit URI for anything that becomes an xmlns (or EPackage).

Regards

Ed Willink
Re: OCL with a profile applied to itself [message #1772393 is a reply to message #1772330] Fri, 08 September 2017 13:55 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Ed Willink wrote on Fri, 08 September 2017 02:50

The failure to apply Packages as Profiles seems eminently sensible. Seems like a, probably Eclipse UML possibly Papyrus, bug that your use of sub-Packages rather than sub-Profiles has not been detected earlier.


No. The UML 2.5 text on Stereotype::profile makes clear that Packages nested in a Profile is the expected hierarchy. No Eclipse UML2/Papyrus bug.

It's just the 12.3.3.3 wording that can be misread.

Regards

Ed Willink

Re: OCL with a profile applied to itself [message #1772401 is a reply to message #1772393] Fri, 08 September 2017 15:21 Go to previous messageGo to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 152
Registered: July 2014
Senior Member
Quote:
Do you really want to apply 10 sub-profiles mindlessly rather than one or two explicitly?


Certainly not!
Not me, at least. And, as I said, I see nothing in the SysML specification about "sub-profiles". It could be a legacy from a former UML version where Profiles where not allowed to have nested packages that were not profiles. But this was changed, at least in 2.4, maybe before, I don't remember exactly.


Yves
Re: OCL with a profile applied to itself [message #1772404 is a reply to message #1772401] Fri, 08 September 2017 16:11 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

A comparison with Java perhaps shows how useful/useless a ProfileApplication is.

In Java I may write

private x.y.z.Type aType;

making explicit reference to x.y.z.Type without any need for an import. Or I may write:

import x.y.z;
private Type aType;

so that the import makes the reference more friendly.

I see a strong similarity between a Stereotype application and a type reference. The XMI can reference the Stereotype regardless of ProfileApplications.

I see a weak similarity between a ProfileApplication and an import. Within a modeling tool a ProfileApplication may facilitate a Stereotype selection menu providing a short list of candidates; rather than everything anywhere.

Mindlessly applying 10 sub-profiles is not a particular problem; profile application has no real semantic significance; profile application just makes your favorite modeling tool friendlier when it comes to creating the important stereotype applications.

Regards

Ed Willink
Re: OCL with a profile applied to itself [message #1772434 is a reply to message #1772404] Sat, 09 September 2017 17:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The latest N-build
http://www.eclipse.org/modeling/download.php?file=/modeling/mdt/ocl/downloads/drops/6.4.0/N201709091308/mdt-ocl-Update-N201709091308.zip
has an OCL->Export Document facility to export embedded OCL to a Complete OCL document within a UML/Ecore editor.
Getting the imports correct was troublesome but fixed a few outstanding obscure bugs.
Keep an eye on https://bugs.eclipse.org/bugs/show_bug.cgi?id=500551 for the OCL->Merge Document facility (one day).

For your SysML.uml, SysML.ocl shows a number of errors:
- blank inv bodies
- use of "context" and "package" properties which are reserved in Complete OCL but not reserved in Essential OCL
"context" and "package" could be escaped automatically to "_'context'" and "_'package'" but that would lose the whitespace preservation

Once the errors are fixed you will see some warnings.
- ambiguous inv names
Some just need an ->asSet(). Others are genuine type conformance issues.

If you enable null navigation analysis via Windows->Preferences->OCL->Unified Pivot Binding you will see many more issues; some may be analysis bugs. Often the problem is an optional multiplicity property that may be null.

(The Complete OCL editor occasionally gets stuck with some stupid errors. Just save and reopen.)

Regards

Ed Willink
Re: OCL with a profile applied to itself [message #1772620 is a reply to message #1772434] Wed, 13 September 2017 08:06 Go to previous messageGo to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 152
Registered: July 2014
Senior Member
Ed,

I've tried the previous version yesterday and I can say that it actually fixes the issue I reported with those error messages, making it much more comfortable to write the OCL statements! :-)

I'll use that enhanced version to improve them. I have to admit that using those reserved names was a bad idea but I can easily fix it. Regarding the blank bodies, they should be related to constraints that cannot be expressed in OCL and which, by the way, contain only a comment.

Thanks for your help and for your advises!


Yves
Re: OCL with a profile applied to itself [message #1772624 is a reply to message #1772620] Wed, 13 September 2017 08:30 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Rather than blank bodies use true/false/null/invalid depending on how many reminders you want until you get round to implementing.

Regards

Ed Willink
Re: OCL with a profile applied to itself [message #1772724 is a reply to message #1772624] Thu, 14 September 2017 11:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Yves

Another style note:

If your invariants are named _1, _2, _3 etc your eventual users are likely to be faced with messages such as

The ContextClass::_3 invariant has been violated by ....

Much better to provide a clear name that expresses the positive expectation so that users see

The ContextClass::ExactlyTwoEnds invariant has been violated by ....

(I prefer camel case, although UML 2.5 is diligently underscore separated.)

(If you are really enthusiastic, you can use the Eclipse OCL Tuple-valued constraint value extension to return a severity and/or a custom message and/or ...)

Regards

Ed Willink
Re: OCL with a profile applied to itself [message #1773093 is a reply to message #1772724] Thu, 21 September 2017 12:14 Go to previous messageGo to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 152
Registered: July 2014
Senior Member
Hi Ed,

I do agree with you regarding the names of the invariants. The point is that I cannot make this decision by myself: I need a vote. The good news is that the proposal I made for it does not generate significant objections so far. I think it should be adopted, eventually. The bad news - for me - is that I'll have to find a significant number of names!

I've used your new export facility. Indeed, it's very convenient for debugging!

The error remaining in the generated file look like parsing bugs. They always appears on the first invariant definition following a "context" statement, but not for all the context statements. I attached the '.ocl' file.

Cheers,

Yves
  • Attachment: SysML.ocl
    (Size: 51.71KB, Downloaded 205 times)


Yves
Re: OCL with a profile applied to itself [message #1773096 is a reply to message #1773093] Thu, 21 September 2017 12:55 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The errors are all due to blank invariant bodies.

Unfortunately the Complete OCL syntax is really bad. keyword ... keyword ... keyword ... without any brace/semicolon punctuation to aid resynchronization by parser error recovery. I've not had time to investigate whether Xtext/ANTLR is just bad, or whether there is some counterpart of the error tokens that I used to exploit with LPG. Whwn I get round to incremental parsing I will see what can be done.

Regards

Ed Willink
Previous Topic:OCL constraints on dependency Metaclass and enumeration issues
Next Topic:Programmatically run OCL queries with multiple meta-models produces unknown type errors
Goto Forum:
  


Current Time: Thu Apr 18 04:09:08 GMT 2024

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

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

Back to the top