Xplain.Db.Object

Xplain.Db.Object(conf)

This class represents a Xplain Object, i.e. a xtable. Provides methods to search and / or travers through this objects sub-objects and dimensions.

find

find(target)

This is a synonym for get the get method.

Parameters

target (string|object) – the element you are looking for

Returns

{Xplain.Db.Dimension | Xplain.Db.Attribute} the dimension, attribute or null.

findDimension

findDimension(did)

Finds a dimension by it’s ID. Traverses through all dimensions assigned to this object and returns the dimension with ID did or false if no dimension could be found.

Parameters

did (string) – the ID of the dimension we are looking for

Returns

{Xplain.Db.Dimension} the dimension found or false.

findObject

findObject(oid)

Finds a sub-object (by it’s ID) under this object. Returns the found sub-objects or false.

Parameters

oid (string) – the ID of the object we are looking for

Returns

{Xplain.Db.Object} instance of Xplain.Db.Object

get

get(target)

Find a dimension or attribute which belongs to this object. The input parameter describes the dimension / attribute you are looking for either as string (in Dot-Notation) or as object (a JSON object). The parameter may contain of up to two parts. If the input contains of one part, a dimension with the corresponding ID will be returned (or null if no dimension could be found). If the input contains of two parts, an attribute will be returned where the first part contains the ID of the dimension and the second part contains the ID of the dimension.

Examples:

...
// returns the dimension with ID Birthdate
var myDim = myObject.get('Birthdate');

// returns the attribute with ID Age within the dimension Birthdate
var myAttr = myObject.get('Birthdate.Age');

// same as above but in JSON notation
// Note that the object does not need to be specified
// because it is already implicitly defined by the object of this method.
var myAttr = myObject.get({dimension: 'Birthdate', attribute: 'Age'});
Parameters

target (string|object) – the element you are looking for (see description for details)

Returns

{Xplain.Db.Dimension | Xplain.Db.Attribute} the dimension, attribute or null.

getAllSubObjects

getAllSubObjects(inclThis)

returns an array of all direct and indirect sub-objects of this object.

Parameters

inclThis (boolean) – if true the array will also consist of this object. Defaults to true.

Returns

{array} array of Xplain.Db.Object

getAttributes

getAttributes()

returns an array of all attributes which belong to this object, i.e. all attributes that belong to a dimension that belongs to this object.

Returns

{array} array of all attributes belonging to this object

getDimensions

getDimensions()

returns an array of all dimensions which belong to this object. A filter function may be applied. receives one input parameter (the dimension as instance of Xplain.Db.Dimension). If the function returns false, this dimension will be filtered out. If the function returns anything else, this dimension will be in the result set. For instance, the following filter function would return all dimension, where the annotation semanticType is set to TimeInstant, i.e. it would return all time dimensions.:

// assuming that obj is an instance of Xplain.Db.Object
var timeDims = obj.getDimensions(function(dim) {
  if (dim.getAnnotations() && dim.getAnnotations().semanticType == "TimeInstant")
     return true;
  else
     return false;
});
Returns

{array} array of Xplain.Db.Dimension

getDisplayName

getDisplayName()

Returns the displayName of this object.

Returns

{string} displayName of this object

getForeignKeyDimensions

getForeignKeyDimensions()

Returns an array of all foreign key dimensions of this object. The first element corresponds to the foreign key, which refers to the root object. The second corresponds to the foreign key that references the object under the root object, and so on. Note: that not each object does have a foreign key, therefore this function could also return false.

Returns

{array|boolean} an array of Xplain.Db.Dimension instances or false if this object has no foreign keys.

getId

getId()

Returns the ID of this object. NOTE: this method will return the ID in escaped form, e.g. if the ID is “dummy.ID” this method will return “dummy/.ID” and NOT “dummy.ID”

Returns

{string} the ID of this object

getName

getName()

Returns the short ID (aka name) of this object.

Returns

{string} the name of this object.

getParent

getParent()

returns this objects parent object or null if this object is the root object

Returns

{Xplain.Db.Object} this objects parent object

getParents

getParents(inclRoot)

returns all parent objects of this object or an empty array if this object is the root object.

Parameters

inclRoot (boolean=true) – if false the root object will not be part of the array returned.

Returns

{Array} array of instances of Xplain.Db.Object. All parent objects of this object

getPath

getPath()

Returns the path which leads to this object, i.e. the path through the raw JSON object returned by the backend.

Returns

{Array} an array of strings.

getPrimaryKeyDimension

getPrimaryKeyDimension()

Find the dimension that represents the primary key of this object. Note that not each object does have a primary key, therefore this function could also return false.

Returns

{Xplain.Db.Dimension|boolean} the dimension found or false.

getRawData

getRawData()

Returns this objects’s data as it has been returned by the backend, i.e. “raw”.

Returns

{Object} This object’s data as it has been returned by the backend

getSession

getSession()

Returns the session to which this object belongs.

Returns

{Xplain.Db.Session} the session to which this objects belongs.

getSiblings

getSiblings()

returns all siblings of this object or an empty array if this object does not have any siblings.

Returns

{Array} array of instances of Xplain.Db.Object. All sibling objects of this object

getSubObjects

getSubObjects()

returns an array of all direct sub-objects of this object.

Returns

{array} array of Xplain.Db.Object

getVerboseId

getVerboseId()

Returns the ID of this object in the format the backend uses natively.

Returns

{object} the ID of this object

isChildOf

isChildOf(obj)

Checks if this object is the child of object obj.

Parameters

obj (Xplain.Db.Object) – the obj for which we would like to check if it is the parent object. An instance of Xplain.Db.Object

Returns

{boolean} returns true if this object is the child of object obj, false otherwise.

isPropagatingSelectionsUpward

isPropagatingSelectionsUpward()

returns true if propagateSelectionsUpward is set for this object, false otherwise.

Returns

{boolean} true if propagateSelectionsUpward is set for this object, false otherwise.

isRoot

isRoot()

returns true if this object is the root object

Returns

{boolean} true if object is root object, false otherwise