Book a Demo

Author Topic: Block link / relationship between 2 objects  (Read 13153 times)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Block link / relationship between 2 objects
« Reply #15 on: February 06, 2015, 10:03:24 am »
Thanks. That made be a bit wiser today  :D Still so many places in EA where I have almost never been.

q.

Monsieur

  • EA User
  • **
  • Posts: 142
  • Karma: +0/-0
    • View Profile
Re: Block link / relationship between 2 objects
« Reply #16 on: February 06, 2015, 09:51:34 pm »
Quote
t_connectorcontstraint = Constraints page of connector properties.

Can I use this to only create links that verifies certain condition?

Using something like this?:
sourceElement = "Need"
destElement = "Need"





NB
I had a thought of our 2 favorites EA admins : Simon and Roy <=> Tweedledum et Tweedledee  :-* :-* :-*  ;D
« Last Edit: February 07, 2015, 12:25:24 am by damien.reche »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Block link / relationship between 2 objects
« Reply #17 on: February 06, 2015, 10:16:03 pm »
Well, this constraint is implicit. All connectors have source and target. You can add things like "only exists if" or "multiplicity depends on" etc. But as my above comment suggests I never in my life have ever used a connector constraint. I'm quite sure its use is more or less academic.

q.
« Last Edit: February 06, 2015, 10:33:29 pm by qwerty »

Monsieur

  • EA User
  • **
  • Posts: 142
  • Karma: +0/-0
    • View Profile
Re: Block link / relationship between 2 objects
« Reply #18 on: February 07, 2015, 12:31:43 am »
Quote
Well, this constraint is implicit. All connectors have source and target. You can add things like "only exists if" or "multiplicity depends on" etc. But as my above comment suggests I never in my life have ever used a connector constraint. I'm quite sure its use is more or less academic.

q.

Tried this :


Does not seem to do anything...

NB :  Need is my own stereotype defined by extending requirement with MDG.
Tried with "Requirement", does not seem to do much more...  :'(
« Last Edit: February 07, 2015, 12:33:57 am by damien.reche »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Block link / relationship between 2 objects
« Reply #19 on: February 07, 2015, 12:38:58 am »
Any constraint is always meant to be read by a human. An OCL constraint can be read by a machine, but EA does only check the syntax of the OCL statement and does not execute it.

What you can do is to write an add-in that checks constraints on a programmatically basis.

q.
« Last Edit: February 07, 2015, 12:40:27 am by qwerty »

Monsieur

  • EA User
  • **
  • Posts: 142
  • Karma: +0/-0
    • View Profile
Re: Block link / relationship between 2 objects
« Reply #20 on: February 07, 2015, 01:04:13 am »
Quote
Any constraint is always meant to be read by a human. An OCL constraint can be read by a machine, but EA does only check the syntax of the OCL statement and does not execute it.

What you can do is to write an add-in that checks constraints on a programmatically basis.

q.

So your advice is to take your book (and it's interesting even i whished it to go a little deeper) and create a script that for every link check if source / typeoflink / destination match. And if not, delete the link.
Not really dynamic.
Can we log what we delete? (create a .txt somewhere, and buffer>txt)
« Last Edit: February 07, 2015, 01:05:59 am by damien.reche »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Block link / relationship between 2 objects
« Reply #21 on: February 07, 2015, 01:56:29 am »
Rather you should take a look at Geerts blog about writing an add-in in 10 minutes ;)

You could turn on the audit log. That logs such changes.

I have done something similar in the past. It's not that difficult.

q.

Gary

  • EA User
  • **
  • Posts: 84
  • Karma: +1/-0
    • View Profile
Re: Block link / relationship between 2 objects
« Reply #22 on: February 11, 2015, 12:18:27 am »
Back to the beginning question about connectors.
I wrote an add-in to do exactly what you want to do. Mine stops modellers from using Realize between requirements.

Use Geerts tutorial (thanks Geert very useful) to create an add-in. The method you want to put your code in is "EA_OnPreNewConnector". The following is the code i wrote:

/*
            EA.EventProperties Info Contains the following EventProperty objects for the connector
            to be created:
            (0)Type: Astring value corresponding to Connector.Type
            (1)Subtype: Astring value corresponding to Connector.Subtype
            (2)Stereotype: Astring value corresponding to Connector.Stereotype
            (3)ClientID: Along value corresponding to Connector.ClientID
            (4)SupplierID: Along value corresponding to Connector.SupplierID
            (5)DiagramID: Along value corresponding to Connector.DiagramID
             */
            bool result = true;
            //create objects to hold the diagram,client and supplier
            EA.IDualDiagram diag = Repository.GetDiagramByID(Info.Get("DiagramID").Value);
            EA.Element client = Repository.GetElementByID(Info.Get("ClientID").Value);
            EA.Element supplier = Repository.GetElementByID(Info.Get("SupplierID").Value);
            
            
                         /*this rule checks relisation is only used between a class and an interface
                         *or between interfaces on a block or class diagram*/
                        if (Info.Get(0).Value == "Realisation" || Info.Get(0).Value == "Realization")
                        {

                            
                            // Check that connection is only between a block/class and an interface or interface to interface
                            if ("Logical" == diag.Type && ("Class" == client.Type || "Interface" == client.Type) && "Interface" == supplier.Type)
                            {
                                                              
                                result = true;
                            }
                            else
                            {
                                MessageBox.Show("Connecor only valid between a block/class and an interface \n or interface to interface", "Invalid Connector Usage",
                                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                result = false;
                            }
                        }

Hope this helps

Gary

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13519
  • Karma: +573/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Block link / relationship between 2 objects
« Reply #23 on: February 11, 2015, 12:46:21 am »
If you are a bit weary to write your own add-in, or you have too many hurdles to overcome to get that approved, you can achieve the same thing with EA-Matic and the built-in scripting feature.

EA-Matic forwards the EA_OnPreNewConnector event to the scripting environment, where you can write your own validation.

Geert

PS. Yes I'm selling a commercial add-in now :D