3.1. Default Operations

In this section, all default operations that are available for almost all objects are listed and explained.

mediniGetContainer()

{Function} - Returns the container - aka the parent - of an element. The container is the object that "contains" a given element. There can be only one container for a single object at all times. In case the object is a root object and has no container, null is returned.

// check for root container
if (object.mediniGetContainer()) {
    console.log("This element has a container (and is no root)");
}

Stability 3 - Stable

mediniGetOpposites(String referenceName)

{Function} - Returns all objects that refer to an element with a given named reference. This function is typically used to reverse navigate uni-directional references. For example, assuming an object A references object B via a reference foo, you may call mediniGetOpposites("foo") on B to get A. To get all referencing elements, independent of which reference they use, pass null.

Note: This operation returns a list of elements which is always defined (not null) but might be empty.

Note: the reference name is case sensitive.

// find all elements that have a "represents" relation to an object
var representing = object.mediniGetOpposites("represents");
console.log("There are {0} elements representing us", represents.size());

// find all elements referring to us
var all = object.mediniGetOpposites(undefined); // or null

Stability 3 - Stable

mediniGetTracedElements(Object type, String traceKind /* optional */)

{Function} - Returns all objects that are traced to an element with a given optional trace kind. This function is typically used to navigate traces. For example, assuming the two objects A:SysMLPart and B:PJPackage are traced with each other, you may call mediniGetTracedElements(SysMLPart) on B to get A. To get only traced elements, with certain trace kinds, pass the kind as optional second argument.

Note: This operation returns a list of elements which is always defined (not null) but might be empty.

Note: the trace kind is case sensitive.

// find parts traced to this object
var parts = object.mediniGetTracedElements(Metamodel.sysml.SysMLPart);
console.log("There are {0} parts traced to us", parts.size());

// find any traced element but only with trace kind "Satisfies"
var all = object.mediniGetTracedElements(Metamodel.Any, "Satisfies");

Stability 3 - Stable

mediniHaveSameType(Object anotherElement)

{Function} - Returns true if - and only if - the static meta classes of this element is the same as a given other element, otherwise false is returned.

Note: the argument is mandatory and must be defined.

// compare types of two selected elements
var sameType = selection[0].mediniHaveSameType(selection[1]);

Stability 3 - Stable