Blame view

js/app/models/RequestParamObject.js 6.13 KB
bb6e93d9   Benjamin Renard   Implement templat...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 * Project      : AMDA-NG
 * Name         : RequestParamObject.js
 * Description  : Request Param Business Object Definition
 * @class amdaModel.RequestParamObject
 * @extends amdaModel.AmdaObject 
 * 
 * @author benjamin
 * @version $Id:  $
 ******************************************************************************
 *    FT Id     :   Date   : Name - Description
 ******************************************************************************
 *	:           :13/06/2016: benjamin – creation 
 */
 
 		
Ext.define('amdaModel.RequestParamObject', {
	extend: 'amdaModel.AmdaObject',
29dfb596   Benjamin Renard   Rework of ParamAr...
19
20
21
22
23

        statics: {
          getEmptyObj: function() {
            return {
            	'paramid': '',
7f23e0f7   Erdogan Furkan   #5119 -Done. Adde...
24
25
				'qtip':'',
				'is-init': false,
29dfb596   Benjamin Renard   Rework of ParamAr...
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
            	'type': 0,
            	'dim1-index': '*',
            	'dim1-sum-type': 0,
            	'dim1-min-value': 0.,
            	'dim1-max-value': 0.,
            	'dim1-min-index': 0,
            	'dim1-max-index': 0,
            	'dim2-index': '*',
            	'dim2-sum-type': 0,
            	'dim2-min-value': 0.,
            	'dim2-max-value': 0.,
            	'dim2-min-index': 0,
            	'dim2-max-index': 0,
            	'template_args': {}
            };
          },
        },
bb6e93d9   Benjamin Renard   Implement templat...
43
44
45
	
	idProperty: 'id',
    
29dfb596   Benjamin Renard   Rework of ParamAr...
46
47
48
        fields : [
          {name: 'type', type: 'int'}, /* Parameter type. 0: Scalar, 1: Tab1D, 2: Tab2D */
          {name: 'is-init', type: 'bool', default:false},
bb6e93d9   Benjamin Renard   Implement templat...
49
          {name: 'paramid', type: 'string'},
7f23e0f7   Erdogan Furkan   #5119 -Done. Adde...
50
		  {name: 'qtip', type:'string'},
29dfb596   Benjamin Renard   Rework of ParamAr...
51
52
53
54
55
56
57
58
59
60
          /* Fields for dim1 */
          {name: 'dim1-index', type: 'string', defaultValue: '*'},
          {name: 'dim1-sum-type', type: 'int', defaultValue: 0}, /* Sum type. 0: None, 1: sum into values range, 2: sum between indexes */
          {name: 'dim1-min-value', type: 'float', defaultValue: 0.},
          {name: 'dim1-max-value', type: 'float', defaultValue: 0.},
          {name: 'dim1-min-index', type: 'int', defaultValue: 0},
          {name: 'dim1-max-index', type: 'int', defaultValue: 0},
          /* Fields for dim2 */
          {name: 'dim2-index', type: 'string', defaultValue: '*'},
          {name: 'dim2-sum-type', type: 'int', defaultValue: 0}, /* Sum type. 0: None, 1: sum into values range, 2: sum between indexes */
b1a45580   Benjamin Renard   Add compatibility...
61
62
63
64
          {name: 'dim2-min-value', type: 'float', defaultValue: 0.},
          {name: 'dim2-max-value', type: 'float', defaultValue: 0.},
          {name: 'dim2-min-index', type: 'int', defaultValue: 0},
          {name: 'dim2-max-index', type: 'int', defaultValue: 0},
29dfb596   Benjamin Renard   Rework of ParamAr...
65
66
67
          /* Field for arguments of a templated parameter */
          {name: 'template_args', type: 'auto', defaultValue: null},
          /* ?? */
cec289da   Hacene SI HADJ MOHAND   attribut rajoute ...
68
          {name: 'plotonly', type: 'bool', defaultValue: false}, 
bb6e93d9   Benjamin Renard   Implement templat...
69
	],
1df8e90c   Benjamin Renard   Add selection for...
70

29dfb596   Benjamin Renard   Rework of ParamAr...
71
72
	getDimSum : function(dim) {
		switch (this.get(dim+'-sum-type')) {
1df8e90c   Benjamin Renard   Add selection for...
73
			case 1:
29dfb596   Benjamin Renard   Rework of ParamAr...
74
				return 'range[' + this.get(dim+'-min-value') + ',' + this.get(dim+'-max-value') + ']';
1df8e90c   Benjamin Renard   Add selection for...
75
			case 2:
29dfb596   Benjamin Renard   Rework of ParamAr...
76
				return 'indexes[' + this.get(dim+'-min-index') + ',' + this.get(dim+'-max-index') + ']';
1df8e90c   Benjamin Renard   Add selection for...
77
78
79
		}
		return false;
	},
bb6e93d9   Benjamin Renard   Implement templat...
80
81
82
	
	getParamFullName : function() {
		var paramIndexes = '';
29dfb596   Benjamin Renard   Rework of ParamAr...
83
84
		var sum_dim1 = this.getDimSum('dim1');
		var sum_dim2 = this.getDimSum('dim2');
bb6e93d9   Benjamin Renard   Implement templat...
85
86
87
88
89
90
		switch (this.get('type')) {
			case 0:
	  			//scalar - nothing to do
	  			break;
	  		case 1:
	  			//Tab1D
29dfb596   Benjamin Renard   Rework of ParamAr...
91
92
	  			if (sum_dim1 !== false) {
	  				paramIndexes = '(' + sum_dim1 + ')';
690e0a87   Benjamin Renard   Add sum in table ...
93
	  			}
29dfb596   Benjamin Renard   Rework of ParamAr...
94
95
	  			else if (sum_dim2 !== false) {
	  				paramIndexes = '(' + sum_dim2 + ')';
690e0a87   Benjamin Renard   Add sum in table ...
96
97
98
99
100
101
102
	  			}
	  			else {
	  				if ((this.get('dim1-index') != '') && (this.get('dim1-index') != '*'))
	  					paramIndexes = '('+this.get('dim1-index')+')';
	  				else if ((this.get('dim2-index') != '') && (this.get('dim2-index') != '*'))
	  					paramIndexes = '('+this.get('dim2-index')+')';
	  			}
bb6e93d9   Benjamin Renard   Implement templat...
103
104
105
	  			break;
	  		case 2:
	  			//Tab2D
690e0a87   Benjamin Renard   Add sum in table ...
106
	  			var dim1 = '';
29dfb596   Benjamin Renard   Rework of ParamAr...
107
108
	  			if (sum_dim1 !== false)
	  				dim1 = sum_dim1;
690e0a87   Benjamin Renard   Add sum in table ...
109
110
111
	  			else
		  			dim1 = this.get('dim1-index') != '' ? this.get('dim1-index') : "*";
	  			var dim2 = '';
29dfb596   Benjamin Renard   Rework of ParamAr...
112
113
	  			if (sum_dim2 !== false)
	  				dim2 = sum_dim2;
690e0a87   Benjamin Renard   Add sum in table ...
114
115
	  			else
	  				dim2 = this.get('dim2-index') != '' ? this.get('dim2-index') : "*";
bb6e93d9   Benjamin Renard   Implement templat...
116
117
118
119
120
121
122
123
	  			if ((dim1 != '*') || (dim2 != '*'))
	  				paramIndexes = '('+dim1+','+dim2+')';
		}
	
		var template_args = "";
		if (this.get('template_args')) {
			Ext.Object.each(this.get('template_args'), function (argKey, argValue) {
				template_args += "_";
3ad6d2e1   Benjamin Renard   Fix boolean argum...
124
125
126
127
128
129
				if (typeof(argValue) === "boolean") {
					template_args += (argValue ? 1 : 0);
				}
				else {
					template_args += argValue;
				}
bb6e93d9   Benjamin Renard   Implement templat...
130
131
132
133
134
135
136
137
138
139
140
141
142
			});
		}
		
		return this.get('paramid')+template_args+paramIndexes;
	},
	
	getJsonValues : function() 
    {
    	var paramValues  = new Object();
    	
    	paramValues['id'] = this.get('id');
    	paramValues['paramid'] = this.get('paramid');
    	paramValues['name'] = this.get('name');
690e0a87   Benjamin Renard   Add sum in table ...
143
    	
29dfb596   Benjamin Renard   Rework of ParamAr...
144
145
	paramValues['dim1-index'] = this.get('dim1-index');
    	paramValues['dim1-sum-type'] = this.get('dim1-sum-type');
cec289da   Hacene SI HADJ MOHAND   attribut rajoute ...
146
147
148
149
                    paramValues['dim1-min-value'] = this.get('dim1-min-value');
                    paramValues['dim1-max-value'] = this.get('dim1-max-value');
                    paramValues['dim1-min-index'] = this.get('dim1-min-index');
                     paramValues['dim1-max-index'] = this.get('dim1-max-index');
b1a45580   Benjamin Renard   Add compatibility...
150
          
29dfb596   Benjamin Renard   Rework of ParamAr...
151
152
	paramValues['dim2-index'] = this.get('dim2-index');
	paramValues['dim2-sum-type'] = this.get('dim2-sum-type');
cec289da   Hacene SI HADJ MOHAND   attribut rajoute ...
153
154
155
156
                    paramValues['dim2-min-value'] = this.get('dim2-min-value');
                    paramValues['dim2-max-value'] = this.get('dim2-max-value');
                    paramValues['dim2-min-index'] = this.get('dim2-min-index');
                    paramValues['dim2-max-index'] = this.get('dim2-max-index');
29dfb596   Benjamin Renard   Rework of ParamAr...
157
   	
cec289da   Hacene SI HADJ MOHAND   attribut rajoute ...
158
159
                    paramValues['type'] = this.get('type');
                    paramValues['is-init'] = this.get('is-init');
a8da7fc5   Hacene SI HADJ MOHAND   ihm plot ok
160
                      	
bb6e93d9   Benjamin Renard   Implement templat...
161
162
163
    	if (this.get('template_args') != null) {
    		paramValues['template_args'] = new Object();
    		Ext.Object.each(this.get('template_args'), function (argKey, argValue) {
3ad6d2e1   Benjamin Renard   Fix boolean argum...
164
165
166
167
168
169
			if (typeof(argValue) === "boolean") {
				paramValues['template_args'][argKey] = (argValue ? 1 : 0);
			}
			else {
    				paramValues['template_args'][argKey] = argValue;
			}
bb6e93d9   Benjamin Renard   Implement templat...
170
171
172
173
174
175
    		});
    	}
    	
    	return paramValues;
    }
      
3ad6d2e1   Benjamin Renard   Fix boolean argum...
176
});