Author Topic: Connector Link to Element Feature  (Read 9355 times)

pdrane

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Connector Link to Element Feature
« on: February 10, 2015, 06:54:58 pm »
I have created a link between the attributes of two elements (right click on end connector points "link to element feature") and am trying to access them via VBScript. I can see them in Documentation generator under Connector>Source>Linked Feature but cannot find the equivalent objects in VB

Any help would be appreciated

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile

pdrane

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Connector Link to Element Feature
« Reply #2 on: February 10, 2015, 09:19:33 pm »
Sorry I am confused the thread you pointed me to, is about getting the name of a connector Client and Supplier Elements (which I already know) with a statement from you that the person should post a separate post if they wanted to you to respond to "linked element" problem which is actually what I am after. Do you have any advice or a link to a post that you responded to this question?
« Last Edit: February 10, 2015, 09:21:12 pm by pdrane »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +564/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connector Link to Element Feature
« Reply #3 on: February 10, 2015, 10:40:33 pm »
Here's how I do it in the EA Navigator:

From ConnectorWrapper.cs

Code: [Select]
/// returns the related elements.
    /// In EA the Connectoris a binary relationship. So only two Elements will
    /// ever be returned.
    /// If there is a linked feature then the linked feature will be returned instead of the EA.Element.
    public List<UML.Classes.Kernel.Element> relatedElements {
      get
      {
        List<UML.Classes.Kernel.Element> returnedElements =  new List<UML.Classes.Kernel.Element>();
        
        //add client element
        //check first if there is a linked feature
        UML.Classes.Kernel.Element linkedClientFeature = this.getLinkedFeature(true) as UML.Classes.Kernel.Element;
        if (linkedClientFeature != null)
        {
              returnedElements.Add(linkedClientFeature);
        }
        else
        {
              returnedElements.Add(this.model.getElementWrapperByID(this.wrappedConnector.ClientID));
        }
        //add supplier element
        //check first if there is a linked feature
        UML.Classes.Kernel.Element linkedSupplierFeature = this.getLinkedFeature(false) as UML.Classes.Kernel.Element;
                if (linkedSupplierFeature != null)
        {
              returnedElements.Add(linkedSupplierFeature);
        }
        else
        {
              returnedElements.Add(this.model.getElementWrapperByID(this.wrappedConnector.SupplierID));
        }
        return returnedElements;
      }
      set { throw new NotImplementedException(); }
    }
    private UML.UMLItem getLinkedFeature(bool start)
    {
          string styleEx = this.wrappedConnector.StyleEx;
          string key;
          UML.UMLItem linkedFeature = null;
          
               if (start)
               {
                key = "LFSP=";
               }else
               {
                     key = "LFEP=";
               }
               int guidStart = styleEx.IndexOf(key) + key.Length ;
               if (guidStart >= key.Length)
          {
                string featureGUID = styleEx.Substring(guidStart,this.WrappedConnector.ConnectorGUID.Length);
                linkedFeature = this.model.getItemFromGUID(featureGUID);
          }
          return linkedFeature;
    }

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Connector Link to Element Feature
« Reply #4 on: February 11, 2015, 12:06:47 am »
Quote
Sorry I am confused the thread ...
Sorry, my bad. Please ignore it.

q.

pdrane

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Connector Link to Element Feature
« Reply #5 on: February 11, 2015, 06:28:35 pm »
Thanks this did provide useful information so that I can now display the linked attributes. I am now looking to addnew/update them but cannot use this field to do that as it does not effect the connector displayed in the diagram or its source and target information in connector properties. Have you do this before?


Quote
Here's how I do it in the EA Navigator:

From ConnectorWrapper.cs

Code: [Select]
/// returns the related elements.
    /// In EA the Connectoris a binary relationship. So only two Elements will
    /// ever be returned.
    /// If there is a linked feature then the linked feature will be returned instead of the EA.Element.
    public List<UML.Classes.Kernel.Element> relatedElements {
      get
      {
        List<UML.Classes.Kernel.Element> returnedElements =  new List<UML.Classes.Kernel.Element>();
        
        //add client element
        //check first if there is a linked feature
        UML.Classes.Kernel.Element linkedClientFeature = this.getLinkedFeature(true) as UML.Classes.Kernel.Element;
        if (linkedClientFeature != null)
        {
              returnedElements.Add(linkedClientFeature);
        }
        else
        {
              returnedElements.Add(this.model.getElementWrapperByID(this.wrappedConnector.ClientID));
        }
        //add supplier element
        //check first if there is a linked feature
        UML.Classes.Kernel.Element linkedSupplierFeature = this.getLinkedFeature(false) as UML.Classes.Kernel.Element;
                if (linkedSupplierFeature != null)
        {
              returnedElements.Add(linkedSupplierFeature);
        }
        else
        {
              returnedElements.Add(this.model.getElementWrapperByID(this.wrappedConnector.SupplierID));
        }
        return returnedElements;
      }
      set { throw new NotImplementedException(); }
    }
    private UML.UMLItem getLinkedFeature(bool start)
    {
          string styleEx = this.wrappedConnector.StyleEx;
          string key;
          UML.UMLItem linkedFeature = null;
          
               if (start)
               {
                key = "LFSP=";
               }else
               {
                     key = "LFEP=";
               }
               int guidStart = styleEx.IndexOf(key) + key.Length ;
               if (guidStart >= key.Length)
          {
                string featureGUID = styleEx.Substring(guidStart,this.WrappedConnector.ConnectorGUID.Length);
                linkedFeature = this.model.getItemFromGUID(featureGUID);
          }
          return linkedFeature;
    }

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +564/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connector Link to Element Feature
« Reply #6 on: February 11, 2015, 06:45:42 pm »
No I've never tried changing that field, but I don't see whey that shouldn't be possible.

You might need to reload the diagram before you see any changes though. Since you are changing the properties of the connector behind the back of EA you'll have to tell it that you have changed it.
You can try Repository.AdviseConnectorChanged or reload the diagram.

If you post the code here we might be able to see what's wrong with it.

Geert

pdrane

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Connector Link to Element Feature
« Reply #7 on: February 11, 2015, 06:58:54 pm »
The update works but does not affect the connector feature to feature link displayed in the connector properties it continues to display previous values

Source : Current Recipient Address.Address Line
Target : LOCATION_ADDRESS.ADDRESS_LINE

Instead of

Source : Current Recipient Address.Address Line
Target : LOCATION_ADDRESS.LOCATION_GUID


set updateConnector = getconnectorByID(599148344)
updateConnector.StyleEx = "LFEP={8CCF5FAC-2D81-46d8-BCF5-E3EDAFE90C81}L;LFSP={8F1D8CEA-47E9-4388-8730-0042E9E6C494}R;"
updateConnector.Update


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +564/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connector Link to Element Feature
« Reply #8 on: February 11, 2015, 07:20:04 pm »
If the update works then either you have not reloaded the diagram, or you have made a mistake somewhere.

Have you compared your result to the result when you change it manually?

Geert

pdrane

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Connector Link to Element Feature
« Reply #9 on: February 11, 2015, 10:34:24 pm »
I have tried this over and over again it does not appear that changing the StyleEx values actually makes the relevant connections

The Realization Properties box states :-
Source: Current Recipient Address.Address Line
Target: LOCATION_ADDRESS.LOCATION_GID
Name: Connector1

But the output from the object model in VBA is as follows :-

Connector1 ID: 771420143 StyleEx: LFEP={D181DC15-3B06-4726-AE69-006614809E4A}L;LFSP={8F1D8CEA-47E9-4388-8730-0042E9E6C494}L; Type: Realisation      

Attribute Name : Address Line ID : {8F1D8CEA-47E9-4388-8730-0042E9E6C494}      
Attribute Name : LOCATION_GID ID : {8CCF5FAC-2D81-46d8-BCF5-E3EDAFE90C81}      
Attribute Name : ADDRESS_LINE ID : {D181DC15-3B06-4726-AE69-006614809E4A}      

I am using direct exports from changing the values manually to update the connector StyleEx field but this does not appear to directly change the relationship although the StyleEx field is updated when done manually

I am completely confused

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +564/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connector Link to Element Feature
« Reply #10 on: February 11, 2015, 10:48:22 pm »
Hmm, weird.
I would have try it myself to be sure.
Maybe EA keeps the information somewhere else as well?
Check t_DiagramLinks and t_xref as a start.

Geert



pdrane

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Connector Link to Element Feature
« Reply #11 on: February 11, 2015, 10:52:12 pm »
It does appear to be linked to the diagram as changing this information does not require a diagram save once the elements have been connected

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +564/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connector Link to Element Feature
« Reply #12 on: February 11, 2015, 11:03:14 pm »
I just tried it and this update query

Code: [Select]
update t_connector set StyleEx = 'LFEP={9F81529D-BEE9-41a4-B8EF-F09A8726021C}L;LFSP={08552805-5C79-4c56-8AE2-18DF4D8B570E}R;' where name = 'linkedFeature'
Actually changed the connector from one attribute to another.

This was only visible after I closed and reopened the diagram.

Geert

pdrane

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Connector Link to Element Feature
« Reply #13 on: February 12, 2015, 12:02:31 am »
I connected to the .eap file with msaccess and looked at the t_connector table and there was no StyleEx column which makes me even more confused. The version I have is 9.3.935
« Last Edit: February 12, 2015, 12:15:40 am by pdrane »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Connector Link to Element Feature
« Reply #14 on: February 12, 2015, 12:26:19 am »
Try looking into the table with the EA build-in SQL search: ctrl-f/Builder/SQL

q.