Archi HTML report - can I change the sorting for elements ?

Started by pkraakman, May 18, 2016, 15:53:29 PM

Previous topic - Next topic

pkraakman

Dear Forum,

I am using the Archi html plugin as a way to communicate my architecture work products to business stakeholder stakeholders. The challenge I have is that the sequence of the elements is alphabetic, where I have a mix of different element on one diagram/view, say application functions and application components and for other views much more.
It would love to be able to sort on element type, say first the application components (alphabetic) and then the application functions (alphabetic).
Is this something which I can easily change or is this a request for the original designers ?

Would be even better if you could simply click/hover the element and then get the information, but I guess that is something only found in the commercial EA tooling domain.

Kind Regards,

Paul Kraakman, Philips Lighting

Jean-Baptiste Sarrodie

Hi,

Welcome to this forum. May I encourage you to describe the way and context in which you use Archi into this thread :-)

Regarding your question, if you are talking about the list of elements into the Elements tab of a View, then you can change it through some hack: In fact all sorts are done "after the fact" through some javascript. So you can customize it by doing some changes in the file frame.js which is located inside your Archi folder in plugins\com.archimatetool.reports_3.2.1.201510051010\templates\html\js

This is done at the end of the file through the call to:
tabElementsRows.sort(strcmp).appendTo(tabElements)

Which basically iterate over each element rows and sort them using the strcmp function which is defined at the begining of the file:
function strcmp(a, b){
var aText = $(a).text().trim().toLowerCase();
var bText = $(b).text().trim().toLowerCase();
if (aText.toString() < bText.toString()) return -1;
  if (aText.toString() > bText.toString()) return 1;
  return 0;
}


You can basically add another function:
function strcmpElement(a, b){
var aText = $(a).children('td').slice(1, 1).text().trim().toLowerCase();
var bText = $(b).children('td').slice(1, 1).text().trim().toLowerCase();
if (aText.toString() < bText.toString()) return -1;
if (aText.toString() > bText.toString()) return 1;
return 0;
}


And use it for sorting Element list:
tabElementsRows.sort(strcmpElement).appendTo(tabElements)

I guess yo get it, so you can do more things if you want.

Regarding "simply click/hover the element and then get the information", that's something that could be done but hasn't been implemented yet (any volunteers ?).

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.

pkraakman

Dear JB,

Yes, I meant the list of elements as they appear below the view. I have made the adjustments in the frame.js file as you have described. As I am not very literate in Java I simply copied your function into the jar and commented out the earlier strcmp call at the end.
The report runs fine, but I see no difference in the sorting of the element list other than alfabetically, where I had hoped to have them sorted according to type, thus on an application behaviour viewpoint first the application functions followed by the application components.

Do I overlook something here, or do I need to use another "hack".

Will post something on the use of Archi as you requested.

Thx. Paul

Jean-Baptiste Sarrodie

Hi,

I've just had a look and finally found several small issues (even a small, unnoticed, bug).

You'll find attached a working .js

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.

pkraakman

Hi JB,

Just re-ran the HTML publication using the frame.js file from your post and yes! it indeed now sorts the elements according to their type in alphabetical order, so for example, first all application components followed by application service, business collaboration etc. This is what I was looking for so thank you very much for that.

However, the sorting order of the names of the elements themselves seems random, in some cases it seems to be based on the sequence in which they appear on the diagram but in other cases not (perhaps based on some internal numbering in the Archi database?). For small models with just a handfull if elements this is ok, but for the larger ones would it be possible to have those sorted in alphabetic order as well or is too complex for a quick implementation?

Kind Regards,

Paul

Jean-Baptiste Sarrodie

Hi,

Quote from: pkraakman on May 24, 2016, 10:25:43 AM
However, the sorting order of the names of the elements themselves seems random, in some cases it seems to be based on the sequence in which they appear on the diagram but in other cases not (perhaps based on some internal numbering in the Archi database?). For small models with just a handfull if elements this is ok, but for the larger ones would it be possible to have those sorted in alphabetic order as well or is too complex for a quick implementation?

And indeed it is (random). For this to change, you have to adapt strcmpElementByType() to use strcmp() when types are the same:

function strcmpElementByType(a, b){
var aText = $(a).children('td')[1].className;
var bText = $(b).children('td')[1].className;
if (aText.toString() < bText.toString()) return -1;
if (aText.toString() > bText.toString()) return 1;
//return 0;
return strcmp(a, b);
}


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.

pkraakman

JB,

Thank you again. :) This is great, I now have the elements listed alphabetically and within that the names of those elements are also alphabetically arranged.

Still would be very interested to have the elements be click-able which would bring us close to the capabiliy of our commercial vendors. Is there some kind of annual or quartely get together to discuus the future developments of Archi where we can propose this ?

Sorry for my late reply as I was on an offsite event last week.

Regards, Paul

Guido Janssen

Hi,

I have been working on html report based on the open group exchange format. I took the inspiration of the html report and the blog of Phil about creating reporting using the exchange format and created report generation using XSLT. I put the code in a github repository: https://github.com/guidohajanssen/archimateviewer It is not finished yet, but a good start  ;)