Book a Demo

Author Topic: Automatically link Physical and Logical attributes  (Read 5138 times)

tjs

  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Automatically link Physical and Logical attributes
« on: September 10, 2014, 01:22:50 am »
I'm writing a script that will create links between the attributes of a logical model (user created) and the columns of a physical model (produce from the Logical model with an MDA transform).

  • How do I access a class's "Transformed from" relationship (that is visible in the traceability view) via the automation interface?
  • What field should I update to mimic the "Link Element To Feature" menu option?
  • I notice the MDA transform generates an "XREF" that links source class to generated tables. How do I access this via automation?

I am doing this so that I can visualize traceability between attributes and columns and so that I can export binding values for JPA annotations.

« Last Edit: September 10, 2014, 01:24:30 am by tjs »

tjs

  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: Automatically link Physical and Logical attrib
« Reply #1 on: September 10, 2014, 05:52:19 am »
After doing some digging into the DB schema,  I noticed that the XREF table maintains all the referencing information that links PIMs to PSMs (after an MDA Transform).

Example: "select * from t_xref where t_xref.Type='Transformation'"

This is the information I need to generate binding information.

How do I access XREF via scripting interface (javascript)?


tjs

  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: Automatically link Physical and Logical attrib
« Reply #2 on: September 10, 2014, 05:54:42 am »
I determined that the "Link Element To Feature" can be mimicked by creating a new connector of type 'Realization'.

Example (javascript):

Code: [Select]
newConnector = supplier.Connectors.AddNew("test binding", "Realization");
      newConnector.ClientID = supplier.ElementID;
      newConnector.SupplierID=client.ElementID;
      newConnector.StyleEx="LFSP="+clientAttribute.AttributeGUID+"R;LFEP="+supplierAttribute.AttributeGUID+"L";      
     

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Automatically link Physical and Logical attrib
« Reply #3 on: September 10, 2014, 08:04:27 am »
You can read all tables via Repository.SQLQuery("SELECT ... ")

q.

tjs

  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: Automatically link Physical and Logical attrib
« Reply #4 on: September 10, 2014, 08:05:31 am »
I am now able to resolve the identity (GUID) of objects that were transformed by the MDA transformation. With this mapping data I can create realization associations between the PIM and the PSM and export JPA annotation data (from tagged values in logical model).

Here is an ugly solution  :-X since there is evidently no Automation interface for XREF data:

Code: [Select]
     //returns an EA.Element (table column) that was generated from a logical models class logicalClass
      function getTransformedClass(classElement) {            
            
            var logicalClass as EA.Element;
            logicalClass = classElement;
            var guid= logicalClass.ElementGUID;
            
            //Session.Output("logicalClass: "+logicalClass.Name+" guid: "+ guid);
                  
            var qry ="select * from t_xref where t_xref.Type='Transformation' and t_xref.supplier='"+guid+"';";       
            var result = Repository.SQLQuery(qry);
      
            //Session.Output("qry for'"+logicalClass.Name+": "+ qry);
            //Session.Output("result: "+ result);
            
            /*
            //Example Dataset result from Repository.SQLQuery() method
            <EADATA version="1.0" exporter="Enterprise Architect">      
            <Dataset_0><Data><Row><XrefID>{23837F97-084A-400f-A51D-1AC275D71EA9}</XrefID><Name>Table</Name><Type>Transformation</Type><Visibility/><Namespace>DDL</Namespace><Requirement/><Constraint/><Behavior/><Partition/><Description/><Client>{243D969E-1F71-47e4-B388-9040F5A73A42}</Client><Supplier>{748E0ED8-4A83-4a4a-8B8E-97598C469DE6}</Supplier><Link>{3FC9840B-3507-4ff8-9E4A-3B64CA18329B}</Link></Row></Data></Dataset_0></EADATA>
            */      

            var startTag = "<Client>";
            var endTag = "</Client>";
            var clientGUID = getXMLValue(result, startTag, endTag);
            //Session.Output("client guid: "+ clientGUID);
            
            /*
            var startTag = "<Supplier>";
            var endTag = "</Supplier>";
            var supplierGUID = getXMLValue(result, startTag, endTag);
            Session.Output("supplier guid: "+supplierGUID);
            */
            return Repository.GetElementByGuid(clientGUID);
            
      }
      
      function getXMLValue(xmlString,startTag,endTag){
            var start = xmlString.lastIndexOf(startTag);
            var end = xmlString.lastIndexOf(endTag);
            
            start= start+ startTag.length;  //adjust for
            var len = end-start;
            leng = len -endTag.length;
            var value = xmlString.substr(start,len);
            return value;
      }