Class

mendix/lib/MxMetaObject

mendix/lib/MxMetaObject()

Provides access to an entity and its meta data in the applications's domain model.

This class should never be instantiated manually.

Constructor

# new mendix/lib/MxMetaObject()

Constructs a new MxMetaObject.

Methods

# getAttributes() → {Array.<string>}

Returns the names of all attributes.

the names of the attributes

Array.<string>
Example
var attrs = mxmetaobject.getAttributes(); // [ "Name", "Age" ];

# getAttributesWithoutReferences() → {Array.<string>}

Returns the names of the non-reference attributes.

the names of the attributes

Array.<string>

# getEntity() → {string}

Returns the entity name.

name of the entity

string

# getEnumCaption(attr, value) → {string}

Returns the caption of an enumeration value.

Parameters:
Name Type Description
attr string

attribute

value string

enumeration value

the caption of the enumeration value.

string
Example
mxmetaobject.getEnumCaption("Color", "red"); // "Rouge"

# getEnumMap(attr) → {Array.<{key: string, caption: string}>}

Returns the enumeration values and captions of an enumeration in the correct order.

Parameters:
Name Type Description
attr string

attribute to get the values and captions for

values and caption of the enumeration

Array.<{key: string, caption: string}>
Example
mxmetaobject.getEnumMap("Color"); // [ { key : "red",   caption : "Red" },
                                  //   { key : "green", caption : "Green" },
                                  //   { key : "blue",  caption : "Blue" } ]

# getOptions(attr) → {Array.<string>}

Returns the possible values for an enumeration attribute.

Parameters:
Name Type Description
attr string

attribute to get the values for

possible values of the attribute

Array.<string>
Example
mxmetaobject.getOptions("Color"); // [ "red", "green", "blue" ]

# getReferenceAttributes() → {Array.<string>}

Returns the names of the reference attributes.

the names of the attributes

Array.<string>
Example
var refs = mxmetaobject.getReferenceAttributes(); // [ "Mod.Person_Parent",
                                                  //   "Mod.Person_Company" ]

# getSelectorEntity(attr) → {string}

Returns the referred entity of a reference attribute.

Parameters:
Name Type Description
attr string

reference attribute

entity name

string
Example
mxobj.getSelectorEntity("CRM.Order_OrderLine"); // "CRM.OrderLine"

# getSubEntities() → {Array.<string>}

Returns the entities that inherit form this entity.

the inheriting entities

Array.<string>
Example
mxmetaobject.getSubEntities(); // [ "MyModule.EntityA", "MyModule.EntityB" ]

# getSuperEntities() → {boolean}

Returns the inheritance chain of this entity.

the names of the entities in the inheritance chain.

boolean
Example
mxmetaobject.getSuperEntities(); // [ "MyModule.EntityC",
                                 //   "MyModule.EntityD",
                                 //   "System.User" ]

# has(attribute) → {boolean}

Checks whether this entity has a specific attribute.

Parameters:
Name Type Description
attribute string

to check

true if the MxMetaObject has the attribute, false otherwise

boolean
Example
if (mxmetaobject.has("Name")) {
    console.log("has Name");
} else {
    console.log("does not have Name");
}

# hasSubEntities() → {boolean}

Checks whether other entities inherit from this entity.

true if other entities inherit from this entity, false otherwise

boolean
Example
if (mxmetaobject.hasSubEntities()) {
    console.log("is inherited from");
} else {
    console.log("is not inherited from");
}

# hasSuperEntities() → {boolean}

Checks whether this entity inherits from another entity.

true if the entity inherits from another entity, false otherwise

boolean
Example
if (mxmetaobject.hasSuperEntities()) {
    console.log("inherits from another entity");
} else {
    console.log("does not inherit from another entity");
}

# inheritsFrom(ancestor)

Checks whether this entity inherits from another.

Parameters:
Name Type Description
ancestor string

the entity to check for ancestry

true if this entity inherits form ancestor, false otherwise

Example
if (mxmetaobject.inheritsFrom("System.User")) {
    console.log("inherits from System.User");
} else {
    console.log("does not inherit from System.User");
}

# isA(entity)

Checks whether this entity is an instance of or inherits from another entity.

Parameters:
Name Type Description
entity string

entity to check for ancestry

true if the object is an instance of entity, false otherwise

Example
if (mxmetaobject.isA("System.User")) {
    console.log("a System.User");
} else {
    console.log("not a System.User");
}

# isBidirectionalReference(attr) → {boolean}

Checks whether a reference attribute is owned by both sides

Parameters:
Name Type Description
attr string

attribute to check

trueif attr is a reference which is owned by both sides, false otherwise

boolean
Example
if (mxmetaobject.isBidirectionalReference("Children" {
    console.log("bidirectional reference");
} else {
    console.log("not a bidirectional reference");
}

# isBoolean(attr) → {boolean}

Checks whether an attribute is of type Boolean.

Parameters:
Name Type Description
attr string

attribute to check

true if attr is of Boolean type, false otherwise

boolean
Example
if (mxmetaobject.isBoolean("Checked")) {
    console.log("Boolean");
} else {
    console.log("not a Boolean");
}

# isDate(attr) → {boolean}

Checks whether an attribute is of type Date.

Parameters:
Name Type Description
attr string

attribute to check

true if attr is of Date type, false otherwise

boolean
Example
if (mxmetaobject.isDate("DoB")) {
    console.log("Date");
} else {
    console.log("not a Date");
}

# isEnum(attr) → {boolean}

Checks whether an attribute is of type Enumeration.

Parameters:
Name Type Description
attr string

attribute to check

true if attr is of Enumeration type, false otherwise

boolean
Example
if (mxmetaobject.isEnum("Colors")) {
    console.log("Enumeration");
} else {
    console.log("not an Enumeration");
}

# isLocalizedDate(attr) → {boolean}

Checks whether an attribute is of type Date and is localized.

Parameters:
Name Type Description
attr string

attribute to check

true if attr is of Date type and is localized, false otherwise

boolean
Example
if (mxmetaobject.isLocalizedDate("DoB")) {
    console.log("localized Date");
} else {
    console.log("not a localized Date");
}

# isNumeric(attr) → {boolean}

Checks whether an attribute has a numeric type.

Types that are considered numeric are: Integer, Long and Decimal.

Parameters:
Name Type Description
attr string

attribute to check

true if attr is of Number type, false otherwise

boolean
Example
if (mxmetaobject.isNumeric("Count")) {
    console.log("Number");
} else {
    console.log("not a Number");
}

# isObjectReference(attr) → {boolean}

Checks whether an attribute is a reference.

Parameters:
Name Type Description
attr string

attribute to check

true if attr is a reference, false otherwise

boolean
Example
if (mxmetaobject.isObjectReference("Mother")) {
    console.log("reference");
} else {
    console.log("not a reference");
}

# isObjectReferenceSet(attr) → {boolean}

Checks whether an attribute is a reference set.

Parameters:
Name Type Description
attr string

attribute to check

true if attr is a reference set, false otherwise

boolean
Example
if (mxmetaobject.isObjectReferenceSet("Children")) {
    console.log("reference set");
} else {
    console.log("not a reference set");
}

# isPassword(attr) → {boolean}

Checks whether an attribute is of type Password.

Parameters:
Name Type Description
attr string

attribute to check

true if attr is of Password type, false otherwise

boolean
Example
if (mxmetaobject.isPassword("Password")) {
    console.log("Password");
} else {
    console.log("not a Password");
}

# isReference(attr) → {boolean}

Checks whether an attribute is a reference or reference set.

Parameters:
Name Type Description
attr string

attribute to check

true if attr is a reference or reference set, false otherwise

boolean
Example
if (mxmetaobject.isReference("Children")) {
    console.log("reference or reference set");
} else {
    console.log("not a reference or reference set");
}