Blame view

js/app/models/RequestParamObject.js 4.18 KB
bb6e93d9   Benjamin Renard   Implement templat...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
 * 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',
	
	idProperty: 'id',
    
    fields : [
          {name: 'type', type: 'int'},
          {name: 'paramid', type: 'string'},
690e0a87   Benjamin Renard   Add sum in table ...
25
26
27
28
29
30
31
32
	      {name: 'dim1-is-range', type: 'bool', defaultValue: false},
	      {name: 'dim1-min-range', type: 'float', defaultValue: 0.},
	      {name: 'dim1-max-range', type: 'float', defaultValue: 0.},
	      {name: 'dim1-index', type: 'string', defaultValue: '*'},
	      {name: 'dim2-is-range', type: 'bool', defaultValue: false},
	      {name: 'dim2-min-range', type: 'float', defaultValue: 0.},
	      {name: 'dim2-max-range', type: 'float', defaultValue: 0.},
	      {name: 'dim2-index', type: 'string', defaultValue: '*'},
bb6e93d9   Benjamin Renard   Implement templat...
33
34
35
36
37
38
39
40
41
42
43
	      {name: 'template_args', type: 'auto', defaultValue: null}
	],
	
	getParamFullName : function() {
		var paramIndexes = '';
		switch (this.get('type')) {
			case 0:
	  			//scalar - nothing to do
	  			break;
	  		case 1:
	  			//Tab1D
690e0a87   Benjamin Renard   Add sum in table ...
44
45
46
	  			if (this.get('dim1-is-range')) {
	  				paramIndexes = '(range[' + this.get('dim1-min-range') + ',' + this.get('dim1-max-range') + '])';
	  			}
d5e126d3   Benjamin Renard   Fix typo
47
	  			else if (this.get('dim2-is-range')) {
690e0a87   Benjamin Renard   Add sum in table ...
48
49
50
51
52
53
54
55
	  				paramIndexes = '(range[' + this.get('dim2-min-range') + ',' + this.get('dim2-max-range') + '])';
	  			}
	  			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...
56
57
58
	  			break;
	  		case 2:
	  			//Tab2D
690e0a87   Benjamin Renard   Add sum in table ...
59
60
61
62
63
64
	  			var dim1 = '';
	  			if (this.get('dim1-is-range'))
	  				dim1 = 'range[' + this.get('dim1-min-range') + ',' + this.get('dim1-max-range') + ']';
	  			else
		  			dim1 = this.get('dim1-index') != '' ? this.get('dim1-index') : "*";
	  			var dim2 = '';
d5e126d3   Benjamin Renard   Fix typo
65
	  			if (this.get('dim2-is-range'))
690e0a87   Benjamin Renard   Add sum in table ...
66
67
68
	  				dim2 = 'range[' + this.get('dim2-min-range') + ',' + this.get('dim2-max-range') + ']';
	  			else
	  				dim2 = this.get('dim2-index') != '' ? this.get('dim2-index') : "*";
bb6e93d9   Benjamin Renard   Implement templat...
69
70
71
72
73
74
75
76
	  			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...
77
78
79
80
81
82
				if (typeof(argValue) === "boolean") {
					template_args += (argValue ? 1 : 0);
				}
				else {
					template_args += argValue;
				}
bb6e93d9   Benjamin Renard   Implement templat...
83
84
85
86
87
88
89
90
91
92
93
94
95
			});
		}
		
		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 ...
96
97
98
99
100
101
102
103
104
105
106
    	
    	paramValues['dim1-is-range'] = this.get('dim1-is-range');
    	paramValues['dim1-min-range'] = this.get('dim1-min-range');
    	paramValues['dim1-max-range'] = this.get('dim1-max-range');
    	paramValues['dim1-index'] = this.get('dim1-index');
    	
    	paramValues['dim2-is-range'] = this.get('dim2-is-range');
    	paramValues['dim2-min-range'] = this.get('dim2-min-range');
    	paramValues['dim2-max-range'] = this.get('dim2-max-range');
    	paramValues['dim2-index'] = this.get('dim2-index');
    	
bb6e93d9   Benjamin Renard   Implement templat...
107
108
109
110
111
    	paramValues['type'] = this.get('type');
    	
    	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...
112
113
114
115
116
117
			if (typeof(argValue) === "boolean") {
				paramValues['template_args'][argKey] = (argValue ? 1 : 0);
			}
			else {
    				paramValues['template_args'][argKey] = argValue;
			}
bb6e93d9   Benjamin Renard   Implement templat...
118
119
120
121
122
123
    		});
    	}
    	
    	return paramValues;
    }
      
3ad6d2e1   Benjamin Renard   Fix boolean argum...
124
});