Xplain.Db.Dimension
- Xplain.Db.Dimension(conf)
This class represents a Xplain Dimension. It provides methods to search and / or traverse through the attributes of this dimension.
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.Attribute} the attribute or null.
findAttribute
- findAttribute(aid)
Finds an attribute by it’s ID. Traverses through all attributes assigned to this dimension and returns the attribute with ID
aid
orfalse
if no attribute could be found.- Parameters
aid (string) – the ID of the attribute we are looking for
- Returns
{Xplain.Db.Attribute} the attribute found or
false
.
get
- get(target)
Find an attribute which belongs to this dimension. The input parameter describes the dimension / attribute you are looking for either as string (in Dot-Notation) or as object (a JSON object). for more details.
Example:
... // returns the attribute with ID Age var myAttr = myDimension.get('Age'); // same as above but in JSON notation // Note that the object and dimension does not need to be specified // because they are already implicitly defined by the dimension // of this method. var myAttr = myDimension.get({attribute: 'Age'});
- Parameters
target (string) – the ID of the attribute you are looking for
- Returns
{Xplain.Db.Attribute} the attribute or null.
getAggregation
- getAggregation()
If this dimension is an aggregation dimension (a dimension representing an aggregation) then this function returns the corresponding aggregation as instance of
Xplain.Db.Aggregation
. Otherwise,false
will be returned @returns {false|Xplain.Db.Aggregation} the corresponding aggregation orfalse
.
getAnnotations
- getAnnotations()
Returns all annotations of this dimension.
- Returns
annotations {Object} an object that contains all annotations
getAssociatedPrimaryKey
- getAssociatedPrimaryKey()
If this dimension is a foreign key, this method returns the associated primary key, i.e. it returns an instance of
Xplain.Db.Dimension
. Otherwise it returns undefined.- Returns
{Xplain.Db.Dimension} The associated primary key
getAttributes
- getAttributes()
returns an array of all attributes which belong to this dimension.
- Returns
attributes {array} array of Xplain.Db.Attribute
getClass
- getClass()
Returns the class of this attribute, e.g. “CategorialDimension”
- Returns
id {string}
getConfiguration
- getConfiguration()
Returns the configuration of this dimension as reported by the Backend. For instance, this method will return something like:
{ aggregation: { aggregationName: "# Prescriptions", aggregationType: "COUNT", complementMissingBranches: false, object: "Prescriptions", type: "COUNT" }, dimensionClass: "AggregationDimension", type: "LONG" }
- Returns
{Object} the configuration of this dimension as reported by the backend.
getDisplayName
- getDisplayName()
Returns the displayName of this dimension.
- Returns
{string} displayName of this dimension
getFormat
- getFormat()
Returns the format string set for this dimension.
- Returns
format {String} the format string set or null if none has been set.
getId
- getId()
Returns the ID of this dimension. The ID of this dimension is the concatenation of the ID of this dimension’s parent object and this dimension’s ID. NOTE: this method will return the ID in escaped form, e.g. if the name of this element contains a dot, this dot will be escaped.
If you prefer the verbose version of the ID, you may also use the
getVerboseId()
method.- Returns
id {string}
getName
- getName()
Returns the short ID (aka name) of this dimension.
- Returns
name {string}
getObject
- getObject()
Synonym for getParent(). Returns this dimensions parent object.
- Returns
dimension {Xplain.Db.Object} this dimensions parent object
getParent
- getParent()
returns this dimensions parent object.
- Returns
parent {Xplain.Db.Object} this dimensions parent object
getPath
- getPath()
Returns the path which leads to this dimension, i.e. the path through the raw JSON object returned by the backend.
- Returns
path {Array}
getPos
- getPos([ignoreHidden])
Returns the position of this dimension within the set of all dimensions of the parent object. If
ignoreHidden
is set totrue
, all hidden dimension will be ignored when counting to the position of this dimension.- Parameters
(optional) (boolean ignoreHidden) – if
true
hidden dimensions will be ignored. Defaults totrue
.- Returns
{int} the position (starting with 0)
getRawData
- getRawData()
Returns this dimension’s data as it has been returned by the backend, i.e. “raw”.
- Returns
{Object} This dimension’s data as it has been returned by the backend
getSelections
- getSelections()
If this dimension is an aggregation dimension (a dimension representing an aggregation) and if it has an assigned fixed selection, then this function returns the corresponding selections as instance of
Xplain.Db.Selections
. Otherwise,false
will be returned @returns {false|Xplain.Db.Selections} the corresponding selections orfalse
.
getSession
- getSession()
Returns the session to which this dimension belongs.
- Returns
session {Xplain.Db.Session}
getType
- getType()
Returns the type of this dimension.
- Returns
id {string}
getVerboseId
- getVerboseId()
Returns the ID of this dimension in the format the backend uses natively.
- Returns
id {object}
isCategorial
- isCategorial()
Returns
true
if this dimension is a categorial dimension, i.e. if it is of type “CATEGORIAL”, “CATEGORIALSHORT” or “CATEGORIALBYTE”- Returns
{boolean}
true
if the dimension is a categorial dimension.
isDate
- isDate()
returns
true
if this dimension is annotated as being aDate
dimension.- Returns
true
if this dimension is annotated as being aDate
dimension.
isForeignKey
- isForeignKey()
Returns
true
if this dimension is a foreign key, e.g. for thepatient-id
dimension in theprescriptions
object. @returns {boolean} true if this dimension is a foreign key.
isKey
- isKey()
Returns
true
if this dimension is a key, e.g. for thepatient-id
dimension in thepatient
object. @returns {boolean} true if this dimension is a key dimension.
isNumeric
- isNumeric()
Returns
true
if this dimension is a numeric dimension.- Returns
{boolean}
true
if the dimension is a numeric dimension.
remove
- remove([settings])
Loads the definition of this dimension from the backend.
- Parameters
(optional) (function settings.error=f(data){throw new Xplain.Db.Exception}) – A set of key/value pairs that configure the
getDefinition
request. All settings are optional. A default can be set using theXplain.Db.Configuration.setDefaults()
method.(optional) – defines if the request sent to the backend should be asynchronous or synchronous.
(optional) – defines if the request should support CORS (note: the backend also has to enable CORS requests).
(optional) – The URL used for this request.
(optional) – number of milliseconds until a timeout will be triggered.
(optional) – function what will be triggered if the Xplain Data backend reports an HTTP Status Code 200. The first parameter passed to this function will be an instance of
Xplain.Db.QueryData
(optional) – function what will be triggered if the Xplain Data backend reports anything but a HTTP Status Code 200. The first parameter passed to this function will be an instance of the data returned by the backend.
- Returns
{null|boolean} if async=false, this method will return
true
if definition has been fetched. If async=true, use the first parameter passed to the success function to fetch returned data.
remove
- remove([settings])
Removes this dimension (and all of its attributes) for the rest of this session from the current configuration. When you reload the current configuration, i.e. when you start a new session with this configuration, this dimension will still be assigned to the corresponding object.
- Parameters
(optional) (function settings.error=f(data){throw new Xplain.Db.Exception}) – A set of key/value pairs that configure the
remove
request. All settings are optional. A default can be set using theXplain.Db.Configuration.setDefaults()
method.(optional) – defines if the request sent to the backend should be asynchronous or synchronous.
(optional) – defines if the request should support CORS (note: the backend also has to enable CORS requests).
(optional) – The URL used for this request.
(optional) – number of milliseconds until a timeout will be triggered.
(optional) – function what will be triggered if the Xplain Data backend reports an HTTP Status Code 200. The first parameter passed to this function will be an instance of
Xplain.Db.QueryData
(optional) – function what will be triggered if the Xplain Data backend reports anything but a HTTP Status Code 200. The first parameter passed to this function will be an instance of the data returned by the backend.
- Returns
{null|Xplain.Db.QueryData} if async=false, this method will return an instance of
Xplain.Db.QueryData
. If async=true, use the first parameter passed to the success function to fetch returned data.