[solved] Deriving matrices from an archi model ?

Started by ubibene, August 30, 2018, 08:35:19 AM

Previous topic - Next topic

ubibene

Hi guys,

How would you derive matrices from an archi model ?

Let's say a matrix with applications (application components) on rows ,  functions on columns, and cells filled with the relationships between apps and functions (serves, realizes, ....) , all informations would come from an archi model.

Ideally the matrix would be stored in a spreadsheet (csv ,odf or xls document).

I'm thinking of
- exporting the archi model to a neo4j database using @Hervé's database plugin
- writing a jarchi script

Both options will require some work as I'm not familiar with neo4j nor javascript, so any tips are welcomed !

Jean-Baptiste Sarrodie

Hi,

I can see several ways of doing it:

You can already use the CSV export (or the Excel export plugin that is available for people supporting Archi on Patreon) to create a spreadsheet that will contains all informations (mainly elements and relationships). Then it's a matter of writting formula and a pivot table.

You will soon (in Archi 4.3) have a new query tab added to the HTML export (this enhanced report could even run on Archi 4.2 if you extract the new template on GitHub). With this you can run an SQL query that export a list of pairs (Application Component / related Function) in CSV, and then open it in Excel to create a very simple pivot table. I would go for this solution if you only have to do it once in a while, it's the easiest IMHO.

jArchi is another very good choice as you can easily do it too, and you could directly create an Excel file (you have an example provided with jArchi). I would go for this solution is I have to export it frequently.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Hervé

Hi,

There is another plugin that I wrote: the form plugin (https://github.com/archi-contribs/form-plugin)

It is already able to generate matrix (tables), but at the moment, only rows can be dynamically generated (columns being fixed).

I believe it should be possible to generate the columns as well.

Then the export of the table is already possible in an Excel spreadsheet  :D

Best regards
Hervé

ubibene

Thanks for the suggestions, I'll keep you posted !

ubibene

Done with jarchi ! (code is ugly but is working)

ubibene

#5
/*
* New Archi Script
*/

// Load MyExcel and JSZip JS file
load(__DIR__ + "lib/jszip-101.js");
load(__DIR__ + "lib/myexcel.js");



sheet = prepareSheet();
fillSheet(sheet,"business-function","application-component","apps-functions","/");
outputFilename=("C:/archimate_matrices.xlsx");
saveSheet(sheet,outputFilename);



function prepareSheet()
{
   var spreadsheet = $JExcel.new("Calibri 12 #333333");

   return spreadsheet;
}

function saveSheet(sheet,outputFilename)
{
// TODO add error checking
sheet.generate(outputFilename);
}
// Add a new sheet with a name
function fillSheet(sheet,columnType,rowType,tabName,cellSeparator)
{
     sheet.set( { sheet:0, value:tabName } );

    // sheets.add("Sheet 0");
     headers = fillColumns(sheet,columnType,rowType);
     fillRows(sheet,headers,rowType,cellSeparator);

}

function fillColumns(sheet,columnType,rowType)
{

  // Fill columns
    var formatHeader = sheet.addStyle ({
        fill: "#dddddd",
        border: "thin, thin, thin, thin #555555",
        font: "Calibri 12 #000000 B",
    });

    var legend = {name:rowType + "/" + columnType};
    var headers = [legend];

    $(columnType).forEach(function(e) {
        headers.push(e);
        });

        for(var i = 0; i < headers.length; i++) {
            sheet.set(0, i, 0, headers[i].name, formatHeader);
            sheet.set(0, i, undefined, "auto"); // column width is auto
        }
  return headers;
}

function fillRows(sheet,headers,rowType,cellSeparator)
{
  var current_row = 1;
  $(rowType).forEach(function(e)
  {

      sheet.set(0, 0, current_row, e.name);
      relations = $(e).rels();
      for(var i = 1; i < headers.length; i++)
      {
        cellText = "";
        for (var j = 0;j< relations.length;j++)
        {

            if( ( (relations[j].source.id == e.id) &&  (relations[j].target.id == headers[i].id))

                )
            {
                cellText = relations[j].type + cellSeparator + cellText
            }
        }
        sheet.set(0,i,current_row,cellText);
      }
      current_row++;
  }
  );
}

Jean-Baptiste Sarrodie

Great !

Maybe you could share your scripts on GitHub Gist so that users can use them or learn from them.

I've written a very small guide for that.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

ubibene


ubibene

Done. Hoping this is working, don't know much about gist

Jean-Baptiste Sarrodie

Quote from: ubibene on August 30, 2018, 20:34:56 PM
Done. Hoping this is working, don't know much about gist

Seems you know enough ;-)

Your script matches criteria used for search and can now be easily found using this query.

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

ubibene


ievgenii

Hi ubibene,

Please advise where to get jszip-101.js and myexcel.js from?
Quote from: ubibene on August 30, 2018, 13:41:09 PM
/*
load(__DIR__ + "lib/jszip-101.js");
load(__DIR__ + "lib/myexcel.js");


Thanks

Phil Beauvoir

Those .js files are included in the examples of the jArchi download. If you install the examples you should see them in a sub-folder.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.