MWZ's picture

Step 1 - Output model names

Based on our first “Hello ARIS” report we now want to generate an output document which contains ARIS content. Therefore we create a report which lists all selected models with their names and the names of the contained objects.

For using the selected models in your report you have to enter the following code line:

var aModels = ArisData.getSelectedModels();

And now you can iterate over these models and output their names.

To get the names we have to call method “Name()” with the language as parameter. To get this language we us the following code line:

var nLocale = Context.getSelectedLanguage();    // Selected database language

So the complete script looks as follows:

var oOutput = Context.createOutputObject();     // Output object
var nLocale = Context.getSelectedLanguage();    // Selected database language

var aModels = ArisData.getSelectedModels();     // Array of selected models
for (var i = 0; i < aModels.length; i++) {            
    var oModel = aModels[i];                    // Current model
    var sModelName = oModel.Name(nLocale);      // Name of current model

    oOutput.OutputLn(sModelName, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 0);
}
oOutput.WriteReport();

Step 2 - Output model and object names

In a further step we want to add the names of all objects which are contained in our models.

To get the objects of the models we use the following method:

var aObjDefs = oModel.ObjDefList();         // All object definitions that have occurrences in the model

So that the report now looks like this:

var oOutput = Context.createOutputObject();     // Output object
var nLocale = Context.getSelectedLanguage();    // Selected database language

var aModels = ArisData.getSelectedModels();     // Array of selected models
for (var i = 0; i < aModels.length; i++) {            
var oModel = aModels[i];                    // Current model
var sModelName = oModel.Name(nLocale);      // Name of current model

oOutput.OutputLn("Model: " + sModelName, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 0);
    
var aObjDefs = oModel.ObjDefList();         // All object definitions that have occurrences in the model
for (var j = 0; j < aObjDefs.length; j++) {            
var oObjDef = aObjDefs[i];              // Current object definition
var sObjName = oObjDef.Name(nLocale);   // Name of current object
        
oOutput.OutputLn("Object: " + sObjName, "Arial", 10, Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 10);
    }    
}
oOutput.WriteReport();

You can see: Getting names of objects works in the same way as getting names of models.

Here you can download the entire source code from the "Output models" report.

Note: This article describe how to develop a report in ARIS. See this post for links to similar articles.

 

Tags: ARIS Report Scripting