Commit 8a2ebb6973f060b0bdead08d80cab8badcb70d11

Authored by Elena Budnik
2 parents cedf0315 48a8a598

Merge branch 'upload_cdf_upgrade' into 'master'

Upload cdf upgrade

See merge request !20
generic_data/remote_sites.json 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +{"remote_sites": [
  2 + {"name": "CDAWeb", "value": "https://cdaweb.gsfc.nasa.gov/pub/data/"}
  3 +]}
... ...
js/app/controllers/UploadModule.js
... ... @@ -20,8 +20,8 @@ Ext.define('amdaDesktop.UploadModule', {
20 20 * @cfg {String} window definitions
21 21 * @required
22 22 */
23   - width: 320,
24   - height: 510,
  23 + width: 330,
  24 + height: 520,
25 25 uiType : 'panelTabUpload',
26 26 helpTitle : 'Help on Upload Module',
27 27 helpFile : 'uploadHelp',
... ...
js/app/models/InteractiveNode.js
... ... @@ -200,22 +200,11 @@ Ext.define('amdaModel.InteractiveNode', {
200 200  
201 201 if (res.info) {
202 202 this.set('info',res.info);
203   - }
204   -
205   - if (this.get('nodeType') == 'myDataParam') {
206   - if (res.isSpectra) {
207   - this.set('iconCls', 'icon-spectra');
208   - }
209   - else {
210   - if (res.size > 1) this.set('iconCls', 'icon-unknowntype');
211   - }
212 203 }
213 204  
214   - // update my data on possibble mask change
215   - if (res.updateMyData) {
216   - this.updateMyData();
217   - this.updateMask(res.mask);
218   - }
  205 + // myDataParam special update
  206 + this.specialUpdate(res, false);
  207 +
219 208 // reload object into the view of corresponding Module
220 209 var me = this;
221 210 myDesktopApp.getLoadedModule(this.get('moduleId'), true, function (module) {
... ... @@ -282,30 +271,10 @@ Ext.define('amdaModel.InteractiveNode', {
282 271 if (res.info){
283 272 // set the tooltip
284 273 this.set('info',res.info);
285   - //set globalStart & global Stop to be used for time selection
286   - if (this.get('nodeType') == 'myDataParam')
287   - {
288   - var startStop = res.info.split("<br/>");
289   - var globalStart = startStop[1].substr(0,19);
290   - var globalStop = startStop[1].substr(20);
291   -
292   - this.set('globalStart', globalStart);
293   - this.set('globalStop', globalStop);
294   -
295   - if (res.mask)
296   - this.set('linkedMask', res.mask);
297   - if (res.size)
298   - this.set('size', res.size);
299   -
300   - if (res.isSpectra) {
301   - this.set('iconCls', 'icon-spectra');
302   - }
303   - else {
304   - if (res.size > 1)
305   - this.set('iconCls', 'icon-unknowntype');
306   - }
307   - }
308   - }
  274 + }
  275 + //set globalStart & global Stop to be used for time selection
  276 + this.specialUpdate(res, true);
  277 +
309 278 //TODO do we need this commission ???
310 279 // fix the modifications for object
311 280 this.get('object').commit();
... ... @@ -333,14 +302,6 @@ Ext.define(&#39;amdaModel.InteractiveNode&#39;, {
333 302 opt.callback.call(scope,'create');
334 303 }
335 304 }, this);
336   -
337   - // myDataParamNode - update MyData subtree
338   - //TODO put this in mydataparamnode
339   - if (res.updateMyData) {
340   - this.updateMyData();
341   - this.updateMask(res.mask);
342   - }
343   -
344 305 }
345 306 // error code from server; but e.status==true
346 307 else {
... ... @@ -359,6 +320,7 @@ Ext.define(&#39;amdaModel.InteractiveNode&#39;, {
359 320 },this);
360 321 },
361 322  
  323 + specialUpdate : function() {},
362 324 /**
363 325 * Generic part of Context Menu
364 326 *
... ...
js/app/models/MyDataNode.js
... ... @@ -188,9 +188,9 @@ Ext.define(&#39;amdaModel.MyDataNode&#39;, {
188 188 if (myParamRootNode.isExpanded) {
189 189 Ext.Array.each(myParamRootNode.childNodes, function(node) {
190 190 if (node.get('linkedMask') && node.get('linkedMask') == mask) {
191   - var globalStart = maskDesc.substr(0,16);
192   - var globalStop = maskDesc.substr(17,16);
193   -
  191 + var globalStart = maskDesc.substr(0,19);
  192 + var globalStop = maskDesc.substr(20);
  193 +
194 194 node.set('globalStart', globalStart);
195 195 node.set('globalStop', globalStop);
196 196 if (node.get('info')) {
... ...
js/app/models/MyDataParamNode.js
... ... @@ -31,12 +31,13 @@ Ext.define(&#39;amdaModel.MyDataParamNode&#39;, {
31 31 this.set('objectDataModel','amdaModel.FileParamObject');
32 32 if (this.get('isParameter')) {
33 33 if (this.get('size') == 1)
34   - this.set('iconCls', 'icon-scalar');
35   - else if (this.get('size') == 3)
  34 + this.set('iconCls', 'icon-scalar');
  35 + else if(this.get('size') == 3)
36 36 this.set('iconCls', 'icon-vector');
37 37 else
38 38 this.set('iconCls', 'icon-unknowntype');
39 39 }
  40 +
40 41 if (this.get('isSpectra')) this.set('iconCls', 'icon-spectra');
41 42 },
42 43  
... ... @@ -76,7 +77,7 @@ Ext.define(&#39;amdaModel.MyDataParamNode&#39;, {
76 77 },
77 78  
78 79 getAllContextMenuItems: function()
79   - {
  80 + {
80 81 var menuItems = this.allMenuItems('Parameter');
81 82 var locMenuItems = this.localMenuItems();
82 83  
... ... @@ -87,52 +88,53 @@ Ext.define(&#39;amdaModel.MyDataParamNode&#39;, {
87 88 {
88 89 var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length);
89 90  
90   - switch (fnId) {
  91 + switch (fnId)
  92 + {
91 93 case 'deleteNode':
92 94 this.deleteNode();
93 95 break;
94 96  
95 97 case 'createDir':
96 98 this.createDir();
97   - break;
  99 + break;
98 100  
99 101 case 'createLeaf':
100   - this.createLeaf(this);
101   - break;
  102 + this.createLeaf(this);
  103 + break;
102 104  
103 105 case 'renameNode':
104   - this.renameNode();
105   - break;
  106 + this.renameNode();
  107 + break;
106 108  
107 109 case 'editLeaf':
108   - this.editLeaf();
109   - break;
  110 + this.editLeaf();
  111 + break;
110 112  
111 113 case 'upload':
112   - this.uploadFile();
113   - break;
114   -
  114 + this.uploadFile();
  115 + break;
  116 +
115 117 case 'plotParam':
116   - this.createPlot(this);
117   - break;
118   -
  118 + this.createPlot(this);
  119 + break;
  120 +
119 121 case 'downParam':
120   - this.createDownload(this);
121   - break;
122   -
  122 + this.createDownload(this);
  123 + break;
  124 +
123 125 default:
124   - break;
125   - } // switch end
126   -
127   - },
  126 + break;
  127 + } // switch end
  128 + },
128 129  
129 130 uploadFile: function() {
130 131 myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.upload.id, true, function (module) {
131 132 module.createWindow();
132 133 });
133 134 },
134   -
135   - editLeaf: function() {
  135 +
  136 + editLeaf: function()
  137 + {
136 138 // load the rootNode and recursively all its child nodes
137 139 // to know all names of DerivedParameters
138 140 var me = this;
... ... @@ -161,20 +163,20 @@ Ext.define(&#39;amdaModel.MyDataParamNode&#39;, {
161 163 var t = remoteEvent.getTransaction();
162 164 if (result) {
163 165 if (result.id) {
164   - var paramObj = Ext.create(this.get('objectDataModel'), result);
165   - // set parameter into node
166   - this.set('object',paramObj);
167   -
168   - paramObj.set('tableDef', result['tableDef']);
169   -
170   - if (paramObj.get('mask')) var file = paramObj.get('mask');
171   - else var file = paramObj.get('file');
172   -
173   - AmdaAction.getObject(file, amdaModel.MyDataNode.nodeType,
174   - this.getFileObjectCallback, this);
  166 + var paramObj = Ext.create(this.get('objectDataModel'), result);
  167 + // set parameter into node
  168 + this.set('object',paramObj);
  169 +
  170 + paramObj.set('tableDef', result['tableDef']);
  171 +
  172 + if (paramObj.get('mask')) var file = paramObj.get('mask');
  173 + else var file = paramObj.get('file');
  174 +
  175 + AmdaAction.getObject(file, amdaModel.MyDataNode.nodeType,
  176 + this.getFileObjectCallback, this);
175 177 }
176 178 else {
177   - myDesktopApp.errorMsg(result.error);
  179 + myDesktopApp.errorMsg(result.error);
178 180 }
179 181 }
180 182 else {
... ... @@ -226,24 +228,59 @@ Ext.define(&#39;amdaModel.MyDataParamNode&#39;, {
226 228 },
227 229  
228 230 updateMyData : function(){
229   - // reload myFiles Tree in explorer
230   - var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);
231   - if (explorerTree) {
232   - var explorerTreeStore = explorerTree.getStore();
233   - var explorerRoot = explorerTreeStore.getRootNode().findChild('text','My Files');
234   -
235   - var explorerPath = '/root/myData-treeRootNode/';
236   -
237   - explorerTreeStore.reload({node : explorerRoot,
238   - params : { nodeType: 'myData'},
239   - callback : function(){
240   - explorerTree.selectPath(explorerPath);
241   - }
242   - });
243   - }
  231 + // reload myFiles Tree in explorer
  232 + var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);
  233 + if (explorerTree) {
  234 + var explorerTreeStore = explorerTree.getStore();
  235 + var explorerRoot = explorerTreeStore.getRootNode().findChild('text','My Files');
  236 +
  237 + var explorerPath = '/root/myData-treeRootNode/';
  238 +
  239 + explorerTreeStore.reload({node : explorerRoot,
  240 + params : { nodeType: 'myData'},
  241 + callback : function(){
  242 + explorerTree.selectPath(explorerPath);
  243 + }
  244 + });
  245 + }
244 246 },
245 247  
246 248 isParameter : function(){
247 249 return this.get('isParameter');
248   - }
  250 + },
  251 +
  252 + specialUpdate : function(res, timeUpdate)
  253 + {
  254 + if (timeUpdate && res.info)
  255 + {
  256 + var startStop = res.info.split("<br/>");
  257 + var globalStart = startStop[1].substr(0,19);
  258 + var globalStop = startStop[1].substr(20);
  259 +
  260 + this.set('globalStart', globalStart);
  261 + this.set('globalStop', globalStop);
  262 +
  263 + if (res.mask)
  264 + this.set('linkedMask', res.mask);
  265 + if (res.size)
  266 + this.set('size', res.size);
  267 + }
  268 +
  269 + if (res.isSpectra) {
  270 + this.set('iconCls', 'icon-spectra');
  271 + }
  272 + else if (res.size == 3) {
  273 + this.set('iconCls', 'icon-vector');
  274 + }
  275 + else if (res.size > 1) {
  276 + this.set('iconCls', 'icon-unknowntype');
  277 + }
  278 +
  279 + // update my data on possible mask change
  280 + if (res.updateMyData) {
  281 + this.updateMyData();
  282 + this.updateMask(res.mask);
  283 + }
  284 + }
  285 +
249 286 });
... ...
js/app/views/ExplorerUI.js
... ... @@ -266,10 +266,12 @@ Ext.define(&#39;amdaUI.ExplorerUI&#39;, {
266 266 model: 'amdaModel.AmdaNode',
267 267 sorters:[{ direction: 'ASC' ,
268 268 sorterFn: function(o1, o2){
269   - if (o1.get('nodeType') !== 'localParam')
270   - return;
271   -
272   - return o1.get('text').toUpperCase() < o2.get('text').toUpperCase() ? -1 : 1;
  269 +
  270 + if (o1.get('nodeType') == 'localParam' || o1.get('nodeType') == 'myData') {
  271 + return o1.get('text').toUpperCase() < o2.get('text').toUpperCase() ? -1 : 1;
  272 + }
  273 +
  274 + return;
273 275 }
274 276 }],
275 277 listeners: {
... ...
js/app/views/MyDataUI.js
... ... @@ -10,474 +10,495 @@
10 10  
11 11  
12 12 Ext.define('amdaUI.MyDataUI', {
13   - extend: 'Ext.container.Container',
14   - alias: 'widget.panelMyData',
15   -
16   - requires: [
17   - 'amdaUI.TableDefPlugUI'
18   - ],
  13 + extend: 'Ext.container.Container',
  14 + alias: 'widget.panelMyData',
  15 +
  16 + requires: [
  17 + 'amdaUI.TableDefPlugUI'
  18 + ],
19 19  
20   - object : null,
21   - fileObject : null,
22   -
23   - module : null,
24   -
25   - fields : [],
26   - columns : [],
27   -
28   - constructor: function(config) {
29   - this.module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.my_data.id);
30   - this.init(config);
31   - this.callParent(arguments);
32   - this.setObject(this.module.linkedNode.get('object'));
33   - },
34   -
35   - /*
36   - * linked node should be MyDataParamNode
37   - */
38   - resetLinkedNode: function()
39   - {
40   - this.linkedNode = null;
41   - this.module.createLinkedNode();
42   - this.module.createObject();
43   - this.module.linkedNode.set('fileObject',this.fileObject);
44   - },
  20 + object : null,
  21 + fileObject : null,
45 22  
46   - getObjectCallback: function(result,remoteEvent)
47   - {
48   - var t = remoteEvent.getTransaction();
49   - if (result && !result.error) {
50   - //this.tmpNode.set('contextNode',mask!!! if exists
51   - this.fileObject = Ext.create('amdaModel.FileObject', result);
52   - var panelConfig = this.initPanel();
53   - }
54   - else {
55   - // EXCEPTION : parameter not found !
56   - myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '"
57   - +this.tmpNode.get('text')+"' found!");
58   - }
59   - },
60   -
61   - /*
62   - * Update info in the form on another parameter selection (cdf, cef formats);
63   - */
64   - updateInfo : function(res, e)
65   - {
66   - if (res.success){
67   - // info panel
68   - this.items.getAt(1).update(res.info.name+': '+res.info.type+' '+res.info.size+' '+res.info.n_records);
69   - var form = this.items.getAt(0).getForm();
70   -
71   - //keep old name and mask if they exist
72   - if (this.object.get('format') == 'vot')
73   - {
74   - if ((res.info.id === this.object.get('realvar'))) {
75   - if (this.object.get('realvar') != this.object.get('name')) {
76   - res.info.name = this.object.get('name');
77   - }
78   - if (res.info.mask != this.object.get('mask')) {
79   - res.info.mask = this.object.get('mask');
80   - }
81   - }
82   - }
83   - else
84   - {
85   - if ((res.info.name === this.object.get('realvar'))) {
86   - if (this.object.get('realvar') != this.object.get('name')) {
87   - res.info.name = this.object.get('name');
88   - }
89   - if (res.info.mask != this.object.get('mask')) {
90   - res.info.mask = this.object.get('mask');
91   - }
92   - }
93   - }
  23 + module : null,
  24 +
  25 + fields : [],
  26 + columns : [],
  27 +
  28 + constructor: function(config) {
  29 + this.module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.my_data.id);
  30 + this.init(config);
  31 + this.callParent(arguments);
  32 + this.setObject(this.module.linkedNode.get('object'));
  33 + },
94 34  
95   - form.setValues(res.info);
96   - }
97   - else {
98   - myDesktopApp.errorMsg("System Error <br/> Error at AMDA Server");
99   - }
100   - },
101   -
102   - /*
103   - * Check if changes were made before closing window
104   - * @return false
105   - */
106   - fclose : function() {
107   - return false;
108   - },
  35 + /*
  36 + * linked node should be MyDataParamNode
  37 + */
  38 + resetLinkedNode: function()
  39 + {
  40 + this.linkedNode = null;
  41 + this.module.createLinkedNode();
  42 + this.module.createObject();
  43 + this.module.linkedNode.set('fileObject',this.fileObject);
  44 + },
109 45  
110   - /**
111   - * set object into form
112   - */
113   - setObject : function (object)
114   - {
115   - // edit in module from FileUpload Module and ExplorerModule (edit param)
116   - if (this.module.linkedNode) {
117   - if (this.module.linkedNode.get('fileObject')) {
118   - this.fileObject = this.module.linkedNode.get('fileObject');
119   - }
120   - // edit in module from Explorer Module (edit file)
121   - else if (this.module.linkedNode.get('object')) {
122   - this.fileObject = this.module.linkedNode.get('object');
123   - this.resetLinkedNode();
124   - }
125   - else {
126   - myDesktopApp.errorMsg("System Error <br/> No FileObject and Object");
127   - }
128   - }
129   - else {
130   - myDesktopApp.errorMsg("System Error <br/> No Linked Node");
131   - }
132   -
133   - var form = this.down('form');
134   - form.getForm().reset();
135   - // remove and DESTROY right panel if it exists
136   - if (form.items.length == 2)
137   - form.remove(form.items.getAt(1),true);
138   - // create right panel depending on file
139   - var rightPanel = this.initPanel();
140   - form.add(rightPanel);
141   - this.object = this.module.linkedNode.get('object');
  46 + getObjectCallback: function(result,remoteEvent)
  47 + {
  48 + var t = remoteEvent.getTransaction();
  49 + if (result && !result.error) {
  50 + //this.tmpNode.set('contextNode',mask!!! if exists
  51 + this.fileObject = Ext.create('amdaModel.FileObject', result);
  52 + var panelConfig = this.initPanel();
  53 + }
  54 + else {
  55 + // EXCEPTION : parameter not found !
  56 + myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '"
  57 + +this.tmpNode.get('text')+"' found!");
  58 + }
  59 + },
  60 + /*
  61 + * Update info in the form on another parameter selection (cdf, cef formats);
  62 + */
  63 + updateInfo : function(res, e)
  64 + {
  65 + if (res.success){
  66 + // info panel
  67 + this.items.getAt(1).update(res.info.name+': '+res.info.type+' '+res.info.size+' '+res.info.n_records);
  68 + var form = this.items.getAt(0).getForm();
  69 +
  70 + //keep old name and mask if they exist
  71 + if (this.object.get('format') == 'vot')
  72 + {
  73 + res.info.ytitle = res.info.name;
  74 + if ((res.info.id === this.object.get('realvar'))) {
  75 + if (this.object.get('realvar') != this.object.get('name')) {
  76 + res.info.name = this.object.get('name');
  77 + }
  78 + if (res.info.mask != this.object.get('mask')) {
  79 + res.info.mask = this.object.get('mask');
  80 + }
  81 + }
  82 + }
  83 + else
  84 + {
  85 + if ((res.info.name === this.object.get('realvar'))) {
  86 + if (this.object.get('realvar') != this.object.get('name')) {
  87 + res.info.name = this.object.get('name');
  88 + }
  89 + if (res.info.mask != this.object.get('mask')) {
  90 + res.info.mask = this.object.get('mask');
  91 + }
  92 + }
  93 + res.info.ytitle = res.info.name;
  94 + }
142 95  
143   - // load object into form
144   - if (object.$className == 'amdaModel.FileObject' || !this.object.get('name'))
145   - form.getForm().loadRecord(this.fileObject);
146   - else
147   - form.getForm().loadRecord(this.object);
  96 + form.setValues(res.info);
  97 + }
  98 + else {
  99 + myDesktopApp.errorMsg("System Error <br/> Error at AMDA Server");
  100 + }
  101 + },
  102 + /*
  103 + * Check if changes were made before closing window
  104 + * @return false
  105 + */
  106 + fclose : function() {
  107 + return false;
  108 + },
  109 +
  110 + /**
  111 + * set object into form
  112 + */
  113 + setObject : function (object)
  114 + {
  115 + // edit in module from FileUpload Module and ExplorerModule (edit param)
  116 + if (this.module.linkedNode) {
  117 + if (this.module.linkedNode.get('fileObject')) {
  118 + this.fileObject = this.module.linkedNode.get('fileObject');
  119 + }
  120 + // edit in module from Explorer Module (edit file)
  121 + else if (this.module.linkedNode.get('object')) {
  122 + this.fileObject = this.module.linkedNode.get('object');
  123 + this.resetLinkedNode();
  124 + }
  125 + else {
  126 + myDesktopApp.errorMsg("System Error <br/> No FileObject and Object");
  127 + }
  128 + }
  129 + else {
  130 + myDesktopApp.errorMsg("System Error <br/> No Linked Node");
  131 + }
  132 +
  133 + var form = this.down('form');
  134 + form.getForm().reset();
  135 + // remove and DESTROY right panel if it exists
  136 + if (form.items.length == 2)
  137 + form.remove(form.items.getAt(1),true);
  138 + // create right panel depending on file
  139 + var rightPanel = this.initPanel();
  140 + form.add(rightPanel);
  141 + this.object = this.module.linkedNode.get('object');
148 142  
149   - // if it is not newly created empty myParamData node
150   - if (this.object.get('name')) {
151   - // file panel work around
152   - if (this.fileObject.get('format') == 'txt') {
153   - form.getForm().findField('start').setValue(this.object.get('realvar'));
154   - }
155   - else if (this.object.get('format') == 'vot')
156   - {
157   - var radio = this.down('radiogroup');
158   - radio.setValue({'votvar' : this.object.get('realvar')});
159   - }
160   - else { // cdf, cef, nc
161   - // select parameter
162   - var radio = this.down('radiogroup');
163   - radio.setValue({'cdfvar' : this.object.get('realvar')});
164   - }
165   - }
166   -
167   - //Set table definition
168   - if (object.get('tableDef'))
169   - this.getPlugin('tabledef').setTableDefinition(object.get('tableDef'));
170   - },
  143 + // load object into form
  144 + if (object.$className == 'amdaModel.FileObject' || !this.object.get('name')) {
  145 + form.getForm().loadRecord(this.fileObject);
  146 + if (this.fileObject.get('format') == 'txt')
  147 + this.disablePredefined(false);
  148 + else
  149 + this.disablePredefined(true);
  150 + }
  151 + else
  152 + form.getForm().loadRecord(this.object);
171 153  
172   -/*
173   - * highlight selected columns in case of param (ASCII) edit
174   - */
175   - updateSelection: function()
176   - {
177   - var start = parseInt(this.object.get('realvar'));
178   - var size = parseInt(this.object.get('size'));
179   -
180   - if (start && size) {
181   - var columns = this.down('gridpanel').columns;
182   - for (var i = start; i < start+size; i++) {
183   - var selected = Ext.select(columns[i].getCellSelector(i));
184   - selected.addCls('meow');
185   - columns[i].selected = true;
186   - }
187   - }
188   - },
  154 + // if it is not newly created empty myParamData node
  155 + if (this.object.get('name')) {
  156 + // file panel work around
  157 + if (this.fileObject.get('format') == 'txt') {
  158 + form.getForm().findField('start').setValue(this.object.get('realvar'));
  159 + this.disablePredefined(false);
  160 + }
  161 + else if (this.object.get('format') == 'vot')
  162 + {
  163 + var radio = this.down('radiogroup');
  164 + radio.setValue({'votvar' : this.object.get('realvar')});
  165 + }
  166 + else { // cdf, cef, nc
  167 + // select parameter
  168 + var radio = this.down('radiogroup');
  169 + radio.suspendEvent('change');
  170 + radio.setValue({'cdfvar' : this.object.get('realvar')});
  171 + radio.resumeEvent('change');
  172 + // disable form fields defined in file
  173 + this.disablePredefined(true);
  174 + }
  175 + }
  176 +
  177 + //Set table definition
  178 + if (object.get('tableDef'))
  179 + this.getPlugin('tabledef').setTableDefinition(object.get('tableDef'));
  180 + },
189 181  
190   - /*
191   - * update this.object from form
192   - */
193   - updateObject : function(nameField)
194   - {
195   - // get the basic form
196   - var basicForm = this.down('form').getForm();
197   - var updateStatus = true;
198   - var fieldsWithoutName = basicForm.getFields().items;
199   -
200   - Ext.Array.each(fieldsWithoutName, function(item, index,allItems){
201   - if(item !== nameField) {
202   - if (!item.isValid()) {
203   - // set update isn't allowed
204   - updateStatus = false;
205   - }
206   - }
207   - }, this);
208   -
209   - // if the update is allowed
210   - if (updateStatus) {
211   - // real object update
212   - // updateobject with the content of form
213   - var values = basicForm.getValues();
214   - basicForm.updateRecord(this.object);
215   - this.object.set('file',this.fileObject.get('fileName'));
216   - this.object.set('format', this.fileObject.get('format'));
217   - if (this.object.get('format') == 'cdf' || this.object.get('format') == 'cef' || this.object.get('format') == 'nc') this.object.set('realvar',values.cdfvar);
218   - if (this.object.get('format') == 'vot') this.object.set('realvar',values.votvar);
219   - if (this.object.get('format') == 'txt') this.object.set('realvar',values.start);
220   - this.object.set('tableDef', this.getPlugin('tabledef').getTableDefinitionObject());
221   - }
222   - // return the update status
223   - return updateStatus;
224   - },
  182 + /*
  183 + * // disable form fields defined in file ( cdf, nc, cef )
  184 + */
  185 + disablePredefined: function(disable)
  186 + {
  187 + var form = this.down('form');
  188 + form.getForm().findField('start').setDisabled(disable);
  189 + form.getForm().findField('size').setReadOnly(disable);
  190 + this.down('combobox').setReadOnly(disable);
  191 + },
  192 +
  193 + /*
  194 + * highlight selected columns in case of param (ASCII) edit
  195 + */
  196 + updateSelection: function()
  197 + {
  198 + var start = parseInt(this.object.get('realvar'));
  199 + var size = parseInt(this.object.get('size'));
  200 +
  201 + if (start && size) {
  202 + var columns = this.down('gridpanel').columns;
  203 + for (var i = start; i < start+size; i++) {
  204 + var selected = Ext.select(columns[i].getCellSelector(i));
  205 + selected.addCls('meow');
  206 + columns[i].selected = true;
  207 + }
  208 + }
  209 + },
  210 +
  211 + /*
  212 + * update this.object from form
  213 + */
  214 + updateObject : function(nameField)
  215 + {
  216 + // get the basic form
  217 + var basicForm = this.down('form').getForm();
  218 + var updateStatus = true;
  219 + var fieldsWithoutName = basicForm.getFields().items;
  220 +
  221 + Ext.Array.each(fieldsWithoutName, function(item, index,allItems){
  222 + if(item !== nameField) {
  223 + if (!item.isValid()) {
  224 + // set update isn't allowed
  225 + updateStatus = false;
  226 + }
  227 + }
  228 + }, this);
  229 +
  230 + // if the update is allowed
  231 + if (updateStatus) {
  232 + // real object update
  233 + // updateobject with the content of form
  234 + var values = basicForm.getValues();
  235 + basicForm.updateRecord(this.object);
  236 + this.object.set('file',this.fileObject.get('fileName'));
  237 + this.object.set('format', this.fileObject.get('format'));
  238 + if (this.object.get('format') == 'cdf' || this.object.get('format') == 'cef' || this.object.get('format') == 'nc') this.object.set('realvar',values.cdfvar);
  239 + if (this.object.get('format') == 'vot') this.object.set('realvar',values.votvar);
  240 + if (this.object.get('format') == 'txt') this.object.set('realvar',values.start);
  241 + this.object.set('tableDef', this.getPlugin('tabledef').getTableDefinitionObject());
  242 + }
  243 + // return the update status
  244 + return updateStatus;
  245 + },
225 246  
226   - /**
227   - * Check mask - length, existed....
228   - * @return true/false
229   - */
230   - validateMask : function(value)
231   - {
232   - // length
233   - if (value.length < 6) return 'mask length is too small (< 6)';
234   -
235   - // first *
236   - if (value.indexOf('*') === 0) return '"*" could not be the first letter in mask';
237   -
238   - // several *
239   - if (value.indexOf('*') !== value.lastIndexOf('*')) return 'several "*" are not allowed in mask';
240   -
241   - // less common
242   - var paramModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.my_data.id);
243   - var oldmask = paramModule.linkedNode.get('object').get('mask');
244   - // no old mask
245   - if (oldmask.length === 0) return true;
246   - if (value.length > oldmask.length) return 'new mask is less common than old one';
247   -
248   - return true;
249   - },
  247 + /**
  248 + * Check mask - length, existed....
  249 + * @return true/false
  250 + */
  251 + validateMask : function(value)
  252 + {
  253 + // length
  254 + if (value.length < 6) return 'mask length is too small (< 6)';
250 255  
251   - /*
252   - *
253   - */
254   - saveProcess : function(toRename)
255   - {
256   - var values = this.down('form').getForm().getValues();
257   - // Parameter Module
258   - var paramModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.my_data.id);
259   -
260   - // if the name has been modified this is a creation
261   - if (this.object.isModified('name')){
262   - var contextNode = paramModule.linkedNode.parentNode;
263   - // if object already has an id : it's a 'rename' of an existing
264   - if (this.object.get('id')){
265   - // get file object of the first node linked this file
266   - var fileObject = paramModule.linkedNode.get('fileObject');
267   -
268   - paramModule.createLinkedNode();
269   - // create a new object linked
270   - var paramobj = Ext.create(paramModule.linkedNode.get('objectDataModel'), values);
271   -
272   - paramobj.set('format', this.fileObject.get('format'));
273   - if (paramobj.get('format') == 'cdf' || paramobj.get('format') == 'cef' ||
274   - paramobj.get('format') == 'nc')
275   - paramobj.set('realvar',values.cdfvar);
276   - if (paramobj.get('format') == 'vot')
277   - paramobj.set('realvar',values.votvar);
278   - if (paramobj.get('format') == 'txt')
279   - paramobj.set('realvar',values.start);
280   -
281   - paramobj.set('file', this.fileObject.get('fileName'));
282   -
283   - paramobj.set('tableDef', this.getPlugin('tabledef').getTableDefinitionObject());
284   -
285   - paramModule.linkedNode.set('object',paramobj);
286   - //synchronize objects
287   - this.object = paramobj;
288   -
289   - paramModule.linkedNode.set('fileObject',fileObject);
290   -
291   - if (toRename)
292   - paramModule.linkedNode.toRename = true;
293   - }
294   - paramModule.linkedNode.set('contextNode',contextNode);
295   - paramModule.linkedNode.create();
296   -
297   - paramModule.linkedNode.set('isParameter', true);
298   -
299   - if (values.size == 1) {
300   - paramModule.linkedNode.set('iconCls', 'icon-scalar');
301   - paramModule.linkedNode.set('isSpectra', false);
302   - }
303   - else {
304   - if (values.plottype == 'Spectra') {
305   - paramModule.linkedNode.set('isSpectra', true);
306   - paramModule.linkedNode.set('iconCls', 'icon-spectra');
307   - }
308   - else {
309   - paramModule.linkedNode.set('iconCls', 'icon-unknowntype');
310   - paramModule.linkedNode.set('isSpectra', false);
311   - }
312   - }
313   -
314   - } else {
315   - paramModule.linkedNode.set('contextNode',paramModule.contextNode);
316   - paramModule.linkedNode.update();
317   - }
318   - },
  256 + // first *
  257 + if (value.indexOf('*') === 0) return '"*" could not be the first letter in mask';
  258 +
  259 + // several *
  260 + if (value.indexOf('*') !== value.lastIndexOf('*')) return 'several "*" are not allowed in mask';
  261 +
  262 + // less common
  263 + var paramModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.my_data.id);
  264 + var oldmask = paramModule.linkedNode.get('object').get('mask');
  265 + // no old mask
  266 + if (oldmask.length === 0) return true;
  267 + if (value.length > oldmask.length) return 'new mask is less common than old one';
  268 +
  269 + return true;
  270 + },
  271 +
  272 + /*
  273 + * save parameter
  274 + */
  275 + saveProcess : function(toRename)
  276 + {
  277 + var values = this.down('form').getForm().getValues();
  278 + // Parameter Module
  279 + var paramModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.my_data.id);
  280 +
  281 + // if the name has been modified this is a creation
  282 + if (this.object.isModified('name'))
  283 + {
  284 + var contextNode = paramModule.linkedNode.parentNode;
  285 + // if object already has an id : it's a 'rename' of an existing
  286 + if (this.object.get('id'))
  287 + {
  288 + // get file object of the first node linked this file
  289 + var fileObject = paramModule.linkedNode.get('fileObject');
  290 +
  291 + paramModule.createLinkedNode();
  292 + // create a new object linked
  293 + var paramobj = Ext.create(paramModule.linkedNode.get('objectDataModel'), values);
  294 +
  295 + paramobj.set('format', this.fileObject.get('format'));
  296 + if (paramobj.get('format') == 'cdf' || paramobj.get('format') == 'cef' ||
  297 + paramobj.get('format') == 'nc')
  298 + paramobj.set('realvar',values.cdfvar);
  299 + if (paramobj.get('format') == 'vot')
  300 + paramobj.set('realvar',values.votvar);
  301 + if (paramobj.get('format') == 'txt')
  302 + paramobj.set('realvar',values.start);
  303 +
  304 + paramobj.set('file', this.fileObject.get('fileName'));
  305 +
  306 + paramobj.set('tableDef', this.getPlugin('tabledef').getTableDefinitionObject());
  307 +
  308 + paramModule.linkedNode.set('object',paramobj);
  309 + //synchronize objects
  310 + this.object = paramobj;
  311 +
  312 + paramModule.linkedNode.set('fileObject',fileObject);
  313 +
  314 + if (toRename)
  315 + paramModule.linkedNode.toRename = true;
  316 + }
  317 + paramModule.linkedNode.set('contextNode',contextNode);
  318 + paramModule.linkedNode.create();
  319 +
  320 + paramModule.linkedNode.set('isParameter', true);
  321 +
  322 + if (values.size == 1) {
  323 + paramModule.linkedNode.set('iconCls', 'icon-scalar');
  324 + paramModule.linkedNode.set('isSpectra', false);
  325 + }
  326 + else if (values.size == 3) {
  327 + paramModule.linkedNode.set('iconCls', 'icon-vector');
  328 + paramModule.linkedNode.set('isSpectra', false);
  329 + }
  330 + else {
  331 + if (values.plottype == 'Spectra') {
  332 + paramModule.linkedNode.set('isSpectra', true);
  333 + paramModule.linkedNode.set('iconCls', 'icon-spectra');
  334 + }
  335 + else {
  336 + paramModule.linkedNode.set('iconCls', 'icon-unknowntype');
  337 + paramModule.linkedNode.set('isSpectra', false);
  338 + }
  339 + }
  340 + } else {
  341 + paramModule.linkedNode.set('contextNode',paramModule.contextNode);
  342 + paramModule.linkedNode.update();
  343 + }
  344 + },
319 345  
320   - /*
321   - * overwrite method called by Save button
322   - */
323   - overwriteProcess : function(btn){
324   - if (btn == 'cancel') return;
325   - var basicForm = this.down('form').getForm();
326   - basicForm.clearInvalid();
327   - this.saveProcess(true);
328   - },
329   -
330   - updateForm : function() {
331   - var basicForm = this.down('form').getForm();
332   - var columns = this.down('gridpanel').columns;
333   -
334   - var start;
335   - var size = 0;
336   - Ext.Array.each(columns, function(column,index){
337   - if (!start && column.selected) start = index;
338   - if (column.selected) size += 1;
339   - });
340   -
341   - basicForm.setValues({start: start, size : size});
342   - },
  346 + /*
  347 + * overwrite method called by Save button
  348 + */
  349 + overwriteProcess : function(btn){
  350 + if (btn == 'cancel') return;
  351 + var basicForm = this.down('form').getForm();
  352 + basicForm.clearInvalid();
  353 + this.saveProcess(true);
  354 + },
  355 +
  356 + updateForm : function() {
  357 + var basicForm = this.down('form').getForm();
  358 + var columns = this.down('gridpanel').columns;
  359 +
  360 + var start;
  361 + var size = 0;
  362 + Ext.Array.each(columns, function(column,index){
  363 + if (!start && column.selected) start = index;
  364 + if (column.selected) size += 1;
  365 + });
  366 +
  367 + basicForm.setValues({start: start, size : size});
  368 + },
343 369  
344   - /*
345   - * Configurations
346   - *
347   - */
348   - initPanel : function()
349   - {
350   - var format = this.fileObject.get('format');
351   - if (format == 'cdf' || format == 'cef' || format == 'nc') return this.cdfPanel(format);
352   - if (format == 'txt') return this.txtPanel();
353   - if (format == 'vot') return this.votPanel();
354   - },
  370 + /*
  371 + * Configurations
  372 + *
  373 + */
  374 + initPanel : function()
  375 + {
  376 + var format = this.fileObject.get('format');
  377 + if (format == 'cdf' || format == 'cef' || format == 'nc') return this.cdfPanel(format);
  378 + if (format == 'txt') return this.txtPanel();
  379 + if (format == 'vot') return this.votPanel();
  380 + },
  381 +
  382 + txtPanel: function()
  383 + {
  384 + var fileName = this.fileObject.get('fileName');
355 385  
356   - txtPanel: function()
357   - {
358   - var fileName = this.fileObject.get('fileName');
359   -
360   - //FOR INFO
361   - // Null out built in convert functions for performance *because the raw data is known to be valid*
362   - // Specifying defaultValue as undefined will also save code.
363   - // As long as there will always be values in the data, or the app tolerates undefined field values*
364   -
365   - // Dynamically created fields and columns
366   - var n_col = this.fileObject.get('vars');
367   - // reset
368   - this.fields = [];
369   - this.columns = [];
  386 + //FOR INFO
  387 + // Null out built in convert functions for performance *because the raw data is known to be valid*
  388 + // Specifying defaultValue as undefined will also save code.
  389 + // As long as there will always be values in the data, or the app tolerates undefined field values*
  390 +
  391 + // Dynamically created fields and columns
  392 + var n_col = this.fileObject.get('vars');
  393 + // reset
  394 + this.fields = [];
  395 + this.columns = [];
370 396  
371   - for (var i = 0; i < n_col; i++){
372   - var name = i === 0 ? 'Time' : 'n'+i;
373   - //TODO width dependent on data?
374   - var width = i === 0 ? 120 : 75;
375   -
376   - this.fields[i] = { name: name };
377   - this.columns[i] = { text: name, sortable : false, dataIndex: name, width : width,
378   - menuDisabled: true, selected : false,
379   - listeners: {
380   - scope : this,
381   - headerclick: function(ct, column){
382   - if (column.text != 'Time') {
383   - var selected = Ext.select(column.getCellSelector(1));
384   - if (column.selected) {
385   - selected.removeCls('meow');
386   - column.selected = false;
387   - }
388   - else {
389   - selected.addCls('meow');
390   - column.selected = true;
391   - }
392   - this.updateForm();
393   - }
394   - }
395   - }
396   - };
397   - }
398   -
399   - // Dynamically created model
400   - Ext.define('myData', {
401   - extend: 'Ext.data.Model',
402   - fields: this.fields,
403   - idProperty: 'Time'
404   - });
405   -
406   - var store = Ext.create('Ext.data.ArrayStore', {
407   - model: 'myData',
408   - autoLoad: true,
409   - proxy: {
410   - type: 'direct',
411   - directFn: AmdaAction.getAsciiFile
412   - },
413   - listeners: {
414   - scope: this,
415   - beforeload: function(store){
416   - store.proxy.extraParams = {
417   - fileName: this.fileObject.get('fileName')
418   - };
419   - },
420   - load: function(store, records, successful, eOpts) {
421   - this.updateSelection();
422   - }
423   - }
424   - });
  397 + for (var i = 0; i < n_col; i++)
  398 + {
  399 + var name = i === 0 ? 'Time' : 'n'+i;
  400 + //TODO width dependent on data?
  401 + var width = i === 0 ? 120 : 75;
  402 +
  403 + this.fields[i] = { name: name };
  404 + this.columns[i] = { text: name, sortable : false, dataIndex: name, width : width,
  405 + menuDisabled: true, selected : false,
  406 + listeners:
  407 + {
  408 + scope : this,
  409 + headerclick: function(ct, column)
  410 + {
  411 + if (column.text != 'Time') {
  412 + var selected = Ext.select(column.getCellSelector(1));
  413 + if (column.selected) {
  414 + selected.removeCls('meow');
  415 + column.selected = false;
  416 + }
  417 + else {
  418 + selected.addCls('meow');
  419 + column.selected = true;
  420 + }
  421 + this.updateForm();
  422 + }
  423 + }
  424 + }
  425 + };
  426 + }
  427 +
  428 + // Dynamically created model
  429 + Ext.define('myData', {
  430 + extend: 'Ext.data.Model',
  431 + fields: this.fields,
  432 + idProperty: 'Time'
  433 + });
  434 +
  435 + var store = Ext.create('Ext.data.ArrayStore', {
  436 + model: 'myData',
  437 + autoLoad: true,
  438 + proxy: {
  439 + type: 'direct',
  440 + directFn: AmdaAction.getAsciiFile
  441 + },
  442 + listeners: {
  443 + scope: this,
  444 + beforeload: function(store){
  445 + store.proxy.extraParams = {
  446 + fileName: this.fileObject.get('fileName')
  447 + };
  448 + },
  449 + load: function(store, records, successful, eOpts) {
  450 + this.updateSelection();
  451 + }
  452 + }
  453 + });
425 454  
426   - // Dynamically created columns dependent of myData model
427   - var panelConfig = {
428   - xtype : 'gridpanel',
429   - store : store,
430   - title : fileName,
431   - height: '100%',
432   - flex : 2,
433   - columnLines: true,
434   - columns: this.columns,
435   - listeners: {
436   - scope : this,
437   - cellclick: function(view,td,cellIndex,record,tr,rowIndex,e){
438   - var column = view.getGridColumns()[cellIndex];
439   - if (cellIndex > 0) {
440   - var selected = Ext.select(column.getCellSelector(cellIndex));
441   - if (column.selected) {
442   - selected.removeCls('meow');
443   - column.selected = false;
444   - }
445   - else {
446   - selected.addCls('meow');
447   - column.selected = true;
448   - }
449   - this.updateForm();
450   - }
451   - },
452   - select: function(selmodel, record, index, e) {
453   - selmodel.deselectAll();
454   - }
455   - }
456   - };
  455 + // Dynamically created columns dependent of myData model
  456 + var panelConfig = {
  457 + xtype : 'gridpanel',
  458 + store : store,
  459 + title : fileName,
  460 + height: '100%',
  461 + flex : 2,
  462 + columnLines: true,
  463 + columns: this.columns,
  464 + listeners:
  465 + {
  466 + scope : this,
  467 + cellclick: function(view,td,cellIndex,record,tr,rowIndex,e)
  468 + {
  469 + var column = view.getGridColumns()[cellIndex];
  470 + if (cellIndex > 0) {
  471 + var selected = Ext.select(column.getCellSelector(cellIndex));
  472 + if (column.selected) {
  473 + selected.removeCls('meow');
  474 + column.selected = false;
  475 + }
  476 + else {
  477 + selected.addCls('meow');
  478 + column.selected = true;
  479 + }
  480 + this.updateForm();
  481 + }
  482 + },
  483 + select: function(selmodel, record, index, e) {
  484 + selmodel.deselectAll();
  485 + }
  486 + }
  487 + };
457 488  
458   - return panelConfig;
459   - },
  489 + return panelConfig;
  490 + },
460 491  
461   - cdfPanel : function(format) {
462   -
463   - var vars = this.fileObject.get('vars');
464   - var fileName = this.fileObject.get('fileName');
465   - var items = [];
466   - Ext.Array.each(vars, function(name, index) {
467   - if (name) {
468   - items[index] = { boxLabel: name, name: 'cdfvar', inputValue: name,
469   - listeners: {
470   - scope: this,
471   - change: function (cb, nv, ov) {
472   - if (nv) {
473   - AmdaAction.getMyParamInfo({format: format, file : fileName, varName : cb.inputValue},
474   - this.updateInfo, this);
475   - }
476   - }
477   - }
478   - }
479   - }
480   - }, this);
  492 + cdfPanel : function(format)
  493 + {
  494 + var vars = this.fileObject.get('vars');
  495 + var fileName = this.fileObject.get('fileName');
  496 + var items = [];
  497 + Ext.Array.each(vars, function(name, index) {
  498 + if (name) {
  499 + items[index] = { boxLabel: name, name: 'cdfvar', inputValue: name }
  500 + }
  501 + }, this);
481 502  
482 503 var panelConfig = {
483 504 xtype : 'fieldset',
... ... @@ -491,39 +512,49 @@ Ext.define(&#39;amdaUI.MyDataUI&#39;, {
491 512 cls: 'x-check-group-alt',
492 513 columns: 2,
493 514 vertical: true,
494   - items: items
  515 + items: items,
  516 + listeners : {
  517 + scope: this,
  518 + change: function (cb, nv, ov) {
  519 + if (nv.cdfvar) {
  520 + AmdaAction.getMyParamInfo({format: format, file : fileName, varName : nv.cdfvar},
  521 + this.updateInfo, this);
  522 + }
  523 + }
  524 + }
495 525 }]
496 526 };
497 527  
498 528 return panelConfig;
499 529 },
500 530  
501   - votPanel : function()
502   - {
503   - var vars = this.fileObject.get('vars');
504   - var fileName = this.fileObject.get('fileName');
505   -
506   - var items = [];
507   -
508   - if (this.fileObject.get('foundTime'))
509   - {
510   - Ext.Array.each(vars, function(obj, index) {
511   - items[index] = { boxLabel: obj.name, name: 'votvar', inputValue: obj.id,
512   - listeners: {
513   - scope: this,
514   - change: function (cb, nv, ov) {
515   - if (nv) {
516   - AmdaAction.getMyParamInfo({format: 'vot', file : fileName, varName : cb.inputValue},
517   - this.updateInfo, this);
518   - }
519   - }
520   - }
521   - };
522   - }, this);
523   - }
524   - else
525   - myDesktopApp.errorMsg("Cannot find a valid time field!");
526   -
  531 + votPanel : function()
  532 + {
  533 + var vars = this.fileObject.get('vars');
  534 + var fileName = this.fileObject.get('fileName');
  535 +
  536 + var items = [];
  537 +
  538 + if (this.fileObject.get('foundTime'))
  539 + {
  540 + Ext.Array.each(vars, function(obj, index) {
  541 + items[index] = { boxLabel: obj.name, name: 'votvar', inputValue: obj.id,
  542 + listeners:
  543 + {
  544 + scope: this,
  545 + change: function (cb, nv, ov) {
  546 + if (nv) {
  547 + AmdaAction.getMyParamInfo({format: 'vot', file : fileName, varName : cb.inputValue},
  548 + this.updateInfo, this);
  549 + }
  550 + }
  551 + }
  552 + };
  553 + }, this);
  554 + }
  555 + else
  556 + myDesktopApp.errorMsg("Cannot find a valid time field!");
  557 +
527 558 var panelConfig = {
528 559 xtype : 'fieldset',
529 560 bodyStyle: { background : '#dfe8f6'},
... ... @@ -555,305 +586,314 @@ Ext.define(&#39;amdaUI.MyDataUI&#39;, {
555 586 ]
556 587 });
557 588  
558   - var combo = {
559   - xtype: 'combo',
560   - fieldLabel: 'Parameter Data Type',
561   - store: store,
562   - queryMode: 'local',
563   - displayField: 'name',
564   - valueField: 'value',
565   - name: 'type',
566   - editable: false,
567   - value: 'FLOAT'
568   - };
  589 + var combo = {
  590 + xtype: 'combo',
  591 + fieldLabel: 'Parameter Data Type',
  592 + store: store,
  593 + queryMode: 'local',
  594 + displayField: 'name',
  595 + valueField: 'value',
  596 + name: 'type',
  597 + editable: false,
  598 + value: 'FLOAT'
  599 + };
569 600  
570   - var store1 = Ext.create('Ext.data.Store', {
571   - fields: ['value', 'name'],
572   - data : [
573   - {"value": "TimeSerie", "name":"Time Serie"},
574   - {"value": "Spectra", "name":"Spectra"}
575   - ]
576   - });
  601 + var store1 = Ext.create('Ext.data.Store', {
  602 + fields: ['value', 'name'],
  603 + data : [
  604 + {"value": "TimeSerie", "name":"Time Serie"},
  605 + {"value": "Spectra", "name":"Spectra"}
  606 + ]
  607 + });
577 608  
578   - var comboPlotType = {
579   - xtype: 'combo',
580   - fieldLabel: 'Display Type',
581   - store: store1,
582   - queryMode: 'local',
583   - displayField: 'name',
584   - valueField: 'value',
585   - name: 'plottype',
586   - editable: false,
587   - value: 'Time Series'
588   - };
589   -
590   - var notTxt = false; //this.fileObject.get('format') !== 'txt';
591   - // var maxSize = notTxt? 100 : this.columns.length - 1;
592   -
593   - // Parameter Form
594   - var panelLeft = {
595   - bodyStyle: { background : '#dfe8f6'},
596   - flex : 1,
597   - defaults: {
598   - xtype:'textfield',
599   - validateOnChange: false,
600   - validateOnBlur: false,
601   - padding : '0 10 0 5',
602   - inputWidth : 80
603   - },
604   - items: [
605   - {
606   - id: 'mydataName',
607   - fieldLabel: 'Parameter Name',
608   - labelAlign: 'top',
609   - name: 'name',
610   - allowBlank : false,
611   - stripCharsRe: /(^\s+|\s+$)/g,
612   - validFlag: false,
613   - validator : function() {
614   - return this.validFlag;
615   - },
616   - inputWidth : 180
617   - }, {
618   - fieldLabel: 'File Name/Mask&nbsp;<img amda_clicktip="fileMask" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"',
619   - labelAlign: 'top',
620   - name: 'mask',
621   - inputWidth : 180,
622   - validator : this.validateMask
623   - }, combo, {
624   - xtype:'numberfield',
625   - fieldLabel: 'Parameter Start Position',
626   - name: 'start',
627   - disabled: notTxt,
628   - minValue : 1,
629   - // maxValue : maxSize,
630   - listeners : {
631   - scope : this,
632   - change : function(field, newValue, oldValue){
633   - var grid = this.down('gridpanel');
634   - if (!grid) return;
635   - if (newValue && newValue != oldValue) {
636   - var size = field.prev().value;
637   - var columns = grid.columns;
638   - Ext.Array.each(columns, function(column,index){
639   - var selected = Ext.select(column.getCellSelector(index));
640   - if (index < newValue){
641   - if (column.selected) {
642   - selected.removeCls('meow');
643   - column.selected = false;
644   - }
645   - }
646   - else if (index == newValue) {
647   - if (!column.selected) {
648   - selected.addCls('meow');
649   - column.selected = true;
650   - }
651   - }
652   - else {
653   - if (column.selected) {
654   - selected.removeCls('meow');
655   - column.selected = false;
656   - }
657   - }
658   - });
659   - }
660   - }
661   - }
662   - }, {
663   - xtype:'numberfield',
664   - fieldLabel: 'Parameter Size',
665   - name: 'size',
666   - minValue: 1,
667   - // maxValue : maxSize,
668   - disabled: notTxt,
669   - listeners : {
670   - scope : this,
671   - change : function(field, newValue, oldValue){
672   - var grid = this.down('gridpanel');
673   - if (!grid) return;
674   - var start = field.prev().value;
675   - var columns = grid.columns;
676   - Ext.Array.each(columns, function(column,index){
677   - var selected = Ext.select(column.getCellSelector(index));
678   - if (index <= start) {}
679   - else if (index - start < newValue) {
680   - if (!column.selected){
681   - selected.addCls('meow');
682   - column.selected = true;
683   - }
684   - }
685   - else {
686   - if (column.selected){
687   - selected.removeCls('meow');
688   - column.selected = false;
689   - }
690   - }
691   - });
692   - }
693   - }
694   - }, {
695   - xtype:'numberfield',
696   - fieldLabel: 'Min Sampling',
697   - name: 'minsampling'//,
698   - // disabled: notTxt
699   - },{
700   - xtype:'numberfield',
701   - fieldLabel: 'Max Sampling',
702   - name: 'maxsampling'//,
703   - // disabled: notTxt
704   - },{
705   - fieldLabel: 'Filling Value',
706   - name: 'fillvalue'
707   - },{
708   - fieldLabel: 'Units',
709   - name: 'units'
710   - }, comboPlotType, {
711   - fieldLabel: 'Y Title',
712   - name: 'ytitle'
713   - },{
714   - fieldLabel: 'Legend',
715   - name: 'legend'
716   - }
717   - ],
718   - listeners: {
719   - click: {
720   - element: 'el',
721   - fn: function(e,t) {
722   - var me = t,
723   - text = me.getAttribute('amda_clicktip');
724   - if (text) {
725   - e.preventDefault();
726   - AmdaAction.getInfo({name : text}, function(res,e) {
727   - if (res.success) myDesktopApp.infoMsg(res.result);
728   - });
729   - }
730   - }
731   - }
732   - }
733   - };
734   -
735   - var myConf = {
736   - layout: 'border',
737   - items: [ {
738   - xtype : 'form',
739   - bodyStyle: { background : '#dfe8f6'},
740   - layout: 'hbox',
741   - region: 'center',
742   - buttonAlign:'left',
743   - items : [
744   - panelLeft
745   - ],
746   - buttons: [
747   - {
748   - scope : this,
749   - text: 'Show/Hide Table definition',
750   - handler: function()
751   - {
752   - this.getPlugin('tabledef').showHide();
753   - }
754   - },
755   - '->',
756   - {
757   - scope : this,
758   - text: 'Save',
759   - handler: function()
760   - {
761   - var form = this.down('form').getForm();
762   - // check if variable was selected
763   - // cdf,...
764   - var radio = this.down('radiogroup');
765   - if (radio && radio.getChecked().length == 0) {
766   - myDesktopApp.warningMsg('Select variable from the file, please');
767   - return;
768   - }
769   - // ascii
770   - if (!radio && this.columns.length > 0) {
771   - if (!form.findField('start').getValue() || !form.findField('size').getValue()) {
772   - myDesktopApp.warningMsg('Select column[s] from the file, please');
773   - return;
774   - }
775   - }
776   - var nameField = form.findField('mydataName');
777   - if (this.updateObject(nameField))
778   - {
779   - var myDataModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.my_data.id);
780   - if (!myDataModule)
781   - return;
782   - var me = this;
783   - myDataModule.linkedNode.isValidName(nameField.getValue(), function (res) {
784   - if (!res)
785   - {
786   - nameField.validFlag = 'Error during object validation';
787   - myDesktopApp.errorMsg(nameField.validFlag);
788   - nameField.validate();
789   - return;
790   - }
791   -
792   - if (!res.valid)
793   - {
794   - if (res.error)
795   - {
796   - if (res.error.search('subtree') != -1) {
797   - Ext.MessageBox.show({title:'Warning',
798   - msg: res.error+'<br/>Do you want to overwrite it?',
799   - width: 300,
800   - buttons: Ext.MessageBox.OKCANCEL,
801   - fn : me.overwriteProcess,
802   - icon: Ext.MessageBox.WARNING,
803   - scope : me
804   - });
805   - nameField.validFlag = true;
806   - }
807   - else
808   - nameField.validFlag = res.error;
809   - }
810   - else
811   - {
812   - nameField.validFlag = 'Invalid object name';
813   - myDesktopApp.errorMsg(nameField.validFlag);
814   - }
815   - nameField.validate();
816   - return;
817   - }
818   -
819   - nameField.validFlag = true;
820   - nameField.validate();
821   - me.saveProcess();
822   - });
823   - }
824   - }
825   - },{
826   - scope : this,
827   - text: 'Reset',
828   - handler: function(){
829   - this.down('form').getForm().reset();
830   - }
831   - }]
832   - },{
833   - xtype: 'panel',
834   - region: 'south',
835   - title: 'Information',
836   - collapsible: true,
837   - collapseMode: 'header',
838   - height: 100,
839   - autoHide: false,
840   - iconCls: 'icon-information',
841   - bodyStyle: 'padding:5px',
842   - loader: {
843   - autoLoad: true,
844   - url: helpDir+'myDataHOWTO'
845   - }
846   - }
847   - ],
848   - plugins: [ {ptype: 'tabledef', pluginId: 'tabledef'} ]
849   - };
850   -
851   - Ext.apply (this, Ext.apply(arguments, myConf));
852   - },
853   -
854   - getParameterSize : function()
855   - {
856   - var form = this.down('form').getForm();
857   - return form.findField('size').getValue();
858   - }
  609 + var comboPlotType = {
  610 + xtype: 'combo',
  611 + fieldLabel: 'Display Type',
  612 + store: store1,
  613 + queryMode: 'local',
  614 + displayField: 'name',
  615 + valueField: 'value',
  616 + name: 'plottype',
  617 + editable: false,
  618 + value: 'Time Series'
  619 + };
  620 +
  621 + // Parameter Form
  622 + var panelLeft = {
  623 + bodyStyle: { background : '#dfe8f6'},
  624 + flex : 1,
  625 + defaults: {
  626 + xtype:'textfield',
  627 + validateOnChange: false,
  628 + validateOnBlur: false,
  629 + padding : '0 10 0 5',
  630 + inputWidth : 80
  631 + },
  632 + items: [
  633 + {
  634 + id: 'mydataName',
  635 + fieldLabel: 'Parameter Name',
  636 + labelAlign: 'top',
  637 + name: 'name',
  638 + allowBlank : false,
  639 + stripCharsRe: /(^\s+|\s+$)/g,
  640 + validFlag: false,
  641 + validator : function() {
  642 + return this.validFlag;
  643 + },
  644 + inputWidth : 180
  645 + },
  646 + {
  647 + fieldLabel: 'File Name/Mask&nbsp;<img amda_clicktip="fileMask" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"',
  648 + labelAlign: 'top',
  649 + name: 'mask',
  650 + inputWidth : 180,
  651 + validator : this.validateMask
  652 + },
  653 + combo,
  654 + {
  655 + xtype:'numberfield',
  656 + fieldLabel: 'Parameter Start Position',
  657 + name: 'start',
  658 + minValue : 1,
  659 + // maxValue : maxSize,
  660 + listeners :
  661 + {
  662 + scope : this,
  663 + change : function(field, newValue, oldValue){
  664 + var grid = this.down('gridpanel');
  665 + if (!grid) return;
  666 + if (newValue && newValue != oldValue)
  667 + {
  668 + var size = field.prev().value;
  669 + var columns = grid.columns;
  670 + Ext.Array.each(columns, function(column,index){
  671 + var selected = Ext.select(column.getCellSelector(index));
  672 + if (index < newValue)
  673 + {
  674 + if (column.selected) {
  675 + selected.removeCls('meow');
  676 + column.selected = false;
  677 + }
  678 + }
  679 + else if (index == newValue) {
  680 + if (!column.selected) {
  681 + selected.addCls('meow');
  682 + column.selected = true;
  683 + }
  684 + }
  685 + else {
  686 + if (column.selected) {
  687 + selected.removeCls('meow');
  688 + column.selected = false;
  689 + }
  690 + }
  691 + });
  692 + }
  693 + }
  694 + }
  695 + },
  696 + {
  697 + xtype:'numberfield',
  698 + fieldLabel: 'Parameter Size',
  699 + name: 'size',
  700 + minValue: 1,
  701 + // maxValue : maxSize,
  702 + listeners :
  703 + {
  704 + scope : this,
  705 + change : function(field, newValue, oldValue){
  706 + var grid = this.down('gridpanel');
  707 + if (!grid) return;
  708 + var start = field.prev().value;
  709 + var columns = grid.columns;
  710 + Ext.Array.each(columns, function(column,index){
  711 + var selected = Ext.select(column.getCellSelector(index));
  712 + if (index <= start) {}
  713 + else if (index - start < newValue) {
  714 + if (!column.selected){
  715 + selected.addCls('meow');
  716 + column.selected = true;
  717 + }
  718 + }
  719 + else {
  720 + if (column.selected){
  721 + selected.removeCls('meow');
  722 + column.selected = false;
  723 + }
  724 + }
  725 + });
  726 + }
  727 + }
  728 + },
  729 + {
  730 + xtype:'numberfield',
  731 + fieldLabel: 'Min Sampling',
  732 + name: 'minsampling'
  733 + },
  734 + {
  735 + xtype:'numberfield',
  736 + fieldLabel: 'Max Sampling',
  737 + name: 'maxsampling'
  738 + },
  739 + {
  740 + fieldLabel: 'Filling Value',
  741 + name: 'fillvalue'
  742 + },
  743 + {
  744 + fieldLabel: 'Units',
  745 + name: 'units'
  746 + },
  747 + comboPlotType,
  748 + {
  749 + fieldLabel: 'Y Title',
  750 + name: 'ytitle'
  751 + },
  752 + {
  753 + fieldLabel: 'Legend',
  754 + name: 'legend'
  755 + }],
  756 + listeners:
  757 + {
  758 + click: {
  759 + element: 'el',
  760 + fn: function(e,t) {
  761 + var me = t,
  762 + text = me.getAttribute('amda_clicktip');
  763 + if (text) {
  764 + e.preventDefault();
  765 + AmdaAction.getInfo({name : text}, function(res,e) {
  766 + if (res.success) myDesktopApp.infoMsg(res.result);
  767 + });
  768 + }
  769 + }
  770 + }
  771 + }
  772 + };
  773 +
  774 + var myConf = {
  775 + layout: 'border',
  776 + items: [
  777 + {
  778 + xtype : 'form',
  779 + bodyStyle: { background : '#dfe8f6'},
  780 + layout: 'hbox',
  781 + region: 'center',
  782 + buttonAlign:'left',
  783 + items : [
  784 + panelLeft
  785 + ],
  786 + buttons: [
  787 + {
  788 + scope : this,
  789 + text: 'Show/Hide Table definition',
  790 + handler: function()
  791 + {
  792 + this.getPlugin('tabledef').showHide();
  793 + }
  794 + },
  795 + '->',
  796 + {
  797 + scope : this,
  798 + text: 'Save',
  799 + handler: function()
  800 + {
  801 + var form = this.down('form').getForm();
  802 + // check if variable was selected
  803 + // cdf,...
  804 + var radio = this.down('radiogroup');
  805 + if (radio && radio.getChecked().length == 0) {
  806 + myDesktopApp.warningMsg('Select variable from the file, please');
  807 + return;
  808 + }
  809 + // ascii
  810 + if (!radio && this.columns.length > 0) {
  811 + if (!form.findField('start').getValue() || !form.findField('size').getValue()) {
  812 + myDesktopApp.warningMsg('Select column[s] from the file, please');
  813 + return;
  814 + }
  815 + }
  816 + var nameField = form.findField('mydataName');
  817 + if (this.updateObject(nameField))
  818 + {
  819 + var myDataModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.my_data.id);
  820 + if (!myDataModule)
  821 + return;
  822 + var me = this;
  823 + myDataModule.linkedNode.isValidName(nameField.getValue(), function (res) {
  824 + if (!res) {
  825 + nameField.validFlag = 'Error during object validation';
  826 + myDesktopApp.errorMsg(nameField.validFlag);
  827 + nameField.validate();
  828 + return;
  829 + }
  830 +
  831 + if (!res.valid)
  832 + {
  833 + if (res.error)
  834 + {
  835 + if (res.error.search('subtree') != -1) {
  836 + Ext.MessageBox.show({title:'Warning',
  837 + msg: res.error+'<br/>Do you want to overwrite it?',
  838 + width: 300,
  839 + buttons: Ext.MessageBox.OKCANCEL,
  840 + fn : me.overwriteProcess,
  841 + icon: Ext.MessageBox.WARNING,
  842 + scope : me
  843 + });
  844 + nameField.validFlag = true;
  845 + }
  846 + else
  847 + nameField.validFlag = res.error;
  848 + }
  849 + else
  850 + {
  851 + nameField.validFlag = 'Invalid object name';
  852 + myDesktopApp.errorMsg(nameField.validFlag);
  853 + }
  854 + nameField.validate();
  855 + return;
  856 + }
  857 +
  858 + nameField.validFlag = true;
  859 + nameField.validate();
  860 + me.saveProcess();
  861 + });
  862 + }
  863 + }
  864 + },
  865 + {
  866 + scope : this,
  867 + text: 'Reset',
  868 + handler: function(){
  869 + this.down('form').getForm().reset();
  870 + }
  871 + }]
  872 + },
  873 + {
  874 + xtype: 'panel',
  875 + region: 'south',
  876 + title: 'Information',
  877 + collapsible: true,
  878 + height: 100,
  879 + autoHide: false,
  880 + iconCls: 'icon-information',
  881 + bodyStyle: 'padding:5px',
  882 + loader: {
  883 + autoLoad: true,
  884 + url: helpDir+'myDataHOWTO'
  885 + }
  886 + }],
  887 +
  888 + plugins: [ {ptype: 'tabledef', pluginId: 'tabledef'} ]
  889 + };
  890 +
  891 + Ext.apply (this, Ext.apply(arguments, myConf));
  892 + },
  893 +
  894 + getParameterSize : function()
  895 + {
  896 + var form = this.down('form').getForm();
  897 + return form.findField('size').getValue();
  898 + }
859 899 });
... ...
js/app/views/RemoteSearchPlugin.js
1 1 /**
2 2 * Project  : AMDA-NG
3 3 * Name : RemoteSearchPlug.js
4   - * @plugin amdaUI.InteractiveIntervalPlug
5   - * @extends Ext.AbstractPlugin
6   - * @ptype interactiveIntervalPlugin
7   - * @brief Plot interactive session UI (View)
8   - * @author Myriam
9   - * @version $Id: RemoteSearchPlugin.js 1130 2012-12-18 16:45:54Z elena $
10   - ********************************************************************************
11   - * FT Id : Date : Name - Description
12   - *******************************************************************************
13   - * :
  4 + * @plugin remoteSearchPlugin
  5 + * @extends Ext.AbstractPlugin
14 6 */
15 7  
16 8  
... ... @@ -22,93 +14,85 @@ Ext.define(&#39;amdaUI.RemoteSearchPlugin&#39;, {
22 14  
23 15 win : null,
24 16  
25   - constructor: function(config) {
26   - Ext.apply(this, config);
27   - this.callParent(arguments);
  17 + constructor: function(config) {
  18 + Ext.apply(this, config);
  19 + this.callParent(arguments);
28 20 },
29 21  
30 22  
31 23 init: function(cmp) {
32   - this.hostCmp = cmp;
33   - this.hostCmp.on({
34   - open: this.onOpen,
35   - scope: this});
  24 + this.hostCmp = cmp;
  25 + this.hostCmp.on({
  26 + open: this.onOpen,
  27 + scope: this});
36 28 },
37   -
  29 +
38 30 onDestroy : function() {
39   - this.win = null;
  31 + this.win = null;
40 32 },
41 33  
42 34 onOpen: function(url) {
43   - //TODO just reloa dtree
44   - if (this.win) this.win.destroy();
  35 + //TODO just reload tree
  36 + if (this.win) this.win.destroy();
45 37  
46 38 if (!this.win) {
47   - this.win = new Ext.Window({
48   - id: 'remoteSearch-win',
49   - width: 310,
50   - height: 500,
51   - title: url,
52   - layout: 'fit',
53   - constrain: true,
54   - ghost: false,
55   - items: this.getTree(url),
56   - listeners: {
57   - scope: this,
58   - beforeclose: function(){
59   - // Ext.PluginManager.unregister(this);
60   - }
61   - },
62   - getConstrainVector: function(constrainTo){
  39 + this.win = new Ext.Window({
  40 + id: 'remoteSearch-win',
  41 + width: 310,
  42 + height: 500,
  43 + title: url,
  44 + layout: 'fit',
  45 + constrain: true,
  46 + ghost: false,
  47 + items: this.getTree(url),
  48 + getConstrainVector: function(constrainTo){
63 49 var me = this;
64   - if (me.constrain || me.constrainHeader) {
65   - constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent();
66   - return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo);
67   - }
68   - }
69   - });
70   - this.win.on('destroy', this.onDestroy, this);
71   -
72   - // Ext.PluginManager.register(this);
73   -
74   - this.win.show();
75   - }
  50 + if (me.constrain || me.constrainHeader) {
  51 + constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container || me.el.getScopeParent();
  52 + return (me.constrainHeader ? me.header.el : me.el).getConstrainVector(constrainTo);
  53 + }
  54 + }
  55 + });
  56 + this.win.on('destroy', this.onDestroy, this);
  57 +
  58 + this.win.show();
  59 + }
76 60 },
77 61  
78   - getTree : function(url) {
79   -
80   - var store = Ext.create('Ext.data.TreeStore', {
81   - model: 'amdaModel.AmdaNode',
82   - root: {
83   - text: url,
84   - nodeType : 'url',
85   - expanded: true
86   - } ,
87   - listeners: {
88   - scope : this,
89   - beforeload: function(store, operation){
90   - store.proxy.extraParams = {
91   - nodeType: 'url',
92   - baseId: url
93   - }}
94   - }
  62 + getTree : function(url)
  63 + {
  64 + var store = Ext.create('Ext.data.TreeStore', {
  65 + model: 'amdaModel.AmdaNode',
  66 + root: {
  67 + text: url,
  68 + nodeType : 'url',
  69 + expanded: true
  70 + } ,
  71 + listeners: {
  72 + scope : this,
  73 + beforeload: function(store, operation){
  74 + store.proxy.extraParams = {
  75 + nodeType: 'url',
  76 + baseId: url
  77 + }
  78 + }
  79 + }
  80 + });
95 81  
96   - });
97   -
98   - var tree = Ext.create('Ext.tree.Panel', {
99   - store: store,
100   - listeners : {
101   - scope : this,
102   - itemdblclick: function(view, record, item, index, event){
103   - event.stopEvent();
104   - var form = this.hostCmp.down('form').next().getForm();
105   - form.getFields().getAt(1).setValue(record.internalId); // internalId ??
106   - this.win.destroy();
107   - }
108   - }
109   - });
  82 + var tree = Ext.create('Ext.tree.Panel', {
  83 + store: store,
  84 + listeners : {
  85 + scope : this,
  86 + itemdblclick: function(view, record, item, index, event){
  87 + event.stopEvent();
  88 + var form = this.hostCmp.down('form').next().getForm();
  89 + form.getFields().getAt(1).setValue(record.internalId); // internalId ??
  90 + this.win.destroy();
  91 + }
  92 + }
  93 + });
110 94  
111   - return tree;
  95 + return tree;
112 96 }
113 97  
114 98 });
115 99 \ No newline at end of file
... ...
js/app/views/UploadPanelUI.js
... ... @@ -15,15 +15,16 @@ Ext.define(&#39;amdaUI.UploadPanelUI&#39;, {
15 15 requires : [
16 16 'amdaUI.RemoteSearchPlugin'
17 17 ],
18   -
19   - isFile : true,
20   - isTimeTable : false,
21   - tmpNode : null,
22 18  
  19 + tmpNode : null,
  20 + specialItems : null,
  21 + formats : null,
  22 + localName : null,
  23 +
23 24 constructor: function(config)
24 25 {
25 26 this.init(config);
26   - this.callParent(arguments);
  27 + this.callParent(arguments);
27 28 },
28 29  
29 30 /*
... ... @@ -39,8 +40,7 @@ Ext.define(&#39;amdaUI.UploadPanelUI&#39;, {
39 40 var me = this;
40 41 myDesktopApp.getLoadedModule(this.tmpNode.get('moduleId'), true, function (module){
41 42 // myData
42   - if (me.tmpNode.get('nodeType') == amdaModel.MyDataParamNode.nodeType)
43   - {
  43 + if (me.tmpNode.get('nodeType') == amdaModel.MyDataParamNode.nodeType) {
44 44 var linkedFile = Ext.create('amdaModel.MyDataNode', {leaf : true, text : me.tmpNode.get('text')});
45 45  
46 46 linkedFile.create(result.mask, result.description, result.maskDesc);
... ... @@ -53,37 +53,33 @@ Ext.define(&#39;amdaUI.UploadPanelUI&#39;, {
53 53 linkedFile.set('object',paramObj);
54 54 me.tmpNode.set('fileObject',paramObj);
55 55 }
56   - else
57   - {
  56 + else {
58 57 // Time Table or Catalog
59 58 var paramObj = Ext.create(me.tmpNode.get('objectDataModel'), result);
60 59  
61 60 paramObj.set('fromPlugin',true);
62   - if (result.intervals)
63   - {
  61 + if (result.intervals) {
64 62 paramObj.set('intervals',result.intervals);
65 63 paramObj.set('nbIntervals',result.intervals.length);
66 64 }
67 65 me.tmpNode.set('object',paramObj);
68 66 }
69   - if (module)
70   - {
  67 + if (module) {
71 68 module.setLinkedNode(me.tmpNode);
72 69 module.linkedNode.editInModule();
73 70 }
74 71 });
75 72 }
76   - else
77   - {
  73 + else {
78 74 // EXCEPTION : parameter not found !
79 75 myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '"+this.tmpNode.get('text')+"' found!");
80 76 }
  77 +
81 78 loadMask.hide();
82 79 },
83 80  
84 81 /*
85 82 * form validation
86   -* TODO markInvalid()?
87 83 */
88 84 validate : function()
89 85 {
... ... @@ -91,59 +87,43 @@ Ext.define(&#39;amdaUI.UploadPanelUI&#39;, {
91 87  
92 88 if (values['filesrc'] == 'LOCAL')
93 89 {
94   - if (this.isFile) var locFile = this.getForm().findField('localFileName').getValue();
95   - else if (this.isTimeTable) var locFile = this.getForm().findField('localTTName').getValue();
96   - else var locFile = this.getForm().findField('localCatName').getValue();
97   -
98   - if (!locFile)
99   - {
  90 + var locFile = this.getForm().findField(this.localName).getValue();
  91 +
  92 + if (!locFile) {
100 93 myDesktopApp.warningMsg("Select File to Upload");
101 94 return false;
102 95 }
103 96 }
104 97 else
105 98 {
106   - if (!values['remoteFile'] && !values['remoteTT'] && !values['remoteCat'])
107   - {
  99 + if (!values['remoteFile'] && !values['remoteTT'] && !values['remoteCat']) {
108 100 myDesktopApp.warningMsg("Select File to Upload");
109 101 return false;
110 102 }
111   - }
  103 + }
  104 +
112 105 return true;
113 106 },
114 107  
115 108  
116   - //TODO proper parsing
  109 +/*
  110 + * Upadte format if user didn't do this himself
  111 + */
117 112 updateFormat: function(value)
118 113 {
119 114 var arrayOfStr = value.split('.');
120   - //TODO use down method?
121   - if (this.isFile)
122   - {
123   - var radios = Ext.getCmp('filefrmt');
124   - var user_format_obj = radios.getValue();
125   - var user_format = user_format_obj.filefrmt;
126   - }
127   - else if (this.isTimeTable)
128   - {
129   - var radios = Ext.getCmp('ttfrmt');
130   - var user_format_obj = radios.getValue();
131   - var user_format = user_format_obj.ttfrmt;
132   - }
133   - else
134   - {
135   - var radios = Ext.getCmp('catfrmt');
136   - var user_format_obj = radios.getValue();
137   - var user_format = user_format_obj.catfrmt;
138   - }
139   -
140   - var auto_format = user_format;
  115 +
  116 + var radios = Ext.getCmp(this.radioId);
  117 + var user_format_obj = radios.getValue();
  118 +
  119 + var user_format = user_format_obj[this.radioId];
141 120  
142 121 // auto define format in some special cases
143 122 //TODO name without extention => ASCII?
144   - if (arrayOfStr.length == 1) auto_format = 'ASCII';
145   - else
146   - {
  123 + if (arrayOfStr.length == 1) {
  124 + auto_format = 'ASCII';
  125 + }
  126 + else {
147 127 var suffix = arrayOfStr[arrayOfStr.length - 1].toLowerCase();
148 128 if (suffix == 'gz')
149 129 suffix = arrayOfStr[arrayOfStr.length - 2].toLowerCase() + '.gz';
... ... @@ -155,35 +135,30 @@ Ext.define(&#39;amdaUI.UploadPanelUI&#39;, {
155 135 case 'cef' : auto_format = 'CEF'; break;
156 136 case 'xml' : auto_format = 'VOT';
157 137 case 'vot' : auto_format = 'VOT'; break;
158   - case 'nc' : auto_format = 'NC'; break;
  138 + case 'nc' : auto_format = 'NC'; break;
159 139 case 'asc' :
160 140 case 'txt' :
161 141 default : auto_format = 'ASCII';
162 142 }
163 143 }
164 144 // set auto format : case when format was not set by user before
165   - if (this.isFile && user_format !== auto_format) {
166   - user_format_obj.filefrmt = auto_format;
167   - } else if (this.isTimeTable && user_format !== auto_format) {
168   - user_format_obj.ttfrmt = auto_format;
169   - } else if (!this.isFile && !this.isTimeTable && user_format !== auto_format) {
170   - user_format_obj.catfrmt = auto_format;
171   - }
172   -
  145 + if (user_format !== auto_format) {
  146 + user_format_obj[this.radioId] = auto_format;
  147 + }
  148 +
173 149 radios.setValue(user_format_obj);
174 150 },
175 151  
176   - /*
177   - *
178   - */
  152 +/*
  153 +*
  154 +*/
179 155 forceUpload : function (url,format,onFinish)
180 156 {
181 157 var me = this;
182 158 var re = /http:\/\/127.0.0.1:/;
183 159 var isRemoteUrl = !re.test(url);
184 160  
185   - switch (format)
186   - {
  161 + switch (format) {
187 162 case 'votable' :
188 163 this.getForm().findField('filefrmt').setValue('VOT');
189 164 break;
... ... @@ -230,14 +205,14 @@ Ext.define(&#39;amdaUI.UploadPanelUI&#39;, {
230 205 this.postUpload(onFinish);
231 206 },
232 207  
233   - /*
234   - *
235   - */
  208 +/*
  209 +*
  210 +*/
236 211 postUpload : function(onFinish)
237 212 {
238 213 // 'global' form containing 'partial' forms
239 214 var form = this.getForm();
240   -
  215 +
241 216 // special validation
242 217 if(this.validate())
243 218 {
... ... @@ -246,16 +221,14 @@ Ext.define(&#39;amdaUI.UploadPanelUI&#39;, {
246 221 scope: this,
247 222 url: 'php/uploadFile.php',
248 223 waitMsg: 'Uploading your file...',
249   - success: function(form, o)
250   - {
  224 + success: function(form, o) {
251 225 if (onFinish)
252 226 onFinish();
253 227 this.tmpNode = Ext.create(this.nodeType,{leaf : true, text : o.result.file});
254 228 AmdaAction.getUploadedObject(o.result.file, o.result.format, this.tmpNode.get('nodeType'), this.getObjectCallback, this);
255 229 loadMask.hide();
256 230 },
257   - failure: function(form, o)
258   - {
  231 + failure: function(form, o) {
259 232 if (onFinish)
260 233 onFinish();
261 234 loadMask.hide();
... ... @@ -265,25 +238,19 @@ Ext.define(&#39;amdaUI.UploadPanelUI&#39;, {
265 238 }
266 239 },
267 240  
268   - /*
269   - * panel config
270   - */
271   - init : function(config)
272   - {
273   - this.isFile = config.panelType == 'file'? true : false;
274   - this.isTimeTable = config.panelType == 'timetable'? true : false;
275   -
276   - // file / time table / catalog settings
277   - if (this.isFile)
278   - {
279   - var title = 'File';
280   - var items = [
  241 + initFileUpload : function()
  242 + {
  243 + this.formats = [
281 244 { boxLabel: 'ASCII', name: 'filefrmt', inputValue: 'ASCII', checked: true,
282   - listeners:
283   - {
  245 + listeners: {
284 246 change: function (cb, nv, ov) {
285   - if (nv) Ext.getCmp('tf').show();
286   - else Ext.getCmp('tf').hide();
  247 + if (nv) {
  248 + Ext.getCmp('tf').show();
  249 + }
  250 + else {
  251 + Ext.getCmp('tf').hide();
  252 + Ext.getCmp('nfs').hide();
  253 + }
287 254 }
288 255 }
289 256 },
... ... @@ -291,143 +258,95 @@ Ext.define(&#39;amdaUI.UploadPanelUI&#39;, {
291 258 { boxLabel: 'CDF&nbsp;<img amda_clicktip="cdfTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'filefrmt', inputValue: 'CDF' },
292 259 // { boxLabel: 'CEF[GZ]', name: 'filefrmt', inputValue: 'CEF' },
293 260 { boxLabel: 'VOTable', name: 'filefrmt', inputValue: 'VOT' }];
294   - var timeFormatId = 'tf';
295   - this.formatId = 'nsf';
  261 +
296 262 this.localUploadId = 'form-uploadfile';
297   - var localUploadName ='localFileName';
298   - var remoteUploadName ='remoteFile';
299 263 this.remoteUploadId = 'form-uploadurl';
300   - this.nodeType = 'amdaModel.MyDataParamNode';
301   - //TODO load XML
302   - var store = Ext.create('Ext.data.Store', {
  264 + this.nodeType = 'amdaModel.MyDataParamNode';
  265 + this.store = Ext.create('Ext.data.Store', {
303 266 fields: ['value', 'name'],
304   - data : [
305   - {"value":"ftp://cdaweb.gsfc.nasa.gov/pub/data/", "name":"CDAWEB/FTP"}/*,
306   - {"value":"ftp://ftp.ngdc.noaa.gov/STP/SOLAR_DATA/", "name":"Solar Data"}*/]
307   - });
308   - }
309   - else if (this.isTimeTable)
310   - {
311   - var title = 'Time Table';
312   - var items = [
313   - { boxLabel: 'ASCII&nbsp;<img amda_clicktip="ttTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'ttfrmt', inputValue: 'ASCII', checked: true},
314   - { boxLabel: 'VOTable', name: 'ttfrmt', inputValue: 'VOT'}
315   - ];
316   - var timeFormatId = 'tf_tt';
317   - this.formatId = 'nsf_tt';
318   - this.localUploadId = 'form-uploadtt';
319   - var localUploadName ='localTTName';
320   - var remoteUploadName ='remoteTT';
321   - this.remoteUploadId = 'form-uploadtturl';
322   - this.nodeType = 'amdaModel.TimeTableNode';
323   - //TODO load XML
324   - var store = Ext.create('Ext.data.Store', {
325   - fields: ['value', 'name'],
326   - data : []
  267 + proxy: {
  268 + type: 'ajax',
  269 + url : 'generic_data/remote_sites.json',
  270 + reader: {
  271 + type: 'json',
  272 + root: 'remote_sites'
  273 + }
  274 + },
  275 + autoLoad: true
327 276 });
328   - }
329   - else
330   - {
331   - var title = 'Catalog';
332   - var items = [
333   - { boxLabel: 'VOTable', name: 'catfrmt', inputValue: 'VOT', checked: true }];
334   -
335   - var timeFormatId = 'tf_cat';
336   - this.formatId = 'nsf_cat';
337   - this.localUploadId = 'form-uploadcat';
338   - var localUploadName ='localCatName';
339   - var remoteUploadName ='remoteCat';
340 277  
341   - this.remoteUploadId = 'form-uploadcaturl';
342   - this.nodeType = 'amdaModel.CatalogNode';
343   - //TODO load XML
344   - var store = Ext.create('Ext.data.Store', {
345   - fields: ['value', 'name'],
346   - data : []
347   - });
348   - }
349   -
350   - var combo = Ext.create('Ext.form.ComboBox', {
351   - flex : 4,
352   - store: store,
353   - emptyText: 'Enter Remote Site URL (ftp)',
354   - queryMode: 'local',
355   - displayField: 'name',
356   - valueField: 'value'
357   - });
358   -
359   - var fieldcontainer =
360   - {
361   - xtype: 'fieldcontainer',
362   - fieldLabel: ' ', labelWidth: 0, labelSeparator : '', labelPad : 0,
363   - layout: 'hbox',
  278 + this.radioId = 'filefrmt';
  279 +
  280 +/*
  281 + * Sampling : TimeFormat Fieldset
  282 + */
  283 + this.autoSampling = Ext.create('Ext.form.RadioGroup', {
  284 + // fieldLabel : 'Constant or Variable ?',
  285 + // labelWidth: 90,
  286 + defaults : {name : 'timesmpl'},
364 287 items: [
365   - combo,
366   - {
367   - xtype : 'button',
368   - flex : 1,
369   - text: 'Browse It',
370   - handler: function()
371   - {
372   - var form = this.up('form').getForm();
373   - var site = form.getFields().getAt(0).getValue();
374   - if (site)
375   - this.up('form').ownerCt.fireEvent('open', site);
376   - else
377   - myDesktopApp.warningMsg("Please Enter Remote Site URL");
378   - }
379   - }]
380   - };
381   -
382   - if (this.isFile) var radioId = 'filefrmt';
383   - else if (this.isTimeTable) var radioId = 'ttfrmt';
384   - else var radioId = 'catfrmt';
  288 + {boxLabel: 'constant sampling', inputValue: 'constant', checked: true},
  289 + {boxLabel: 'variable sampling&nbsp;<img amda_clicktip="variableSampling" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'variable'}
  290 + ]
  291 + });
385 292  
386   - var fileFormat = Ext.create('Ext.form.FieldSet', {
387   - title: 'File Format',
388   - items : [{
389   - xtype: 'radiogroup',
390   - id : radioId,
391   - columns: 3,
392   - cls: 'x-check-group-alt',
393   - items: items
  293 + this.manualSampling = Ext.create('Ext.form.FieldContainer', {
  294 + defaultType: 'numberfield',
  295 + layout: 'anchor',
  296 + defaults: {
  297 + layout: '100%',
  298 + labelWidth : 150,
  299 + minValue : 0.001,
  300 + hideTrigger: true
  301 + },
  302 + hidden : true,
  303 + items: [
  304 + {
  305 + fieldLabel : 'min sampling',
  306 + name : 'min_manual_sampling'
  307 + },
  308 + {
  309 + fieldLabel : 'max sampling',
  310 + name : 'max_manual_sampling'
394 311 }]
  312 + });
  313 +
  314 + var Sampling = Ext.create('Ext.form.RadioGroup', {
  315 + fieldLabel: 'Time Sampling',
  316 + labelWidth: 90,
  317 + cls: 'x-check-group-alt',
  318 + defaults : {name : 'smpl'},
  319 + items: [
  320 + {boxLabel: 'auto-defined', inputValue: 'auto', checked: true},
  321 + {boxLabel: 'manual', inputValue: 'manual'}
  322 + ],
  323 + listeners: {
  324 + scope : this,
  325 + change: function (cb, nv, ov) {
  326 + if (nv.smpl == 'manual') {
  327 + this.autoSampling.setVisible(false);
  328 + this.manualSampling.setVisible(true);
  329 + }
  330 + else {
  331 + this.autoSampling.setVisible(true);
  332 + this.manualSampling.setVisible(false);
  333 + }
  334 + }
  335 + }
395 336 });
396   -
397   - var Sampling =
398   - {
399   - xtype: 'radiogroup',
400   - fieldLabel: 'Time Sampling',
401   - labelWidth: 90,
402   - cls: 'x-check-group-alt',
403   - hidden : !this.isFile,
404   - defaults : {name : 'timesmpl'},
405   - items: [
406   - {boxLabel: 'constant', inputValue: 'constant', checked: true},
407   - {boxLabel: 'variable&nbsp;<img amda_clicktip="variableSampling" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'variable'}
408   - ]
409   - };
410   -
411   - var dayStart =
412   - {
413   - xtype: 'checkbox',
414   - name : 'doy',
415   - hidden : true,
416   - fieldLabel: 'DOY starts from 1',
417   - inputValue: '1'
418   - };
419   -
420   - var nonStandardFormat =
421   - {
  337 +
  338 +/*
  339 + * NonStandardFormat : TimeFormat Fieldset
  340 + */
  341 + var nonStandardFormat = {
422 342 xtype: 'fieldcontainer',
423 343 defaultType: 'textfield',
424 344 layout: 'anchor',
425   - defaults:
426   - {
427   - layout: '100%',
428   - labelWidth : 150
  345 + defaults: {
  346 + layout: '100%',
  347 + labelWidth : 150
429 348 },
430   - id : this.formatId,
  349 + id : 'nfs',
431 350 hidden : true,
432 351 items: [
433 352 {
... ... @@ -435,8 +354,7 @@ Ext.define(&#39;amdaUI.UploadPanelUI&#39;, {
435 354 name : 'nonstd',
436 355 value: 'Y-m-d H:i:s',
437 356 enableKeyEvents: true,
438   - listeners :
439   - {
  357 + listeners : {
440 358 keyUp : function() {
441 359 if (this.getValue().indexOf('z') > 0) {
442 360 this.nextSibling().show();
... ... @@ -446,67 +364,165 @@ Ext.define(&#39;amdaUI.UploadPanelUI&#39;, {
446 364 }
447 365 }
448 366 }
449   - },
450   - dayStart,
451   - {
452   - fieldLabel : 'define max time length',
453   - name : 'timelength',
454   - value: 'auto'
  367 + },{
  368 + xtype: 'checkbox',
  369 + name : 'doy',
  370 + fieldLabel: 'DOY starts from 1',
  371 + hidden : true,
  372 + inputValue: '1'
  373 + },{
  374 + fieldLabel : 'define max time length',
  375 + name : 'timelength',
  376 + value: 'auto'
455 377 }],
456   - listeners :
457   - {
  378 + listeners : {
458 379 hide : function() {
459 380 this.items.getAt(1).hide();
  381 + },
  382 + show : function() {
  383 + if (this.items.getAt(0).getValue().indexOf('z') > 0)
  384 + this.items.getAt(1).show();
460 385 }
461 386 }
462   - };
463   -
464   - var timeFormat = Ext.create('Ext.form.FieldSet', {
465   - id: timeFormatId,
466   - title: 'Time Settings',
467   - hidden : !this.isFile,
468   - items : [
469   - {
  387 + };
  388 +
  389 +/*
  390 + * TimeFormat Fieldset : Global form
  391 + */
  392 + var timeFormat = Ext.create('Ext.form.FieldSet', {
  393 + title: 'Time Settings',
  394 + items : [{
  395 + id: 'tf',
470 396 xtype: 'radiogroup',
471 397 fieldLabel: 'Time Format',
472   - labelWidth: 90,
  398 + labelWidth: 90,
473 399 cls: 'x-check-group-alt',
474 400 defaults : { name : 'timefrmt'},
475   - items: [
476   - { boxLabel: 'standard&nbsp;<img amda_clicktip="standardTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'standard', checked: true},
477   - { boxLabel: 'no&nbsp;<img amda_clicktip="userTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'user',
478   - listeners:
479   - {
480   - scope : this,
481   - change: function (cb, nv, ov) {
482   - if (nv)
483   - Ext.getCmp(this.formatId).show();
484   - else
485   - Ext.getCmp(this.formatId).hide();
486   - }
487   - }
488   - }]
489   - },
490   - nonStandardFormat,
491   - Sampling ]
  401 + items: [
  402 + { boxLabel: 'standard&nbsp;<img amda_clicktip="standardTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'standard', checked: true},
  403 + { boxLabel: 'no&nbsp;<img amda_clicktip="userTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'user',
  404 + listeners: {
  405 + change: function (cb, nv, ov) {
  406 + if (nv)
  407 + Ext.getCmp('nfs').show();
  408 + else
  409 + Ext.getCmp('nfs').hide();
  410 + }
  411 + }
  412 + }]
  413 + },
  414 + nonStandardFormat,
  415 + Sampling,
  416 + this.autoSampling,
  417 + this.manualSampling
  418 + ]
492 419 });
  420 +
  421 + this.specialItems = [ timeFormat,
  422 + {
  423 + xtype: 'hidden',
  424 + name: 'sampData',
  425 + value: null
  426 + },
  427 + {
  428 + xtype: 'hidden',
  429 + name: 'sampFileName',
  430 + value: null
  431 + }]
  432 + },
493 433  
494   - var localFile = Ext.create('Ext.form.Panel', {
  434 + initTTUpload : function(isTT)
  435 + {
  436 + if (isTT) {
  437 + this.formats = [
  438 + { boxLabel: 'ASCII&nbsp;<img amda_clicktip="ttTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'ttfrmt', inputValue: 'ASCII', checked: true},
  439 + { boxLabel: 'VOTable', name: 'ttfrmt', inputValue: 'VOT'}
  440 + ];
  441 + this.localUploadId = 'form-uploadtt';
  442 + this.remoteUploadId = 'form-uploadtturl';
  443 + this.nodeType = 'amdaModel.TimeTableNode';
  444 +
  445 + this.store = Ext.create('Ext.data.Store', {
  446 + fields: ['value', 'name']/*,
  447 + proxy: {
  448 + type: 'ajax',
  449 + url : 'generic_data/remote_sites.json',
  450 + reader: {
  451 + type: 'json',
  452 + root: 'remote_sites'
  453 + }
  454 + },
  455 + autoLoad: true*/
  456 + });
  457 +
  458 + this.radioId = 'ttfrmt';
  459 + }
  460 + else {
  461 + this.formats = [
  462 + { boxLabel: 'VOTable', name: 'catfrmt', inputValue: 'VOT', checked: true }];
  463 +
  464 + this.localUploadId = 'form-uploadcat';
  465 + this.remoteUploadId = 'form-uploadcaturl';
  466 + this.nodeType = 'amdaModel.CatalogNode';
  467 + this.store = Ext.create('Ext.data.Store', {
  468 + fields: ['value', 'name']/*,
  469 + proxy: {
  470 + type: 'ajax',
  471 + url : 'generic_data/remote_sites.json',
  472 + reader: {
  473 + type: 'json',
  474 + root: 'remote_sites'
  475 + }
  476 + },
  477 + autoLoad: true*/
  478 + });
  479 +
  480 + this.radioId = 'catfrmt';
  481 + }
  482 + },
  483 +/*
  484 +* panel config
  485 +*/
  486 + init : function(config)
  487 + {
  488 +
  489 + if ( config.panelType == 'file' )
  490 + this.initFileUpload();
  491 + else
  492 + this.initTTUpload(config.panelType == 'timetable');
  493 +
  494 + this.localName = config.localUploadName;
  495 + /*
  496 + * FileFormat Fieldset
  497 + */
  498 + var fileFormat = Ext.create('Ext.form.FieldSet', {
  499 + title: 'File Format',
  500 + items : [{
  501 + xtype: 'radiogroup',
  502 + id : this.radioId,
  503 + columns: 3,
  504 + cls: 'x-check-group-alt',
  505 + items: this.formats
  506 + }]
  507 + });
  508 +
  509 +/*
  510 + * FileSource Fieldset : Local File Upload
  511 + */
  512 + var localFile = Ext.create('Ext.form.Panel', {
495 513 id: this.localUploadId,
496 514 fileUpload: true,
497 515 hideLabels: true,
498 516 frame: true,
499   - items: [
500   - {
501   - xtype: 'fileuploadfield',
  517 + items: [{
  518 + xtype: 'fileuploadfield',
502 519 emptyText: 'Select Your File',
503 520 width: 300,
504   - name: localUploadName,
  521 + name: this.localName,
505 522 buttonText: 'Browse',
506   - listeners:
507   - {
  523 + listeners: {
508 524 scope : this,
509   - change: function (field, value, e) {
  525 + change: function (field, value, e) {
510 526 this.updateFormat(value);
511 527 }
512 528 }
... ... @@ -517,41 +533,75 @@ Ext.define(&#39;amdaUI.UploadPanelUI&#39;, {
517 533 name: 'MAX_FILE_SIZE',
518 534 value: myDesktopApp.MAX_UPLOADED_FILE_SIZE // 30MB
519 535 }]
520   - });
521   -
522   - var remoteFile = Ext.create('Ext.form.Panel', {
523   - id: this.remoteUploadId,
  536 + });
  537 +
  538 +/*
  539 + * FileSource Fieldset : Remote File Upload
  540 + */
  541 + var combo = Ext.create('Ext.form.ComboBox', {
  542 + flex : 4,
  543 + store: this.store,
  544 + emptyText: 'Enter Remote Site URL (ftp/http[s])',
  545 + queryMode: 'local',
  546 + displayField: 'name',
  547 + valueField: 'value'
  548 + });
  549 +
  550 + var fieldcontainer = {
  551 + xtype: 'fieldcontainer',
  552 + fieldLabel: ' ', labelWidth: 0, labelSeparator : '', labelPad : 0,
  553 + layout: 'hbox',
  554 + items: [
  555 + combo,
  556 + {
  557 + xtype : 'button',
  558 + flex : 1,
  559 + text: 'Browse It',
  560 + handler: function() {
  561 + var form = this.up('form').getForm();
  562 + var site = form.getFields().getAt(0).getValue();
  563 + if (site)
  564 + this.up('form').ownerCt.fireEvent('open', site);
  565 + else
  566 + myDesktopApp.warningMsg("Please Enter Remote Site URL");
  567 + }
  568 + }]
  569 + };
  570 +
  571 + var remoteFile = Ext.create('Ext.form.Panel', {
  572 + id: this.remoteUploadId,
524 573 hideLabels: true,
525   - autoHeight: true,
  574 + autoHeight: true,
526 575 frame: true,
527 576 hidden : true,
528 577 items: [
529 578 fieldcontainer,
530 579 {
531 580 xtype : 'textfield',
532   - name : remoteUploadName,
533   - emptyText: 'Enter Remote File URL (http or ftp)',
  581 + name : config.remoteUploadName,
  582 + emptyText: 'Enter Remote File URL (ftp/http[s])',
534 583 width: 310,
535 584 listeners:
536 585 {
537 586 scope : this,
538   - change: function (field, value, e) {
539   - this.updateFormat(value);
  587 + change: function (field, value, e) {
  588 + this.updateFormat(value);
540 589 }
541 590 }
542 591 }]
543 592 });
544   -
545   - var uploadForm = Ext.create('Ext.form.FieldSet',{
546   - title: 'File Source',
547   - items : [
548   - {
549   - xtype: 'radiogroup',
  593 +
  594 + /*
  595 + * FileSource Fieldset : global form
  596 + */
  597 + var uploadForm = Ext.create('Ext.form.FieldSet',{
  598 + title: 'File Source',
  599 + items : [{
  600 + xtype: 'radiogroup',
550 601 cls: 'x-check-group-alt',
551 602 items: [
552 603 { boxLabel: 'Local', name: 'filesrc', inputValue: 'LOCAL', checked: true,
553   - listeners:
554   - {
  604 + listeners: {
555 605 scope : this,
556 606 change: function (cb, nv, ov) {
557 607 if (nv == ov) return;
... ... @@ -559,67 +609,52 @@ Ext.define(&#39;amdaUI.UploadPanelUI&#39;, {
559 609 var remote = Ext.getCmp(this.remoteUploadId);
560 610 if (nv) {
561 611 remote.hide();
562   - local.show();
  612 + local.show();
563 613 }
564 614 else {
565 615 local.hide();
566   - remote.show();
  616 + remote.show();
567 617 }
568 618 }
569 619 }
570 620 },
571   - { boxLabel: 'URL', name: 'filesrc', inputValue: 'URL'} ]
  621 + { boxLabel: 'URL', name: 'filesrc', inputValue: 'URL'}]
572 622 }]
573 623 });
574   -
  624 +
  625 +/*
  626 + * Panel Config
  627 + */
575 628 var myConf =
576 629 {
577   - title : title,
  630 + title : config.title,
578 631 layout: {type: 'vbox', align: 'stretch'},
  632 + autoScroll : true,
579 633 bodyStyle: { background : '#dfe8f6'},
580   - items : [
581   - uploadForm,
582   - localFile,
583   - remoteFile,
584   - fileFormat,
585   - timeFormat,
586   - {
587   - xtype: 'hidden',
588   - name: 'sampData',
589   - value: null
590   - },
591   - {
592   - xtype: 'hidden',
593   - name: 'sampFileName',
594   - value: null,
595   - }
596   - ],
597   - buttons: [
598   - {
  634 + items : Ext.Array.merge(
  635 + [ uploadForm, localFile, remoteFile, fileFormat ],
  636 + this.specialItems ),
  637 + buttons: [{
599 638 text: 'Upload',
600   - handler: function()
601   - {
  639 + handler: function() {
602 640 this.postUpload();
603 641 },
604 642 scope : this
605 643 },
606 644 {
607 645 text: 'Reset',
608   - handler: function(){
  646 + handler: function() {
609 647 this.up('form').getForm().reset();
610 648 }
611 649 }],
612 650 plugins: [{ptype: 'remoteSearchPlugin'}],
613   - listeners:
614   - {
615   - click:
616   - {
  651 + listeners:{
  652 + click: {
617 653 element: 'el',
618   - fn: function(e,t) {
  654 + fn: function(e,t) {
619 655 var me = t,
620 656 text = me.getAttribute('amda_clicktip');
621   - if (text)
622   - {
  657 + if (text) {
623 658 e.preventDefault();
624 659 AmdaAction.getInfo({name : text}, function(res,e) {
625 660 if (res.success) myDesktopApp.infoMsg(res.result);
... ...
js/app/views/UploadUI.js
... ... @@ -33,9 +33,9 @@ Ext.define(&#39;amdaUI.UploadUI&#39;, {
33 33 region: 'center',
34 34 activeTab : 0,
35 35 items : [
36   - { xtype: 'panelUpload', panelType : 'file'},
37   - { xtype: 'panelUpload', panelType : 'timetable'},
38   - { xtype: 'panelUpload', panelType : 'catalog'}]
  36 + { xtype: 'panelUpload', panelType : 'file', title : 'File', localUploadName : 'localFileName', remoteUploadName : 'remoteFile'},
  37 + { xtype: 'panelUpload', panelType : 'timetable', title : 'Time Table', localUploadName : 'localTTName', remoteUploadName : 'remoteTT'},
  38 + { xtype: 'panelUpload', panelType : 'catalog', title : 'Catalog', localUploadName : 'localCatName', remoteUploadName :'remoteCat'}]
39 39 },
40 40 {
41 41 xtype: 'panel',
... ...
php/classes/FilesMgr.php
... ... @@ -113,19 +113,28 @@ class FilesMgr extends AmdaObjectMgr
113 113 else {
114 114 $size = 1;
115 115 }
116   -
117   - return array('type' => $data_type, 'size' => $size, 'n_records' => $n_recs);
  116 +
  117 + $units = exec('cdfvar_attr '.$this->fileName.' '.$cdfVarId.' UNITS');
  118 + $fillval = exec('cdfvar_attr '.$this->fileName.' '.$cdfVarId.' FILLVAL');
  119 +
  120 + return array('type' => $data_type, 'size' => $size, 'n_records' => $n_recs, 'units' => $units, 'fillvalue' => $fillval);
118 121 }
119 122  
120   - public function getCdfSampling()
121   - {
  123 + public function getCdfSampling() {
122 124 copy($this->fileName, "temp.cdf");
123 125 exec('cdfsamplingfromdata ', $results);
124 126 unlink("temp.cdf");
125 127  
126 128 return $results;
127 129 }
  130 +
  131 + public function getCdfSamplings() {
  132 + copy($this->fileName, "temp.cdf");
  133 + exec('cdfsamplingsfromdata ', $results);
  134 + unlink("temp.cdf");
128 135  
  136 + return $results;
  137 + }
129 138 /*
130 139 * CEF format processing
131 140 */
... ... @@ -214,7 +223,7 @@ class FilesMgr extends AmdaObjectMgr
214 223 {
215 224 exec('ncvarinfo '.$this->fileName.' '.$this->param2dd($varId), $results);
216 225 $tempArr = explode(' ', $results[0]);
217   - // data type
  226 + // data type
218 227 switch ($tempArr[0]) {
219 228 case "5": $data_type = 'FLOAT';
220 229 break;
... ... @@ -238,7 +247,15 @@ class FilesMgr extends AmdaObjectMgr
238 247 $size = 1;
239 248 }
240 249  
241   - return array('type' => $data_type, 'size' => $size, 'n_records' => $n_recs);
  250 + $units = exec('ncvar_attr '.$this->fileName.' '.$this->param2dd($varId).' UNITS');
  251 + if (substr($units, 0,5) == 'error') $units = '';
  252 +
  253 + $fillval = exec('ncvar_attr '.$this->fileName.' '.$this->param2dd($varId).' _Fillvalue'); // _Fillvalue
  254 + if (substr($fillval, 0,5) == 'error') $fillval = exec('ncvar_attr '.$this->fileName.' '.$this->param2dd($varId).' Fillvalue');
  255 + if (substr($fillval, 0,5) == 'error') $fillval = exec('ncvar_attr '.$this->fileName.' '.$this->param2dd($varId).' Fillval');
  256 + if (substr($fillval, 0,5) == 'error') $fillval = '';
  257 +
  258 + return array('type' => $data_type, 'size' => $size, 'n_records' => $n_recs, 'units' => $units, 'fillvalue' => $fillval);
242 259 }
243 260  
244 261 protected function param2dd($paramID)
... ... @@ -583,22 +600,30 @@ class FilesMgr extends AmdaObjectMgr
583 600 }
584 601  
585 602  
586   - protected function createFile($format)
  603 + protected function createFile($format, $samplingType)
587 604 {
588 605 $newFile = $this->contentDom->createElement('file');
589 606 $newFile->setAttribute('xml:id', $this->fileId);
590 607 $newFile->setAttribute('name', $this->fileId);
591 608 $newFile->setAttribute('format', $format);
592   -
  609 +
  610 + $minSamp = $this->sampling;
  611 + $maxSamp = $this->maxSampling;
  612 +
593 613 switch ($format)
594 614 {
595 615 case "cdf":
596 616 $start_stop = explode(" ",$this->getCdfStartStop());
597   - $result = $this->getCdfSampling();
598   - //TODO process errors
599   - $minSamp = $result[count($result)-1];
600   - //TODO if min & max
601   - $maxSamp = $minSamp;
  617 + if ($minSamp < 0) {
  618 + if ($samplingType == 'constant') {
  619 + $result = $this->getCdfSampling();
  620 + //TODO process errors
  621 + $minSamp = $result[count($result)-1];
  622 + $maxSamp = $minSamp;
  623 + } else {
  624 + // $result = $this->getCdfSamplings();
  625 + }
  626 + }
602 627 break;
603 628 case "txt":
604 629 $start_stop = explode(" ",$this->reformatTxt());
... ... @@ -610,16 +635,14 @@ class FilesMgr extends AmdaObjectMgr
610 635 // Test if 'standard' meta exist in CEF
611 636 $cefMetaTest = $this->getCefStartStop();
612 637  
613   - if ($cefMetaTest != -1)
614   - {
  638 + if ($cefMetaTest != -1) {
615 639 $cefStartStop = explode("/",$cefMetaTest);
616 640 $start_stop[] = strtotime($cefStartStop[0]);
617 641 $start_stop[] = strtotime($cefStartStop[1]);
618 642 $result = $this->getCefSampling();
619 643 $minSamp = $result[count($result)-1];
620 644 }
621   - else
622   - {
  645 + else {
623 646 // no META data - so time processing
624 647 $timeInfo = $this->getCefTimeInfo();
625 648 $timeInfoArr = explode(" ", $timeInfo);
... ... @@ -633,8 +656,10 @@ class FilesMgr extends AmdaObjectMgr
633 656 case "vot" :
634 657 $start_stop = explode(" ",$this->getVotFileMgr()->getStartStop());
635 658 $samplings = $this->getVotFileMgr()->getSamplings();
636   - $minSamp = $samplings["minSampling"];
637   - $maxSamp = $samplings["maxSampling"];
  659 + if ($minSamp < 0) {
  660 + $minSamp = $samplings["minSampling"];
  661 + $maxSamp = $samplings["maxSampling"];
  662 + }
638 663 $desc = $this->getVotFileMgr()->getDescription();
639 664 break;
640 665 case "nc":
... ... @@ -644,11 +669,13 @@ class FilesMgr extends AmdaObjectMgr
644 669 return $ncInfo;
645 670 }
646 671 $ncInfoArr = explode("#",$ncInfo);
647   - $start_stop = explode(":",$ncInfoArr[0]);
648   - //TODO process errors
649   - $minSamp = $ncInfoArr[1];
650   - //TODO if min & max
651   - $maxSamp = $minSamp;
  672 + $start_stop = explode(":",$ncInfoArr[0]);
  673 + if ($minSamp < 0) {
  674 + //TODO process errors
  675 + $minSamp = $ncInfoArr[1];
  676 + //TODO if min & max
  677 + $maxSamp = $minSamp;
  678 + }
652 679 break;
653 680 default:
654 681 }
... ... @@ -1117,20 +1144,27 @@ class FilesMgr extends AmdaObjectMgr
1117 1144  
1118 1145 $format = $this->getFormat();
1119 1146  
1120   - if ($format === 'unknown')
1121   - {
  1147 + if ($format === 'unknown') {
1122 1148 unlink($this->fileName);
1123 1149 return array('success' => false, 'error' => 'Sorry, unknown format of '.$fileName);
1124 1150 }
1125 1151  
  1152 + // if sampling is defined by user
  1153 + if ($formats["samplingType"] == "manual") {
  1154 + $this->sampling = $formats["min_sampling"];
  1155 + if ($formats["max_sampling"])
  1156 + $this->maxSampling = $formats["max_sampling"];
  1157 + else
  1158 + $this->maxSampling = $this->sampling;
  1159 + }
  1160 +
  1161 +
1126 1162 if ($format == 'txt')
1127 1163 {
1128   - if ($formats["timeFormat"] == "user")
1129   - {
  1164 + if ($formats["timeFormat"] == "user") {
1130 1165 $res = $this->reformatTime($formats["nonStandard"], $formats["timeLength"], $formats["doy"]);
1131 1166  
1132   - if (!$res)
1133   - {
  1167 + if (!$res) {
1134 1168 unlink($this->fileName);
1135 1169 return array('success' => false, 'error' => 'can\'t reformat time');
1136 1170 }
... ... @@ -1138,60 +1172,54 @@ class FilesMgr extends AmdaObjectMgr
1138 1172 // check if file is not empty
1139 1173 $vars = $this->getTxtColNumber(false);
1140 1174  
1141   - if ($vars == -100)
1142   - {
  1175 + if ($vars == -100) {
1143 1176 return array('success' => false, 'error' => 'no such file');
1144 1177 }
1145 1178  
1146   - if ($vars == -1)
1147   - {
  1179 + if ($vars == -1) {
1148 1180 unlink($this->fileName);
1149 1181 return array('success' => false, 'error' => 'while reading file');
1150 1182 }
1151 1183  
1152   - if ($vars === 0)
1153   - {
  1184 + if ($vars === 0) {
1154 1185 unlink($this->fileName);
1155 1186 return array('success' => false, 'error' => 'file contains no data');
1156 1187 }
  1188 +
  1189 + // sampling is to be defined automatically
  1190 + if ($this->sampling < 0) {
  1191 + if ($formats["timeSampling"] == "constant") {
  1192 + $this->sampling = $this->getTxtSampling();
  1193 + $this->maxSampling = $this->sampling;
  1194 + }
  1195 + else {
  1196 + $samplings = $this->getTxtSamplings();
  1197 + $this->sampling = $samplings[0];
  1198 + $this->maxSampling = $samplings[1];
  1199 + }
1157 1200  
1158   - if ($formats["timeSampling"] == "constant")
1159   - {
1160   - $this->sampling = $this->getTxtSampling();
1161   - $this->maxSampling = $this->sampling;
1162   - }
1163   - else
1164   - {
1165   - $samplings = $this->getTxtSamplings();
1166   - $this->sampling = $samplings[0];
1167   - $this->maxSampling = $samplings[1];
  1201 + if ($this->sampling <= 0) {
  1202 + unlink($this->fileName);
  1203 + if ($this->sampling == -10) {
  1204 + return array('success' => false, 'error' => 'Sorry, can\'t process'.$fileName.PHP_EOL.'. Check if there are non numeric chars in the data');
  1205 + }
  1206 + return array('success' => false, 'error' => 'Sorry, can\'t process Time for '.$fileName.PHP_EOL.'. Check time format, start time (> 1970-01-01) or sampling time (>= 1s)');
  1207 + }
1168 1208 }
1169   -
1170   - if ($this->sampling <= 0)
1171   - {
1172   - unlink($this->fileName);
1173   - if ($this->sampling == -10)
1174   - {
1175   - return array('success' => false, 'error' => 'Sorry, can\'t process'.$fileName.PHP_EOL.'. Check if there are non numeric chars in the data');
1176   - }
1177   - return array('success' => false, 'error' => 'Sorry, can\'t process Time for '.$fileName.PHP_EOL.'. Check time format, start time (> 1970-01-01) or sampling time (>= 1s)');
1178   - }
1179 1209 }
1180 1210  
1181 1211 if ($format == 'nc')
1182 1212 {
1183 1213 $status = $this->reformatNcTime();
1184   - if ($status <= 0)
1185   - {
  1214 + if ($status <= 0) {
1186 1215 unlink($this->fileName);
1187 1216 return array('success' => false, 'error' => 'error '.$timeFormat.PHP_EOL.'Time Format problem');
1188 1217 }
1189 1218 }
1190 1219  
1191 1220 //create new file tag with all attributes and add it to the content DOM
1192   - $newFile = $this->createFile($format);
1193   - if (is_int($newFile) && ($newFile < 0))
1194   - {
  1221 + $newFile = $this->createFile($format, $formats["timeSampling"]);
  1222 + if (is_int($newFile) && ($newFile < 0)) {
1195 1223 unlink($this->fileName);
1196 1224 return array( 'success' => false, 'file' => $fileName);
1197 1225 }
... ... @@ -1207,8 +1235,8 @@ class FilesMgr extends AmdaObjectMgr
1207 1235 $mask->appendChild($newFile);
1208 1236  
1209 1237 $files = $mask->getElementsByTagName("file");
1210   - foreach ($files as $file)
1211   - {
  1238 +
  1239 + foreach ($files as $file) {
1212 1240 $starts[] = $file->getAttribute("start");
1213 1241 $stops[] = $file->getAttribute("stop");
1214 1242 }
... ... @@ -1219,8 +1247,7 @@ class FilesMgr extends AmdaObjectMgr
1219 1247 }
1220 1248 }
1221 1249 // no corresponding masks => add to fileList
1222   - if (!$isMask)
1223   - {
  1250 + if (!$isMask) {
1224 1251 $filesList = $this->contentDom->getElementById($this->contentRootId);
1225 1252 $filesList->appendChild($newFile);
1226 1253 }
... ... @@ -1230,8 +1257,7 @@ class FilesMgr extends AmdaObjectMgr
1230 1257 //if mask exists - add to data base
1231 1258 $myBaseManager = new BaseManager();
1232 1259 $mask = $myBaseManager->addFile($fileName);
1233   - if ($mask != null)
1234   - {
  1260 + if ($mask != null) {
1235 1261 $startstop = $myBaseManager->getStartStop($myBaseManager->getVi($mask));
1236 1262 $myParamMgr = new DerivedParamMgr('myDataParam');
1237 1263 $myParamMgr->updateMydata($mask,$startstop);
... ...
php/src/Makefile
... ... @@ -4,8 +4,8 @@ CFLAGS = -ggdb -DLINUX -m64 -march=core2 -fPIC -Dlinux -D_REENTRANT -malign-doub
4 4 CC = gcc
5 5  
6 6 EXE = nctimestring2double nctimeinfo getncvars ncvarinfo \
7   - ncinfo_remote \
8   - cdfinfo cdfvarinfo cdfstartstopfromdata cdfsamplingfromdata \
  7 + ncinfo_remote ncvar_attr \
  8 + cdfinfo cdfvarinfo cdfstartstopfromdata cdfsamplingfromdata cdfvar_attr \
9 9 AddVI
10 10  
11 11 lib: ${EXE}
... ... @@ -14,8 +14,11 @@ AddVI: AddVI.c
14 14 ${CC} ${CFLAGS} -o AddVI AddVI.c ${INC} ${LIB} -lDDClientLibC
15 15  
16 16 ncinfo_remote: ncinfo_remote.c
17   - ${CC} ${CFLAGS} -o ncinfo_remote ncinfo_remote.c ${INC} ${LIB} -lnetcdf
18   -
  17 + ${CC} ${CFLAGS} -o ncinfo_remote ncinfo_remote.c ${INC} ${LIB} -lnetcdf
  18 +
  19 +ncvar_attr: ncvar_attr.c
  20 + ${CC} ${CFLAGS} -o ncvar_attr ncvar_attr.c ${INC} ${LIB} -lnetcdf
  21 +
19 22 nctimestring2double: nctimestring2double.c
20 23 ${CC} ${CFLAGS} -o nctimestring2double nctimestring2double.c ${INC} ${LIB} -lDDClientLibC -lnetcdf
21 24  
... ... @@ -48,7 +51,10 @@ cdfinfo: cdfinfo.c
48 51  
49 52 cdfvarinfo: cdfvarinfo.c
50 53 ${CC} ${CFLAGS} -o cdfvarinfo cdfvarinfo.c ${INC} ${LIB} -lcdf
51   -
  54 +
  55 +cdfvar_attr: cdfvar_attr.c
  56 + ${CC} ${CFLAGS} -o cdfvar_attr cdfvar_attr.c ${INC} ${LIB} -lcdf
  57 +
52 58 cdfstartstopfromdata: cdfstartstopfromdata.c
53 59 ${CC} ${CFLAGS} -o cdfstartstopfromdata cdfstartstopfromdata.c ${INC} ${LIB} -lcdf
54 60  
... ...
php/src/cdfsamplingfromdata.c
1   -/* $Id: timeResFromData.c,v 1.1 2010/08/31 10:32:55 budnik Exp $ */
  1 +/* $Id: cdf constant samplig from data $ */
2 2  
3   -/** @file timeResFromData.c
4   -* @brief Function to get CDAWEB dataset sampling times from data files
5   -*/
6 3 #include <stdio.h>
7 4 #include <stdlib.h>
8 5 #include <cdf.h>
... ... @@ -46,48 +43,18 @@ void cdf_handle_error(CDFstatus status)
46 43 exit(1);
47 44 }
48 45  
49   -void find_min(int* delta, int nRecs, int minFalse, int* minVal)
50   -{
51   - int i, n, min;
52   -
53   - n = 1;
54   - i = 0;
55   - while (abs(delta[i]) <= minFalse) i++;
56   - if (i < nRecs) {
57   - min = abs(delta[i]);
58   - // printf(" first MIN %d \n", min);
59   - for (i = 1; i < nRecs; i++) {
60   - // printf(" delta %d \n", delta[i]);
61   - if (delta[i] == min) n++;
62   - if (delta[i] < min && delta[i] > minFalse) {
63   - min = delta[i];
64   - n = 1;
65   - }
66   - }
67   - } else {
68   - min = -10;
69   - n = nRecs;
70   - }
71   -
72   - minVal[0] = min;
73   - minVal[1] = n;
74   - printf(" MIN %d %d\n", min, n);
75   -}
76   -
77 46 int main(int argc, char *argv[])
78 47 {
79   - long RecStart = 0, RecCount, RecInt = 1;
  48 + long RecStart = 0, RecCount = 2, RecInt = 1;
80 49 long indices[1] = {0}, intervals[1] = {1}, counts[1] = {1};
81 50 long varN = -1;
82 51 long datatype = 0, attrN, maxEntry;
83 52 CDFstatus cstatus; // CDF status code
84 53 CDFid id;
85 54 double *value;
86   - int *delta;
87 55 int i, minFalse = 0, numEnough;
88   - int min[2] = {0, 0};
89 56 char attrValue[300];
90   - float Sampling;
  57 + int sampling;
91 58 double epoch16[2], dbl_value, dbl_value_;
92 59 long year, month, day, hour, minute, sec, msec, mksec, nsec, psec;
93 60 long long *int_value;
... ... @@ -106,26 +73,27 @@ int main(int argc, char *argv[])
106 73 if ((cstatus = CDFlib(SELECT_, zVAR_, varN,
107 74 GET_, zVAR_DATATYPE_, &datatype, NULL_)) != CDF_OK)
108 75 cdf_handle_error (cstatus);
109   - // if (datatype == CDF_EPOCH16) break;
110 76 }
  77 +
111 78 fprintf(stdout,"DATATYPE %d %d\n", varN, datatype);
112 79 if ((cstatus = CDFlib(SELECT_, zVAR_, varN,
113 80 GET_, zVAR_MAXREC_, &CDFmaxRec, NULL_)) != CDF_OK)
114 81 cdf_handle_error (cstatus);
115 82  
116 83 fprintf(stdout,"Max Recs %d\n", CDFmaxRec+1);
117   - if (CDFmaxRec < 10) {
  84 +
  85 + if (CDFmaxRec < 3) {
118 86 fprintf(stdout," %d\n", badFile);
119 87 exit (0);
120 88 }
121 89  
122 90 if ( datatype == CDF_TIME_TT2000 ) {
123   - int_value = (long long *) malloc (sizeof(long long) * (CDFmaxRec+1));
  91 + int_value = (long long *) malloc (sizeof(long long) * (RecCount+1));
124 92 /******************* Get Epoch *************************/
125 93 if ((cstatus = CDFlib (SELECT_,
126 94 zVAR_, varN,
127 95 zVAR_RECNUMBER_, RecStart,
128   - zVAR_RECCOUNT_, CDFmaxRec+1,
  96 + zVAR_RECCOUNT_, RecCount + 1,
129 97 zVAR_RECINTERVAL_, RecInt,
130 98 zVAR_DIMINDICES_, indices,
131 99 zVAR_DIMCOUNTS_, counts,
... ... @@ -134,12 +102,12 @@ int main(int argc, char *argv[])
134 102 cdf_handle_error (cstatus);
135 103 }
136 104 else {
137   - value = (double *)malloc(sizeof(double)* (CDFmaxRec+1)*((datatype == CDF_EPOCH16)+1));
  105 + value = (double *)malloc(sizeof(double)* (RecCount + 1)*((datatype == CDF_EPOCH16)+1));
138 106 /******************* Get Epoch *************************/
139 107 if ((cstatus = CDFlib (SELECT_,
140 108 zVAR_, varN,
141 109 zVAR_RECNUMBER_, RecStart,
142   - zVAR_RECCOUNT_, CDFmaxRec+1,
  110 + zVAR_RECCOUNT_, RecCount + 1,
143 111 zVAR_RECINTERVAL_, RecInt,
144 112 zVAR_DIMINDICES_, indices,
145 113 zVAR_DIMCOUNTS_, counts,
... ... @@ -147,46 +115,35 @@ int main(int argc, char *argv[])
147 115 GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK)
148 116 cdf_handle_error (cstatus);
149 117 }
150   -
151 118  
152   -
153   - delta = (int *)malloc(sizeof(int)* CDFmaxRec);
154   - for (i = 1; i < CDFmaxRec+1; i++)
155   - {
  119 +
156 120 if (datatype == CDF_TIME_TT2000) {
157   - dbl_value_ = CDF_TT2000_to_UTC_EPOCH(int_value[i-1]);
158   - dbl_value = CDF_TT2000_to_UTC_EPOCH(int_value[i]);
159   - delta[i-1] = (int)(dbl_value - dbl_value_ + 50)/100;
  121 + dbl_value_ = CDF_TT2000_to_UTC_EPOCH(int_value[0]);
  122 + dbl_value = CDF_TT2000_to_UTC_EPOCH(int_value[1]);
  123 + sampling = (int)(dbl_value - dbl_value_ + 50)/100;
160 124 }
161 125 else {
162 126 if (datatype == CDF_EPOCH16) {
163   - epoch16[0] = value[2*(i-1)];
164   - epoch16[1] = value[2*(i-1)+1];
  127 + epoch16[0] = value[0];
  128 + epoch16[1] = value[1];
165 129 EPOCH16breakdown(epoch16, &year, &month, &day, &hour, &minute, &sec, &msec, &mksec, &nsec, &psec);
166   - value[i-1] = computeEPOCH(year, month, day, hour, minute, sec, msec);
167   - epoch16[0] = value[2*i];
168   - epoch16[1] = value[2*i+1];
  130 + value[0] = computeEPOCH(year, month, day, hour, minute, sec, msec);
  131 + epoch16[0] = value[2];
  132 + epoch16[1] = value[3];
169 133 EPOCH16breakdown(epoch16, &year, &month, &day, &hour, &minute, &sec, &msec, &mksec, &nsec, &psec);
170   - value[i] = computeEPOCH(year, month, day, hour, minute, sec, msec);
  134 + value[1] = computeEPOCH(year, month, day, hour, minute, sec, msec);
171 135 }
172   - delta[i-1] = (int)(value[i] - value[i-1] + 50)/100;
  136 + sampling = (int)(value[1] - value[0] + 50)/100;
173 137 }
174   - }
  138 +
175 139 // fprintf(stdout,"value %f\n", value[11]-value[10]);
176 140 if (datatype == CDF_TIME_TT2000) free(int_value);
177 141 else free(value);
178   - // fprintf(stdout,"delta %d\n", delta[0]);
179   - numEnough = CDFmaxRec/10;
180   - while (min[1] < numEnough) {
181   - fprintf(stdout,"minFalse %d\n", minFalse);
182   - find_min(delta, CDFmaxRec, minFalse, min);
183   - minFalse = min[0];
184   - }
  142 +
185 143  
186   - free(delta);
187 144 if ((cstatus = CDFlib(CLOSE_, CDF_, NULL_)) != CDF_OK)
188 145 cdf_handle_error (cstatus);
189 146  
190 147 // fprintf(stdout,"%d %f\n",min[1], (float)min[0]/100.0);
191   - fprintf(stdout,"%f\n",(float)min[0]/10.0);
  148 + fprintf(stdout,"%f\n",(float)sampling/10.0);
192 149 }
... ...
php/src/cdfsamplingsfromdata.c 0 → 100644
... ... @@ -0,0 +1,192 @@
  1 +/* $Id: timeResFromData.c,v 1.1 2010/08/31 10:32:55 budnik Exp $ */
  2 +
  3 +/** @file timeResFromData.c
  4 +* @brief Function to get CDAWEB dataset sampling times from data files
  5 +*/
  6 +#include <stdio.h>
  7 +#include <stdlib.h>
  8 +#include <cdf.h>
  9 +#include <string.h>
  10 +#include <time.h>
  11 +#include <math.h>
  12 +
  13 +#define fileName "temp.cdf"
  14 +#define badFile -100
  15 +
  16 +/*************************************
  17 + Global variables and structures
  18 +**************************************/
  19 +long CDFDims, // Number of dimensions in a CDF file
  20 + CDFVars, // Number of variables in a CDF file
  21 + CDFDimSizes[CDF_MAX_DIMS], // Dimension Sizes in a CDF file
  22 + CDFencoding, // Data encoding
  23 + CDFmajority, // Variable majority
  24 + CDFmaxRec, // max Record number
  25 + CDFAttrs; // number of CDF Attributes
  26 +// CDFdatatype;
  27 +
  28 +struct cdfvar { // CDF variable structure
  29 + char name[CDF_VAR_NAME_LEN+1];
  30 + long num; //variable number
  31 + long datatype;
  32 + long numElem; // variable dimensionality
  33 + long recVariance; // variable rec Variance
  34 + long dimVariances[CDF_MAX_DIMS]; // # of data values in dimSizes
  35 +} cdfVar;
  36 +
  37 +/*--------------------------------------------------------------------------
  38 + * Handles a CDF error.
  39 + *--------------------------------------------------------------------------*/
  40 +void cdf_handle_error(CDFstatus status)
  41 +{
  42 + char message[CDF_STATUSTEXT_LEN+1];
  43 +
  44 + CDFerror (status, message); /* Get the appropriate message */
  45 + fprintf (stderr, "%s\n", message);
  46 + exit(1);
  47 +}
  48 +
  49 +void find_min(int* delta, int nRecs, int minFalse, int* minVal)
  50 +{
  51 + int i, n, min;
  52 +
  53 + n = 1;
  54 + i = 0;
  55 + while (abs(delta[i]) <= minFalse) i++;
  56 + if (i < nRecs) {
  57 + min = abs(delta[i]);
  58 + // printf(" first MIN %d \n", min);
  59 + for (i = 1; i < nRecs; i++) {
  60 + // printf(" delta %d \n", delta[i]);
  61 + if (delta[i] == min) n++;
  62 + if (delta[i] < min && delta[i] > minFalse) {
  63 + min = delta[i];
  64 + n = 1;
  65 + }
  66 + }
  67 + } else {
  68 + min = -10;
  69 + n = nRecs;
  70 + }
  71 +
  72 + minVal[0] = min;
  73 + minVal[1] = n;
  74 + printf(" MIN %d %d\n", min, n);
  75 +}
  76 +
  77 +int main(int argc, char *argv[])
  78 +{
  79 + long RecStart = 0, RecCount, RecInt = 1;
  80 + long indices[1] = {0}, intervals[1] = {1}, counts[1] = {1};
  81 + long varN = -1;
  82 + long datatype = 0, attrN, maxEntry;
  83 + CDFstatus cstatus; // CDF status code
  84 + CDFid id;
  85 + double *value;
  86 + int *delta;
  87 + int i, minFalse = 0, numEnough;
  88 + int min[2] = {0, 0};
  89 + char attrValue[300];
  90 + float Sampling;
  91 + double epoch16[2], dbl_value, dbl_value_;
  92 + long year, month, day, hour, minute, sec, msec, mksec, nsec, psec;
  93 + long long *int_value;
  94 +
  95 +/*********************** Open CDF file *****************************/
  96 + if ((cstatus = CDFopen(fileName, &id)) != CDF_OK)
  97 + cdf_handle_error(cstatus);
  98 +
  99 +/*********** treat all vars as zVars with eliminated false dimensionality and get Nrecs **********/
  100 +
  101 + if ((cstatus = CDFlib(SELECT_, CDF_zMODE_, zMODEon2, NULL_)) != CDF_OK)
  102 + cdf_handle_error (cstatus);
  103 +
  104 + while (datatype != CDF_EPOCH && datatype != CDF_EPOCH16 && datatype != CDF_TIME_TT2000){
  105 + varN++;
  106 + if ((cstatus = CDFlib(SELECT_, zVAR_, varN,
  107 + GET_, zVAR_DATATYPE_, &datatype, NULL_)) != CDF_OK)
  108 + cdf_handle_error (cstatus);
  109 + // if (datatype == CDF_EPOCH16) break;
  110 + }
  111 + fprintf(stdout,"DATATYPE %d %d\n", varN, datatype);
  112 + if ((cstatus = CDFlib(SELECT_, zVAR_, varN,
  113 + GET_, zVAR_MAXREC_, &CDFmaxRec, NULL_)) != CDF_OK)
  114 + cdf_handle_error (cstatus);
  115 +
  116 + fprintf(stdout,"Max Recs %d\n", CDFmaxRec+1);
  117 + if (CDFmaxRec < 10) {
  118 + fprintf(stdout," %d\n", badFile);
  119 + exit (0);
  120 + }
  121 +
  122 + if ( datatype == CDF_TIME_TT2000 ) {
  123 + int_value = (long long *) malloc (sizeof(long long) * (CDFmaxRec+1));
  124 + /******************* Get Epoch *************************/
  125 + if ((cstatus = CDFlib (SELECT_,
  126 + zVAR_, varN,
  127 + zVAR_RECNUMBER_, RecStart,
  128 + zVAR_RECCOUNT_, CDFmaxRec+1,
  129 + zVAR_RECINTERVAL_, RecInt,
  130 + zVAR_DIMINDICES_, indices,
  131 + zVAR_DIMCOUNTS_, counts,
  132 + zVAR_DIMINTERVALS_, intervals,
  133 + GET_, zVAR_HYPERDATA_, int_value, NULL_)) != CDF_OK)
  134 + cdf_handle_error (cstatus);
  135 + }
  136 + else {
  137 + value = (double *)malloc(sizeof(double)* (CDFmaxRec+1)*((datatype == CDF_EPOCH16)+1));
  138 + /******************* Get Epoch *************************/
  139 + if ((cstatus = CDFlib (SELECT_,
  140 + zVAR_, varN,
  141 + zVAR_RECNUMBER_, RecStart,
  142 + zVAR_RECCOUNT_, CDFmaxRec+1,
  143 + zVAR_RECINTERVAL_, RecInt,
  144 + zVAR_DIMINDICES_, indices,
  145 + zVAR_DIMCOUNTS_, counts,
  146 + zVAR_DIMINTERVALS_, intervals,
  147 + GET_, zVAR_HYPERDATA_, value, NULL_)) != CDF_OK)
  148 + cdf_handle_error (cstatus);
  149 + }
  150 +
  151 +
  152 +
  153 + delta = (int *)malloc(sizeof(int)* CDFmaxRec);
  154 + for (i = 1; i < CDFmaxRec+1; i++)
  155 + {
  156 + if (datatype == CDF_TIME_TT2000) {
  157 + dbl_value_ = CDF_TT2000_to_UTC_EPOCH(int_value[i-1]);
  158 + dbl_value = CDF_TT2000_to_UTC_EPOCH(int_value[i]);
  159 + delta[i-1] = (int)(dbl_value - dbl_value_ + 50)/100;
  160 + }
  161 + else {
  162 + if (datatype == CDF_EPOCH16) {
  163 + epoch16[0] = value[2*(i-1)];
  164 + epoch16[1] = value[2*(i-1)+1];
  165 + EPOCH16breakdown(epoch16, &year, &month, &day, &hour, &minute, &sec, &msec, &mksec, &nsec, &psec);
  166 + value[i-1] = computeEPOCH(year, month, day, hour, minute, sec, msec);
  167 + epoch16[0] = value[2*i];
  168 + epoch16[1] = value[2*i+1];
  169 + EPOCH16breakdown(epoch16, &year, &month, &day, &hour, &minute, &sec, &msec, &mksec, &nsec, &psec);
  170 + value[i] = computeEPOCH(year, month, day, hour, minute, sec, msec);
  171 + }
  172 + delta[i-1] = (int)(value[i] - value[i-1] + 50)/100;
  173 + }
  174 + }
  175 + // fprintf(stdout,"value %f\n", value[11]-value[10]);
  176 + if (datatype == CDF_TIME_TT2000) free(int_value);
  177 + else free(value);
  178 + // fprintf(stdout,"delta %d\n", delta[0]);
  179 + numEnough = CDFmaxRec/10;
  180 + while (min[1] < numEnough) {
  181 + fprintf(stdout,"minFalse %d\n", minFalse);
  182 + find_min(delta, CDFmaxRec, minFalse, min);
  183 + minFalse = min[0];
  184 + }
  185 +
  186 + free(delta);
  187 + if ((cstatus = CDFlib(CLOSE_, CDF_, NULL_)) != CDF_OK)
  188 + cdf_handle_error (cstatus);
  189 +
  190 + // fprintf(stdout,"%d %f\n",min[1], (float)min[0]/100.0);
  191 + fprintf(stdout,"%f\n",(float)min[0]/10.0);
  192 +}
... ...
php/src/cdfvar_attr.c 0 → 100644
... ... @@ -0,0 +1,292 @@
  1 +/**
  2 +* @file cdfvarinfo.c
  3 +* @version $Id: cdfvarinfo.c,v 1.1 2010/08/31 10:32:55 budnik Exp $
  4 +* @brief
  5 +*/
  6 +
  7 +
  8 +#include <stdio.h>
  9 +#include <stdlib.h>
  10 +#include <cdf.h>
  11 +#include <string.h>
  12 +
  13 +#define MAX_FILE_NAME_LEN 120
  14 +
  15 +void cdf_status_handler (CDFstatus, char *);
  16 +char * cdf_str_datatype (long);
  17 +
  18 +typedef struct cdfvar { /* CDF variable structure */
  19 + char name[CDF_VAR_NAME_LEN+1];
  20 + long datatype;
  21 + long numElements; /* string length for CDF_CHAR, 1 otherwise */
  22 + long dimensionality; /* variable dimensionality */
  23 + long dimSizes[CDF_MAX_DIMS]; /* variable dimension sizes */
  24 + long recVariance; /* record variance */
  25 + long numRecs; /* # of records this variable contains */
  26 +} CDFvar;
  27 +
  28 +int main(int argc, char *argv[])
  29 +{
  30 +
  31 + CDFvar var;
  32 + CDFid id; /* CDF file ID */
  33 + CDFstatus status; /* CDF status code */
  34 +
  35 + long nZvars, nAttrs, attrId, attrScope, varId, datatype, numElements;
  36 + char attrName[CDF_ATTR_NAME_LEN+1];
  37 + char fileName[MAX_FILE_NAME_LEN], varName[CDF_VAR_NAME_LEN+1], attName[CDF_ATTR_NAME_LEN+1];
  38 + char msg[100];
  39 + int dummy, i;
  40 + char *cPtr;
  41 + signed char *scPtr;
  42 + short *sPtr;
  43 + int *iPtr;
  44 + float *fPtr;
  45 + double *dPtr;
  46 +
  47 +
  48 + if (argc <= 3)
  49 + exit(0); /* CDF input file name not specified */
  50 + else {
  51 + strcpy(fileName, argv[1]); /* Get the input file name */
  52 + strcpy(varName, argv[2]);
  53 + strcpy(attName, argv[3]);
  54 + }
  55 +
  56 + status = CDFlib (OPEN_, CDF_, fileName, &id, NULL_);
  57 +
  58 + if (status != CDF_OK) {
  59 + strcpy(msg, "OPEN_, CDF_, ");
  60 + strcat(msg, fileName);
  61 + cdf_status_handler (status, msg);
  62 + }
  63 +
  64 + /*---------------------------------------------------------------------------
  65 + * This routine retrievs the following information:
  66 + *
  67 + * nAttr - number of attributes (including global and variable)
  68 + * nZvars - number of zVariables
  69 + *
  70 + * CDF file can have both rVariables (old style) and zVariables (new style)
  71 + * simultaneously. zVariable is a superset of rVariable, and it is a lot
  72 + * more efficient and offers all the functionality a rVariable offers and
  73 + * more. Treat all CDF variables as zVariables.
  74 + *--------------------------------------------------------------------------*/
  75 +
  76 + status = CDFlib (SELECT_, CDF_zMODE_, zMODEon2,
  77 + GET_, CDF_NUMATTRS_, &nAttrs,
  78 + CDF_NUMzVARS_, &nZvars,
  79 + NULL_);
  80 + if (status != CDF_OK) cdf_status_handler(status, "GET_, CDF_FILEINFO_");
  81 +
  82 + // printf(" nAttrs %d Zvars %d\n",nAttrs, nZvars);
  83 + // printf ("Attributes:\n");
  84 +
  85 + for (attrId = 0; attrId < nAttrs; attrId++) {
  86 + status = CDFlib (SELECT_, ATTR_, attrId,
  87 + GET_, ATTR_NAME_, attrName, ATTR_SCOPE_, &attrScope,
  88 + NULL_);
  89 +
  90 + if (status != CDF_OK) cdf_status_handler (status, "SELECT_, ATTR_");
  91 + // printf("Attr %d %s %d\n", attrId, attrName, attrScope);
  92 + }
  93 +
  94 + // printf ("Variables:\n");
  95 + for (varId=0; varId < nZvars; varId++)
  96 + {
  97 + status = CDFlib (SELECT_,zVAR_, varId,
  98 + GET_, zVAR_NAME_, var.name,
  99 + zVAR_DATATYPE_, &var.datatype,
  100 + zVAR_NUMELEMS_, &var.numElements,
  101 + zVAR_NUMDIMS_, &var.dimensionality,
  102 + zVAR_DIMSIZES_, var.dimSizes,
  103 + zVAR_NUMRECS_, &var.numRecs,
  104 + zVAR_RECVARY_, &var.recVariance,
  105 + NULL_);
  106 + if (status != CDF_OK) cdf_status_handler (status, "GET_, zVARS_");
  107 +
  108 + if (strcmp(var.name, varName) == 0)
  109 + {
  110 + for (attrId = 0; attrId < nAttrs; attrId++) {
  111 + status = CDFlib (SELECT_, ATTR_, attrId,
  112 + GET_, ATTR_NAME_, attrName, ATTR_SCOPE_, &attrScope,
  113 + NULL_);
  114 +
  115 + if (status != CDF_OK) cdf_status_handler (status, "SELECT_, ATTR_");
  116 + if (attrScope == GLOBAL_SCOPE) continue;
  117 + if (strcasecmp(attrName, attName) != 0) continue;
  118 +
  119 + // printf("%d %s ", attrId, attrName);
  120 +
  121 + status = CDFlib (SELECT_, zENTRY_, varId,
  122 + GET_, zENTRY_DATATYPE_, &datatype,
  123 + zENTRY_NUMELEMS_, &numElements,
  124 + NULL_);
  125 + //printf("%d %s", numElements,cdf_str_datatype(datatype));
  126 + if (status == NO_SUCH_ENTRY) continue;
  127 +
  128 + if (status != CDF_OK) cdf_status_handler (status,"GET_ATTR_INFO_");
  129 +
  130 + switch (datatype)
  131 + {
  132 + case CDF_CHAR:
  133 + cPtr = (char *) malloc(numElements * sizeof(char) + 1);
  134 +
  135 + status = CDFlib (GET_, zENTRY_DATA_, cPtr, NULL_);
  136 + if (status != CDF_OK) cdf_status_handler (status, msg);
  137 + strcpy(&cPtr[numElements],"\0");
  138 + printf("%s\n", cPtr);
  139 + free(cPtr);
  140 + break;
  141 +
  142 + case CDF_BYTE:
  143 + case CDF_INT1:
  144 + scPtr = (signed char *) malloc (sizeof(signed char) * numElements);
  145 + status = CDFlib (GET_, zENTRY_DATA_, scPtr, NULL_);
  146 + if (status != CDF_OK) cdf_status_handler (status, msg);
  147 + free (scPtr);
  148 + break;
  149 +
  150 + case CDF_INT2:
  151 + case CDF_UCHAR:
  152 + case CDF_UINT1:
  153 + sPtr = (short *) malloc (sizeof(short) * numElements);
  154 + status = CDFlib (GET_, zENTRY_DATA_, sPtr, NULL_);
  155 + if (status != CDF_OK) cdf_status_handler (status, msg);
  156 + free (sPtr);
  157 + break;
  158 +
  159 + case CDF_INT4:
  160 + case CDF_UINT2:
  161 + iPtr = (int *) malloc (sizeof(int) * numElements);
  162 + status = CDFlib (GET_, zENTRY_DATA_, iPtr, NULL_);
  163 + if (status != CDF_OK) cdf_status_handler (status, msg);
  164 + printf("%d\n", *iPtr);
  165 + free (iPtr);
  166 + break;
  167 +
  168 + case CDF_FLOAT:
  169 + case CDF_REAL4:
  170 + fPtr = (float *) malloc (sizeof(float) * numElements);
  171 + status = CDFlib (GET_, zENTRY_DATA_, fPtr, NULL_);
  172 + if (status != CDF_OK) cdf_status_handler (status, msg);
  173 + printf("%8.1e\n", *fPtr);
  174 + free (fPtr);
  175 + break;
  176 +
  177 + case CDF_DOUBLE:
  178 + case CDF_REAL8:
  179 + case CDF_UINT4:
  180 + dPtr = (double *) malloc (sizeof(double) * numElements);
  181 +
  182 + status = CDFlib (GET_, zENTRY_DATA_, dPtr, NULL_);
  183 + if (status != CDF_OK) cdf_status_handler (status, msg);
  184 + printf("%8.1e\n", *dPtr);
  185 + free (dPtr);
  186 + break;
  187 +
  188 + case CDF_EPOCH: /* 8-byte real number */
  189 + dPtr = (double *) malloc (sizeof(double) * numElements);
  190 +
  191 + status = CDFlib (GET_, zENTRY_DATA_, dPtr, NULL_);
  192 + if (status != CDF_OK) cdf_status_handler (status, msg);
  193 +
  194 + free (dPtr);
  195 + break;
  196 +
  197 + case CDF_EPOCH16: /* 16-byte real number */
  198 + dPtr = (double *) malloc (sizeof(double) * numElements * 2);
  199 + status = CDFlib (GET_, zENTRY_DATA_, dPtr, NULL_);
  200 + if (status != CDF_OK) cdf_status_handler (status, msg);
  201 + free (dPtr);
  202 + break;
  203 +
  204 + default:
  205 + printf ("** Error in get_cdf_attribute: bad data type");
  206 + }
  207 + }
  208 + break;
  209 + }
  210 + }
  211 +
  212 + /* Close the CDF file */
  213 + status = CDFlib (CLOSE_, CDF_, NULL_);
  214 +
  215 +}
  216 +
  217 +
  218 +void cdf_status_handler (CDFstatus status, char *source)
  219 +{
  220 + char message[CDF_STATUSTEXT_LEN+1];
  221 +
  222 + CDFerror (status, message); /* Get the appropriate message */
  223 +
  224 + if (status < CDF_WARN) {
  225 + printf ("An error has occurred, halting...\n");
  226 + printf ("%s\n", message);
  227 + printf ("** Error source: %s\n", source);
  228 + exit (status);
  229 + }
  230 + else if (status < CDF_OK) {
  231 + printf ("Warning, function may not have compeleted as expected...\n");
  232 + printf ("%s\n", message);
  233 + }
  234 + else if (status > CDF_OK) {
  235 + printf ("Function compeleted successfully, but be advised that...\n");
  236 + printf ("%s\n", message);
  237 + }
  238 +}
  239 +
  240 +/*--------------------------------------------------------------------------
  241 + * This routine returns the string representation of the given CDF
  242 + * datatype.
  243 + *--------------------------------------------------------------------------*/
  244 +char * cdf_str_datatype (long type)
  245 +{
  246 + switch (type) {
  247 + case CDF_BYTE:
  248 + return "CDF_BYTE";
  249 +
  250 + case CDF_INT1:
  251 + return "CDF_INT1";
  252 +
  253 + case CDF_CHAR:
  254 + return "CDF_CHAR";
  255 +
  256 + case CDF_INT2:
  257 + return "CDF_INT2";
  258 +
  259 + case CDF_UCHAR:
  260 + return "CDF_UCHAR";
  261 +
  262 + case CDF_UINT1:
  263 + return "CDF_UINT1";
  264 +
  265 + case CDF_INT4:
  266 + return "CDF_INT4";
  267 +
  268 + case CDF_UINT2:
  269 + return "CDF_UINT2";
  270 +
  271 + case CDF_FLOAT:
  272 + return "CDF_FLOAT";
  273 +
  274 + case CDF_REAL4:
  275 + return "CDF_REAL4";
  276 +
  277 + case CDF_DOUBLE:
  278 + return "CDF_DOUBLE";
  279 +
  280 + case CDF_REAL8:
  281 + return "CDF_REAL8";
  282 +
  283 + case CDF_UINT4:
  284 + return "CDF_UINT4";
  285 +
  286 + case CDF_EPOCH:
  287 + return "CDF_EPOCH";
  288 +
  289 + case CDF_EPOCH16:
  290 + return "CDF_EPOCH16";
  291 + }
  292 +}
... ...
php/src/cdfvarinfo.c
... ... @@ -16,49 +16,42 @@ void cdf_status_handler (CDFstatus, char *);
16 16 char * cdf_str_datatype (long);
17 17  
18 18 typedef struct cdfvar { /* CDF variable structure */
19   - char name[CDF_VAR_NAME_LEN+1];
20   - long datatype;
21   - long numElements; /* string length for CDF_CHAR, 1 otherwise */
22   - long dimensionality; /* variable dimensionality */
23   - long dimSizes[CDF_MAX_DIMS]; /* variable dimension sizes */
24   - long recVariance; /* record variance */
25   - long numRecs; /* # of records this variable contains */
  19 + char name[CDF_VAR_NAME_LEN+1];
  20 + long datatype;
  21 + long numElements; /* string length for CDF_CHAR, 1 otherwise */
  22 + long dimensionality; /* variable dimensionality */
  23 + long dimSizes[CDF_MAX_DIMS]; /* variable dimension sizes */
  24 + long recVariance; /* record variance */
  25 + long numRecs; /* # of records this variable contains */
26 26 } CDFvar;
27 27  
28 28 int main(int argc, char *argv[])
29   -{
30   -
31   - CDFvar var;
32   - CDFid id; /* CDF file ID */
33   - CDFstatus status; /* CDF status code */
34   -
35   - long nZvars, nAttrs, attrId, attrScope, varId, datatype, numElements;
36   - char attrName[CDF_ATTR_NAME_LEN+1];
37   - char fileName[MAX_FILE_NAME_LEN], varName[CDF_VAR_NAME_LEN+1];
38   - char msg[100];
39   - int dummy, i;
40   - char *cPtr;
41   - signed char *scPtr;
42   - short *sPtr;
43   - int *iPtr;
44   - float *fPtr;
45   - double *dPtr;
  29 +{
  30 + CDFvar var;
  31 + CDFid id; /* CDF file ID */
  32 + CDFstatus status; /* CDF status code */
  33 +
  34 + long nZvars, nAttrs, attrId, attrScope, varId, datatype, numElements;
  35 + char attrName[CDF_ATTR_NAME_LEN+1];
  36 + char fileName[MAX_FILE_NAME_LEN], varName[CDF_VAR_NAME_LEN+1];
  37 + char msg[100];
  38 + int dummy, i;
46 39  
47 40  
48   - if (argc <= 2)
49   - exit(0); /* CDF input file name not specified */
50   - else {
51   - strcpy(fileName, argv[1]); /* Get the input file name */
52   - strcpy(varName, argv[2]);
53   - }
  41 + if (argc <= 2)
  42 + exit(0); /* CDF input file name not specified */
  43 + else {
  44 + strcpy(fileName, argv[1]); /* Get the input file name */
  45 + strcpy(varName, argv[2]);
  46 + }
54 47  
55   - status = CDFlib (OPEN_, CDF_, fileName, &id, NULL_);
  48 + status = CDFlib (OPEN_, CDF_, fileName, &id, NULL_);
56 49  
57   - if (status != CDF_OK) {
58   - strcpy(msg, "OPEN_, CDF_, ");
59   - strcat(msg, fileName);
60   - cdf_status_handler (status, msg);
61   - }
  50 + if (status != CDF_OK) {
  51 + strcpy(msg, "OPEN_, CDF_, ");
  52 + strcat(msg, fileName);
  53 + cdf_status_handler (status, msg);
  54 + }
62 55  
63 56 /*---------------------------------------------------------------------------
64 57 * This routine retrievs the following information:
... ... @@ -72,225 +65,114 @@ int main(int argc, char *argv[])
72 65 * more. Treat all CDF variables as zVariables.
73 66 *--------------------------------------------------------------------------*/
74 67  
75   - status = CDFlib (SELECT_, CDF_zMODE_, zMODEon2,
76   - GET_, CDF_NUMATTRS_, &nAttrs,
77   - CDF_NUMzVARS_, &nZvars,
78   - NULL_);
79   - if (status != CDF_OK) cdf_status_handler(status, "GET_, CDF_FILEINFO_");
80   -
81   - // printf(" nAttrs %d Zvars %d\n",nAttrs, nZvars);
82   -
83   -// printf ("Attributes:\n");
84   -
85   - for (attrId = 0; attrId < nAttrs; attrId++) {
86   - status = CDFlib (SELECT_, ATTR_, attrId,
87   - GET_, ATTR_NAME_, attrName, ATTR_SCOPE_, &attrScope,
88   - NULL_);
89   - if (status != CDF_OK) cdf_status_handler (status, "SELECT_, ATTR_");
90   -
91   -
92   - // printf("Attr %d %s %d\n", attrId, attrName, attrScope);
93   - }
94   -
95   - // printf ("Variables:\n");
96   - for (varId=0; varId < nZvars; varId++) {
97   -
98   - status = CDFlib (SELECT_,zVAR_, varId,
99   - GET_, zVAR_NAME_, var.name,
100   - zVAR_DATATYPE_, &var.datatype,
101   - zVAR_NUMELEMS_, &var.numElements,
102   - zVAR_NUMDIMS_, &var.dimensionality,
103   - zVAR_DIMSIZES_, var.dimSizes,
104   - zVAR_NUMRECS_, &var.numRecs,
105   - zVAR_RECVARY_, &var.recVariance,
106   - NULL_);
107   - if (status != CDF_OK) cdf_status_handler (status, "GET_, zVARS_");
  68 + status = CDFlib (SELECT_, CDF_zMODE_, zMODEon2,
  69 + GET_, CDF_NUMATTRS_, &nAttrs,
  70 + CDF_NUMzVARS_, &nZvars,
  71 + NULL_);
  72 +
  73 + if (status != CDF_OK) cdf_status_handler(status, "GET_, CDF_FILEINFO_");
  74 +
  75 + for (varId=0; varId < nZvars; varId++)
  76 + {
  77 + status = CDFlib (SELECT_,zVAR_, varId,
  78 + GET_, zVAR_NAME_, var.name,
  79 + zVAR_DATATYPE_, &var.datatype,
  80 + zVAR_NUMELEMS_, &var.numElements,
  81 + zVAR_NUMDIMS_, &var.dimensionality,
  82 + zVAR_DIMSIZES_, var.dimSizes,
  83 + zVAR_NUMRECS_, &var.numRecs,
  84 + zVAR_RECVARY_, &var.recVariance,
  85 + NULL_);
  86 +
  87 + if (status != CDF_OK) cdf_status_handler (status, "GET_, zVARS_");
108 88  
109   - if (strcmp(var.name, varName) == 0) {
110   -
111   - printf("%s %d %d ", cdf_str_datatype(var.datatype), var.dimensionality, var.numRecs);
112   - for (i = 0; i < var.dimensionality; i++) printf("%d ",var.dimSizes[i]);
113   - printf("\n");
114   -
115   - for (attrId = 0; attrId < nAttrs; attrId++) {
116   - status = CDFlib (SELECT_, ATTR_, attrId,
117   - GET_, ATTR_NAME_, attrName,
118   - ATTR_SCOPE_, &attrScope,
119   - NULL_);
120   -
121   - if (status != CDF_OK) cdf_status_handler (status, "SELECT_, ATTR_");
122   - if (attrScope == GLOBAL_SCOPE) continue;
123   -//printf("\n%d %s ", attrId, attrName);
124   - status = CDFlib (SELECT_, zENTRY_, varId,
125   - GET_, zENTRY_DATATYPE_, &datatype,
126   - zENTRY_NUMELEMS_, &numElements,
127   - NULL_);
128   -//printf("%d %s", numElements,cdf_str_datatype(datatype));
129   - if (status == NO_SUCH_ENTRY) continue;
130   -
131   - if (status != CDF_OK) cdf_status_handler (status,"GET_ATTR_INFO_");
132   -
133   - switch (datatype) {
134   - case CDF_CHAR:
135   - cPtr = (char *) malloc(numElements * sizeof(char) + 1);
136   - status = CDFlib (GET_, zENTRY_DATA_, cPtr, NULL_);
137   - if (status != CDF_OK) cdf_status_handler (status, msg);
138   -// printf(" %s", cPtr);
139   - free(cPtr);
140   - break;
141   -
142   - case CDF_BYTE:
143   - case CDF_INT1:
144   - scPtr = (signed char *) malloc (sizeof(signed char) * numElements);
145   - status = CDFlib (GET_, zENTRY_DATA_, scPtr, NULL_);
146   - if (status != CDF_OK) cdf_status_handler (status, msg);
147   - free (scPtr);
148   - break;
149   -
150   - case CDF_INT2:
151   - case CDF_UCHAR:
152   - case CDF_UINT1:
153   - sPtr = (short *) malloc (sizeof(short) * numElements);
154   - status = CDFlib (GET_, zENTRY_DATA_, sPtr, NULL_);
155   - if (status != CDF_OK) cdf_status_handler (status, msg);
156   - free (sPtr);
157   - break;
158   -
159   - case CDF_INT4:
160   - case CDF_UINT2:
161   - iPtr = (int *) malloc (sizeof(int) * numElements);
162   - status = CDFlib (GET_, zENTRY_DATA_, iPtr, NULL_);
163   - if (status != CDF_OK) cdf_status_handler (status, msg);
164   - free (iPtr);
165   - break;
166   -
167   - case CDF_FLOAT:
168   - case CDF_REAL4:
169   - fPtr = (float *) malloc (sizeof(float) * numElements);
170   - status = CDFlib (GET_, zENTRY_DATA_, fPtr, NULL_);
171   - if (status != CDF_OK) cdf_status_handler (status, msg);
172   - free (fPtr);
173   - break;
174   -
175   - case CDF_DOUBLE:
176   - case CDF_REAL8:
177   - case CDF_UINT4:
178   - dPtr = (double *) malloc (sizeof(double) * numElements);
179   -
180   - status = CDFlib (GET_, zENTRY_DATA_, dPtr, NULL_);
181   - if (status != CDF_OK) cdf_status_handler (status, msg);
182   -
183   - free (dPtr);
184   - break;
185   -
186   - case CDF_EPOCH: /* 8-byte real number */
187   - dPtr = (double *) malloc (sizeof(double) * numElements);
188   -
189   - status = CDFlib (GET_, zENTRY_DATA_, dPtr, NULL_);
190   - if (status != CDF_OK) cdf_status_handler (status, msg);
191   -
192   - free (dPtr);
193   - break;
194   -
195   - case CDF_EPOCH16: /* 16-byte real number */
196   - dPtr = (double *) malloc (sizeof(double) * numElements * 2);
197   - status = CDFlib (GET_, zENTRY_DATA_, dPtr, NULL_);
198   - if (status != CDF_OK) cdf_status_handler (status, msg);
199   - free (dPtr);
200   - break;
201   -
202   - default:
203   - printf ("** Error in get_cdf_attribute: bad data type");
204   - }
205   -
206   - }
207   - break;
  89 + if (strcmp(var.name, varName) == 0)
  90 + {
  91 + printf("%s %d %d ", cdf_str_datatype(var.datatype), var.dimensionality, var.numRecs);
  92 + for (i = 0; i < var.dimensionality; i++) printf("%d ",var.dimSizes[i]);
  93 +
  94 + printf("\n");
  95 + break;
  96 + }
208 97 }
209   - }
210   -
211   -
212   -
213   - /* Close the CDF file */
214   - status = CDFlib (CLOSE_, CDF_, NULL_);
215   -
  98 +
  99 + /* Close the CDF file */
  100 + status = CDFlib (CLOSE_, CDF_, NULL_);
216 101 }
217 102  
218 103  
219   -
220   -
221 104 void cdf_status_handler (CDFstatus status, char *source)
222 105 {
223   - char message[CDF_STATUSTEXT_LEN+1];
  106 + char message[CDF_STATUSTEXT_LEN+1];
224 107  
225   - CDFerror (status, message); /* Get the appropriate message */
  108 + CDFerror (status, message); /* Get the appropriate message */
226 109  
227   - if (status < CDF_WARN) {
228   - printf ("An error has occurred, halting...\n");
229   - printf ("%s\n", message);
230   - printf ("** Error source: %s\n", source);
231   - exit (status);
232   - }
233   - else if (status < CDF_OK) {
234   - printf ("Warning, function may not have compeleted as expected...\n");
235   - printf ("%s\n", message);
236   - }
237   - else if (status > CDF_OK) {
238   - printf ("Function compeleted successfully, but be advised that...\n");
239   - printf ("%s\n", message);
240   - }
241   -
242   -
  110 + if (status < CDF_WARN) {
  111 + printf ("An error has occurred, halting...\n");
  112 + printf ("%s\n", message);
  113 + printf ("** Error source: %s\n", source);
  114 + exit (status);
  115 + }
  116 + else if (status < CDF_OK) {
  117 + printf ("Warning, function may not have compeleted as expected...\n");
  118 + printf ("%s\n", message);
  119 + }
  120 + else if (status > CDF_OK) {
  121 + printf ("Function compeleted successfully, but be advised that...\n");
  122 + printf ("%s\n", message);
  123 + }
243 124 }
  125 +
244 126 /*--------------------------------------------------------------------------
245 127 * This routine returns the string representation of the given CDF
246 128 * datatype.
247 129 *--------------------------------------------------------------------------*/
248 130 char * cdf_str_datatype (long type)
249 131 {
250   - switch (type) {
251   - case CDF_BYTE:
252   - return "CDF_BYTE";
  132 + switch (type) {
  133 + case CDF_BYTE:
  134 + return "CDF_BYTE";
253 135  
254   - case CDF_INT1:
255   - return "CDF_INT1";
  136 + case CDF_INT1:
  137 + return "CDF_INT1";
256 138  
257   - case CDF_CHAR:
258   - return "CDF_CHAR";
  139 + case CDF_CHAR:
  140 + return "CDF_CHAR";
259 141  
260   - case CDF_INT2:
261   - return "CDF_INT2";
  142 + case CDF_INT2:
  143 + return "CDF_INT2";
262 144  
263   - case CDF_UCHAR:
264   - return "CDF_UCHAR";
  145 + case CDF_UCHAR:
  146 + return "CDF_UCHAR";
265 147  
266   - case CDF_UINT1:
267   - return "CDF_UINT1";
  148 + case CDF_UINT1:
  149 + return "CDF_UINT1";
268 150  
269   - case CDF_INT4:
270   - return "CDF_INT4";
  151 + case CDF_INT4:
  152 + return "CDF_INT4";
271 153  
272   - case CDF_UINT2:
273   - return "CDF_UINT2";
  154 + case CDF_UINT2:
  155 + return "CDF_UINT2";
274 156  
275   - case CDF_FLOAT:
276   - return "CDF_FLOAT";
  157 + case CDF_FLOAT:
  158 + return "CDF_FLOAT";
277 159  
278   - case CDF_REAL4:
279   - return "CDF_REAL4";
  160 + case CDF_REAL4:
  161 + return "CDF_REAL4";
280 162  
281   - case CDF_DOUBLE:
282   - return "CDF_DOUBLE";
  163 + case CDF_DOUBLE:
  164 + return "CDF_DOUBLE";
283 165  
284   - case CDF_REAL8:
285   - return "CDF_REAL8";
  166 + case CDF_REAL8:
  167 + return "CDF_REAL8";
286 168  
287   - case CDF_UINT4:
288   - return "CDF_UINT4";
  169 + case CDF_UINT4:
  170 + return "CDF_UINT4";
289 171  
290   - case CDF_EPOCH:
291   - return "CDF_EPOCH";
  172 + case CDF_EPOCH:
  173 + return "CDF_EPOCH";
292 174  
293   - case CDF_EPOCH16:
294   - return "CDF_EPOCH16";
295   - }
296   -}
  175 + case CDF_EPOCH16:
  176 + return "CDF_EPOCH16";
  177 + }
  178 +}
297 179 \ No newline at end of file
... ...
php/src/ncvar_attr.c 0 → 100644
... ... @@ -0,0 +1,76 @@
  1 +/*
  2 + * get parameter info from nc file
  3 + * args : ncfile varId infoId
  4 + * infoId :
  5 + * UNITS
  6 + * FILLVALUE
  7 + */
  8 +
  9 +#include <stdio.h>
  10 +#include <stdlib.h>
  11 +#include <string.h>
  12 +#include <netcdf.h>
  13 +
  14 +void check(int stat)
  15 +{
  16 + if (stat != NC_NOERR)
  17 + {
  18 + printf("error: %s\n", nc_strerror(stat));
  19 + exit(1);
  20 + }
  21 +}
  22 +
  23 +main(int argc, char **argv)
  24 +{
  25 + int ncID, varID;
  26 + size_t i, k;
  27 +// char varname[NC_MAX_NAME];
  28 + int stat = 0;
  29 + nc_type xtype;
  30 + char name_in[NC_MAX_NAME];
  31 + float number_attr;
  32 + int nattsp;
  33 +
  34 + if (argc <= 3) {
  35 + printf("Incorrect number of arguments\n");
  36 + exit(1);
  37 + }
  38 +
  39 + check(nc_open(argv[1],NC_WRITE|NC_SHARE,&ncID));
  40 +
  41 + check(nc_inq_varid(ncID, argv[2], &varID));
  42 + check(nc_inq_varnatts(ncID, varID, &nattsp));
  43 + // fprintf(stdout, "%d\n", nattsp);
  44 +
  45 + for (i = 0; i < nattsp; i++) {
  46 + check(nc_inq_attname(ncID, varID, i, name_in));
  47 +
  48 + if (strcasecmp(name_in, argv[3]) == 0) {
  49 +
  50 + check(nc_inq_atttype(ncID, varID, name_in, &xtype));
  51 +
  52 + if (xtype == NC_CHAR) {
  53 + size_t attlen = 0;
  54 + check(nc_inq_attlen(ncID, varID, name_in, &attlen));
  55 + unsigned char *string_attr = (unsigned char *)malloc(attlen * sizeof(char*) + 1);
  56 +
  57 + check(nc_get_att(ncID, varID, name_in, string_attr));
  58 + strcpy(&string_attr[attlen],"\0");
  59 + fprintf(stdout, "%s\n", string_attr);
  60 + free(string_attr);
  61 + }
  62 + else {
  63 + check(nc_get_att(ncID, varID, name_in, &number_attr));
  64 + fprintf(stdout, "%e\n", number_attr);
  65 + }
  66 +
  67 + exit(0);
  68 + }
  69 + }
  70 +
  71 + stat = nc_close(ncID);
  72 + fprintf(stdout, "undefined\n");
  73 + exit(0);
  74 +}
  75 +
  76 +
... ...
php/uploadFile.php
... ... @@ -112,11 +112,23 @@
112 112 $nonStd = $_POST['nonstd'] ? $_POST['nonstd'] : null;
113 113 $timeLength = $_POST['timelength'] ? $_POST['timelength'] : null;
114 114 $doy = isset($_POST['doy']) ? $_POST['doy'] : null;
  115 + $sampling = isset($_POST['smpl']) ? $_POST['smpl'] : null;
  116 + $min_sampling = isset($_POST['min_manual_sampling']) ? $_POST['min_manual_sampling'] : null;
  117 + $max_sampling = isset($_POST['max_manual_sampling']) ? $_POST['max_manual_sampling'] : null;
  118 +
  119 + if ($sampling == "auto" && $timeSmplg == "variable"
  120 + && (strtolower($fileFrmt) == "cdf" || strtolower($fileFrmt) == "nc")) {
  121 + $response = array('success' => false, 'error' => " : Auto-definition of variable sampling for $fileFrmt isn't implemented yet.
  122 + Use manual sampling definition");
  123 + die(json_encode($response));
  124 + }
  125 +
115 126 $sampData = isset($_POST['sampData']) ? $_POST['sampData'] : null;
116 127 $sampFileName = isset($_POST['sampFileName']) ? $_POST['sampFileName'] : null;
117 128  
118 129 $allFormats = array('fileFormat' => $fileFrmt, 'timeFormat' => $timeFrmt, 'doy' => $doy,
119   - 'timeSampling' => $timeSmplg, 'nonStandard' => $nonStd, 'timeLength' => $timeLength);
  130 + 'timeSampling' => $timeSmplg, 'nonStandard' => $nonStd, 'timeLength' => $timeLength,
  131 + 'samplingType' => $sampling, 'min_sampling' => $min_sampling, 'max_sampling' => $max_sampling);
120 132  
121 133 if ($_POST['filesrc'] == 'URL') $fromURL = true;
122 134 else $fromURL = false;
... ...