Blame view

js/app/models/Statistic.js 3.17 KB
d18b535d   elena   catalog draft + c...
1
2
/**
 * Project      : AMDA-NG
2e7079bb   Benjamin Renard   First implementat...
3
 * Name         : Statistic.js 
d18b535d   elena   catalog draft + c...
4
 * Description  : Statistics Object Definition
2e7079bb   Benjamin Renard   First implementat...
5
6
 * @class amdaModel.Statistic
 * @extends amdaModel.AmdaTimeObject
d18b535d   elena   catalog draft + c...
7
8
9
 * @author  elena
 */

2e7079bb   Benjamin Renard   First implementat...
10
Ext.define('amdaModel.Statistic', {
96cdc664   Elena.Budnik   new record type i...
11
	extend: 'amdaModel.AmdaTimeObject',
2e7079bb   Benjamin Renard   First implementat...
12
13
14
15
16
 
	requires: [
		"amdaModel.StatisticParam"
	],
   
96cdc664   Elena.Budnik   new record type i...
17
	fields : [
2e7079bb   Benjamin Renard   First implementat...
18
		{name: 'type', type: 'string', defaultValue: 'Statistic'},
698494ac   Benjamin Renard   Add tooltip for s...
19
20
		{name: 'description', type: 'string'},
		{name: 'last_update', type: 'int', defaultValue: 0}
d18b535d   elena   catalog draft + c...
21
	],
2e7079bb   Benjamin Renard   First implementat...
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

	associations : [
		{
			type : 'hasMany',
			model : 'amdaModel.StatisticParam',
			name  : 'params'
		}
	],

	constructor: function(){
		var me = this;
		me.callParent(arguments);
		if ((arguments.length > 0) && arguments[0])
		{
			if (arguments[0].parameter)
				me.loadParams(arguments[0].parameter);
		}
		this.dirty = false;
	},

	loadParams: function(params)
	{
		/* Compatability mode */
		Ext.each(params, function(param, index) {
			if (param.hasOwnProperty('is-init')) {
				return;
			}
			params[index]['dim1-sum-type']  = param['dim1-is-range'] ? 1 : 0;
			params[index]['dim1-min-value'] = param['dim1-min-range'];
			params[index]['dim1-max-value'] = param['dim1-max-range'];
			params[index]['dim2-sum-type']  = param['dim2-is-range'] ? 1 : 0;
			params[index]['dim2-min-value'] = param['dim2-min-range'];
			params[index]['dim2-max-value'] = param['dim2-max-range'];
			params[index]['is-init'] = true;
		});
		this.params().loadData(params);
        },

	isDirty : function() {
		if (this.dirty)
			return true;

		var d = false;

		this.params().each(function (param, index) {
			if (param.dirty)
				d = true;
		});
		return d;
	},
d18b535d   elena   catalog draft + c...
72
    
2e7079bb   Benjamin Renard   First implementat...
73
	getJsonValues : function () 
96cdc664   Elena.Budnik   new record type i...
74
75
	{
		var values  = new Object();	    
2e7079bb   Benjamin Renard   First implementat...
76
77
78
                values.nodeType =  'statistic';
                values.type = this.get('type');
                values.name = this.get('name');
804b5599   Elena.Budnik   catalog name
79
		values.timesrc = this.get('timesrc');
f43a0a5e   Benjamin Renard   Fix save statisti...
80
		values.description = this.get('description');
d18b535d   elena   catalog draft + c...
81
        	
96cdc664   Elena.Budnik   new record type i...
82
		// if there's at least one parameter
2e7079bb   Benjamin Renard   First implementat...
83
84
85
86
		values.parameter = [];
                this.params().each(function (param, index) {
			values.parameter[index] = param.getJsonValues();
		});
96cdc664   Elena.Budnik   new record type i...
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
		
		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 
		{
79a60955   Hacene SI HADJ MOHAND   ms ok affichage ko
107
108
			values.startDate =  Ext.Date.format(this.get('startDate'), 'Y-m-d\\TH:i:s.u');	
			values.stopDate =  Ext.Date.format(this.get('stopDate'), 'Y-m-d\\TH:i:s.u');	
96cdc664   Elena.Budnik   new record type i...
109
110
111
112
			values.durationDay = this.get('durationDay');
			values.durationHour = this.get('durationHour');
			values.durationMin = this.get('durationMin');
			values.durationSec = this.get('durationSec');
b852834a   Hacene SI HADJ MOHAND   progress
113
                                                            values.durationMs = this.get('durationMs');
96cdc664   Elena.Budnik   new record type i...
114
		} 
d18b535d   elena   catalog draft + c...
115
	 
96cdc664   Elena.Budnik   new record type i...
116
		values.leaf = true;
96cdc664   Elena.Budnik   new record type i...
117
118
119

		return values;
	}
e63ad8ec   Nathanael Jourdane   Fix the mysteriou...
120
});