Book a Demo

Author Topic: isConjugated in Proxy Ports via SQL  (Read 4526 times)

alexen1337

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
isConjugated in Proxy Ports via SQL
« on: September 20, 2024, 06:08:57 pm »
Hey folks,

I am writing a validation script to check if the information flow is directed correctly. Right now I am searching for the direction with Repository.SQLQuery() in t_xref table in the description column. In EA15 it was working that every port had the isConjugated value but in EA16 it is not the case. Some ports do and some don't.
Is there a smarter way to validate this?

Thanks in advance

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: isConjugated in Proxy Ports via SQL
« Reply #1 on: September 20, 2024, 07:34:39 pm »
If you are a bit (or a lot) more specific on what you are actually validating we could maybe help.

Now it's a bit vague.

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: isConjugated in Proxy Ports via SQL
« Reply #2 on: September 20, 2024, 09:14:14 pm »
From a personal message from Alex
Quote from: alexen1337 date=1726819737
For some reasons I can't reply in the thread as it seems to be spam. So I hope it's fine if I text you here.

So I have an InformationFlow between 2 ProxyPorts. These Ports have Interface Blocks typed with FlowProperties. I want to automate checking the logical direction of the ports. So if my source port has a flowproperty with direction out, the target port has to have direction in/inout. But there are cases where the flowproperty of the target port has a direction of out aswell so the port must be conjugated.
This is my testing script to get my port information: Code: [Select]
!INC Local Scripts.EAConstants-JScript

// Clear session output and ensure output is visible
Repository.ClearOutput("Script");
Repository.EnsureOutputVisible("Script");

// Get the currently selected package in the Project Browser
var selectedPackage = Repository.GetTreeSelectedPackage();

// Check if a package is selected
if (selectedPackage != null) {
    // Get the Package_ID of the selected package
    var packageID = selectedPackage.PackageID;

    // SQL query to retrieve all ProxyPort elements in the selected package from the t_object table
    var sqlQuery = "SELECT Object_ID, Name, ea_guid FROM t_object WHERE Stereotype = 'ProxyPort' " +
                   "AND Package_ID = " + packageID + ";";

    // Execute the SQL query to get all ProxyPorts
    var resultXML = Repository.SQLQuery(sqlQuery);

    // Load and parse the XML result for ProxyPorts
    var xmlDoc = new ActiveXObject("MSXML2.DOMDocument.6.0");
    xmlDoc.async = false;
    xmlDoc.loadXML(resultXML);

    // Select all 'Row' nodes from the result
    var proxyPorts = xmlDoc.selectNodes("//Row");

    // Check if we have any ProxyPorts
    if (proxyPorts.length > 0) {
        for (var i = 0; i < proxyPorts.length; i++) {
            var proxyPort = proxyPorts.item(i);
            var name = proxyPort.selectSingleNode("Name").text;
            var ea_guid = proxyPort.selectSingleNode("ea_guid").text;

            // Output ProxyPort name
            Session.Output("ProxyPort Name: " + name);

            // Query the t_xref table to get all metadata for this ProxyPort using its ea_guid
            var sqlXrefQuery = "SELECT * FROM t_xref WHERE Client = '" + ea_guid + "';";
            var xrefResultXML = Repository.SQLQuery(sqlXrefQuery);
            var xrefXmlDoc = new ActiveXObject("MSXML2.DOMDocument.6.0");
            xrefXmlDoc.async = false;
            xrefXmlDoc.loadXML(xrefResultXML);

            var xrefRows = xrefXmlDoc.selectNodes("//Row");

            // Print the relevant xref table data for this ProxyPort
            if (xrefRows.length > 0) {
                for (var j = 0; j < xrefRows.length; j++) {
                    var row = xrefRows.item(j);
                    var xrefID = row.selectSingleNode("XrefID").text;
                    var description = row.selectSingleNode("Description").text;
                    var client = row.selectSingleNode("Client").text;

                    // Output only the relevant fields
                    Session.Output("Xref Record #" + (j + 1) + ":");
                    Session.Output("XrefID: " + xrefID);
                    Session.Output("Description: " + description);
                    Session.Output("Client: " + client);
                    Session.Output("\n"); // Print a line break between rows
                }
            } else {
                Session.Output("No xref data found for ProxyPort: " + name);
            }
            Session.Output("\n");  // Print a line break between ProxyPorts
        }
    } else {
        Session.Output("No ProxyPorts found in the selected package.");
    }
} else {
    Session.Output("No package selected in the Project Browser.");
}


Some ports have a value in the Description column like this:  Description: @PROP=@NAME=isConjugated@ENDNAME;@TYPE=Boolean@ENDTYPE;@VALU=-1@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;
  where I can retrieve the isConjugated but on some other, which are also conjugated, the output looks like this:  Description: @STEREO;Name=ProxyPort;FQName=SysML1.4::ProxyPort;@ENDSTEREO;
.
Even if I conjugate it in the diagram, it still has no value for isConjugated. Am I missing something like refresh of my diagram to update the table or is there a better way? Hope my problem is more understandable now.

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: isConjugated in Proxy Ports via SQL
« Reply #3 on: September 20, 2024, 09:19:28 pm »
Ah, I see. The problem is that query for t_xref is not specific enough.

SELECT * FROM t_xref WHERE Client = '" + ea_guid + "'"
often returns more then one result, one for the steroetypes, one for the custom properties.

If you are only interested in the custom properties you should select only those

SELECT * FROM t_xref WHERE name = 'CustomProperties' and Client = '" + ea_guid + "'"

Geert