Blame view

js/app/models/Search.js 3.37 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
 * Project      : AMDA-NG
 * Name         : Search.js
 * Description  : Condition Business Object Definition
 * @class amdaModel.Search
 * @extends amdaModel.AmdaObject 
 * 
 * @author myriam
 * @version $Id: Search.js 2068 2014-02-06 11:27:38Z elena $
 ******************************************************************************
 *    FT Id     :   Date   : Name - Description
 ******************************************************************************
 *	:           :23/06/2011: myriam – creation 
 *	:           :04/07/2011: elena – event Execute
 *	:           :06/07/2011: elena – date fields 
 */
 
 		
Ext.define('amdaModel.Search', {
		extend: 'amdaModel.AmdaTimeObject',
    
    fields : [
//	      {name: 'name', type: 'string', defaultValue: 'Search'},
d66dfcfd   Benjamin Renard   Set Time Step fie...
24
	      {name: 'sampling', type: 'float', defaultValue: '600'},
16035364   Benjamin Renard   First commit
25
26
	      {name: 'gap', type: 'int', defaultValue: '5'},
	      {name: 'description', type: 'string'},
69c5bc1e   Benjamin Renard   Add modif. time f...
27
28
29
30
	      {name: 'expression', type: 'string'},    
              {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'
16035364   Benjamin Renard   First commit
31
32
	],
	
69c5bc1e   Benjamin Renard   Add modif. time f...
33
	propertiesToCopy : 'id,name,sampling,gap,description,expression,last_update,sampling_mode,reference_param',
16035364   Benjamin Renard   First commit
34
35
36
37
38
39
40
41
42
43

	getJsonValues : function(hasId){

        var myValues  = new Object();       
        if (hasId) {
            myValues.id = this.get('id');
        }
        myValues.name = this.get('name');
        myValues.sampling = this.get('sampling');
        myValues.gap = this.get('gap');
69c5bc1e   Benjamin Renard   Add modif. time f...
44
45
	myValues.sampling_mode = this.get('sampling_mode');
	myValues.reference_param = this.get('reference_param');
16035364   Benjamin Renard   First commit
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
76
77
78
79
80
        myValues.description = this.get('description');
        myValues.expression = this.get('expression').replace(/\n/g," ");;
        myValues.timesrc =  this.get('timesrc');                         
        // if there's at least one timeTable name into 'timeTables' collection
        if (this.get('timesrc') == amdaModel.AmdaTimeObject.inputTimeSrc[0] && this.get('timeTables') && this.get('timeTables').length){
//          myValues.timeTables = this.get('timeTables').items;
            // get complete timeTables collection
            var timeTables = this.get('timeTables');
            // init an empty array for timeTables
            myValues.timeTables=[];
            // for each interval record
            Ext.Array.each(timeTables, function(item, index, all){
                // get Json simplified value
                if (!item.$className) {
		    myValues.timeTables[index] = {timeTableName : item.timeTableName, id : item.id};
	       }
                // get Json simplified value 
               else {
                myValues.timeTables[index] = item.getJsonValues();
	       }                
            });            
        } else {
            myValues.startDate = this.get('startDate');
            myValues.stopDate = this.get('stopDate');
            myValues.durationDay = this.get('durationDay');
            myValues.durationHour = this.get('durationHour');
            myValues.durationMin = this.get('durationMin');
            myValues.durationSec = this.get('durationSec');
        }
        
        myValues.leaf = true;
        myValues.nodeType = amdaModel.SearchNode.nodeType;
        return myValues;
	}
      
69c5bc1e   Benjamin Renard   Add modif. time f...
81
});