Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL constraints on dependency Metaclass and enumeration issues
OCL constraints on dependency Metaclass and enumeration issues [message #1772618] Wed, 13 September 2017 07:51 Go to next message
MG Gharib is currently offline MG GharibFriend
Messages: 25
Registered: September 2014
Junior Member
Dear all,

I'm trying to create a UML profile that consist of several stereotypes that extends the class Metaclass and other stereotypes that extends the dependency Metaclass.

I have several issues I couldn't solve since I'm new to OCL.

1- when I try to define a constrint on an enumeration literal value I get an error.
For example, one of my stereotypes has a property SS of type enumeration that can be eaither S1 or S2, when I use the following contraint "self.SS = SS::S1" or "self.SS = SS::S2" and I apply the profile to some model, I get this error

Severity Description Element Parent Type
Error The 'Constraint' invariant is violated on '«Hazard»RootElement::accident' <<Hazard>> <Class> accident null EMF Problem

Note that when the value should be S1/S2 it is S1/S2 in the model that I apply the profile to. Apparently, there is a problem in recognising the value of SS. Any idea how such thing can be solved?

2- the second problem, I need to define a constraint that checks if there is a specific dependency from a class to another one. In other words, if I have a class A and B, I need to know if there is a dependency relation of type X between them. And I think this should done from the class perspective

I have defined a constraint that limit the client and supplier of a dependency to specific classes but I wasn't able to do the same from the perspective of a class. Any ideas?

Best regards
Re: OCL constraints on dependency Metaclass and enumeration issues [message #1772623 is a reply to message #1772618] Wed, 13 September 2017 08:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5533
Registered: July 2009
Senior Member
Hi

A problem with Enumerations was fixed recently. What version are you using?

Non-trivial problems usually need a repro to get a useful answer.

Redefining constraints is a difficult philosophical issue. Or not that difficult. A redefinition is a breach of the OO contract. It is not supported. The way round it is to define a variation point such as NamedElement::isDistinguishableFrom so that a variant derived behavior is part of the contract.

Regards

Ed Willink
Re: OCL constraints on dependency Metaclass and enumeration issues [message #1772625 is a reply to message #1772623] Wed, 13 September 2017 08:33 Go to previous messageGo to next message
MG Gharib is currently offline MG GharibFriend
Messages: 25
Registered: September 2014
Junior Member
Hi Ed,

Thanks for the fast response. I'm using Luna SR 2 (4.4.2), but the same problem appears in Kepler, Neon, and Oxygen. Also I tried a Papyrus standalone platform. Anyway, as far as I understood, Luna is better than the rest that is why I'm using it.

I need to ask you, are you aware of a good documentation, manual, etc. that can help me with a bit complex OCL constraints. I was not able to find any so far.

Best regards

Re: OCL constraints on dependency Metaclass and enumeration issues [message #1772629 is a reply to message #1772625] Wed, 13 September 2017 09:06 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5533
Registered: July 2009
Senior Member
Hi

'fixed recently' was Oxygen M7, so if your problem is with Oxygen I need a repro so that I can fix it.

The best documentation is the classic Warner & Kleppe book. The OCL embedded in UML 2.5 is now tool checked, but I wouldn't really recommend it for style, since it obstinately refuses to introduce helper operations/properties to aid re-use/readability. The Eclipse OCL documentation has some help, but its revamp for the resolution of OCL problems is a long way off.

OCL can be very compact and correspondingly unreadable, even a day after you wrote it. For non-trivial constraints, I strongly recommend using numerous let variables with long self documenting names. And for re-useable sub-tasks use helper operations/properties. If the helpers are defined using Complete OCL you don't have the conflict between helpful analysis time code and bloated run-time code that the UML specification resolves so poorly.

Regards

Ed Willink
Re: OCL constraints on dependency Metaclass and enumeration issues [message #1772630 is a reply to message #1772629] Wed, 13 September 2017 09:30 Go to previous messageGo to next message
MG Gharib is currently offline MG GharibFriend
Messages: 25
Registered: September 2014
Junior Member
Thank you very much, I will check Oxygen again and I will keep you updated.

Best regards
Re: OCL constraints on dependency Metaclass and enumeration issues [message #1772652 is a reply to message #1772629] Wed, 13 September 2017 15:06 Go to previous messageGo to next message
MG Gharib is currently offline MG GharibFriend
Messages: 25
Registered: September 2014
Junior Member
Hi ED,

Same problem, but now it is able to reference the Enum literals but it does not perform the check as expected. I don't know if something I did wrong or there is also something wrong with Oxygen.

I have attached a zip file that contains a very simple profile and a model that uses this profile. It will be appreciated if you can check what is wrong.

Best regards
Re: OCL constraints on dependency Metaclass and enumeration issues [message #1772659 is a reply to message #1772652] Wed, 13 September 2017 15:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5533
Registered: July 2009
Senior Member
Hi

You haven't told me what to do with your model, what you observe or what you would prefer to have observed.

Regards

Ed Willink
Re: OCL constraints on dependency Metaclass and enumeration issues [message #1772661 is a reply to message #1772659] Wed, 13 September 2017 15:58 Go to previous messageGo to next message
MG Gharib is currently offline MG GharibFriend
Messages: 25
Registered: September 2014
Junior Member
Hi Ed,

Sorry for that, the profile is very simple one stereotype, one enumeration item with two literals, and one simple constraint applied to the stereotype to test if the selected literal is "ASIL_A".

While the model apply the profile on one class, and then I run the validation test and I get a constraint violation even if I chose the right literal ("ASIL_A").

If you need any further information please let me know

Best regards
Re: OCL constraints on dependency Metaclass and enumeration issues [message #1772662 is a reply to message #1772661] Wed, 13 September 2017 16:07 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5533
Registered: July 2009
Senior Member
Hi

I see a constraint violation, but I have no idea whether it is the one you observe. I doubt it because I'm using a command that I don't think should execute any OCL at all.

I have no idea what you mean by even if I select the right literal.

As I observed before, you must tell me what you select and execute and observe. In this case a screen shot might be good.

Then tell me what you would prefer to observe.

If an interesting model edit changes the scenario, then explain that clearly.

Inaccurate descriptions waste both of our times.

Regards

Ed Willink
Re: OCL constraints on dependency Metaclass and enumeration issues [message #1772664 is a reply to message #1772662] Wed, 13 September 2017 16:35 Go to previous messageGo to next message
MG Gharib is currently offline MG GharibFriend
Messages: 25
Registered: September 2014
Junior Member
Hi Ed,

The first screen shot is the profile, very simple one just to test the Oxygen ability to constraint the chosen value of the literal.

The second screen shot is the model that I apply the profile to, and then I check its validity and it is shown that the constraint is violated whether I chose "ASIL_A" or "ASIL_B".

I think the problem is when the platform tries to evaluate the chosen value. I have no idea why this happened. If you know why, please let me know so I can solve it.

Best regards
Re: OCL constraints on dependency Metaclass and enumeration issues [message #1772672 is a reply to message #1772664] Wed, 13 September 2017 17:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5533
Registered: July 2009
Senior Member
Hi

Looks like yet another example of the problem of not specifying your Model/Profile/Package URI. Consequently UML2Ecore synthesizes one automatically and makes the the run-time EPackage and EEnumLiteral inconsistent with the UML Profile and EnumerationLiteral .

I'll have to work harder on trying to generate a sensible error message.

Regards

Ed Willink
Re: OCL constraints on dependency Metaclass and enumeration issues [message #1772673 is a reply to message #1772672] Wed, 13 September 2017 17:42 Go to previous messageGo to next message
MG Gharib is currently offline MG GharibFriend
Messages: 25
Registered: September 2014
Junior Member
I wish I could help you more, but I have very limited experience with this platform.
Thanks for your help

Nest regards
Re: OCL constraints on dependency Metaclass and enumeration issues [message #1772732 is a reply to message #1772673] Thu, 14 September 2017 12:53 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5533
Registered: July 2009
Senior Member
Hi

I don't quite understand your comment. Your repro was eventually very helpful. A bug in EnumerationLiteral processing has now been fixed [1] and also a failure to launch the debugger [2]. Fixes should be available in Photon M2 next week or as an N-build shortly.

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=522256
[2] https://bugs.eclipse.org/bugs/show_bug.cgi?id=522290

Regards

Ed Willink
Re: OCL constraints on dependency Metaclass and enumeration issues [message #1772798 is a reply to message #1772732] Fri, 15 September 2017 12:08 Go to previous messageGo to next message
MG Gharib is currently offline MG GharibFriend
Messages: 25
Registered: September 2014
Junior Member
Dear Ed,

Thank you very much for your help, I have read the bug reports you listed, but it is not clear to me how I can solve this problem in my Eclipse platform, you said "Fixes should be available in Photon M2 next week or as an N-build", how I know when they will be released and how I can get them, i.e., they will be provided as plugins?

Waiting your kind response

Best regards

Re: OCL constraints on dependency Metaclass and enumeration issues [message #1772800 is a reply to message #1772798] Fri, 15 September 2017 12:18 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5533
Registered: July 2009
Senior Member
Hi

Builds are available from the OCL downloads page: https://www.eclipse.org/modeling/mdt/downloads/?project=ocl

The latest N-build is http://www.eclipse.org/modeling/download.php?file=/modeling/mdt/ocl/downloads/drops/6.4.0/N201709140848/mdt-ocl-Update-N201709140848.zip

Regards

Ed Willink
Previous Topic:includesAll fails
Next Topic:OCL with a profile applied to itself
Goto Forum:
  


Current Time: Thu Dec 14 23:07:00 GMT 2017

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

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