Blame view

js/app/models/Download.js 4.14 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
/**
 * Project      : AMDA-NG
 * Name         : Download.js
 * Description  : Download Request Business Object Definition
 * @class amdaModel.Download
fdf1413b   Elena.Budnik   TT download
6
 * @extends amdaModel.AmdaTimeObject 
16035364   Benjamin Renard   First commit
7
8
 * @author myriam
 * @version $Id: Download.js 2068 2014-02-06 11:27:38Z elena $
16035364   Benjamin Renard   First commit
9
10
11
12
 */
 
 		
Ext.define('amdaModel.Download', {
fdf1413b   Elena.Budnik   TT download
13
	extend: 'amdaModel.AmdaTimeObject',
16035364   Benjamin Renard   First commit
14
    
fdf1413b   Elena.Budnik   TT download
15
16
17
18
19
20
21
22
23
24
25
26
27
28
	fields : [
		{name: 'type', type: 'string', defaultValue: 'Download'},
		{name: 'downloadSrc', type: 'string'},
		{name: 'list', defaultValue: null },    // array of parameters	  
		{name: 'timeformat', type: 'string'},
		{name: 'timeformatTT', type: 'string'},
		{name: 'structure', type: 'string'},
		{name: 'refparamSampling', type: 'boolean', defaultValue: false},
		{name: 'sampling', type: 'int', defaultValue: '600'},
		{name: 'fileprefix', type: 'string'},
		{name: 'fileformat', type: 'string'},
		{name: 'fileformatTT', type: 'string'},
		{name: 'compression', type: 'string'},
		{name: 'compressionTT', type: 'string'}
16035364   Benjamin Renard   First commit
29
	],
fdf1413b   Elena.Budnik   TT download
30

3604e40f   Benjamin Renard   "File Name" repla...
31
	propertiesToCopy : 'id,name,downloadSrc,refparamSampling,sampling,list,timeformat,timeformatTT,structure,fileprefix,fileformat,fileformatTT,compression,compressionTT',
16035364   Benjamin Renard   First commit
32
33
34

	getJsonValues : function(){

fdf1413b   Elena.Budnik   TT download
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
		var myValues  = new Object();       
		myValues.nodeType =  'download';//amdaModel.DownloadNode.nodeType;
		myValues.type = this.get('type');
		myValues.downloadSrc = this.get('downloadSrc');
		//Data download	 
		if (myValues.downloadSrc === '0') {	 // Data download 
			myValues.structure = this.get('structure');
			myValues.refparamSampling = this.get('refparamSampling');
			myValues.sampling = this.get('sampling');
			myValues.fileprefix = this.get('fileprefix');
		
			myValues.timesrc =  this.get('timesrc');
			// if there's at least one timeTable in case of Download data
			if (this.get('timesrc') == amdaModel.AmdaTimeObject.inputTimeSrc[0] && this.get('timeTables') && this.get('timeTables').length){
				// 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');
			} 
         
			// if there's at least one parameter
			if (this.get('list') && this.get('list').length) {
				var list = this.get('list');
				myValues.list=[];					
				Ext.each(list, function(item, index){   
					myValues.list[index] = item.getJsonValues();
				});
			}  
			myValues.fileformat = this.get('fileformat');
			myValues.timeformat = this.get('timeformat');
			myValues.compression = this.get('compression');
		}
		// TT download
		else if (myValues.downloadSrc === '1') {
			// if there's at least one timeTable
			if (this.get('timeTables') && this.get('timeTables').length) {
				var list = this.get('timeTables');
				myValues.list=[];
				
				Ext.each(list, function(item, index){					
					var tt = new Object();
					tt.name = item.get('name');
					tt.id = item.get('id');					
					myValues.list[index] = tt;
				});  
			}
			myValues.fileformat = this.get('fileformatTT');
			myValues.timeformat = this.get('timeformatTT');
			myValues.compression = this.get('compressionTT');
		}
		// fits images download
		else { 
			myValues.list=[];
			if (this.get('list') && this.get('list').length)
			Ext.each(this.get('list'), function(item, index){  
				var image = new Object();
				image.name = item['name'];
				image.url  = item['url'];
				myValues.list[index] = image;
			});
			myValues.compression = this.get('compression');
		}
		myValues.leaf = true;
		//   myValues.nodeType = amdaModel.PlotNode.nodeType;
		return myValues;
	}      
9cb1f3cd   Benjamin Renard   Update download i...
119
});