Stats.js
2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* Project : AMDA-NG
* Name : Stats.js
* Description : Statistics Object Definition
* @class amdaModel.Stats
* @extends amdaModel.TimeTable
* @author elena
*/
Ext.define('amdaModel.Stats', {
extend: 'amdaModel.AmdaTimeObject',
fields : [
{ name: 'parameter' } ,
{ name: 'description' }
],
getJsonValues : function (hasId)
{
var values = new Object();
if (hasId) {
values.id = this.get('id');
}
values.timesrc = this.get('timesrc');
values.name = 'test'; //this.get('name');
// if (this.get('description').match(/[a-z,0-9]/gi) != null) {
// values.description = this.get('description');
// }
// if (this.get('history').match(/[a-z,0-9]/gi) != null) {
// values.history = this.get('history');
// }
values.objName = this.get('objName');
values.objFormat = this.get('objFormat');
// values.cacheToken = this.get('cacheToken');
values.parameter = this.get('parameter');
// if there's at least one parameter
// if (this.get('parameter') && this.get('parameter').length)
// {
// var list = this.get('parameter');
// values.parameter=[];
// Ext.each(list, function(item, index){
// values.parameter[index] = item.getJsonValues();
// });
// }
if (values.timesrc == amdaModel.AmdaTimeObject.inputTimeSrc[0])
{
// get complete timeTables collection
var timeTables = this.get('timeTables');
// init an empty array for timeTables
values.timeTables=[];
// for each interval record
Ext.Array.each(timeTables, function(item, index, all)
{
if (!item.$className) {
values.timeTables[index] = {timeTableName : item.timeTableName, id : item.id};
}
// get Json simplified value
else {
values.timeTables[index] = item.getJsonValues();
}
});
} else
{
values.startDate = this.get('startDate');
values.stopDate = this.get('stopDate');
values.durationDay = this.get('durationDay');
values.durationHour = this.get('durationHour');
values.durationMin = this.get('durationMin');
values.durationSec = this.get('durationSec');
}
values.leaf = true;
values.nodeType = 'statistics';
return values;
}
});