1. Connector for Sparx Enterprise Architect

    Artikel: AN0002474Aktualisiert: 16.05.2022
    Die vorgegebene Sprachenversion vom Artikeltext wird angezeigt, weil es kein Text von der ausgewählten Sprache und Version gibt.

    By means of this connector you can transfer data between ObjectGears and Sparx Enterprise Architect. This enables you to get e.g. information about processes modelled in EA to configuration database CMDB and perform Business Impact Analysis or vice versa load into EA configuration items (applications, servers) and connect these items with processes into maps containing both process, application, data and technology layer.

    Connector is provided by program Com.ObjectGears.EnterpriseArchitect.exe. Connector configuration is performed in the file Com.ObjectGears.EnterpriseArchitect.exe.config (incl. definition of database connection stringu). Connector is executed with parameter model_code.class_code. You can use bat file for execution.

    Example of bat file:

    "C:\OG\OG.EA\Com.ObjectGears.EnterpriseArchitect.exe" "ea.ea_scripts"
    pause

    Above stated cmd command (bat file) executed connector, that performs scripts stored in the class ea_scripts of the model ea. The execution has to be performed on computer with a logged in user because, because Enterprise Architect requires user context. Connector therefore cannot be executed e.g. by ObjectGears winservice nor ObjectGears web, but can run e.g. as scheduled task in Windows. 

    The logic itself is stored in ObjectGears class, where you can easily edit it.

    Mandatory columns of the class for EA scripts:

    Column code Column type Description
    name Text Script name
    script Text Script itself
    active Yes/No Information, whether script should be executed.
    order Integer Order, in which the script should be executed.

    Example of the script for transfering data from Enterprise Architect to ObjectGears:

    OGEA.Open('C:\\EA\\Archimate\\Devices.eap');
    var pac = OGEA.FindPackage('Model\\Technology layer\\Source elements');


    var cl = OGModel.ClassDefs['ea_data'];
    var f = OG.DataRow.GetDataRowFilter(cl.Id);
    f.Datas_OnlyActiveRows = true;
    var drl = OG.DataRow.GetDataByFilter(f);

    var map = OGEA.CreateDataRowMapping();
    map.ElementName = 'name';

    //created new items into EA and "deletes" those in EA which are not in drl
    var mres = pac.Merge(drl, map);

    //create records in OG
    for( var i = 0; i < mres.NotMappingElements.Count; ++i)
    {
      var el = mres.NotMappingElements[i];
      var ndr = OG.DataRow. CreateNew(cl.Id);
      ndr['name'] = el.Name;
      ndr['stereotype'] = el.Stereotype;
      OG.DataRow.SaveData(ndr);
    }

    //delete DR that were not paired
    for( var i = 0; i < mres.NotMappingDataRows.Count; ++i)
    {
      var dr = mres.NotMappingDataRows[i];
      OG.DataRow.DeleteData(dr.Id, cl.Id);
    }

    //update DR if there was a change
    for( var i = 0; i < mres.CurrentDataRows.Count; ++i)
    {
      var dr = mres.CurrentDataRows[i];
      var el = dr.GetColumnData(-1);

      if (dr['stereotype'] != el.Stereotype)
      {
        dr['stereotype'] = el.Stereotype;
        OG.DataRow.SaveData(dr);
      }
    }

    OGEA.Close();

    The script will from Enterprise Architect elements in folder Source elements...

    ...and stores them into class EA data.

     

    Example of a script for transferring data from ObjectGears to Enterprise Architect:

    OGEA.Open('C:\\EA\\Archimate\\Devices.eap');
    var pac = OGEA.FindPackage('Model\\Technology layer\\Imported elements');


    var cl = OGModel.ClassDefs['ea_data'];
    var f = OG.DataRow.GetDataRowFilter(cl.Id);
    f.Datas_OnlyActiveRows = true;
    var drl = OG.DataRow.GetDataByFilter(f);

    var map = OGEA.CreateDataRowMapping();
    map.ElementName = 'name';

    //creates new items into ea and "deletes" those from ea that are not in drl
    var mres = pac.Merge(drl, map);

    for( var i = 0; i < mres.NotMappingDataRows.Count; ++i)
    {
      var dr = mres.NotMappingDataRows[i];
      var el = pac.CreateElement(dr['name'], 'Class');
      el.Stereotype = dr['stereotype'];
      el.Update();
    }

    //delete EA elements which were not paired
    for( var i = 0; i < mres.NotMappingElements.Count; ++i)
    {
      var el = mres.NotMappingElements[i];
      pac.DeleteElement(el);
    }

    //load changes in dr into el
    for( var i = 0; i < mres.CurrentDataRows.Count; ++i)
    {
      var dr = mres.CurrentDataRows[i];
      var el = dr.GetColumnData(-1);

      if (dr['stereotype'] != el.Stereotype)
      {
        el.Stereotype = dr['stereotype'];
        el.Update();
      }
    }

    pac.Update();

    OGEA.Close();

    The script will read data from the given EA class and stores them in folder Imported elements.

×