Book a Demo

Author Topic: How to get the connector related to a proxyconnector?  (Read 3607 times)

Jayson

  • EA User
  • **
  • Posts: 363
  • Karma: +1/-0
    • View Profile
How to get the connector related to a proxyconnector?
« on: November 12, 2019, 04:01:10 am »
Good morning all!

So I have created a stereotyped connector called "Impact" that is used by our users to denote which elements and connectors will be impacted by a particular solution.

The next step is to create a script that sets the colour of all such connectors and elements.
In order to do this, the script simply iterations through all the "Impact" connectors that connect the solution with any other connectors or elements.

When I do this, I get back:

1. The GUID's of the elements that the solution is connected to (so far so good!)
2. The GUID's of a repository object called a "proxyconnector" (this is where I come unstuck).

The problem here is that the GUID of the proxy connector is NOT the GUID of the actual connector and it is THAT GUID that I need.

Any help is as always immensely appreciated.

Cheers :-)

Jayson

  • EA User
  • **
  • Posts: 363
  • Karma: +1/-0
    • View Profile
Re: How to get the connector related to a proxyconnector?
« Reply #1 on: November 12, 2019, 04:42:15 am »
Ok, so it appears as if the GUID to the underlying connector is stored in t_object.classifier_guid. (But I could be wrong)

However, the next question is how to access this field via the API?

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: How to get the connector related to a proxyconnector?
« Reply #2 on: November 12, 2019, 10:36:50 am »
Hi Jays,

Don't forget that "ProxyConnector" is actually a misnomer.  The item is really a ConnectorProxy.  It doesn't really affect your question directly, but it might help the conceptualisation of your solution.

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

Jayson

  • EA User
  • **
  • Posts: 363
  • Karma: +1/-0
    • View Profile
Re: How to get the connector related to a proxyconnector?
« Reply #3 on: November 14, 2019, 03:06:29 am »
SOLVED! Code below.
Hope it saves some other poor soul from brain damage!  :o

' This extracts the Proxy Connector GUID from the SQL result "SELECT Object_ID, Classifier_guid FROM t_object WHERE Object_ID = objectID"
function GetProxyConnectorGUID(objectID)

   dim regExpr
   dim matchPattern1
   dim matchPattern2
   dim matches
   dim match
   dim token
   dim proxyString
   dim sql
   
   set regExpr = new RegExp
   regExpr.IgnoreCase = true
   regExpr.Global = false
   
   sql = "SELECT Object_ID, Classifier_guid FROM t_object WHERE Object_ID = " & objectID
   
   matchPattern1 = "<Object_ID>" & objectID & "</Object_ID><Classifier_guid>{[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}}</Classifier_guid>"
   matchPattern2 = "{[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}}"
   
   proxyString = Repository.SQLQuery(sql)
   
   regExpr.Pattern = matchPattern1
         
   Set matches = regExpr.Execute(proxyString)
      
   if( matches.Count > 0) then
      For Each match in matches
         token = Mid(proxyString,match.FirstIndex + 1, match.Length)
      Next
   else
      GetProxyConnectorGUID = ""
      Exit Function
   end if
      
   regExpr.Pattern = matchPattern2
   Set matches = regExpr.Execute(token)
      
   if(matches.Count > 0 ) Then

      for each match in matches
         
         GetProxyConnectorGUID = Mid(token,match.FirstIndex + 1, match.Length)
      next

   Else
      GetProxyConnectorGUID = ""
         
   End if
      
end function