JArchi finding a visual note with a property

Started by Manj75, December 11, 2019, 15:16:11 PM

Previous topic - Next topic

Manj75

Hi,

I have a number of views where I have used a Visual Note concept - these do not have any name property that can be assigned to the concept, however there is a properties tab to define key/value properties.  So I have a Note concept with a property name 'modelName' = 'test'.

What I want to do using JArchi script to to find that Note concept and update the text.

Issue I am having is that I and unable to successfully find the concept using as basic:

$('diagram-model-note').each(function(o) {
  console.log("> concept: " + o.name + " modelName=" + o.prop('modelName') + " [type:" + o.type + "]");
});


This does not even show the log line indicating that it is not even finding diagram-model-note.  To further support this I changed the type to a 'capability', having added the property to one capability concept in my model the same line succeeds and actually shows a log line for each 'capability' found.

$('capability').each(function(o) {
  console.log("> concept: " + o.name + " modelName=" + o.prop('modelName') + " [type:" + o.type + "]");
});


Result:

> concept: Browse and Shop modelName=null [type:capability]
> concept: Mobile/Apps modelName=null [type:capability]
> concept: Search modelName=null [type:capability]
> concept: Image Service modelName=null [type:capability]
> concept: Reviews modelName=null [type:capability]
> concept: Product Information Management modelName=null [type:capability]
> concept: Spreads modelName=null [type:capability]
> concept: My Account modelName=null [type:capability]
> concept: Innovation modelName=null [type:capability]
> concept: Checkout modelName=null [type:capability]
> concept: Platform Modernisation modelName=null [type:capability]
> concept: Payments modelName=null [type:capability]
> concept: Google Tag Manager modelName=null [type:capability]
> concept: CRM modelName=null [type:capability]
> concept: CMS modelName=null [type:capability]
> concept: Ordering modelName=null [type:capability]
> concept: Technical Enablement modelName=test [type:capability]


Is Visual Note and other visual concepts not supported in this way within JArchi or am I doing something wrong?

Appreciate your assistance.

Thanks,
Manjit

Manj75

Update:

I've created a new empty model and just added a Capability and Visual Note concepts to the Default View, but this time I parse all objects, and it confirms that Visual * elements are not supported - is there any reason for this as this is not stated in the JArchi guide and really should be supported.

$("*").each(function(o) {
  console.log("> concept: " + o.name + " modelName=" + o.prop('modelName') + " [type:" + o.type + "]");
});


Result:

Test Archi Script
Model name: Test
> Found model dashboard property, modelDashboardViewName = Default View
> Number of views in model: 1
> concept: Strategy modelName=null [type:folder]
> concept: Capability modelName=null [type:capability]
> concept: Business modelName=null [type:folder]
> concept: Application modelName=null [type:folder]
> concept: Technology & Physical modelName=null [type:folder]
> concept: Motivation modelName=null [type:folder]
> concept: Implementation & Migration modelName=null [type:folder]
> concept: Other modelName=null [type:folder]
> concept: Relations modelName=null [type:folder]
> concept: Views modelName=null [type:folder]
> concept: Default View modelName=null [type:archimate-diagram-model]
>>

Phil Beauvoir

Visual objects can be found something like this:

$('view').find('diagram-model-note').each(function(note) {
    console.log(note.text);
});


Get all views in the current model and find notes and then print each text.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Manj75

Fantastic Phil 8)

So, to confirm it seems that 'diagram-model-note' has to be searched within a 'view' collection using find method - is this correct?

It's a shame that it is not consistent in that the wiki guide states that a Selector using type can be used and I'd have thought that $('diagram-model-note') would work.  It would be good to understand the reason why this does not work.

Many thanks for the resolution.


Phil Beauvoir

There's probably a lot of documentation in the wiki that could be improved and re-organised or clarified. But that's why we made it an open wiki for folks to improve it.  :)
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

Quote from: Manj75 on December 11, 2019, 15:49:46 PM
Fantastic Phil 8)

So, to confirm it seems that 'diagram-model-note' has to be searched within a 'view' collection using find method - is this correct?

Yep.

QuoteIt would be good to understand the reason why this does not work.

$('selector') works on the current model and valid selectors are "view", "folder" or "concept".
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Jean-Baptiste Sarrodie

Hi,

The main goal of the API is to navigate the model tree, thus focusing on real ArchiMate concepts (folders and views are added because they are seen as "containers"). That's why $() function has several guardrails included, and thus why $('*') returns a collection with only ArchiMate related objects, so no visual things like notes.

But... there's a trick ;-)

The model is itself an object that you can work on, so if you create a collection containing the model object (and not the model content), then you can use the API on it... unfiltered:


$(model).find('diagram-model-note').each(function(o) {
  console.log("> concept: " + o.text);
});


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

Quote from: Jean-Baptiste Sarrodie on December 11, 2019, 20:26:28 PM
But... there's a trick ;-)

The model is itself an object that you can work on, so if you create a collection containing the model object (and not the model content), then you can use the API on it... unfiltered:


$(model).find('diagram-model-note').each(function(o) {
  console.log("> concept: " + o.text);
});


Good grief, that's clever. I didn't know that.  ;)
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Jean-Baptiste Sarrodie

Hi,

;D

That's also useful to get toptevel folders: $(model).children('folder.Strategy')

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

#9
Quote from: Jean-Baptiste Sarrodie on December 11, 2019, 20:40:47 PM
Hi,

;D

That's also useful to get toptevel folders: $(model).children('folder.Strategy')

JB

We should make jArchi open source then people could add these useful tips to a wiki!  (just kidding ;) )
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Manj75

This is all great stuff and really handy for what I need - a better understanding of how the API works really helps.

To give some context I am creating a Dashboard view for the Architecture department model, which will show model statistics as well as view links, and the primary objective is to incorporate the example Statistics.ajs to populate diagram-model-note boxes that have a property to name it.  I search for the property to identify it and then update the text with statistics, number of archimate elements, relationship and views and model name.

I am slowly but surely moving towards a means to have a scheduled, daily or weekly, generate HTML report and publish and will find out if I hit any other hurdles.  The aim is to have a read-only view of the model accessible to a broader audience in the business.

I have not yet used the Archi CLI, but I intend to use that to write a powershell script that is run on a schedule to:

  • Refresh model from remote GIT
  • Generate HTML report
  • Publish the HTML folders/files to the local site/wiki

It would also be good to have Markdown reporting supported, but I notice some people have produced jarchi scripts for this and I'll look into these.

Future improvements that I'm looking at are:

  • Incorporate ServiceNow import to capture definitive concepts for the technology/physical layer using Herve's plugin for which I am awaiting a new plugin release. I've raised a number of feature requests to improve it and currently it is not supported in CLI, so I can't automate this.
  • Create heatmap based on risk assessments driven off ServiceNow parameters.
  • Fill concepts/elements with an image that scales well, similar to the specialisation plugin, which I recall JB mentioned that this is on the roadmap.

The model becomes much for dynamic rather than just static views.

Another request I posted on the forum was to have jArchi scripts run on startup of Archi, but you are looking the see if this would be popular with the community to implement it.  If this was available it would enable me for example to find a model dashboard view and if one exists have it opened as a landing page for the model.  Will see if this gets put on the roadmap.

Things are progressing very well with the changes I am putting in place and Archi tool is just brilliant for what is needed.

Thanks,

Manjit

Manj75

Hi Phil/JB,

I've now decided that instead of an ArchiMate View I will create the dashboard as a Canvas, where I can use the canvas-model-block and canvas-model-sticky.  These objects offer more functionality in terms of embedding images, adding hints, etc, than a View diagram-model-note.

However, the issue I now face is that there is nothing documented in the jarchi wiki about how to get/set the attributes of these elements:

Sticky: How to get and set the Content and Notes on the Main tab
Block: How to get and set the Content on the Main tab

If there is a way to do the above that I'm good to complete what I plan to do.

Thanks

Phil Beauvoir

Hi Manjit,

Creating Canvas and Sketch objects is not implemented yet in jArchi. I think you can get them as objects to get bounds, color etc but no getters/setter for text hints image etc.

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

Manj75

I'll revert back to using a View then - thanks for confirming this.