jArchi – Scripting for Archi

Today, J-B Sarrodie and I are releasing a preliminary beta version of jArchi, the scripting plug-in for Archi. jArchi has a long (albeit slow) development history and received a recent speed bump with some funding and feedback from the technical architecture team at Adeo, in France. This allowed us to develop a closer integration between the jArchi engine and Archi’s UI, resulting in a seamless menu-driven experience for the end-user.

jArchi is a JavaScript-based scripting plug-in built on the Nashorn engine. This means that the end-user can write code, or simple scripts, using JavaScript, and this is then translated into the underlying Java code that drives Archi. jArchi exposes a user-friendly API to the scripter, allowing them to access their models in ways that were only possible before if they were a Java and Eclipse developer. I first wrote a basic implementation of this about 10 years ago using the Rhino engine. This lay on the shelf until now.

J-B and I revived this work earlier this year and invested a lot of time developing a usable API that allows the user to query and manipulate Archi’s ArchiMate models. The API is modelled on that of jQuery and uses the idea of operating on a collection of objects. The $ (dollar) symbol is used as a JavaScript alias for “jArchi”, in the same way as it used as an alias for “jQuery”, and allows operations on the current model. The current model is either the one selected in Archi’s UI or set by the scripter. The following line of code returns a collection of all elements in the current model:

var allElements = $('element');

This collection can be manipulated to query names, documentation and instances in views.

console.log("There are " + $('element').size() + " elements in this model";
console.log("The name of this model is " + model.name);
// All concept type and names
$("concept").each(function(concept) {
    console.log(concept.type + ": " + concept.name);
});
The scripter is able to read and set attributes of all concepts and views including the name, documentation, properties, colour, font, and so on. This leads to some very powerful possibilities. Some examples of use:
  • Anonymise models for sharing
  • Bulk change element types
  • Create heat maps based on certain criteria
  • Generate Excel spreadsheets
  • Create reports
  • Import and export model data in various formats

We think that jArchi will be a game changer.

But we are also changing the way that we distribute this plug-in. J-B and I have invested a lot of time and work into jArchi, and also into the continuing development and support of Archi itself. We would like this to continue as a two-way process and to thank and reward those Archi users who have joined us in this reciprocal endeavour. So, we are releasing the beta version of jArchi at first to our friends at Patreon and to our friends who have kindly donated to Archi previously via PayPal or in other ways. After a beta testing period we will be asking other users for a relatively small donation in order to download jArchi. If you have already donated (via Patreon or PayPal or in another way) we will be making the download available to you today. Patreon members will be provided with a download link, while our non-Patreon friends (Paypal donators, patch/pull-request submitters and Archi plug-in developers) will need to contact us for the download (we are working on providing a more convenient distribution platform post-beta).

The source code for jArchi is available at GitHub and is licenced under the MIT licence. This will always be the case, and you are, of course, free to use this. But we kindly ask that the binary distribution that we are providing is not shared and that jArchi users please contribute back to us. As a thank-you, the binary distribution will contain premium content in the form of example jArchi scripts and some level of support. For this content we have used the “HUMANS” licence:

The HUMANS (Help Us Make Archi Noteworthy & Sustainable) licence goal is to bring happiness
to both Archi users and developers. This means that we would like users of
jArchi to donate something and get this useful script as a gift in return (and feel great!).

The only restrictions that apply are:
– You can’t redistribute this script.
– You can’t use this script for commercial purposes unless you obtained it from the official
Archi distribution channels.

If we are able to make Archi and plug-ins such as jArchi successful we will be able to continue to develop more tooling solutions and sustain the overall development and support of Archi. So, please, join us in this adventure! The starting point is the jArchi Wiki.

Posts created 35

6 thoughts on “jArchi – Scripting for Archi

  1. Hi
    Would it be possible to put a jArchi example of importing a xlsx file into a Archi model?
    Thank you

  2. Thanks for all the hard work and huge effort you guys are doing with jScript it’s highly appreciated. I do however have a couple of questions:
    1) How do I change the plug-in such that I can use for instance Visual Studio code instead of Notepad is this a Registry setting?
    2) Would it be possible to activate/initiate intellisense like code helper functionality in Visual Studio Code or similar. If not how do I find out such things as the properties of a model element. (I would like to query and find all concepts /model elements of a specific type having a custom made property set to a specific value)
    Thanks

    1. Hi Claus,

      1) You can set the editor in Archi’s preferences. For example, I have it set to “C:\Program Files\Microsoft VS Code\Code.exe”

      2) I don’t know how you would do this, except maybe as a VS Code extension.

  3. I found the prop functions in the EObjectProxy.java file i GitHub – they are most likely enough/supporting me to accomplish what I’m trying to do.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top