Skip to content

jArchi Quick Start

Phil Beauvoir edited this page Jul 1, 2018 · 35 revisions

jArchi Quick Start

This is a very brief introduction to jArchi to help you get going.

AS THIS IS IN THE BETA STAGE, PLEASE DO NOT RUN JARCHI SCRIPTS ON MODELS WITHOUT A BACKUP!

ONLY USE JARCHI ON TEST MODELS!

Install the jArchi plug-in

  1. Once you have downloaded the jArchi plug-in zip file, run Archi in administrator mode (On Windows, right-click the Archi program file or shortcut and select "Run as Administrator"). On Mac and Linux you may not need to do this if you have write access permission to Archi's installation.
  2. From Archi's Help menu select "Install Archi Plug-in" and, in the dialog, select the zip file and follow the instructions.
  3. Restart Archi.
  4. The two tabs ("Scripts Manager" and "Scripts Console") will not be visible at first. You can either show the Scripts Manager tab from the "Tools" menu item or select "Reset Window Layout" from the "Window" menu. We suggest the latter as the positioning of the Scripts Manager will default to a less than ideal position.

Install the example Scripts

From the Scripts Manager click the "Restore Example Scripts" button. Example jArchi scripts will be copied to the Scripts Manager in an "examples" folder.

You can run each script by double-clicking it or clicking the "Run Script" button. Note that some scripts assume that you have an ArchiMate model selected in the Models Tree or a View.

jArchi scripts have an *.ajs file extension.

A good start is to select a model in the Models Tree and run the "Anonymize" script. Take a look at the model's names, documentation and properties. Click "Undo" in Archi to undo this action.

Select your Script Editor

As jArchi scripts are JavaScript you should set your preferred code editor in Archi's Preferences. This is found in the "Scripting" tab of Preferences. Set the path to your preferred editor. An example is "C:\Program Files\Microsoft VS Code\Code.exe". You can edit the script by pressing the "Edit" button.

Organise your Scripts

You can add new folders and files in the Scripts Manager as well as organising them with drag and drop. You can drag and drop files from the desktop to the Scripts Manager with the option to either copy them or link to them.

The Scripts Console

Script output messages and error messages can be seen in the Scripts Console. The Scripts Console can be toggled on or off by pressing the "Show Console" button in the Scripts Manager.

The Current Model ("model")

jArchi works on the "Current Model". This is the selected model in the Models Tree or a View. For example, the following snippet adds a new Business Actor to the currently selected model:

model.addElement("business-actor", "foo");

You reference the current model as the model global variable.

The Current Selection

You can reference currently selected objects in the Models Tree or View by using the selection global variable, $(selection) or selection.

For example, if you select some elements in the Models Tree and run the following script, all (valid) elements will be set to the Business Role type, " (changed)" appended to the name, and the fill color set to red.

$(selection).each(function(element) {
    element.type = "business-role";
    element.name += " (changed)";
    element.objectRefs().attr("fill-color", "#ff0000");
});
Clone this wiki locally