Blame view

js/app/models/Statistics.js 2.21 KB
d18b535d   elena   catalog draft + c...
1
2
3
4
5
6
7
8
9
/**
 * Project      : AMDA-NG
 * Name         : Statistics.js 
 * Description  : Statistics Object Definition
 * @class amdaModel.Statistics
 * @extends amdaModel.TimeTable 
 * @author  elena
 */

d18b535d   elena   catalog draft + c...
10
Ext.define('amdaModel.Statistics', {
96cdc664   Elena.Budnik   new record type i...
11
	extend: 'amdaModel.AmdaTimeObject',
d18b535d   elena   catalog draft + c...
12
    
96cdc664   Elena.Budnik   new record type i...
13
14
15
	fields : [
		{ name: 'parameter' } ,
		{ name: 'description' }
d18b535d   elena   catalog draft + c...
16
17
	],
    
96cdc664   Elena.Budnik   new record type i...
18
19
20
21
22
23
24
25
26
	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');
d18b535d   elena   catalog draft + c...
27
    
5f7d3cff   Elena.Budnik   no description fo...
28
29
30
// 		if (this.get('description').match(/[a-z,0-9]/gi) != null) {
// 			values.description = this.get('description');
// 		}
d18b535d   elena   catalog draft + c...
31
32
33
//     	if (this.get('history').match(/[a-z,0-9]/gi) != null) {
//     		values.history = this.get('history');
//     	}
96cdc664   Elena.Budnik   new record type i...
34
35
		values.objName = this.get('objName');
		values.objFormat = this.get('objFormat');
d18b535d   elena   catalog draft + c...
36
        	
96cdc664   Elena.Budnik   new record type i...
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
//    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');
		} 
d18b535d   elena   catalog draft + c...
76
	 
96cdc664   Elena.Budnik   new record type i...
77
78
79
80
81
		values.leaf = true;
		values.nodeType = 'statistics';

		return values;
	}
d18b535d   elena   catalog draft + c...
82
});