@easyquery/enterprise 7.2.3-rc03 → 7.2.4-beta03
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/eq.enterprise.js +31879 -33487
- package/dist/browser/eq.enterprise.js.map +1 -1
- package/dist/browser/eq.enterprise.min.js +1 -10
- package/dist/browser/eq.enterprise.min.js.map +1 -1
- package/dist/bundles/easyquery.enterprise.js +8069 -8062
- package/dist/bundles/easyquery.enterprise.js.map +1 -1
- package/dist/bundles/easyquery.enterprise.min.js +1 -1
- package/dist/bundles/easyquery.enterprise.min.js.map +1 -1
- package/dist/lib/data/data_table_aggr_calculator.d.ts +47 -47
- package/dist/lib/data/data_table_aggr_calculator.js +163 -163
- package/dist/lib/data/eqs_aggr_calculator.d.ts +14 -14
- package/dist/lib/data/eqs_aggr_calculator.js +172 -172
- package/dist/lib/data/eqs_aggr_calculator.js.map +1 -1
- package/dist/lib/dm/model_ex.d.ts +9 -9
- package/dist/lib/dm/model_ex.js +151 -149
- package/dist/lib/dm/model_ex.js.map +1 -1
- package/dist/lib/extensions.d.ts +26 -26
- package/dist/lib/extensions.js +120 -120
- package/dist/lib/license/lc-dialog.d.ts +19 -19
- package/dist/lib/license/lc-dialog.js +310 -310
- package/dist/lib/license/lc-dialog.js.map +1 -1
- package/dist/lib/main/eqs_query_storage.d.ts +11 -11
- package/dist/lib/main/eqs_query_storage.js +105 -105
- package/dist/lib/public_api.d.ts +7 -7
- package/dist/lib/public_api.js +7 -7
- package/dist/lib/query/condition_ex.d.ts +14 -14
- package/dist/lib/query/condition_ex.js +97 -95
- package/dist/lib/query/condition_ex.js.map +1 -1
- package/dist/lib/query/query_column_ex.d.ts +13 -13
- package/dist/lib/query/query_column_ex.js +57 -55
- package/dist/lib/query/query_column_ex.js.map +1 -1
- package/dist/lib/query/query_ex.d.ts +15 -15
- package/dist/lib/query/query_ex.js +75 -73
- package/dist/lib/query/query_ex.js.map +1 -1
- package/dist/lib/utils/lcv.d.ts +4 -4
- package/dist/lib/utils/lcv.js +101 -101
- package/dist/lib/utils/lcv.js.map +1 -1
- package/package.json +16 -16
- package/webpack.config.js +8 -7
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { AggregatesCalculator, AggregatesContainer, AggrCalculationOptions, DataRow } from '@easydata/core';
|
|
2
|
-
import { EqContext } from '@easyquery/core';
|
|
3
|
-
interface ColumnAggregates {
|
|
4
|
-
sum: number;
|
|
5
|
-
min: number;
|
|
6
|
-
max: number;
|
|
7
|
-
}
|
|
8
|
-
interface ColumnsWithAggregates {
|
|
9
|
-
[columnId: string]: ColumnAggregates;
|
|
10
|
-
}
|
|
11
|
-
interface RowAggregates {
|
|
12
|
-
count: number;
|
|
13
|
-
columns: ColumnsWithAggregates;
|
|
14
|
-
}
|
|
15
|
-
export declare class DataTableAggregatesCalculator implements AggregatesCalculator {
|
|
16
|
-
protected context: EqContext;
|
|
17
|
-
private aggrContainer;
|
|
18
|
-
private aggrSettings;
|
|
19
|
-
private groups;
|
|
20
|
-
private aggregates;
|
|
21
|
-
private aggrColIds;
|
|
22
|
-
private aggrCols;
|
|
23
|
-
private levelsTotals;
|
|
24
|
-
constructor(context: EqContext);
|
|
25
|
-
getAggrContainer(): AggregatesContainer;
|
|
26
|
-
protected initObjects(): void;
|
|
27
|
-
private createColumnAggregatesObject;
|
|
28
|
-
calculate(options?: AggrCalculationOptions): Promise<void>;
|
|
29
|
-
protected resetLevelTotals(rowTotals: RowAggregates): void;
|
|
30
|
-
private prevRow;
|
|
31
|
-
protected processDataRow(row: DataRow): void;
|
|
32
|
-
/** Checks if the values in group columns were changed
|
|
33
|
-
and return the level number they were */
|
|
34
|
-
protected checkLevelChange(row: DataRow): number;
|
|
35
|
-
/** Saves the current values in levelData for the specified level to AggregateContainer
|
|
36
|
-
and then reset the data row for that level
|
|
37
|
-
*/
|
|
38
|
-
protected flushLevelTotals(levelIndex: number): void;
|
|
39
|
-
protected applyAggrFunc(funcId: string, columnTotals: ColumnAggregates, levelTotals: RowAggregates): Number;
|
|
40
|
-
/** Updates the totals by values in the current DataRow
|
|
41
|
-
* and according to the specified aggregate
|
|
42
|
-
*/
|
|
43
|
-
protected updateLevelTotals(levelIndex: number, row: DataRow): void;
|
|
44
|
-
needRecalculation(): boolean;
|
|
45
|
-
reset(): void;
|
|
46
|
-
}
|
|
47
|
-
export {};
|
|
1
|
+
import { AggregatesCalculator, AggregatesContainer, AggrCalculationOptions, DataRow } from '@easydata/core';
|
|
2
|
+
import { EqContext } from '@easyquery/core';
|
|
3
|
+
interface ColumnAggregates {
|
|
4
|
+
sum: number;
|
|
5
|
+
min: number;
|
|
6
|
+
max: number;
|
|
7
|
+
}
|
|
8
|
+
interface ColumnsWithAggregates {
|
|
9
|
+
[columnId: string]: ColumnAggregates;
|
|
10
|
+
}
|
|
11
|
+
interface RowAggregates {
|
|
12
|
+
count: number;
|
|
13
|
+
columns: ColumnsWithAggregates;
|
|
14
|
+
}
|
|
15
|
+
export declare class DataTableAggregatesCalculator implements AggregatesCalculator {
|
|
16
|
+
protected context: EqContext;
|
|
17
|
+
private aggrContainer;
|
|
18
|
+
private aggrSettings;
|
|
19
|
+
private groups;
|
|
20
|
+
private aggregates;
|
|
21
|
+
private aggrColIds;
|
|
22
|
+
private aggrCols;
|
|
23
|
+
private levelsTotals;
|
|
24
|
+
constructor(context: EqContext);
|
|
25
|
+
getAggrContainer(): AggregatesContainer;
|
|
26
|
+
protected initObjects(): void;
|
|
27
|
+
private createColumnAggregatesObject;
|
|
28
|
+
calculate(options?: AggrCalculationOptions): Promise<void>;
|
|
29
|
+
protected resetLevelTotals(rowTotals: RowAggregates): void;
|
|
30
|
+
private prevRow;
|
|
31
|
+
protected processDataRow(row: DataRow): void;
|
|
32
|
+
/** Checks if the values in group columns were changed
|
|
33
|
+
and return the level number they were */
|
|
34
|
+
protected checkLevelChange(row: DataRow): number;
|
|
35
|
+
/** Saves the current values in levelData for the specified level to AggregateContainer
|
|
36
|
+
and then reset the data row for that level
|
|
37
|
+
*/
|
|
38
|
+
protected flushLevelTotals(levelIndex: number): void;
|
|
39
|
+
protected applyAggrFunc(funcId: string, columnTotals: ColumnAggregates, levelTotals: RowAggregates): Number;
|
|
40
|
+
/** Updates the totals by values in the current DataRow
|
|
41
|
+
* and according to the specified aggregate
|
|
42
|
+
*/
|
|
43
|
+
protected updateLevelTotals(levelIndex: number, row: DataRow): void;
|
|
44
|
+
needRecalculation(): boolean;
|
|
45
|
+
reset(): void;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -1,164 +1,164 @@
|
|
|
1
|
-
import { EqAggregatesContainer } from '@easyquery/core';
|
|
2
|
-
var DataTableAggregatesCalculator = /** @class */ (function () {
|
|
3
|
-
function DataTableAggregatesCalculator(context) {
|
|
4
|
-
this.context = context;
|
|
5
|
-
//stores current totals by level (group) number
|
|
6
|
-
this.levelsTotals = [];
|
|
7
|
-
this.prevRow = null;
|
|
8
|
-
this.aggrContainer = new EqAggregatesContainer(context);
|
|
9
|
-
}
|
|
10
|
-
DataTableAggregatesCalculator.prototype.getAggrContainer = function () {
|
|
11
|
-
return this.aggrContainer;
|
|
12
|
-
};
|
|
13
|
-
DataTableAggregatesCalculator.prototype.initObjects = function () {
|
|
14
|
-
var _this = this;
|
|
15
|
-
this.aggrSettings = this.context.getQuery().getAggregationSettings();
|
|
16
|
-
this.groups = this.aggrSettings.getGroups();
|
|
17
|
-
this.aggregates = this.aggrSettings.getAggregates();
|
|
18
|
-
this.aggrColIds = this.aggrSettings.getAggregates().map(function (a) { return a.colId; });
|
|
19
|
-
this.aggrCols = this.context.resultTable.columns.getItems()
|
|
20
|
-
.filter(function (col) { return _this.aggrColIds.indexOf(col.id) >= 0; });
|
|
21
|
-
this.levelsTotals = [];
|
|
22
|
-
this.prevRow = null;
|
|
23
|
-
};
|
|
24
|
-
DataTableAggregatesCalculator.prototype.createColumnAggregatesObject = function () {
|
|
25
|
-
return {
|
|
26
|
-
sum: 0,
|
|
27
|
-
min: Number.MAX_VALUE,
|
|
28
|
-
max: Number.MIN_VALUE
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
DataTableAggregatesCalculator.prototype.calculate = function (options) {
|
|
32
|
-
this.initObjects();
|
|
33
|
-
this.aggrContainer.clear();
|
|
34
|
-
options = options || {};
|
|
35
|
-
options.maxLevel = options.maxLevel >= 0
|
|
36
|
-
? options.maxLevel : 0;
|
|
37
|
-
var levelNumber = this.groups.length + 1; //number of groups plus grand totals
|
|
38
|
-
for (var levelIndex = 0; levelIndex < levelNumber; levelIndex++) {
|
|
39
|
-
var levelTotals = { count: 0, columns: {} };
|
|
40
|
-
this.resetLevelTotals(levelTotals);
|
|
41
|
-
this.levelsTotals.push(levelTotals);
|
|
42
|
-
}
|
|
43
|
-
var allRows = this.context.resultTable.getCachedRows();
|
|
44
|
-
if (allRows.length > 0) {
|
|
45
|
-
for (var _i = 0, allRows_1 = allRows; _i < allRows_1.length; _i++) {
|
|
46
|
-
var row = allRows_1[_i];
|
|
47
|
-
this.processDataRow(row);
|
|
48
|
-
}
|
|
49
|
-
//flusing the totals for all group levels
|
|
50
|
-
for (var levelIndex = 1; levelIndex < levelNumber; levelIndex++) {
|
|
51
|
-
this.flushLevelTotals(levelIndex);
|
|
52
|
-
}
|
|
53
|
-
//flusing the grand totals (if they are turned on)
|
|
54
|
-
if (this.aggrSettings.hasGrandTotals()) {
|
|
55
|
-
this.flushLevelTotals(0);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return Promise.resolve();
|
|
59
|
-
};
|
|
60
|
-
DataTableAggregatesCalculator.prototype.resetLevelTotals = function (rowTotals) {
|
|
61
|
-
for (var _i = 0, _a = this.aggrCols; _i < _a.length; _i++) {
|
|
62
|
-
var aggrCol = _a[_i];
|
|
63
|
-
rowTotals.columns[aggrCol.id] = this.createColumnAggregatesObject();
|
|
64
|
-
}
|
|
65
|
-
rowTotals.count = 0;
|
|
66
|
-
};
|
|
67
|
-
DataTableAggregatesCalculator.prototype.processDataRow = function (row) {
|
|
68
|
-
var levelIndexChanged = this.checkLevelChange(row);
|
|
69
|
-
if (levelIndexChanged >= 0) {
|
|
70
|
-
for (var levelIndex_1 = levelIndexChanged; levelIndex_1 < this.levelsTotals.length; levelIndex_1++) {
|
|
71
|
-
this.flushLevelTotals(levelIndex_1);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (this.aggrSettings.hasGrandTotals()) {
|
|
75
|
-
this.updateLevelTotals(0, row);
|
|
76
|
-
}
|
|
77
|
-
var levelIndex = 1;
|
|
78
|
-
for (var _i = 0, _a = this.groups; _i < _a.length; _i++) {
|
|
79
|
-
var group = _a[_i];
|
|
80
|
-
this.updateLevelTotals(levelIndex, row);
|
|
81
|
-
levelIndex++;
|
|
82
|
-
}
|
|
83
|
-
this.prevRow = row;
|
|
84
|
-
};
|
|
85
|
-
/** Checks if the values in group columns were changed
|
|
86
|
-
and return the level number they were */
|
|
87
|
-
DataTableAggregatesCalculator.prototype.checkLevelChange = function (row) {
|
|
88
|
-
if (this.prevRow == null)
|
|
89
|
-
return -1;
|
|
90
|
-
for (var groupIndex = 0; groupIndex < this.groups.length; groupIndex++) {
|
|
91
|
-
var group = this.groups[groupIndex];
|
|
92
|
-
for (var _i = 0, _a = group.columns; _i < _a.length; _i++) {
|
|
93
|
-
var colId = _a[_i];
|
|
94
|
-
var value = row.getValue(colId);
|
|
95
|
-
var prevValue = this.prevRow.getValue(colId);
|
|
96
|
-
if (!this.aggrSettings.compareValues(prevValue, value)) {
|
|
97
|
-
return groupIndex + 1;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return -1;
|
|
102
|
-
};
|
|
103
|
-
/** Saves the current values in levelData for the specified level to AggregateContainer
|
|
104
|
-
and then reset the data row for that level
|
|
105
|
-
*/
|
|
106
|
-
DataTableAggregatesCalculator.prototype.flushLevelTotals = function (levelIndex) {
|
|
107
|
-
var levelTotals = this.levelsTotals[levelIndex];
|
|
108
|
-
var group = levelIndex > 0 ? this.groups[levelIndex - 1] : null;
|
|
109
|
-
var groupKey = this.aggrSettings.buildGroupKey(group, this.prevRow);
|
|
110
|
-
var groupTotals = {};
|
|
111
|
-
for (var _i = 0, _a = this.aggregates; _i < _a.length; _i++) {
|
|
112
|
-
var aggr = _a[_i];
|
|
113
|
-
var columnTotals = levelTotals.columns[aggr.colId];
|
|
114
|
-
groupTotals[aggr.colId] = this.applyAggrFunc(aggr.funcId, columnTotals, levelTotals);
|
|
115
|
-
}
|
|
116
|
-
if (this.aggrSettings.hasRecordCount()) {
|
|
117
|
-
groupTotals[this.aggrSettings.COUNT_FIELD_NAME] = levelTotals.count;
|
|
118
|
-
}
|
|
119
|
-
this.aggrContainer.updateAggregateData(levelIndex, groupKey, groupTotals);
|
|
120
|
-
this.resetLevelTotals(levelTotals);
|
|
121
|
-
};
|
|
122
|
-
DataTableAggregatesCalculator.prototype.applyAggrFunc = function (funcId, columnTotals, levelTotals) {
|
|
123
|
-
switch (funcId) {
|
|
124
|
-
case "SUM":
|
|
125
|
-
return columnTotals.sum;
|
|
126
|
-
case "AVG":
|
|
127
|
-
return columnTotals.sum / levelTotals.count;
|
|
128
|
-
case "COUNT":
|
|
129
|
-
case "CNTDST":
|
|
130
|
-
return levelTotals.count;
|
|
131
|
-
case "MIN":
|
|
132
|
-
return columnTotals.min;
|
|
133
|
-
case "MAX":
|
|
134
|
-
return columnTotals.max;
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
/** Updates the totals by values in the current DataRow
|
|
138
|
-
* and according to the specified aggregate
|
|
139
|
-
*/
|
|
140
|
-
DataTableAggregatesCalculator.prototype.updateLevelTotals = function (levelIndex, row) {
|
|
141
|
-
var levelTotals = this.levelsTotals[levelIndex];
|
|
142
|
-
levelTotals.count += 1;
|
|
143
|
-
for (var _i = 0, _a = this.aggregates; _i < _a.length; _i++) {
|
|
144
|
-
var aggr = _a[_i];
|
|
145
|
-
var value = row.getValue(aggr.colId);
|
|
146
|
-
var columnTotals = levelTotals.columns[aggr.colId];
|
|
147
|
-
columnTotals.sum += value;
|
|
148
|
-
if (value < columnTotals.min) {
|
|
149
|
-
columnTotals.min = value;
|
|
150
|
-
}
|
|
151
|
-
if (value > columnTotals.max) {
|
|
152
|
-
columnTotals.max = value;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
DataTableAggregatesCalculator.prototype.needRecalculation = function () {
|
|
157
|
-
return true;
|
|
158
|
-
};
|
|
159
|
-
DataTableAggregatesCalculator.prototype.reset = function () {
|
|
160
|
-
};
|
|
161
|
-
return DataTableAggregatesCalculator;
|
|
162
|
-
}());
|
|
163
|
-
export { DataTableAggregatesCalculator };
|
|
1
|
+
import { EqAggregatesContainer } from '@easyquery/core';
|
|
2
|
+
var DataTableAggregatesCalculator = /** @class */ (function () {
|
|
3
|
+
function DataTableAggregatesCalculator(context) {
|
|
4
|
+
this.context = context;
|
|
5
|
+
//stores current totals by level (group) number
|
|
6
|
+
this.levelsTotals = [];
|
|
7
|
+
this.prevRow = null;
|
|
8
|
+
this.aggrContainer = new EqAggregatesContainer(context);
|
|
9
|
+
}
|
|
10
|
+
DataTableAggregatesCalculator.prototype.getAggrContainer = function () {
|
|
11
|
+
return this.aggrContainer;
|
|
12
|
+
};
|
|
13
|
+
DataTableAggregatesCalculator.prototype.initObjects = function () {
|
|
14
|
+
var _this = this;
|
|
15
|
+
this.aggrSettings = this.context.getQuery().getAggregationSettings();
|
|
16
|
+
this.groups = this.aggrSettings.getGroups();
|
|
17
|
+
this.aggregates = this.aggrSettings.getAggregates();
|
|
18
|
+
this.aggrColIds = this.aggrSettings.getAggregates().map(function (a) { return a.colId; });
|
|
19
|
+
this.aggrCols = this.context.resultTable.columns.getItems()
|
|
20
|
+
.filter(function (col) { return _this.aggrColIds.indexOf(col.id) >= 0; });
|
|
21
|
+
this.levelsTotals = [];
|
|
22
|
+
this.prevRow = null;
|
|
23
|
+
};
|
|
24
|
+
DataTableAggregatesCalculator.prototype.createColumnAggregatesObject = function () {
|
|
25
|
+
return {
|
|
26
|
+
sum: 0,
|
|
27
|
+
min: Number.MAX_VALUE,
|
|
28
|
+
max: Number.MIN_VALUE
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
DataTableAggregatesCalculator.prototype.calculate = function (options) {
|
|
32
|
+
this.initObjects();
|
|
33
|
+
this.aggrContainer.clear();
|
|
34
|
+
options = options || {};
|
|
35
|
+
options.maxLevel = options.maxLevel >= 0
|
|
36
|
+
? options.maxLevel : 0;
|
|
37
|
+
var levelNumber = this.groups.length + 1; //number of groups plus grand totals
|
|
38
|
+
for (var levelIndex = 0; levelIndex < levelNumber; levelIndex++) {
|
|
39
|
+
var levelTotals = { count: 0, columns: {} };
|
|
40
|
+
this.resetLevelTotals(levelTotals);
|
|
41
|
+
this.levelsTotals.push(levelTotals);
|
|
42
|
+
}
|
|
43
|
+
var allRows = this.context.resultTable.getCachedRows();
|
|
44
|
+
if (allRows.length > 0) {
|
|
45
|
+
for (var _i = 0, allRows_1 = allRows; _i < allRows_1.length; _i++) {
|
|
46
|
+
var row = allRows_1[_i];
|
|
47
|
+
this.processDataRow(row);
|
|
48
|
+
}
|
|
49
|
+
//flusing the totals for all group levels
|
|
50
|
+
for (var levelIndex = 1; levelIndex < levelNumber; levelIndex++) {
|
|
51
|
+
this.flushLevelTotals(levelIndex);
|
|
52
|
+
}
|
|
53
|
+
//flusing the grand totals (if they are turned on)
|
|
54
|
+
if (this.aggrSettings.hasGrandTotals()) {
|
|
55
|
+
this.flushLevelTotals(0);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return Promise.resolve();
|
|
59
|
+
};
|
|
60
|
+
DataTableAggregatesCalculator.prototype.resetLevelTotals = function (rowTotals) {
|
|
61
|
+
for (var _i = 0, _a = this.aggrCols; _i < _a.length; _i++) {
|
|
62
|
+
var aggrCol = _a[_i];
|
|
63
|
+
rowTotals.columns[aggrCol.id] = this.createColumnAggregatesObject();
|
|
64
|
+
}
|
|
65
|
+
rowTotals.count = 0;
|
|
66
|
+
};
|
|
67
|
+
DataTableAggregatesCalculator.prototype.processDataRow = function (row) {
|
|
68
|
+
var levelIndexChanged = this.checkLevelChange(row);
|
|
69
|
+
if (levelIndexChanged >= 0) {
|
|
70
|
+
for (var levelIndex_1 = levelIndexChanged; levelIndex_1 < this.levelsTotals.length; levelIndex_1++) {
|
|
71
|
+
this.flushLevelTotals(levelIndex_1);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (this.aggrSettings.hasGrandTotals()) {
|
|
75
|
+
this.updateLevelTotals(0, row);
|
|
76
|
+
}
|
|
77
|
+
var levelIndex = 1;
|
|
78
|
+
for (var _i = 0, _a = this.groups; _i < _a.length; _i++) {
|
|
79
|
+
var group = _a[_i];
|
|
80
|
+
this.updateLevelTotals(levelIndex, row);
|
|
81
|
+
levelIndex++;
|
|
82
|
+
}
|
|
83
|
+
this.prevRow = row;
|
|
84
|
+
};
|
|
85
|
+
/** Checks if the values in group columns were changed
|
|
86
|
+
and return the level number they were */
|
|
87
|
+
DataTableAggregatesCalculator.prototype.checkLevelChange = function (row) {
|
|
88
|
+
if (this.prevRow == null)
|
|
89
|
+
return -1;
|
|
90
|
+
for (var groupIndex = 0; groupIndex < this.groups.length; groupIndex++) {
|
|
91
|
+
var group = this.groups[groupIndex];
|
|
92
|
+
for (var _i = 0, _a = group.columns; _i < _a.length; _i++) {
|
|
93
|
+
var colId = _a[_i];
|
|
94
|
+
var value = row.getValue(colId);
|
|
95
|
+
var prevValue = this.prevRow.getValue(colId);
|
|
96
|
+
if (!this.aggrSettings.compareValues(prevValue, value)) {
|
|
97
|
+
return groupIndex + 1;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return -1;
|
|
102
|
+
};
|
|
103
|
+
/** Saves the current values in levelData for the specified level to AggregateContainer
|
|
104
|
+
and then reset the data row for that level
|
|
105
|
+
*/
|
|
106
|
+
DataTableAggregatesCalculator.prototype.flushLevelTotals = function (levelIndex) {
|
|
107
|
+
var levelTotals = this.levelsTotals[levelIndex];
|
|
108
|
+
var group = levelIndex > 0 ? this.groups[levelIndex - 1] : null;
|
|
109
|
+
var groupKey = this.aggrSettings.buildGroupKey(group, this.prevRow);
|
|
110
|
+
var groupTotals = {};
|
|
111
|
+
for (var _i = 0, _a = this.aggregates; _i < _a.length; _i++) {
|
|
112
|
+
var aggr = _a[_i];
|
|
113
|
+
var columnTotals = levelTotals.columns[aggr.colId];
|
|
114
|
+
groupTotals[aggr.colId] = this.applyAggrFunc(aggr.funcId, columnTotals, levelTotals);
|
|
115
|
+
}
|
|
116
|
+
if (this.aggrSettings.hasRecordCount()) {
|
|
117
|
+
groupTotals[this.aggrSettings.COUNT_FIELD_NAME] = levelTotals.count;
|
|
118
|
+
}
|
|
119
|
+
this.aggrContainer.updateAggregateData(levelIndex, groupKey, groupTotals);
|
|
120
|
+
this.resetLevelTotals(levelTotals);
|
|
121
|
+
};
|
|
122
|
+
DataTableAggregatesCalculator.prototype.applyAggrFunc = function (funcId, columnTotals, levelTotals) {
|
|
123
|
+
switch (funcId) {
|
|
124
|
+
case "SUM":
|
|
125
|
+
return columnTotals.sum;
|
|
126
|
+
case "AVG":
|
|
127
|
+
return columnTotals.sum / levelTotals.count;
|
|
128
|
+
case "COUNT":
|
|
129
|
+
case "CNTDST":
|
|
130
|
+
return levelTotals.count;
|
|
131
|
+
case "MIN":
|
|
132
|
+
return columnTotals.min;
|
|
133
|
+
case "MAX":
|
|
134
|
+
return columnTotals.max;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
/** Updates the totals by values in the current DataRow
|
|
138
|
+
* and according to the specified aggregate
|
|
139
|
+
*/
|
|
140
|
+
DataTableAggregatesCalculator.prototype.updateLevelTotals = function (levelIndex, row) {
|
|
141
|
+
var levelTotals = this.levelsTotals[levelIndex];
|
|
142
|
+
levelTotals.count += 1;
|
|
143
|
+
for (var _i = 0, _a = this.aggregates; _i < _a.length; _i++) {
|
|
144
|
+
var aggr = _a[_i];
|
|
145
|
+
var value = row.getValue(aggr.colId);
|
|
146
|
+
var columnTotals = levelTotals.columns[aggr.colId];
|
|
147
|
+
columnTotals.sum += value;
|
|
148
|
+
if (value < columnTotals.min) {
|
|
149
|
+
columnTotals.min = value;
|
|
150
|
+
}
|
|
151
|
+
if (value > columnTotals.max) {
|
|
152
|
+
columnTotals.max = value;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
DataTableAggregatesCalculator.prototype.needRecalculation = function () {
|
|
157
|
+
return true;
|
|
158
|
+
};
|
|
159
|
+
DataTableAggregatesCalculator.prototype.reset = function () {
|
|
160
|
+
};
|
|
161
|
+
return DataTableAggregatesCalculator;
|
|
162
|
+
}());
|
|
163
|
+
export { DataTableAggregatesCalculator };
|
|
164
164
|
//# sourceMappingURL=data_table_aggr_calculator.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { AggregatesCalculator, AggregatesContainer, AggrCalculationOptions } from '@easydata/core';
|
|
2
|
-
import { EqContext } from '@easyquery/core';
|
|
3
|
-
export declare class EqServerAggregatesCalculator implements AggregatesCalculator {
|
|
4
|
-
protected context: EqContext;
|
|
5
|
-
constructor(context: EqContext);
|
|
6
|
-
private aggrContainer;
|
|
7
|
-
getAggrContainer(): AggregatesContainer;
|
|
8
|
-
calculate(options?: AggrCalculationOptions): Promise<void>;
|
|
9
|
-
private processLevel;
|
|
10
|
-
private buildLevelData;
|
|
11
|
-
private _needRecalculation;
|
|
12
|
-
needRecalculation(): boolean;
|
|
13
|
-
reset(): void;
|
|
14
|
-
}
|
|
1
|
+
import { AggregatesCalculator, AggregatesContainer, AggrCalculationOptions } from '@easydata/core';
|
|
2
|
+
import { EqContext } from '@easyquery/core';
|
|
3
|
+
export declare class EqServerAggregatesCalculator implements AggregatesCalculator {
|
|
4
|
+
protected context: EqContext;
|
|
5
|
+
constructor(context: EqContext);
|
|
6
|
+
private aggrContainer;
|
|
7
|
+
getAggrContainer(): AggregatesContainer;
|
|
8
|
+
calculate(options?: AggrCalculationOptions): Promise<void>;
|
|
9
|
+
private processLevel;
|
|
10
|
+
private buildLevelData;
|
|
11
|
+
private _needRecalculation;
|
|
12
|
+
needRecalculation(): boolean;
|
|
13
|
+
reset(): void;
|
|
14
|
+
}
|