Parameter.js
2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
/**
* Project : AMDA-NG
* Name : parameter.js
* Description : Parameter Business Object Definition
* @class amdaModel.Parameter
* @extends amdaModel.AmdaObject
*
* @author cdarmon
* @version $Id: Parameter.js 1435 2013-04-04 14:24:04Z elena $
******************************************************************************
* FT Id : Date : Name - Description
******************************************************************************
* : :15/12/2010: CDA – creation
* : :22/06/2011: elena - extends generic class AmdaObject
*/
Ext.define('amdaModel.Parameter', {
extend: 'amdaModel.AmdaObject',
fields : [
{name: 'timestep', type: 'string'}, // only used if 'sampling_mode' is 'timestep'
{name: 'units', type: 'string'},
{name: 'buildchain', type: 'string'},
{name: 'description', type: 'string'},
{name: 'ytitle', type: 'string'},
{name: 'dim_1', type: 'number'},
{name: 'dim_2', type: 'number'},
{name: 'last_update', type: 'int', defaultValue: 0},
{name: 'sampling_mode', type: 'string', defaultValue: 'timestep'}, // 'timestep' or 'refparam'
{name: 'reference_param', type: 'string'} // only used if 'sampling_mode' is 'refparam'
],
/**
* get parameter values into object to be sent to Server
* @return object
*/
//TODO utf8_encode() and Ext.urlEncode() ???
getJsonValues : function (hasId) {
var myValues = new Object();
if (hasId) {
myValues.id = this.get('id');
}
myValues.name = this.get('name');
myValues.buildchain = this.get('buildchain').replace(/\n/g," ");
myValues.timestep = this.get('timestep');
myValues.leaf = true;
if (this.get('ytitle').match(/[a-z,0-9]/gi) != null) {
myValues.ytitle = this.get('ytitle');
}
if (this.get('description').match(/[a-z,0-9]/gi) != null) {
myValues.description = this.get('description');
}
if (this.get('units').match(/[a-z,0-9]/gi) != null) {
myValues.units = this.get('units');
}
myValues.dim_1 = this.get('dim_1');
myValues.dim_2 = this.get('dim_2');
myValues.nodeType = amdaModel.DerivedParamNode.nodeType;
myValues.sampling_mode = this.get('sampling_mode');
myValues.reference_param = this.get('reference_param');
return myValues;
}
});