Author Topic: Restrict allowed relationships with the Quicklinker?  (Read 268 times)

Guillaume

  • EA User
  • **
  • Posts: 816
  • Karma: +22/-0
    • View Profile
    • www.umlchannel.com
Restrict allowed relationships with the Quicklinker?
« on: October 22, 2019, 09:16:06 pm »
Hi,
I used the MetaModel stereotyped relationship links in my UML profile to define allowed relationships between stereotyped elements.
e.g. "TypeA" Class can be linked with a "aaa" stereotyped dependency to "TypeB" Class
I also added the  "aaa" stereotyped dependency  in my toolbox

It works when I use the quicklinker on a test project, but the toolbox makes it possible to create a link from TypeB to TypeA.
I read Phil's article on the community site: https://community.sparxsystems.com/tutorials/1232-using-stereotyped-relationships-to-define-quicklink-rules

Quote
NOTE: The rules defined using Stereotyped-relationships only apply when using the Quicklinker, these rules can be broken by using any relationships visible in the toolbox.
Therefore, to fully enforce relationship rules, define all relationships using Stereotyped-relationships and do not provide any relationships in the diagram toolbox.

I tried to remove the relationships from the toolbox which prevents me from creating the association from the quicklinker.
Is there any way to apply restrictions on the allowed relationships e.g. in my example so only an "aaa" stereotyped dependency can be created from a TypeA class to a TypeB class?

I haven't tried the old style CSV quicklinker definition ; could this enforce such restrictions?
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 9536
  • Karma: +274/-27
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Restrict allowed relationships with the Quicklinker?
« Reply #1 on: October 22, 2019, 09:51:37 pm »
Yes, you can add the attribute "_HideUmlLinks" with default value "true" to the metaclass.
That should hide all default relations for the metatype.

Geert

philchudley

  • EA User
  • **
  • Posts: 575
  • Karma: +11/-0
  • UML/EA Principal Consultant / Trainer
    • View Profile
Re: Restrict allowed relationships with the Quicklinker?
« Reply #2 on: October 22, 2019, 11:32:26 pm »
Ah

This puzzled me for a while and the answer is use metaconstraint relationships, in addition to stereotype relationships

Say, for example, that Stereotype A can only connect to Stereotype B via a stereotyped Association, then in addition to the stereotype relationship (the quicklinker definition), add a metaconstraint relationship from the stereotyped Association to B (or A), and set the tag value umlRole to target, or umlRole to source. This will enforce these constraints when using the diagram tool box and am error dialog will be displayed.

I presented this at the EAUG meeting Gdansk, so you might be able to download the example used in the presentation from the EAUG web site

A little experimentation with metaconstraints may be necessary in order to see how they work.

All the best

Phil
follow me on Twitter

@SparxEAGuru

Guillaume

  • EA User
  • **
  • Posts: 816
  • Karma: +22/-0
    • View Profile
    • www.umlchannel.com
Re: Restrict allowed relationships with the Quicklinker?
« Reply #3 on: October 23, 2019, 06:23:38 pm »
Thank you for your answers.

Geert: the hideUMLLinks options is very useful indeed.
Phil: I tried using the metaconstraint as per your suggestion but I can't get the restriction to work. Using your EAUG presentation sample, I created a test EA Project and imported your MDG.
I created 2 elements: Problem and Cause, and used the toolbox to create a Solved By relationship from Cause to Problem; this doesn't trigger an error message. Is there something that I'm missing? (I can send you with test EA project if needed)

Guillaume
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


philchudley

  • EA User
  • **
  • Posts: 575
  • Karma: +11/-0
  • UML/EA Principal Consultant / Trainer
    • View Profile
Re: Restrict allowed relationships with the Quicklinker?
« Reply #4 on: October 23, 2019, 07:13:47 pm »
Hi Guillaume

I have sent you a PM with the e-mail to which to send your EA project so I can take a look

All the best

Phil
follow me on Twitter

@SparxEAGuru

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 6867
  • Karma: +147/-104
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Restrict allowed relationships with the Quicklinker?
« Reply #5 on: October 23, 2019, 07:22:32 pm »
Hi Guillaume

I have sent you a PM with the e-mail to which to send your EA project so I can take a look

All the best

Phil
Hi guys, when this is sorted, can we get a copy of the MDG repository so we can see how and why it works?

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Guillaume

  • EA User
  • **
  • Posts: 816
  • Karma: +22/-0
    • View Profile
    • www.umlchannel.com
Re: Restrict allowed relationships with the Quicklinker?
« Reply #6 on: October 24, 2019, 12:14:28 am »
I eventually got it to work by enabling the Strict Connector Syntax option in EA Preferences under Links.
Note: the MDG must be visible in the active perspective (as suggested by Phil).

Thank you Phil for your time in looking at the issue.


Update: the remaining issue I have is to do with a built-in relationship e.g. I added the Association metaclass with a metaconstraint on the Cause (src) and the Problem (target) + a metarelationship from Cause to Problem. I also added the Association to the toolbox profile. The result is not 100% compliant: I can create association between any element (Cause, Problem, Solution) as source or target except from the following: Cause to Solution (it seems to detect a matching source and non matching target).
As a workaround I created a stereotype association (it works) but this is not ideal
« Last Edit: October 24, 2019, 04:57:13 pm by Guillaume »
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6841
  • Karma: +66/-7
    • View Profile
Re: Restrict allowed relationships with the Quicklinker?
« Reply #7 on: October 28, 2019, 09:34:58 am »
Quote
NOTE: The rules defined using Stereotyped-relationships only apply when using the Quicklinker, these rules can be broken by using any relationships visible in the toolbox.
Therefore, to fully enforce relationship rules, define all relationships using Stereotyped-relationships and do not provide any relationships in the diagram toolbox.
This seems to be the opposite of the intent. The metamodel relationships define what is allowed, and quicklinkers are generated from the result of that. EA does try to validate rules if you have strict connector syntax enabled. I don't know if it captures every scenario.

As you found, the solution proposed by that article is wrong. If you don't include a link type in the toolbox it will be filtered out of the quicklinker by default.

I haven't tried the old style CSV quicklinker definition ; could this enforce such restrictions?
The CSV quicklinker definition is only that. It doesn't define any rules.
Eve

support@sparxsystems.com

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 6867
  • Karma: +147/-104
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Restrict allowed relationships with the Quicklinker?
« Reply #8 on: October 28, 2019, 11:07:44 am »
Quote
NOTE: The rules defined using Stereotyped-relationships only apply when using the Quicklinker, these rules can be broken by using any relationships visible in the toolbox.
Therefore, to fully enforce relationship rules, define all relationships using Stereotyped-relationships and do not provide any relationships in the diagram toolbox.
This seems to be the opposite of the intent. The metamodel relationships define what is allowed, and quicklinkers are generated from the result of that. EA does try to validate rules if you have strict connector syntax enabled. I don't know if it captures every scenario.

As you found, the solution proposed by that article is wrong. If you don't include a link type in the toolbox it will be filtered out of the quicklinker by default.

I haven't tried the old style CSV quicklinker definition ; could this enforce such restrictions?
The CSV quicklinker definition is only that. It doesn't define any rules.
As I've previously requested, I believe the metamodel should also be able to cover what is NOT allowed.

Sometimes there is a broad set of specializations, but one (or a restricted number) may not be allowed.  I think this allows for a more natural view of the hierarchy.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6841
  • Karma: +66/-7
    • View Profile
Re: Restrict allowed relationships with the Quicklinker?
« Reply #9 on: October 28, 2019, 01:21:42 pm »
The authors of UAF (where EA takes the metamodeling relationships from) had similar instances. In a few places they appear to have  introduced superclasses that are effectively "can be a source/target for x". You can use this approach either by inserting the type into the hierarchy, or as a separate inheritance chain.

Conceptually, I don't like creating a relationship in the metamodel that says these types aren't related.
Eve

support@sparxsystems.com