Name
global.SummaryTableWriter
Description
Creates a new Summary table entry used in building charts
Script
gs.include("PrototypeServer");
var SummaryTableWriter = Class.create();
SummaryTableWriter.prototype = {
initialize : function(table, column) {
this.table = table;
this.column = column;
this.trendColumn = null;
this.trendInterval = null;
this.query = null;
this.title = null;
this.stackField = null;
this.aggregate = "COUNT";
},
setTrend : function(field, interval) {
this.trendColumn = field;
this.trendInterval = interval;
},
setTitle : function(title) {
this.title = title;
},
setQuery : function(query) {
this.query = query;
},
setAggregate : function(agg) {
this.aggregate = agg;
},
setColumn : function(column) {
this.column = column;
},
setStackOn : function(column) {
this.stackField = column;
},
generate : function() {
if (this.aggregate == 'COUNT') {
var column = this.column;
if (this.stackField) {
this.column = this.stackField;
this.stackField = column;
}
}
var cp = new GlideappChartParameters("bar", this.table, this.column);
cp.setTimeAggregate(this.trendColumn);
cp.setTimeTimeInterval(this.trendInterval);
cp.setTitle(this.title);
cp.setQuery(this.query);
if (this.stackField)
cp.setGroupBy(this.stackField);
cp.setAggregate(this.aggregate);
var stw = new GlideSummaryTableWriter(cp);
return stw.generate();
}
};
Sys ID
f50a214dc0a8016a0052373aedd4baf8