Ext.ns('Oracle.BDD.Portlets.Visualization.Model');
/**
* <b>Do NOT instantiate this class directly.</b> The token object
* should be accessed and modified through the {@link Oracle.BDD.Portlets.Visualization.Model.QueryConfig#getToken}
* function ONLY.
*
* For example, to set the direction of a sort token named "sort_token", do the following:
* queryConfig.getToken("sort_token").setSortDirection("ASC");
*
* @class Oracle.BDD.Portlets.Visualization.Model.Token
*
*/
Oracle.BDD.Portlets.Visualization.Model.Token = function(tokenConfig) {
this._token = tokenConfig;
return this;
};
Oracle.BDD.Portlets.Visualization.Model.Token.prototype = {
/**
* Gets the token type (e.g. 'metric', 'dimension', 'sort', data', 'dataview'
* @return {string} The token's type ('metric', 'dimension', etc.)
*/
getType: function() {
return this._token.type;
},
/**
* Gets the value for token of the given name. This is the literal value that replaced the
* value in the EQL query.
*
* @return {string|Number} The token's value
*/
getValue: function() {
return this._token.value;
}
};
/**
* <b>Do NOT instantiate this class directly.</b> Token objects
* should be accessed and modified through the {@link Oracle.BDD.Portlets.Visualization.Model.QueryConfig#getToken}
* function ONLY.
* @class Oracle.BDD.Portlets.Visualization.Model.AttributeToken
* @extends Oracle.BDD.Portlets.Visualization.Model.Token
*/
Oracle.BDD.Portlets.Visualization.Model.AttributeToken = Ext.extend(Oracle.BDD.Portlets.Visualization.Model.Token, {
/**
* Gets the attribute key for the attribute token of the given name
* @memberof Oracle.BDD.Portlets.Visualization.Model.AttributeToken#
* @return {string} The token's attribute key
*/
getAttributeKey: function() {
return this._token.attributeKey;
},
/**
* Gets the MDEX datatype of the token's attribute
* @memberof Oracle.BDD.Portlets.Visualization.Model.AttributeToken#
* @return {string} The token's data type
*/
getDataType: function() {
return this._token.attributeDataType;
},
/**
* Gets the token's dataview key
* @memberof Oracle.BDD.Portlets.Visualization.Model.AttributeToken#
* @return {string} The token's dataview key
*/
getDataViewKey: function() {
return this._token.dataviewKey;
},
/**
* Gets the attribute display name for the attribute token of the given name
* @memberof Oracle.BDD.Portlets.Visualization.Model.AttributeToken#
* @return {string} The token's attribute display name
*/
getDisplayName: function() {
return this._token.attributeDisplayName;
},
/**
* Indicates if the attribute is single assign
* @memberof Oracle.BDD.Portlets.Visualization.Model.AttributeToken#
* @return {boolean}
*/
isSingleAssign: function() {
return this._token.attributeSingleAssign;
},
/**
* Sets the attribute key for the attribute token of the given name
* @memberof Oracle.BDD.Portlets.Visualization.Model.AttributeToken#
* @param {string} attributeKey The attribute key value
*/
setAttributeKey: function(attributeKey) {
this._token.attributeKey = attributeKey;
}
});
/**
* <b>Do NOT instantiate this class directly.</b> Token objects
* should be accessed and modified through the {@link Oracle.BDD.Portlets.Visualization.Model.QueryConfig#getToken}
* function ONLY.
* @class Oracle.BDD.Portlets.Visualization.Model.DimensionToken
* @extends Oracle.BDD.Portlets.Visualization.Model.AttributeToken
*
*/
Oracle.BDD.Portlets.Visualization.Model.DimensionToken = Ext.extend(Oracle.BDD.Portlets.Visualization.Model.AttributeToken, {
/**
* Returns boolean indicating if this token is configured to group its multi-assign attributes my set members
* in eql grouping functions. Default true for multi-assign attributes.
* @memberof Oracle.BDD.Portlets.Visualization.Model.DimensionToken#
* @return {boolean} The token's aggregation function
*/
isGroupByMembers : function() {
return !this._token.attributeSingleAssign && this._token.groupByMembers;
},
});
/**
* <b>Do NOT instantiate this class directly.</b> Token objects
* should be accessed and modified through the {@link Oracle.BDD.Portlets.Visualization.Model.QueryConfig#getToken}
* function ONLY.
* @class Oracle.BDD.Portlets.Visualization.Model.MetricToken
* @extends Oracle.BDD.Portlets.Visualization.Model.AttributeToken
*
*/
Oracle.BDD.Portlets.Visualization.Model.MetricToken = Ext.extend(Oracle.BDD.Portlets.Visualization.Model.AttributeToken, {
/**
* Gets the attribute aggregation function for the token of the given name
* @memberof Oracle.BDD.Portlets.Visualization.Model.MetricToken#
* @return {string} The token's aggregation function
*/
getAggregationFunction: function() {
return this._token.aggregation;
},
/**
* Gets an array of aggregation functions that are valid for the token of the given name <i>and</i> the token's
* attribute.
* @memberof Oracle.BDD.Portlets.Visualization.Model.MetricToken#
* @param {string} tokenName Name of the token
* @return {Object[]} The token's valid aggregation functions
*/
getValidAggregations: function() {
var attributeAvailable = this._token.availableAggregations || [];
var tokenAvailable = this._token.aggregations || [];
var aggrs = [];
Ext.each(tokenAvailable, function(aggr){
if (tokenAvailable.length == 0 || attributeAvailable.indexOf(aggr) > -1) aggrs.push(aggr);
});
return aggrs;
},
/**
* Sets the aggregation function for the token of the given name
* @memberof Oracle.BDD.Portlets.Visualization.Model.MetricToken#
* @param {string} aggregation The aggregation function to set
*/
setAggregationFunction: function(aggregation) {
if (this.getValidAggregations().indexOf(aggregation.toLowerCase()) > -1) {
this._token.aggregation = aggregation;
}
//TODO: throw exception is invalid function is attempted
}
});
/**
* <b>Do NOT instantiate this class directly.</b> Token objects
* should be accessed and modified through the {@link Oracle.BDD.Portlets.Visualization.Model.QueryConfig#getToken}
* function ONLY.
* @class Oracle.BDD.Portlets.Visualization.Model.SortToken
* @extends Oracle.BDD.Portlets.Visualization.Model.Token
*/
Oracle.BDD.Portlets.Visualization.Model.SortToken = Ext.extend(Oracle.BDD.Portlets.Visualization.Model.Token, {
/**
* Gets the sort direction for the token of the given name as either 'ASC' or 'DESC'
* @memberof Oracle.BDD.Portlets.Visualization.Model.SortToken#
* @return {string} The token's sort direction
*/
getSortDirection: function() {
return this._token.sortConfig.sortDirection;
},
/**
* Sets the sort direction for sort token. Value must be 'ASC' nor 'DESC'.
* @memberof Oracle.BDD.Portlets.Visualization.Model.SortToken#
* @param {string} direction 'ASC' or 'DESC'
*/
setSortDirection: function(direction) {
direction = direction.toUpperCase();
if (direction === "ASC" || direction === "DESC") this._token.sortConfig.sortDirection = direction;
//TODO: throw exception is invalid direction is attempted
},
/**
* Toggles the sort direction for the sort token
* @memberof Oracle.BDD.Portlets.Visualization.Model.SortToken#
*/
toggleSortDirection: function() {
if (this._token.sortConfig.sortDirection.toUpperCase() === 'ASC') this._token.sortConfig.sortDirection = 'DESC';
else this._token.sortConfig.sortDirection = 'ASC';
}
});
/**
* <b>Do NOT instantiate this class directly.</b> Token objects
* should be accessed and modified through the {@link Oracle.BDD.Portlets.Visualization.Model.QueryConfig#getToken}
* function ONLY.
* @class Oracle.BDD.Portlets.Visualization.Model.DataToken
* @extends Oracle.BDD.Portlets.Visualization.Model.Token
*/
Oracle.BDD.Portlets.Visualization.Model.DataToken = Ext.extend(Oracle.BDD.Portlets.Visualization.Model.Token, {
/**
* Sets the replacement value for the data token of the given name.
* @memberof Oracle.BDD.Portlets.Visualization.Model.SortToken#
* @param {string} value The value to set
*/
setValue: function(value) {
this._token.dataTokenValue = value + '';
}
});
/**
* <b>Do NOT instantiate this class directly.</b> Token objects
* should be accessed and modified through the {@link Oracle.BDD.Portlets.Visualization.Model.QueryConfig#getToken}
* function ONLY.
* @class Oracle.BDD.Portlets.Visualization.Model.DataViewToken
* @extends Oracle.BDD.Portlets.Visualization.Model.Token
*/
Oracle.BDD.Portlets.Visualization.Model.DataViewToken = Ext.extend(Oracle.BDD.Portlets.Visualization.Model.Token, {
/**
* Gets the token's dataview key
* @memberof Oracle.BDD.Portlets.Visualization.Model.SortToken#
* @return {string} The token's dataview key
*/
getDataViewKey: function() {
return this._token.dataviewKey;
}
});
//@ sourceURL=Token.js