Blame view

js/app/models/Download.js 8.85 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
 */
0e540b69   Benjamin Renard   Finalize save of ...
10
11
12


Ext.define('amdaModel.DownloadConfig', {
06b20411   Hacene SI HADJ MOHAND   I have changed th...
13
14
15
16
17
18
19
20
21
    singleton: true,

    defaultValues: {
        timeformat: 'YYYY-MM-DDThh:mm:ss',
        timeformatTT: 'YYYY-MM-DDThh:mm:ss',
        fileformat: 'ASCII',
        fileformatTT: 'text',
        filecompress: 'tar+gzip',
        filecompressTT: 'tar+gzip',
a64a6068   Erdogan Furkan   9628 - Resolution...
22
        filestructure: '0'
06b20411   Hacene SI HADJ MOHAND   I have changed th...
23
24
25
26
    },

    timeformatData: [
        ['YYYY-MM-DDThh:mm:ss', 'YYYY-MM-DDThh:mm:ss.ms', 'ISO format with msecs'],
6d335d6d   Menouard AZIB   Change git userna...
27
        ['DOY TIME', 'YYYYDOYhhmmssms', 'Day-Of-Year, 1 Jan => DOY = 1'],
06b20411   Hacene SI HADJ MOHAND   I have changed th...
28
29
30
31
32
33
34
        ['Timestamp', 'Seconds from 1970', 'Total of seconds from the Unix Epoch on January 1st, 1970 at UTC.'],
        ['YYYY MM DD hh mm ss', 'YYYY MM DD hh mm ss ms', 'date with spaces'],
        ['Timestamp-with-milliseconds', 'Seconds from 1970 with ms', 'Total of seconds from the Unix Epoch with milliseconds.']
    ],
    fileformatData: [
        ['ASCII', 'ASCII'],
        ['vot', 'VOTable'],
3994bd1f   Benjamin Renard   Give the possibil...
35
36
        ['cdf-istp', 'CDF/ISTP'],
        ['cdf', 'CDF (deprecated)'],
06b20411   Hacene SI HADJ MOHAND   I have changed th...
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
        ['json', 'JSON']
    ],
    fileformatTTData: [
        ['text', 'plain text'],
        ['vot', 'VOTable'],
        ['space', 'HPEvent']
    ],
    filecompressData: [
        ['zip', 'zip'],
        ['tar+gzip', 'tar+gzip']
    ],
    filecompressTTData: [
        ['zip', 'zip'],
        ['tar+gzip', 'tar+gzip'],
        ['none', 'none']
    ],
    filestructureData: [
        ['0', 'All In One File'],
        ['1', 'One File Per Time Interval'],
        ['2', 'One File Per Param/Interval']
    ]
0e540b69   Benjamin Renard   Finalize save of ...
58
});
06b20411   Hacene SI HADJ MOHAND   I have changed th...
59

16035364   Benjamin Renard   First commit
60
Ext.define('amdaModel.Download', {
06b20411   Hacene SI HADJ MOHAND   I have changed th...
61
62
63
64
65
66
67
68
69
70
71
72
    extend: 'amdaModel.AmdaTimeObject',

    requires: [
        "amdaModel.DownloadParam"
    ],

    fields: [
        { name: 'type', type: 'string', defaultValue: 'Download' },
        { name: 'downloadSrc', type: 'string' },
        { name: 'timeformat', type: 'string', defaultValue: amdaModel.DownloadConfig.defaultValues.timeformat },
        { name: 'timeformatTT', type: 'string', defaultValue: amdaModel.DownloadConfig.defaultValues.timeformatTT },
        { name: 'filestructure', type: 'string', defaultValue: amdaModel.DownloadConfig.defaultValues.filestructure },
a64a6068   Erdogan Furkan   9628 - Resolution...
73
        { name: 'refparamSampling', type: 'boolean', defaultValue: true },
06b20411   Hacene SI HADJ MOHAND   I have changed th...
74
75
76
77
78
79
80
81
        { name: 'separateInfoFile', type: 'boolean', defaultValue: false },
        { name: 'sampling', type: 'float', defaultValue: '600' },
        { name: 'scientificformat', type: 'boolean', defaultValue: true },
        { name: 'fileprefix', type: 'string' },
        { name: 'fileformat', type: 'string', defaultValue: amdaModel.DownloadConfig.defaultValues.fileformat },
        { name: 'fileformatTT', type: 'string', defaultValue: amdaModel.DownloadConfig.defaultValues.fileformatTT },
        { name: 'compression', type: 'string', defaultValue: amdaModel.DownloadConfig.defaultValues.filecompress },
        { name: 'compressionTT', type: 'string', defaultValue: amdaModel.DownloadConfig.defaultValues.filecompressTT },
29a2024c   Erdogan Furkan   10852
82
83
        { name: 'last_update', type: 'int', defaultValue: 0 },
        { name: 'description', type: 'string', defaultValue: '' },
06b20411   Hacene SI HADJ MOHAND   I have changed th...
84
85
86
87
88
89
90
91
92
93
    ],

    associations: [{
        type: 'hasMany',
        model: 'amdaModel.DownloadParam',
        name: 'params'
    }],

    propertiesToCopy: 'id,name,downloadSrc,refparamSampling,separateInfoFile,sampling,scientificformat,list,timeformat,timeformatTT,filestructure,fileprefix,fileformat,fileformatTT,compression,compressionTT',

a64a6068   Erdogan Furkan   9628 - Resolution...
94
    constructor: function () {
06b20411   Hacene SI HADJ MOHAND   I have changed th...
95
96
97
98
99
100
101
102
103
        var me = this;
        me.callParent(arguments);
        if ((arguments.length > 0) && arguments[0]) {
            if (arguments[0].list)
                me.loadParams(arguments[0].list);
        }
        this.dirty = false;
    },

a64a6068   Erdogan Furkan   9628 - Resolution...
104
    loadParams: function (params) {
06b20411   Hacene SI HADJ MOHAND   I have changed th...
105
        /* Compatability mode */
a64a6068   Erdogan Furkan   9628 - Resolution...
106
        Ext.each(params, function (param, index) {
06b20411   Hacene SI HADJ MOHAND   I have changed th...
107
108
109
110
111
112
113
114
115
116
117
118
119
120
            if (param.hasOwnProperty('is-init')) {
                return;
            }
            params[index]['dim1-sum-type'] = param['dim1-is-range'] ? 1 : 0;
            params[index]['dim1-min-value'] = param['dim1-min-range'];
            params[index]['dim1-max-value'] = param['dim1-max-range'];
            params[index]['dim2-sum-type'] = param['dim2-is-range'] ? 1 : 0;
            params[index]['dim2-min-value'] = param['dim2-min-range'];
            params[index]['dim2-max-value'] = param['dim2-max-range'];
            params[index]['is-init'] = true;
        });
        this.params().loadData(params);
    },

a64a6068   Erdogan Furkan   9628 - Resolution...
121
    isDirty: function () {
06b20411   Hacene SI HADJ MOHAND   I have changed th...
122
123
124
125
126
        if (this.dirty)
            return true;

        var d = false;

a64a6068   Erdogan Furkan   9628 - Resolution...
127
        this.params().each(function (param, index) {
06b20411   Hacene SI HADJ MOHAND   I have changed th...
128
129
130
131
132
133
            if (param.dirty)
                d = true;
        });
        return d;
    },

a64a6068   Erdogan Furkan   9628 - Resolution...
134
    getJsonValues: function () {
06b20411   Hacene SI HADJ MOHAND   I have changed th...
135
136
137
138
139
140
141
142
143
144
145
146
147
148

        var myValues = new Object();
        myValues.nodeType = 'download'; //amdaModel.DownloadNode.nodeType;
        myValues.type = this.get('type');
        myValues.downloadSrc = this.get('downloadSrc');
        myValues.name = this.get('name');
        //Data download	 
        if (myValues.downloadSrc === '0') { // Data download 
            myValues.filestructure = this.get('filestructure');
            myValues.refparamSampling = this.get('refparamSampling');
            myValues.separateInfoFile = this.get('separateInfoFile');
            myValues.scientificformat = this.get('scientificformat');
            myValues.sampling = this.get('sampling');
            myValues.fileprefix = this.get('fileprefix');
29a2024c   Erdogan Furkan   10852
149
            myValues.description =this.get('description');
06b20411   Hacene SI HADJ MOHAND   I have changed th...
150
151
152
153
154
155
156
157

            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
a64a6068   Erdogan Furkan   9628 - Resolution...
158
                Ext.Array.each(timeTables, function (item, index, all) {
06b20411   Hacene SI HADJ MOHAND   I have changed th...
159
160
161
162
163
164
165
166
167
168
                    // 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 {
79a60955   Hacene SI HADJ MOHAND   ms ok affichage ko
169
170
                myValues.startDate = Ext.Date.format(this.get('startDate'), 'Y-m-d\\TH:i:s.u');	
                myValues.stopDate =  Ext.Date.format(this.get('stopDate'), 'Y-m-d\\TH:i:s.u');	
06b20411   Hacene SI HADJ MOHAND   I have changed th...
171
172
173
174
                myValues.durationDay = this.get('durationDay');
                myValues.durationHour = this.get('durationHour');
                myValues.durationMin = this.get('durationMin');
                myValues.durationSec = this.get('durationSec');
b852834a   Hacene SI HADJ MOHAND   progress
175
                myValues.durationMs = this.get('durationMs');
06b20411   Hacene SI HADJ MOHAND   I have changed th...
176
177
178
179
            }

            // if there's at least one parameter
            myValues.list = []
a64a6068   Erdogan Furkan   9628 - Resolution...
180
            this.params().each(function (param, index) {
06b20411   Hacene SI HADJ MOHAND   I have changed th...
181
                myValues.list[index] = param.getJsonValues();
0e540b69   Benjamin Renard   Finalize save of ...
182
            });
06b20411   Hacene SI HADJ MOHAND   I have changed th...
183
184
185
186
187
188
189
190
191
192
193
            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 = [];

a64a6068   Erdogan Furkan   9628 - Resolution...
194
                Ext.each(list, function (item, index) {
06b20411   Hacene SI HADJ MOHAND   I have changed th...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
                    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)
a64a6068   Erdogan Furkan   9628 - Resolution...
209
                Ext.each(this.get('list'), function (item, index) {
06b20411   Hacene SI HADJ MOHAND   I have changed th...
210
211
212
213
214
215
216
217
218
219
220
221
                    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;
    }
});