Author Topic: OCL constraints on a profile and consistency check.  (Read 554 times)

Philipp91

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
OCL constraints on a profile and consistency check.
« on: October 06, 2020, 12:36:00 am »
Hello,

i created a new stereotype where I want to apply well-formedness rules on my stereotype.
This can be achieved by OCL constraints where I saw in the properties of the stereotype I created, there is the option to apply constraints OCL type.
An example of how my rules might look:
context ConceptualClass
inv: self.feature->forAll( oclIsKindOf(ConceptualOperation) or
f.oclIsKindOf(ConceptualAttribute) )
inv: self.association->forAll( association.oclIsKindOf(ConceptualAssociation) )

So my questions basically are:
-will EA accept my OCL constraints like that? And if not is there any documentation of how to adapt the for EA?
-Is there any consistency check between the models provided by EA after i created those constraints?

Kind Regards,
Philipp

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 10528
  • Karma: +358/-31
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: OCL constraints on a profile and consistency check.
« Reply #1 on: October 06, 2020, 01:16:20 am »
EA will happily accept your OCL constraint (as in, you can type them in, and they will be stored in the database). But unfortunately, there is not functionality whatsoever to validate OCL constraints (except for OCL syntax)

The good news is that most of these type of constraints can be modelled in your UML profile meta model.

Geert

Philipp91

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Re: OCL constraints on a profile and consistency check.
« Reply #2 on: October 06, 2020, 01:49:56 am »
Thanks for the quick reply!
So how I understood I am able to apply constraints but there is no functionality to validate OCL constraints. However, is there any model consistency check in EA? To check the consistency between my diagrams? And if so, does it consider my defined constraints?

"The good news is that most of these type of constraints can be modelled in your UML profile meta model."
I did not understood your point here fully. Could you elaborate it, is there any documentation how to achieve something like this?
By UML profile meta model you mean creating a package with stereotype "profile" and there we can model our constraints?

Kind Regards,
Philipp

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 10528
  • Karma: +358/-31
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: OCL constraints on a profile and consistency check.
« Reply #3 on: October 06, 2020, 02:56:31 am »
There is a model consistency check, however it will not use your OCL constraints in any way.
They are just text, nothing more.

For the meta model constraints, see https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/modeling/metamodelconstraints.html

Geert

PS. If you are looking for a more advanced model validator, see https://bellekens.com/ea-validator/

Philipp91

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Re: OCL constraints on a profile and consistency check.
« Reply #4 on: October 06, 2020, 08:20:15 am »
Thank you for your answer it was very helpful.
One last question, except the advanced model validator you suggest me, which is the default one from EA?
I could not really find how to check the consistency between UML diagrams in EA.

Kind Regards,
Philipp

qwerty

  • EA Guru
  • *****
  • Posts: 11472
  • Karma: +305/-263
  • I'm no guru at all
    • View Profile
Re: OCL constraints on a profile and consistency check.
« Reply #5 on: October 06, 2020, 08:37:51 am »
I'm not so sure about the syntax check either. I once tried to enter a valid OCL and EA croaked about it not being valid. Since it was just an academic test I did not put much effort in research. It might also be fixed in current releases (I tried in V14 since they promote it on their web page as feater - big fat lie, isn't it?) but I doubt that. Even their example model does not use a single OCL constraint.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 10528
  • Karma: +358/-31
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: OCL constraints on a profile and consistency check.
« Reply #6 on: October 06, 2020, 03:10:51 pm »
For the default validation, see Design | Model | Manage | Validate

EA also validates connectors on the fly. It refuses to create any invalid connectors (unless you uncheck the option Strict Connector Syntax)

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 11472
  • Karma: +305/-263
  • I'm no guru at all
    • View Profile
Re: OCL constraints on a profile and consistency check.
« Reply #7 on: October 06, 2020, 07:02:35 pm »
Well, right now I put an invalid OCL in and EA tells me "OCL validation successful". Sun is shining now. Maybe it has to do with the weather.

q.

Philipp91

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Re: OCL constraints on a profile and consistency check.
« Reply #8 on: October 06, 2020, 11:21:53 pm »
Thank you Geert for the answer. So a basic consistency check between the uml diagrams exists by not allowing you create invalid diagrams.

Qwerty, so in other words I can just theoretically define the consistency rules for the stereotypes through OCL. However, practically they cannot
be used for the consistency between diagrams and the OCL validator is not working properly? So even to use my consistency rules theoretically
just by adding them in the stereotype, I have to validate my constraints somewhere else...?

Kind Regards,
Philipp

qwerty

  • EA Guru
  • *****
  • Posts: 11472
  • Karma: +305/-263
  • I'm no guru at all
    • View Profile
Re: OCL constraints on a profile and consistency check.
« Reply #9 on: October 07, 2020, 12:56:44 am »
That's my interpretation. Maybe there's a secret sauce but I doubt that. OCL has never been working in EA and I only have seen some academic approaches to it elsewhere. I would not expect to see it in EA unless there will be a bigger demand for it out there. (Even then it will be a doubtful implementation and you'll be a beta tester for a long time.)

q.

Philipp91

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Re: OCL constraints on a profile and consistency check.
« Reply #10 on: October 07, 2020, 03:49:29 am »
Thanks for you answer, it was really helpful!
Do you mind with providing me some details of how you reproduced the invalid OCL with was validated sucessfully?

Kind Regards,
Philipp

qwerty

  • EA Guru
  • *****
  • Posts: 11472
  • Karma: +305/-263
  • I'm no guru at all
    • View Profile
Re: OCL constraints on a profile and consistency check.
« Reply #11 on: October 07, 2020, 08:38:31 am »
Basically what I did was to copy an OCL from the UML specs as test
Quote from: UML p. 48 bottom
body: if owner.oclIsKindOf(TemplateParameter) and owner.oclAsType(TemplateParameter).signature.template.oclIsKindOf(Namespace) then
let enclosingNamespace : Namespace = owner.oclAsType(TemplateParameter).signature.template.oclAsType(Namespace) in
enclosingNamespace.allNamespaces()->prepend(enclosingNamespace)
else
if namespace->isEmpty()
    then OrderedSet{}
  else
namespace.allNamespaces()->prepend(namespace) endif
endif
. When pasting it the result was truncated (don't ask my why, but it was cut somewhere after the else so it was left with
Quote
body: if owner.oclIsKindOf(TemplateParameter) and owner.oclAsType(TemplateParameter).signature.template.oclIsKindOf(Namespace) then
let enclosingNamespace : Namespace = owner.oclAsType(TemplateParameter).signature.template.oclAsType(Namespace) in
enclosingNamespace.allNamespaces()->prepend(enclosingNamespace)
el
V14 swallowed that without issue. V13.5 on the other hand issued a warning. Hm, yes. As said I'm not too much interested in playing QA for Sparx. Maybe V15 has fixed that (V14 is said to be a bag of bugs) maybe not.

q.

Philipp91

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Re: OCL constraints on a profile and consistency check.
« Reply #12 on: October 08, 2020, 02:02:37 am »
Thanks!

I just tried your example by myself. I am using the EA version 15.2

So i added those OCL constraints  on an elemenet (properties-> type=OCL and so..) and i validate it through design -> validate current package (i added the box OCL conformance).
So after running the validation there was no error in return. However, when i just added a random OCL which does not make sense I also did not
received any errors..
So did I anything wrong with the process or validation? Or its just not working properly?
So I guess a cheap solution is to create my models in EA and adding those constraints, and then exporting the project to validate the OCL constraints on some other tool.....?

Kind Regards,
Philipp

Kind Regards,
Philipp.

qwerty

  • EA Guru
  • *****
  • Posts: 11472
  • Karma: +305/-263
  • I'm no guru at all
    • View Profile
Re: OCL constraints on a profile and consistency check.
« Reply #13 on: October 08, 2020, 04:34:06 am »
Well, I'm no Sparxian, so I might be wrong. But just guessing that it simply does not work has a high chance to be the correct answer.

q.

Philipp91

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Re: OCL constraints on a profile and consistency check.
« Reply #14 on: October 08, 2020, 05:34:59 am »
No worries, you already answered what I was looking for, thanks again!

Kind Regards,
Philipp