Chapter 3: Object Model

Scripting is all about finding and manipulating objects in the tool. There might be differences in syntax and style between the individual scripting languages, but the general underlying Object Model (OM) is the same. It is based on the medini analyze metamodel that is described in detail in a separate document.

In general, any Object, once obtained by a Finder operation or pre-defined in the current scope, has attributes, references and operations. Attributes and references can be read; they can also be modified if they are not derived or read-only and if the scripting language supports it. Operations can be executed.

// read a value from an attribute (JS . notation)
var name = object.name;

// write a value
object.name = object.name + " Tested";

// get a reference element
var otherEnd = object.customReference;

// set a referenced element
object.otherEnd = otherObject;

// execute an operation
var traced = object.mediniGetTracedElements(Metamodel.sysml.SysMLPart);

The way how attributes and reference are accessed, depends on the scripting language. In most cases the '.' notation followed by the name of the attribute is used.

// JavaScript
object.name != "" 
  && object.mediniGetTracedElements(Metamodel.sysml.SysMLPart).size() != 0;

-- OCL
self.name <> '' 
  and mediniGetTracedElements(sysml::SysMLPart)->notEmpty()

Note that in OCL the access to an unknown property is not allowed and will result in an execution error while Java Script allows it unless the script is executed in strict mode.