Commit 33fb4c3066db3910d6cdd39a07cf937903a65ba4

Authored by Elena Budnik
2 parents 9b94f8bc 5a3191ba

Merge branch 'upload-check-mask' into 'master'

Upload check mask

See merge request !31
help/fileMask
1   -<h2>WORKING WITH FILE MASKS</h2><br/>
  1 +<h2>WORKING WITH FILE MASKS</h2>
2 2 To simplify the life you may organize uploaded files in the groups (folders) using File Masks.<br/><br/>
3 3 For example files <br/>
4 4 <i>ac_h0_mfi_20090828_v05.cdf; ac_h0_mfi_20090829_v05.cdf; ac_h0_mfi_20090830_v05.cdf</i>
... ... @@ -21,5 +21,6 @@ In the above example mask &lt;b&gt;&lt;i&gt;ac_h0_mfi_&lt;/i&gt;&lt;/b&gt; is more common than &lt;b&gt;&lt;i&gt;ac_
21 21 replace <b><i>ac_h0_mfi_</i></b> with <b><i>ac_h0_mfi_2009</i></b> or <b><i>ac_h0_mfi_200908</i></b>.
22 22 <li>Association of different types of files with one mask (ac_h1_mfi..., ac_h2_mfi...,
23 23 ac_h2_mfi => ac_h) could produce an error.
  24 +<li>Association of the parameters from one file with different masks produces an error
24 25 </ul>
25 26  
... ...
help/myDataHOWTO
... ... @@ -2,5 +2,5 @@
2 2 Define parameter from the file: check variable in case of cdf, vot, netcdf formats
3 3 or select column[s] in case of ASCII. After <b>Saving</b> the parameter -
4 4 it appears in the <b>My Data</b> parameters tree of WS Explorer. Don't forget about possibility
5   - to use the <b>Mask</b> while defining a paarmeter.
  5 + to use the <b>Mask</b> while defining a parameter.
6 6  
7 7 \ No newline at end of file
... ...
js/app/views/MyDataUI.js
... ... @@ -367,6 +367,49 @@ Ext.define(&#39;amdaUI.MyDataUI&#39;, {
367 367 basicForm.setValues({start: start, size : size});
368 368 },
369 369  
  370 + checkMask : function(mask) {
  371 + if (mask.indexOf('*') < 0) {
  372 + if (mask.length < 6) {
  373 + myDesktopApp.warningMsg('Mask cannot be shorter than 6 letters');
  374 + return false;
  375 + }
  376 + if (this.fileObject.get('fileName').indexOf(mask) !== 0) {
  377 + myDesktopApp.warningMsg('No correspondance between '+mask+' and '+this.fileObject.get('fileName'));
  378 + return false;
  379 + }
  380 + }
  381 +
  382 + if (mask.indexOf('*') == 0) {
  383 + myDesktopApp.warningMsg("Mask should not start with *");
  384 + return false;
  385 + }
  386 +
  387 + if (mask.indexOf('*') != mask.lastIndexOf('*')) {
  388 + myDesktopApp.warningMsg("Mask can include only one *");
  389 + return false;
  390 + }
  391 +
  392 + var maskParts = mask.split('*');
  393 + if (this.fileObject.get('fileName').indexOf(maskParts[0]) !== 0) {
  394 + myDesktopApp.warningMsg('No correspondance between '+mask+' and '+this.fileObject.get('fileName'));
  395 + return false;
  396 + }
  397 +
  398 + if (maskParts.length == 2) {
  399 + if (this.fileObject.get('fileName').indexOf(maskParts[1]) < 0) {
  400 + myDesktopApp.warningMsg('No correspondance between ' +mask+' and '+this.fileObject.get('fileName'));
  401 + return false;
  402 + }
  403 + }
  404 +
  405 + if ((maskParts[0].length + maskParts[1].length) < 6) {
  406 + myDesktopApp.warningMsg('Mask cannot be shorter than 6 letters');
  407 + return false;
  408 + }
  409 +
  410 + return true;
  411 + },
  412 +
370 413 /*
371 414 * Configurations
372 415 *
... ... @@ -813,6 +856,15 @@ Ext.define(&#39;amdaUI.MyDataUI&#39;, {
813 856 return;
814 857 }
815 858 }
  859 +
  860 + var maskName = form.findField('mask').getValue();
  861 + if (maskName !== this.fileObject.get('fileName')) {
  862 + if (!this.checkMask(maskName)) {
  863 + form.findField('mask').setValue(this.fileObject.get('fileName'));
  864 + return;
  865 + }
  866 + }
  867 +
816 868 var nameField = form.findField('mydataName');
817 869 if (this.updateObject(nameField))
818 870 {
... ...