Blame view

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

e63ad8ec   Nathanael Jourdane   Fix the mysteriou...
10
Ext.define('amdaModel.Stats', {
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
	getJsonValues : function (hasId) 
	{
		var values  = new Object();	    
		if (hasId) {
			values.id = this.get('id');
		}

804b5599   Elena.Budnik   catalog name
25
26
		values.timesrc = this.get('timesrc');
		values.name = 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;
	}
e63ad8ec   Nathanael Jourdane   Fix the mysteriou...
82
});