Sparx Systems Forum
Enterprise Architect => Uml Process => Topic started by: Philipp91 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
-
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
-
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
-
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 (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/ (https://bellekens.com/ea-validator/)
-
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
-
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 (https://sparxsystems.com/enterprise_architect_user_guide/14.0/model_domains/ocl_conformance_element_relati.html) as feater - big fat lie, isn't it?) but I doubt that. Even their example model does not use a single OCL constraint.
q.
-
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
-
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.
-
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
-
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.
-
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
-
Basically what I did was to copy an OCL from the UML specs as test
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 withbody: 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.
-
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.
-
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.
-
No worries, you already answered what I was looking for, thanks again!
Kind Regards,
Philipp