Get the number of elements per ArchiMate layer in JArchi

Started by Manj75, October 28, 2019, 13:32:20 PM

Previous topic - Next topic

Manj75

Hi,

This may be a simple question but I could not find in the wiki how in JArchi to get the number of elements in each ArchiMate layer.

I am using the example Statistics.ajs are reference and there is a 'business-object' and I can use the following, but there is no equivalent for the other layers:

msg += "Number of ArchiMate business objects: " + $("business-object").size() + "\n";

I want to do the same for each of the layers, but I cannot find what I would expect to be equivalent to 'business-object'

application-object
motivation-object
strategy-object
technology-object
physical-object
implementation&migration-object
other-object

Can you please advise how I can achieve and element count without having to iterate through each specific element type of each layer.

Thanks,
Manjit

Jean-Baptiste Sarrodie

Hi,

The easiest way is to get the folder matching the layer and count its descendants.

Shoud be something like: model.children('folder.Business').find('element').size()

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.

Phil Beauvoir

"business-object" is an ArchiMate element not a layer, and "application-object" etc are neither layers nor objects.

There is no jArchi API to ascertain the ArchiMate layer as the underlying Java object is (purposefully) not exposed in jArchi. One could write a JS method to map all the type names ("business-actor", etc) to layer constants.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Manj75

My apologies; of course 'business-object' is an ArchiMate concept - I made a quick presumption that it was all business layer objects and was a type instead of an actual element.  I will try the solution suggested by JB.

Thanks

Manj75

Hi JB,

I was getting a TypeError with your suggestion stating as follows:

model.children('folder.Business').find('element').size()

Script Error at: javax.script.ScriptException, javax.script.ScriptException: TypeError: model.children is not a function

So having played around I got it working with the following:

$("folder.Business").find('element').size()

Thanks for your help

Jean-Baptiste Sarrodie

Hi,

I've tested it. The right way to do it is:

$(model).children('folder.Business').find('element').size()


using
$("folder.Business")

can match any folder named " Business", so this might go wrong.

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.

Manj75

So, just to confirm the $(model).children will look for the specified Named Selector directly under the model, whereas my approach could result in folders with the Named Selector at any level in the hierarchy, e.g. a folder nested 5 levels in Views with the name given.

I appreciate your corrective suggestion.