Commit 0fea5567bf802cb5463bfc3f3dec30b894ac1b4c

Authored by Benjamin Renard
1 parent 2f1cd444

First step for rework of TT and Catalog cache managers

js/app/views/CatalogUI.js
... ... @@ -10,77 +10,77 @@
10 10 Ext.define('amdaUI.CatalogUI', {
11 11 extend: 'Ext.container.Container',
12 12 alias: 'widget.panelCatalog',
13   -
  13 +
14 14 requires: [
15 15 'Ext.grid.plugin.BufferedRenderer',
16 16 'amdaUI.StatisticalPlug'
17 17 ],
18   -
  18 +
19 19 isCatalog : true,
20 20 statics: {
21 21 COL_TO_HIDE_DURATION : 'colToHideDuration'
22 22 },
23   -
  23 +
24 24 constructor: function(config) {
25 25 this.init(config);
26 26 this.callParent(arguments);
27 27 this.toReconfigure = true;
28   -
  28 +
29 29 if (this.object) {
30 30 this.loadObject();
31 31 }
32 32 },
33   -
34   - setObject : function (object, toReconfigure) {
35   - if (toReconfigure)
  33 +
  34 + setObject : function (object, toReconfigure) {
  35 + if (toReconfigure)
36 36 this.toReconfigure = true;
37   - // set object
38   - this.object = object;
  37 + // set object
  38 + this.object = object;
39 39 // load object into view
40 40 this.loadObject();
41 41 // show the default duration column
42 42 this.TTGrid.headerCt.getGridColumns();
43   -
  43 +
44 44 Ext.Array.each(this.TTGrid.headerCt.getGridColumns(), function(item,index,all){
45 45 // if item is the default duration column
46 46 if ( item.id == amdaUI.CatalogUI.COL_TO_HIDE_DURATION+'2' ) {
47 47 // show this column
48 48 item.show();
49 49 }
50   - });
  50 + });
51 51 // fire the refresh event (to statistical plugin)
52 52 this.fireEvent("refresh");
53 53 // global event
54 54 myDesktopApp.EventManager.fireEvent("refresh");
55 55 },
56   -
  56 +
57 57 /**
58 58 * set params description into this.object
59 59 */
60 60 setParamInfo : function(parameters) {
61 61 var params = [];
62 62 Ext.Array.each(parameters, function(item, index) {
63   - params[index] = item;
  63 + params[index] = item;
64 64 }, this);
65   -
  65 +
66 66 this.object.set('parameters', params);
67   - this.object.set('nbParameters', params.length);
  67 + this.object.set('nbParameters', params.length);
68 68 },
69   -
  69 +
70 70 /**
71 71 * update this.object from form
72   - */
73   - updateObject : function(){
74   - // get the basic form
75   - var basicForm = this.formPanel.getForm();
  72 + */
  73 + updateObject : function(){
  74 + // get the basic form
  75 + var basicForm = this.formPanel.getForm();
76 76 var updateStatus = true;
77 77  
78 78 var fieldsWithoutName = basicForm.getFields().items;
79 79 Ext.Array.each(fieldsWithoutName, function(item, index,allItems){
80   - if(item !== this.fieldName) {
  80 + if(item !== this.fieldName) {
81 81 if (!item.isValid()) {
82 82 // set update isn't allowed
83   - updateStatus = false;
  83 + updateStatus = false;
84 84 }
85 85 }
86 86 }, this);
... ... @@ -88,10 +88,10 @@ Ext.define('amdaUI.CatalogUI', {
88 88 if (updateStatus) {
89 89 /// real object update
90 90 // update TimeTable object with the content of form
91   - basicForm.updateRecord(this.object);
  91 + basicForm.updateRecord(this.object);
92 92 }
93   - // return the update status
94   - return updateStatus;
  93 + // return the update status
  94 + return updateStatus;
95 95 },
96 96  
97 97 addInterval : function(start, stop) {
... ... @@ -111,12 +111,12 @@ Ext.define('amdaUI.CatalogUI', {
111 111 }
112 112 }, this);
113 113 },
114   -
  114 +
115 115 updateCount : function() {
116   - this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount());
  116 + this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount());
117 117 this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals'));
118   - },
119   - generateTT : function(catId){
  118 + },
  119 + generateTT : function(catId){
120 120 var catObj = Ext.create('amdaModel.TimeTable');
121 121 var timeTabNode = Ext.create('amdaModel.TimeTableNode',{leaf : true});
122 122 catObj.set('relatedCatalogId', catId)
... ... @@ -133,17 +133,17 @@ Ext.define('amdaUI.CatalogUI', {
133 133 // edit newNode into Parameter Module with node as contextNode
134 134 timeTabNode.editInModule();
135 135 });
136   -
137   -
138   -
  136 +
  137 +
  138 +
139 139 },
140   - onAfterInit: function(result, e)
  140 + onAfterInit: function(result, e)
141 141 {
142 142 var me = this;
143   - if (!result) {
  143 + if (!result) {
144 144 myDesktopApp.errorMsg(e.message);
145 145 Ext.defer(function(){Ext.Msg.toFront()},10);
146   -
  146 +
147 147 return;
148 148 }
149 149 else if (!result.success)
... ... @@ -156,9 +156,9 @@ Ext.define('amdaUI.CatalogUI', {
156 156 Ext.defer(function(){Ext.Msg.toFront()},10);
157 157 return;
158 158 }
159   -
160   - if (me.toReconfigure)
161   - {
  159 +
  160 + if (me.toReconfigure)
  161 + {
162 162 var fieldsConfig = [
163 163 {
164 164 name : 'start',
... ... @@ -250,7 +250,7 @@ Ext.define('amdaUI.CatalogUI', {
250 250 text: 'Start Time',
251 251 format: 'Y-m-d\\TH:i:s',
252 252 sortable : true,
253   - dataIndex: 'start',
  253 + dataIndex: 'start',
254 254 width : 120,
255 255 menuDisabled: false,
256 256 editor : {
... ... @@ -264,7 +264,7 @@ Ext.define('amdaUI.CatalogUI', {
264 264 xtype: 'datecolumn',
265 265 text: 'Stop Time',
266 266 format: 'Y-m-d\\TH:i:s',
267   - sortable : true,
  267 + sortable : true,
268 268 dataIndex: 'stop',
269 269 width : 120,
270 270 menuDisabled: false,
... ... @@ -279,9 +279,9 @@ Ext.define('amdaUI.CatalogUI', {
279 279 xtype: 'gridcolumn',
280 280 text: 'Duration (hour)',
281 281 sortable : true,
282   - dataIndex: 'durationHour',
  282 + dataIndex: 'durationHour',
283 283 width : 120,
284   - menuDisabled: false,
  284 + menuDisabled: false,
285 285 hidden:true,
286 286 id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION+'1',
287 287 renderer: function(value) {
... ... @@ -297,9 +297,9 @@ Ext.define('amdaUI.CatalogUI', {
297 297 xtype: 'gridcolumn',
298 298 text: 'Duration (Min)',
299 299 sortable : true,
300   - dataIndex: 'durationMin',
  300 + dataIndex: 'durationMin',
301 301 width : 120,
302   - menuDisabled: false,
  302 + menuDisabled: false,
303 303 hidden:false,
304 304 id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION+'2',
305 305 renderer: function(value) {
... ... @@ -315,7 +315,7 @@ Ext.define('amdaUI.CatalogUI', {
315 315 xtype: 'gridcolumn',
316 316 text: 'Duration (Sec)',
317 317 sortable : true,
318   - dataIndex: 'durationSec',
  318 + dataIndex: 'durationSec',
319 319 width : 120,
320 320 menuDisabled: false,
321 321 hidden:true,
... ... @@ -327,7 +327,7 @@ Ext.define('amdaUI.CatalogUI', {
327 327 beforeshow : function(){
328 328 updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION+'3');
329 329 }
330   - }
  330 + }
331 331 }
332 332 ];
333 333  
... ... @@ -339,7 +339,13 @@ Ext.define('amdaUI.CatalogUI', {
339 339 text: obj.name,
340 340 sortable : true,
341 341 dataIndex: 'param'+(index+2),
342   - menuDisabled: false
  342 + menuDisabled: false,
  343 + listeners: {
  344 + 'sortchange' : function(ct, column, direction, eOpts) {
  345 + //console.log(column);
  346 + },
  347 + scope: this
  348 + }
343 349 };
344 350 switch (obj.type) {
345 351 case 1: //dateTime
... ... @@ -353,7 +359,7 @@ Ext.define('amdaUI.CatalogUI', {
353 359 }
354 360 return value;
355 361 }
356   -
  362 +
357 363 });
358 364 column = Ext.apply({}, column, {
359 365 xtype: 'datecolumn',
... ... @@ -371,6 +377,7 @@ Ext.define('amdaUI.CatalogUI', {
371 377 type: 'string'
372 378 });
373 379 column = Ext.apply({}, column, {
  380 + xtype: 'gridcolumn',
374 381 width : 50. * parseInt(obj.size),
375 382 editor: 'textfield'
376 383 });
... ... @@ -383,7 +390,7 @@ Ext.define('amdaUI.CatalogUI', {
383 390 fields: fieldsConfig,
384 391 autoDestroy: false,
385 392 pageSize : 200,
386   - buffered : true,
  393 + buffered : true,
387 394 purgePageCount: 0,
388 395 remoteSort: true,
389 396 proxy: {
... ... @@ -400,77 +407,77 @@ Ext.define('amdaUI.CatalogUI', {
400 407 },
401 408 listeners: {
402 409 scope : me,
403   - load: function(store,records) {
  410 + load: function(store,records) {
404 411 // myDesktopApp.EventManager.fireEvent('refresh');
405 412 me.TTGrid.getView().refresh();
406 413 me.TTGrid.getSelectionModel().refresh();
407 414 me.updateCount();
408 415 //Statistical plugin
409 416 this.fireEvent("refresh");
410   - }
  417 + }
411 418 }
412 419 });
413   -
  420 +
414 421 me.TTGrid.reconfigure(store, columnsConfig);
415 422 }
416 423 me.TTGrid.getSelectionModel().deselectAll();
417   - //
  424 + //
418 425 // // clear filters
419 426 // me.TTGrid.getStore().clearFilter(true);
420   - //
  427 + //
421 428 // clear sort
422 429 me.TTGrid.getStore().sorters.clear();
423   - // me.TTGrid.getStore().sorters = new Ext.util.MixedCollection();
424   -
  430 + me.TTGrid.getStore().sorters = new Ext.util.MixedCollection();
  431 +
425 432 //set cache token to the Catalog object
426 433 me.object.set('cacheToken', result.token);
427   - me.setParamInfo(result.parameters);
  434 + me.setParamInfo(result.parameters);
428 435 me.TTGrid.getStore().load();
429   -
  436 +
430 437 me.status = result.status;
431 438 //Statistical plugin
432 439 me.fireEvent("refresh");
433 440 },
434   -
  441 +
435 442 /**
436 443 * load object catalog into this view
437 444 */
438   - loadObject : function(){
  445 + loadObject : function(){
439 446 // load object into form
440 447 this.formPanel.getForm().loadRecord(this.object);
441   -
  448 +
442 449 this.status = null;
443   -
444   - if (this.object.get('fromPlugin') && (this.object.get('objName') != '')){
  450 +
  451 + if (this.object.get('fromPlugin') && (this.object.get('objName') != '')){
445 452 if (this.object.get('objFormat') && this.object.get('objFormat') != ''){
446 453 //From uploaded file
447   - AmdaAction.initTTCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), this.isCatalog, this.onAfterInit, this);
  454 + AmdaAction.initObjectCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), this.isCatalog, this.onAfterInit, this);
448 455 }
449 456 else {
450   - //From tmp object (ie Statistics result)
451   - AmdaAction.initTTCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), this.isCatalog, this.onAfterInit, this);
  457 + //From tmp object (ie Statistics result)
  458 + AmdaAction.initObjectCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), this.isCatalog, this.onAfterInit, this);
452 459 }
453 460 }
454 461 else {
455 462 var typeTT = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id).linkedNode.data.nodeType;
456   -
  463 +
457 464 if (this.object.get('id') == '') {
458   - AmdaAction.initTTCache(this.isCatalog, this.object.get('nbParameters'), this.onAfterInit,this);
459   - }
  465 + AmdaAction.initObjectCache(this.isCatalog, this.object.get('nbParameters'), this.onAfterInit,this);
  466 + }
460 467 else {
461 468 //From existing TT file
462   - AmdaAction.initTTCacheFromTT(this.object.get('id'), typeTT, this.onAfterInit, this);
  469 + AmdaAction.initObjectCacheFromTT(this.object.get('id'), typeTT, this.onAfterInit, this);
463 470 }
464 471 }
465 472 //Statistical plugin
466 473 this.fireEvent("refresh");
467 474 },
468   -
  475 +
469 476 checkIntervalsStatusForSave : function(onStatusOk) {
470 477 onStatusOk();
471 478 },
472   -
473   - /*
  479 +
  480 + /*
474 481 * save method called by Save button
475 482 */
476 483 saveProcess : function(toRename)
... ... @@ -478,22 +485,22 @@ Ext.define('amdaUI.CatalogUI', {
478 485 var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
479 486 // store / columns are the same - not needed to reconfigure grid
480 487 this.toReconfigure = false;
481   -
  488 +
482 489 // if save shared catalog
483 490 if (module.contextNode && (module.contextNode.get('id') == 'sharedcatalog-treeRootNode'))
484   - {
485   - module.linkedNode = null;
  491 + {
  492 + module.linkedNode = null;
486 493 module.createLinkedNode();
487   - module.createObject(this.object.getJsonValues());
488   - var obj = module.linkedNode.get('object');
  494 + module.createObject(this.object.getJsonValues());
  495 + var obj = module.linkedNode.get('object');
489 496 // synchronisation of objects
490 497 this.object = obj;
491 498 module.linkedNode.create();
492 499 }
493 500 // if the name has been modified this is a creation
494   - else if (this.fclose()) {
495   - if (this.object.isModified('name') || this.object.get('fromPlugin')) {
496   - // if object already has an id : it's a 'rename' of an existing
  501 + else if (this.fclose()) {
  502 + if (this.object.isModified('name') || this.object.get('fromPlugin')) {
  503 + // if object already has an id : it's a 'rename' of an existing
497 504 if (this.object.get('id')){
498 505 // the context Node is the parent node of current edited one
499 506 var contextNode = module.linkedNode.parentNode;
... ... @@ -503,46 +510,46 @@ Ext.define('amdaUI.CatalogUI', {
503 510 module.linkedNode.set('contextNode',contextNode);
504 511 // create a new object linked
505 512 module.createObject(this.object.getJsonValues());
506   -
507   - var obj = module.linkedNode.get('object');
  513 +
  514 + var obj = module.linkedNode.get('object');
508 515 // synchronisation of objects
509 516 this.object = obj;
510 517 if (toRename) module.linkedNode.toRename = true;
511   - }
  518 + }
512 519 module.linkedNode.create({callback : function() {module.linkedNode.update();}, scope : this});
513 520 } else {
514   - //update
  521 + //update
515 522 module.linkedNode.update();
516   - }
  523 + }
517 524 }
518 525 },
519   -
  526 +
520 527 /**
521 528 * overwrite metod called by Save button
522 529 */
523   - overwriteProcess : function(btn) {
  530 + overwriteProcess : function(btn) {
524 531 if (btn == 'cancel') return;
525   -
  532 +
526 533 this.fieldName.clearInvalid();
527 534 this.saveProcess(true);
528 535 },
529   -
  536 +
530 537 /**
531   - * Check if changes were made before closing window
  538 + * Check if changes were made before closing window
532 539 * @return true if changes
533   - */
  540 + */
534 541 fclose : function() {
535 542 if (this.status == null)
536 543 return false;
537   -
  544 +
538 545 var isDirty = this.formPanel.getForm().isDirty() || (this.status.isModified) || (this.status.nbModified > 0) || (this.status.nbNew > 0);
539 546 return isDirty;
540 547 },
541   -
542   - init : function (config)
543   - {
  548 +
  549 + init : function (config)
  550 + {
544 551 this.object = config.object;
545   -
  552 +
546 553 this.fieldName = new Ext.form.field.Text({
547 554 fieldLabel: 'Name',
548 555 allowBlank : false,
... ... @@ -556,7 +563,7 @@ Ext.define('amdaUI.CatalogUI', {
556 563 return this.validFlag;
557 564 }
558 565 });
559   -
  566 +
560 567 var cellEditing = Ext.create('Ext.grid.plugin.CellEditing',{
561 568 // clicksToEdit: 2,
562 569 onEditComplete : function(ed, value, startValue) {
... ... @@ -571,7 +578,7 @@ Ext.define('amdaUI.CatalogUI', {
571 578 me.setActiveEditor(null);
572 579 me.setActiveColumn(null);
573 580 me.setActiveRecord(null);
574   -
  581 +
575 582 context.value = value;
576 583 if (!me.validateEdit()) {
577 584 me.editing = false;
... ... @@ -581,16 +588,16 @@ Ext.define('amdaUI.CatalogUI', {
581 588 // Only update the record if the new value is different than the
582 589 // startValue. When the view refreshes its el will gain focus
583 590 if (!record.isEqual(value, startValue)) {
584   - var obj = {};
585   -
  591 + var obj = {};
  592 +
586 593 obj['cacheId'] = record.get('cacheId');
587 594 obj['isCatalog'] = true;
588   - obj[activeColumn.dataIndex] = value;
589   -
  595 + obj[activeColumn.dataIndex] = value;
  596 +
590 597 //Interval is modified on the server side
591 598 me.editing = true;
592   -
593   - AmdaAction.modifyTTCacheInterval(obj, function (result, e) {
  599 +
  600 + AmdaAction.modifyTTCacheInterval(obj, function (result, e) {
594 601 var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
595 602 if (module)
596 603 module.getUiContent().status = result.status;
... ... @@ -613,32 +620,32 @@ Ext.define('amdaUI.CatalogUI', {
613 620 else
614 621 me.editing = false;
615 622 }
616   - }
  623 + }
617 624 });
618 625  
619   - this.TTGrid = Ext.create('Ext.grid.Panel', {
  626 + this.TTGrid = Ext.create('Ext.grid.Panel', {
620 627 height: 530,
621 628 columns: [ ],
622 629 frame: true,
623   - columnLines: true,
  630 + columnLines: true,
624 631 selModel: {pruneRemoved: false},
625 632 // selType: 'cellmodel',
626 633 plugins: [ cellEditing, { ptype : 'bufferedrenderer'} ],
627 634 dockedItems: [{
628   - xtype: 'toolbar',
  635 + xtype: 'toolbar',
629 636 items: [{
630 637 iconCls: 'icon-add',
631 638 scope: this,
632   - handler: function(){
  639 + handler: function(){
633 640 cellEditing.cancelEdit();
634 641 var store = this.TTGrid.getStore();
635   -
  642 +
636 643 var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0];
637 644 var row = 0;
638 645 if (selection)
639 646 row = store.indexOf(selection) + 1;
640 647 this.TTGrid.getSelectionModel().deselectAll();
641   -
  648 +
642 649 var me = this;
643 650 AmdaAction.addTTCacheInterval({'index' : row, 'isCatalog' : true}, function (result, e) {
644 651 this.status = result.status;
... ... @@ -647,7 +654,7 @@ Ext.define('amdaUI.CatalogUI', {
647 654 callback : function(records, options, success) {
648 655 me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function() {
649 656 me.TTGrid.getView().select(row);
650   - cellEditing.startEditByPosition({row: row, column: 1});
  657 + cellEditing.startEditByPosition({row: row, column: 1});
651 658 }, me);
652 659 }
653 660 });
... ... @@ -661,9 +668,9 @@ Ext.define('amdaUI.CatalogUI', {
661 668 scope: this,
662 669 handler: function(){
663 670 var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0];
664   - if (selection)
  671 + if (selection)
665 672 {
666   - var rowId = selection.get('cacheId');
  673 + var rowId = selection.get('cacheId');
667 674 this.TTGrid.getSelectionModel().deselectAll();
668 675 AmdaAction.removeTTCacheIntervalFromId(rowId, this.isCatalog, function (result, e) {
669 676 this.status = result.status;
... ... @@ -676,34 +683,39 @@ Ext.define('amdaUI.CatalogUI', {
676 683 }]
677 684 }]
678 685 });
679   -
680   - this.formPanel = Ext.create('Ext.form.Panel', {
  686 +
  687 + this.TTGrid.down('.headercontainer').on('sortchange', function(ct, column, direction, eOpts) {
  688 + console.log(column);
  689 +console.log(direction);
  690 +});
  691 +
  692 + this.formPanel = Ext.create('Ext.form.Panel', {
681 693 region : 'center',
682 694 layout: 'hbox',
683 695 model : 'amdaModel.Catalog',
684   - trackResetOnLoad : true, // reset to the last loaded record
  696 + trackResetOnLoad : true, // reset to the last loaded record
685 697 bodyStyle: {background : '#dfe8f6'},
686 698 defaults: { border : false, align: 'stretch', bodyStyle: {background : '#dfe8f6'}, padding: '3'},
687 699 fieldDefaults: { labelWidth: 80, labelAlign : 'top' },
688   - items: [{
689   - xtype: 'form',
  700 + items: [{
  701 + xtype: 'form',
690 702 flex: 1,
691 703 buttonAlign: 'left',
692   - // title : 'Information',
  704 + // title : 'Information',
693 705 layout: {type: 'vbox', pack: 'start', align: 'stretch'},
694 706 items : [
695 707 this.fieldName,
696 708 {
697 709 xtype: 'fieldcontainer',
698   - layout: 'hbox',
  710 + layout: 'hbox',
699 711 items: [{
700 712 xtype:'datefield', fieldLabel:'Creation date',
701   - name: 'created', disabled: true,
  713 + name: 'created', disabled: true,
702 714 hideTrigger: true, format: 'Y/m/d H:i:s'
703   - },
704   - { xtype: 'splitter' },
  715 + },
  716 + { xtype: 'splitter' },
705 717 { xtype:'textfield', fieldLabel: 'Intervals', name: 'nbIntervals', disabled: true }
706   - ]
  718 + ]
707 719 },
708 720 {
709 721 xtype: 'textarea',
... ... @@ -714,28 +726,28 @@ Ext.define('amdaUI.CatalogUI', {
714 726 {
715 727 xtype: 'component',
716 728 height: 90
717   - }],
  729 + }],
718 730 dockedItems:[{
719 731 xtype: 'toolbar',
720   - dock: 'bottom',
  732 + dock: 'bottom',
721 733 ui: 'footer',
722 734 items: [{
723 735 type: 'button',
724 736 text: 'Create New Catalog',
725 737 scope : this,
726   - handler: function ()
727   - {
728   - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
729   -
  738 + handler: function ()
  739 + {
  740 + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
  741 +
730 742 if (!module) return;
731   -
  743 +
732 744 module.createLinkedNode();
733 745 module.createObject();
734   -
  746 +
735 747 var obj = module.linkedNode.get('object');
736   -
  748 +
737 749 var me = this;
738   -
  750 +
739 751 Ext.Msg.prompt('Define Parameters', 'Please enter parameters number:', function(btn, text){
740 752 if (btn == 'ok'){
741 753 module.createLinkedNode();
... ... @@ -751,27 +763,27 @@ Ext.define('amdaUI.CatalogUI', {
751 763 me.setObject(obj,true);
752 764 }
753 765 }, this);
754   -
  766 +
755 767 }
756 768 }]
757 769 },
758   -
759   - {
  770 +
  771 + {
760 772 xtype: 'toolbar',
761   - dock: 'bottom',
  773 + dock: 'bottom',
762 774 ui: 'footer',
763 775 items: [
764 776 {
765 777 type: 'button',
766 778 text: 'Save',
767 779 scope : this,
768   - handler: function ()
  780 + handler: function ()
769 781 {
770 782 if (this.updateObject())
771 783 {
772   - var basicForm = this.formPanel.getForm();
  784 + var basicForm = this.formPanel.getForm();
773 785 // if there's at least one record in the store of TTGrid
774   - if (this.TTGrid.getStore().getTotalCount() > 0)
  786 + if (this.TTGrid.getStore().getTotalCount() > 0)
775 787 {
776 788 // update TimeTable object which the content of form
777 789 basicForm.updateRecord(this.object);
... ... @@ -779,10 +791,10 @@ Ext.define('amdaUI.CatalogUI', {
779 791 var me = this;
780 792 this.checkIntervalsStatusForSave(function () {
781 793 //Name validation
782   - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
783   -
  794 + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
  795 +
784 796 if (!module) return;
785   - module.linkedNode.isValidName(me.fieldName.getValue(), function (res)
  797 + module.linkedNode.isValidName(me.fieldName.getValue(), function (res)
786 798 {
787 799 if (!res) {
788 800 me.fieldName.validFlag = 'Error during object validation';
... ... @@ -790,14 +802,14 @@ Ext.define('amdaUI.CatalogUI', {
790 802 me.fieldName.validate();
791 803 return;
792 804 }
793   -
  805 +
794 806 if (!res.valid) {
795 807 if (res.error) {
796   - if (res.error.search('subtree') != -1) {
797   - Ext.MessageBox.show({title:'Warning',
  808 + if (res.error.search('subtree') != -1) {
  809 + Ext.MessageBox.show({title:'Warning',
798 810 msg: res.error+'<br/>Do you want to overwrite it?',
799 811 width: 300,
800   - buttons: Ext.MessageBox.OKCANCEL,
  812 + buttons: Ext.MessageBox.OKCANCEL,
801 813 fn : me.overwriteProcess,
802 814 icon: Ext.MessageBox.WARNING,
803 815 scope : me
... ... @@ -814,35 +826,35 @@ Ext.define(&#39;amdaUI.CatalogUI&#39;, {
814 826 me.fieldName.validate();
815 827 return;
816 828 }
817   -
  829 +
818 830 me.fieldName.validFlag = true;
819 831 me.fieldName.validate();
820 832 me.saveProcess(false);
821 833 });
822   - });
823   - }
  834 + });
  835 + }
824 836 else {
825 837 Ext.Msg.alert('No intervals', 'Your catalog is invalid, <br>you must have at least one interval');
826 838 }
827 839 }
828   - }
  840 + }
829 841 },{
830 842 type: 'button',
831 843 text: 'Reset',
832 844 scope : this,
833 845 handler: function() {
834   - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
  846 + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id);
835 847 // module.createLinkedNode();
836 848 // module.createObject();
837   - this.setObject(module.getLinkedNode().get('object'), true);
838   - }
839   - },
840   -// {
  849 + this.setObject(module.getLinkedNode().get('object'), true);
  850 + }
  851 + },
  852 +// {
841 853 // type: 'button',
842 854 // text: 'Share',
843 855 // scope : this,
844   -// handler: function() {
845   -// var me = this;
  856 +// handler: function() {
  857 +// var me = this;
846 858 // myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id, true, function (module) {
847 859 // var catalog = module.getLinkedNode().get('object');
848 860 // module.shareCatalog({'name' : catalog.get('text'), 'id' : catalog.get('id')});
... ... @@ -852,48 +864,48 @@ Ext.define(&#39;amdaUI.CatalogUI&#39;, {
852 864  
853 865 ]
854 866 },
855   - //statistical info
  867 + //statistical info
856 868 {
857 869 xtype: 'toolbar',
858   - dock: 'bottom',
  870 + dock: 'bottom',
859 871 ui: 'footer',
860   - items:[{
  872 + items:[{
861 873 xtype: 'button',
862 874 text: 'Statistical info',
863 875 scope: this,
864   - //dock: 'bottom',
  876 + //dock: 'bottom',
865 877 //ui: 'footer',
866 878 handler: function() {
867 879 this.fireEvent('info','catalogUI');
868 880 }
869 881 },
870   - {
  882 + {
871 883 type: 'button',
872 884 text: 'Visualize',
873 885 scope: this,
874 886 handler: function() {
875 887 var me = this;
876   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) {
  888 + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) {
877 889 //temporary linked node - as Visu module is 'pseudo' interactive - no 'save', no 'execute'
878 890 var temporaryNode = Ext.create('amdaModel.CatalogNode', { leaf : true });
879   - if (temporaryNode) temporaryNode.set('object',me.object);
  891 + if (temporaryNode) temporaryNode.set('object',me.object);
880 892 module.setLinkedNode(temporaryNode);
881   -
882   - module.createWindow();
883   - });
  893 +
  894 + module.createWindow();
  895 + });
884 896 }
885 897 }
886 898 ]
887 899 },
888 900 {
889 901 xtype: 'toolbar',
890   - dock: 'bottom',
  902 + dock: 'bottom',
891 903 ui: 'footer',
892   - items:[{
  904 + items:[{
893 905 xtype: 'button',
894 906 text: 'Generate Time Table',
895 907 scope: this,
896   - //dock: 'bottom',
  908 + //dock: 'bottom',
897 909 //ui: 'footer',
898 910 handler: function() {
899 911 this.generateTT(this.object.get('id'));
... ... @@ -902,24 +914,24 @@ Ext.define(&#39;amdaUI.CatalogUI&#39;, {
902 914 ]
903 915 },
904 916 {
905   - xtype: 'form',
  917 + xtype: 'form',
906 918 bodyStyle: {background : '#dfe8f6'},
907 919 //padding: '3',
908 920 flex: 2,
909   - items : [ this.TTGrid ]
910   - }]
911   - });
912   -
  921 + items : [ this.TTGrid ]
  922 + }]
  923 + });
  924 +
913 925 this.TTGrid.getSelectionModel().on('selectionchange', function(selModel,selections) {
914   - this.TTGrid.down('#delete').setDisabled(selections.length === 0);
915   - }, this);
916   -
  926 + this.TTGrid.down('#delete').setDisabled(selections.length === 0);
  927 + }, this);
  928 +
917 929 var myConf = {
918 930 layout: 'border',
919   - items: [
920   - this.formPanel,
  931 + items: [
  932 + this.formPanel,
921 933 {
922   - xtype: 'panel',
  934 + xtype: 'panel',
923 935 region: 'south',
924 936 title: 'Information',
925 937 collapsible: true,
... ... @@ -928,16 +940,16 @@ Ext.define(&#39;amdaUI.CatalogUI&#39;, {
928 940 autoHide: false,
929 941 bodyStyle: 'padding:5px',
930 942 iconCls: 'icon-information',
931   - loader:
  943 + loader:
932 944 {
933 945 autoLoad: true,
934 946 url: helpDir+'catalogHOWTO'
935   - }
  947 + }
936 948 }
937 949 ] ,
938   - plugins: [ {ptype: 'statisticalPlugin'} ]
939   - };
940   - Ext.apply (this, Ext.apply(arguments, myConf));
  950 + plugins: [ {ptype: 'statisticalPlugin'} ]
  951 + };
  952 + Ext.apply (this, Ext.apply(arguments, myConf));
941 953 }
942   -
943   -});
  954 +
  955 +});
... ...
js/app/views/TimeTableUI.js
... ... @@ -11,7 +11,7 @@
11 11 Ext.define('amdaUI.TimeTableUI', {
12 12 extend: 'Ext.container.Container',
13 13 alias: 'widget.panelTimeTable',
14   -
  14 +
15 15 requires: [
16 16 'Ext.ux.grid.FiltersFeature',
17 17 'Ext.ux.grid.filter.DateFilter',
... ... @@ -20,14 +20,14 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
20 20 'amdaUI.StatisticalPlug',
21 21 'Ext.grid.plugin.BufferedRenderer'
22 22 ],
23   -
  23 +
24 24 statics: {
25 25 COL_TO_HIDE : 'colToHide'
26 26 },
27   -
  27 +
28 28 status: null,
29   -
30   - constructor: function(config) {
  29 +
  30 + constructor: function(config) {
31 31 this.init(config);
32 32 this.callParent(arguments);
33 33 // load object into view
... ... @@ -38,42 +38,42 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
38 38 * set the current editing object
39 39 * this method will be used on timetable edition when this win is already opened
40 40 */
41   - setObject : function (object)
  41 + setObject : function (object)
42 42 {
43 43 // set object
44 44 this.object = object;
45   -
  45 +
46 46 // load object into view
47 47 this.loadObject();
48   -
  48 +
49 49 // show the default duration column
50 50 this.TTGrid.headerCt.getGridColumns();
51   -
  51 +
52 52 Ext.Array.each(this.TTGrid.headerCt.getGridColumns(), function(item,index,all){
53 53 // if item is the default duration column
54 54 if ( item.id == amdaUI.TimeTableUI.COL_TO_HIDE+'2' ) {
55 55 // show this column
56 56 item.show();
57 57 }
58   - });
  58 + });
59 59 // fire the refresh event (to statistical plugin)
60 60 this.fireEvent("refresh");
61 61 // global event
62 62 myDesktopApp.EventManager.fireEvent("refresh");
63 63 },
64   -
  64 +
65 65 /**
66 66 * load object timetable into this view
67 67 */
68   - loadObject : function(){
  68 + loadObject : function(){
69 69 // load object into form
70 70 this.formPanel.getForm().loadRecord(this.object);
71   -
  71 +
72 72 this.status = null;
73   -
  73 +
74 74 //
75 75 var me = this;
76   -
  76 +
77 77 var onAfterInit = function(result, e) {
78 78 if (!result || !result.success)
79 79 {
... ... @@ -83,63 +83,63 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
83 83 myDesktopApp.errorMsg('Unknown error during cache initialisation');
84 84 return;
85 85 }
86   -
  86 +
87 87 me.TTGrid.getSelectionModel().deselectAll();
88   -
  88 +
89 89 // clear filters
90 90 me.TTGrid.getStore().clearFilter(true);
91 91 me.TTGrid.filters.clearFilters();
92   -
  92 +
93 93 //clear sort
94 94 me.TTGrid.getStore().sorters.clear();
95 95 //me.TTGrid.getStore().sorters = new Ext.util.MixedCollection();
96   -
  96 +
97 97 //set cache token to the Time Table object
98 98 me.object.set('cacheToken', result.token);
99   -
  99 +
100 100 me.TTGrid.getStore().load();
101   -
  101 +
102 102 me.status = result.status;
103   -
  103 +
104 104 //Statistical plugin
105 105 me.fireEvent("refresh");
106 106 };
107   -
  107 +
108 108 if (this.object.get('fromPlugin'))
109 109 {
110 110 if (this.object.get('objFormat') && this.object.get('objFormat') != '')
111 111 {
112 112 //From uploaded file
113   - AmdaAction.initTTCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), false, onAfterInit);
  113 + AmdaAction.initObjectCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), false, onAfterInit);
114 114 }
115 115 else
116 116 {
117 117 //From tmp object (ie Search result)
118   - AmdaAction.initTTCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), false, onAfterInit);
  118 + AmdaAction.initObjectCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), false, onAfterInit);
119 119 }
120 120 }
121 121 else if(this.object.get('relatedCatalogId') != '')
122   - {
  122 + {
123 123 var pathern=this.object.get('relatedCatalogId').split('_')[0] ;
124 124 catType='';
125 125 if(pathern=='cat')
126 126 catType=' catalog' ;
127 127 if(pathern=='sharedcatalog')
128 128 catType='sharedcatalog' ;
129   - AmdaAction.initTTCacheFromCatalog(this.object.get('relatedCatalogId'), catType, onAfterInit);
  129 + AmdaAction.initObjectCacheFromCatalog(this.object.get('relatedCatalogId'), catType, onAfterInit);
130 130 }
131   - else
  131 + else
132 132 {
133 133 var typeTT = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id).linkedNode.data.nodeType;
134 134 if (this.object.get('id') == '')
135 135 {
136 136 //Init empty cache
137   - AmdaAction.initTTCache(false,0,onAfterInit);
138   - }
  137 + AmdaAction.initObjectCache(false,0,onAfterInit);
  138 + }
139 139 else
140 140 {
141 141 //From existing TT file
142   - AmdaAction.initTTCacheFromTT(this.object.get('id'), typeTT, onAfterInit);
  142 + AmdaAction.initObjectCacheFromTT(this.object.get('id'), typeTT, onAfterInit);
143 143 }
144 144 }
145 145 },
... ... @@ -150,17 +150,17 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
150 150 updateObject : function()
151 151 {
152 152 this.updateCount();
153   -
  153 +
154 154 // get the basic form
155   - var basicForm = this.formPanel.getForm();
  155 + var basicForm = this.formPanel.getForm();
156 156 var updateStatus = true;
157 157  
158 158 var fieldsWithoutName = basicForm.getFields().items;
159 159 Ext.Array.each(fieldsWithoutName, function(item, index,allItems){
160   - if(item !== this.fieldName) {
  160 + if(item !== this.fieldName) {
161 161 if (!item.isValid()) {
162 162 // set update isn't allowed
163   - updateStatus = false;
  163 + updateStatus = false;
164 164 }
165 165 }
166 166 }, this);
... ... @@ -168,40 +168,40 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
168 168 if (updateStatus) {
169 169 /// real object update
170 170 // update TimeTable object with the content of form
171   - basicForm.updateRecord(this.object);
  171 + basicForm.updateRecord(this.object);
172 172 }
173 173 // return the update status
174   - return updateStatus;
175   - },
  174 + return updateStatus;
  175 + },
176 176  
177   - updateCount : function()
  177 + updateCount : function()
178 178 {
179 179 this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount());
180 180 this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals'));
181 181 },
182   -
183   - /*
  182 +
  183 + /*
184 184 * save method called by Save button
185 185 */
186 186 saveProcess : function(toRename)
187 187 {
188   - var timeTableModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id);
189   -
  188 + var timeTableModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id);
  189 +
190 190 // if the name has been modified this is a creation
191 191 if (timeTableModule.contextNode && (timeTableModule.contextNode.data.id == 'sharedtimeTable-treeRootNode'))
192   - {
193   - timeTableModule.linkedNode = null;
  192 + {
  193 + timeTableModule.linkedNode = null;
194 194 timeTableModule.createLinkedNode();
195   - timeTableModule.createObject(this.object.getJsonValues());
196   - var ttobj = timeTableModule.linkedNode.get('object');
  195 + timeTableModule.createObject(this.object.getJsonValues());
  196 + var ttobj = timeTableModule.linkedNode.get('object');
197 197 // synchronisation of objects
198 198 this.object = ttobj;
199 199 timeTableModule.linkedNode.create();
200 200 }
201 201 else if (this.fclose()) /*TimeTable object has been modified*/
202 202 {
203   - if (this.object.isModified('name') || this.object.get('fromPlugin'))
204   - {
  203 + if (this.object.isModified('name') || this.object.get('fromPlugin'))
  204 + {
205 205 // if object already has an id : it's a 'rename' of an existing TimeTable
206 206 if (this.object.get('id'))
207 207 {
... ... @@ -213,17 +213,17 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
213 213 timeTableModule.linkedNode.set('contextNode',contextNode);
214 214 // create a new object linked
215 215 timeTableModule.createObject(this.object.getJsonValues());
216   -
217   - var ttobj = timeTableModule.linkedNode.get('object');
  216 +
  217 + var ttobj = timeTableModule.linkedNode.get('object');
218 218 // synchronisation of objects
219 219 this.object = ttobj;
220   -
  220 +
221 221 if (toRename) timeTableModule.linkedNode.toRename = true;
222   - }
  222 + }
223 223 timeTableModule.linkedNode.create({callback : function ($action) {
224 224 if (timeTableModule.linkedNode.get('object').get('fromPlugin'))
225 225 timeTableModule.linkedNode.get('object').set('fromPlugin',false);
226   - timeTableModule.linkedNode.update();},
  226 + timeTableModule.linkedNode.update();},
227 227 scope : this});
228 228 } else {
229 229 //update
... ... @@ -231,20 +231,20 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
231 231 }
232 232 }
233 233 },
234   -
  234 +
235 235 /**
236 236 * overwrite metod called by Save button
237 237 */
238 238 overwriteProcess : function(btn)
239   - {
  239 + {
240 240 if (btn == 'cancel') return;
241   -
  241 +
242 242 this.fieldName.clearInvalid();
243   - this.saveProcess(true);
244   -
  243 + this.saveProcess(true);
  244 +
245 245 },
246   -
247   - addInterval : function(start, stop)
  246 +
  247 + addInterval : function(start, stop)
248 248 {
249 249 var row = this.TTGrid.getStore().getTotalCount();
250 250 var me = this;
... ... @@ -262,11 +262,11 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
262 262 }
263 263 }, this);
264 264 },
265   -
266   - init : function(config)
267   - {
  265 +
  266 + init : function(config)
  267 + {
268 268 this.object = config.object;
269   -
  269 +
270 270 this.fieldName = new Ext.form.field.Text({
271 271 fieldLabel: 'Name*',
272 272 allowBlank : false,
... ... @@ -281,7 +281,7 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
281 281 return this.validFlag;
282 282 }
283 283 });
284   -
  284 +
285 285 this.formPanel = new Ext.form.Panel({
286 286 bodyStyle: {background : '#dfe8f6'},
287 287 id: 'formTimeTable',
... ... @@ -291,22 +291,22 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
291 291 border : false,
292 292 fieldDefaults: { labelWidth: 80 },
293 293 items: [
294   - this.fieldName,
  294 + this.fieldName,
295 295 {
296 296 xtype: 'fieldcontainer',
297 297 layout: 'hbox',
298 298 fieldLabel:'Creation date',
299 299 items: [
300 300 {
301   - xtype:'datefield', width: 180,
302   - name: 'created', disabled: true,
  301 + xtype:'datefield', width: 180,
  302 + name: 'created', disabled: true,
303 303 hideTrigger: true, format: 'Y/m/d H:i:s'
304 304 },
305 305 { xtype:'component', width: 20 },
306 306 { xtype:'displayfield', value: 'Intervals:', width: 50 },
307 307 { xtype:'component', width: 8 },
308 308 { xtype:'textfield', name: 'nbIntervals', disabled: true, width: 70 }
309   - ]
  309 + ]
310 310 },
311 311 {
312 312 xtype: 'textarea',
... ... @@ -323,7 +323,7 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
323 323 ]
324 324  
325 325 });
326   -
  326 +
327 327 var store = Ext.create('Ext.data.Store', {
328 328 model: 'amdaModel.Interval',
329 329 autoDestroy: false,
... ... @@ -332,10 +332,10 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
332 332 autoLoad: true,
333 333 purgePageCount: 0,
334 334 remoteSort: true,
335   - listeners: {
  335 + listeners: {
336 336 load: function(store,records) {
337   -
338   - // alert('nb of records in store:'+records.length );
  337 +
  338 + // alert('nb of records in store:'+records.length );
339 339 myDesktopApp.EventManager.fireEvent('refresh');
340 340 this.TTGrid.getView().refresh();
341 341 this.TTGrid.getSelectionModel().refresh();
... ... @@ -366,21 +366,21 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
366 366 this.fireEvent("refresh");
367 367 },
368 368 scope : this
369   - }
370   - });
371   -
  369 + }
  370 + });
  371 +
372 372 var filters = {
373 373 ftype: 'filters',
374 374 encode: true, // json encode the filter query
375 375 local: false, // defaults to false (remote filte
376 376 filters: [
377 377 { type: 'numeric', dataIndex: 'durationHour'},
378   - { type: 'numeric', dataIndex: 'durationMin'},
379   - { type: 'numeric', dataIndex: 'durationSec'},
  378 + { type: 'numeric', dataIndex: 'durationMin'},
  379 + { type: 'numeric', dataIndex: 'durationSec'},
380 380 { type: 'date', dataIndex: 'start', dateFormat: 'Y-m-d'},
381 381 { type: 'date', dataIndex: 'stop', dateFormat: 'Y-m-d' }
382 382 ]
383   - };
  383 + };
384 384  
385 385 var cellEditing = Ext.create('Ext.grid.plugin.CellEditing',{
386 386 onEditComplete : function(ed, value, startValue) {
... ... @@ -395,7 +395,7 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
395 395 me.setActiveEditor(null);
396 396 me.setActiveColumn(null);
397 397 me.setActiveRecord(null);
398   -
  398 +
399 399 context.value = value;
400 400 if (!me.validateEdit()) {
401 401 me.editing = false;
... ... @@ -421,13 +421,13 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
421 421 me.editing = false;
422 422 return;
423 423 }
424   -
  424 +
425 425 //context.grid.getSelectionModel().deselectAll();
426 426 //Interval is modified on the server side
427 427 me.editing = true;
428   -
  428 +
429 429 AmdaAction.modifyTTCacheInterval(obj, function (result, e) {
430   -
  430 +
431 431 var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id);
432 432 if (ttModule)
433 433 ttModule.getUiContent().status = result.status;
... ... @@ -438,7 +438,7 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
438 438 context.view.bufferedRenderer.scrollTo(context.rowIdx, true, function() {
439 439 me.fireEvent('edit', me, context);
440 440 me.editing = false;
441   - }, me);
  441 + }, me);
442 442 }
443 443 });
444 444 }
... ... @@ -451,7 +451,7 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
451 451 me.editing = false;
452 452 }
453 453 }
454   -
  454 +
455 455 });
456 456  
457 457 this.TTGrid = Ext.create('Ext.grid.Panel', {
... ... @@ -459,7 +459,7 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
459 459 features: [filters],
460 460 columnLines: true,
461 461 selModel: {pruneRemoved: false},
462   - columns: [
  462 + columns: [
463 463 {
464 464 xtype: 'rownumberer',
465 465 width: 50,
... ... @@ -473,10 +473,10 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
473 473 return msg;
474 474 }
475 475 },
476   - {
  476 + {
477 477 header: 'Start Time', dataIndex: 'start', width: 120,
478   - editor: { xtype:'datefield', allowBlank:false, hideTrigger: true, format : 'Y-m-d\\TH:i:s'},
479   - renderer: function(value){
  478 + editor: { xtype:'datefield', allowBlank:false, hideTrigger: true, format : 'Y-m-d\\TH:i:s'},
  479 + renderer: function(value){
480 480 if (value != null) {
481 481 if(Ext.isDate(value)){
482 482 return Ext.Date.format(value, 'Y-m-d\\TH:i:s');
... ... @@ -488,8 +488,8 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
488 488 }
489 489 }
490 490 },
491   - {
492   - header: 'Stop Time', dataIndex: 'stop', width: 120,
  491 + {
  492 + header: 'Stop Time', dataIndex: 'stop', width: 120,
493 493 editor: { xtype: 'datefield', allowBlank: false, hideTrigger: true, format : 'Y-m-d\\TH:i:s'},
494 494 renderer: function(value) {
495 495 if (value != null) {
... ... @@ -502,7 +502,7 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
502 502 return value;
503 503 }
504 504 }
505   - },
  505 + },
506 506 {
507 507 header: 'Duration (hour)', width: 120, dataIndex: 'durationHour',
508 508 id: amdaUI.TimeTableUI.COL_TO_HIDE+'1',
... ... @@ -524,7 +524,7 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
524 524 });
525 525 }
526 526 }
527   - },
  527 + },
528 528 {
529 529 header: 'Duration (min)', width: 120, dataIndex: 'durationMin',
530 530 id: amdaUI.TimeTableUI.COL_TO_HIDE+'2',
... ... @@ -545,7 +545,7 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
545 545 });
546 546 }
547 547 }
548   - },
  548 + },
549 549 {
550 550 header: 'Duration (sec)', width: 120, dataIndex: 'durationSec',
551 551 id: amdaUI.TimeTableUI.COL_TO_HIDE+'3',
... ... @@ -568,22 +568,22 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
568 568 }
569 569 }
570 570 }
571   - ],
  571 + ],
572 572 frame: true,
573 573 dockedItems: [{
574   - xtype: 'toolbar',
  574 + xtype: 'toolbar',
575 575 items: [{
576 576 iconCls: 'icon-add',
577 577 scope: this,
578 578 handler: function(){
579 579 cellEditing.cancelEdit();
580   -
  580 +
581 581 var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0];
582 582 var row = 0;
583 583 if (selection)
584 584 row = store.indexOf(selection) + 1;
585 585 this.TTGrid.getSelectionModel().deselectAll();
586   -
  586 +
587 587 var me = this;
588 588 AmdaAction.addTTCacheInterval({'index' : row}, function (result, e) {
589 589 this.status = result.status;
... ... @@ -592,8 +592,8 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
592 592 callback : function(records, options, success) {
593 593 me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function() {
594 594 me.TTGrid.getView().select(row);
595   - cellEditing.startEditByPosition({row: row, column: 1});
596   - }, me);
  595 + cellEditing.startEditByPosition({row: row, column: 1});
  596 + }, me);
597 597 }
598 598 });
599 599 }
... ... @@ -625,14 +625,14 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
625 625 handler: function () {
626 626 this.TTGrid.getStore().clearFilter(true);
627 627 this.TTGrid.filters.clearFilters();
628   - }
  628 + }
629 629 }
630   - ]
  630 + ]
631 631 }],
632 632 plugins: [ cellEditing, {ptype : 'bufferedrenderer'} ],
633 633 listeners : {
634 634 scope : this,
635   - edit : function(editor,e) {
  635 + edit : function(editor,e) {
636 636 if (e.record.get('stop') != null && e.record.get('start') != null) {
637 637 e.record.set('durationHour', (e.record.get('stop') - e.record.get('start'))/3600000.0);
638 638 e.record.set('durationMin', (e.record.get('stop') - e.record.get('start'))/60000.0);
... ... @@ -645,9 +645,9 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
645 645 });
646 646  
647 647 this.TTGrid.getSelectionModel().on('selectionchange', function(selModel,selections){
648   - this.TTGrid.down('#delete').setDisabled(selections.length === 0);
  648 + this.TTGrid.down('#delete').setDisabled(selections.length === 0);
649 649 }, this);
650   -
  650 +
651 651 var myConf = {
652 652 layout: 'border',
653 653 defaults: { layout: 'fit', border: false },
... ... @@ -658,8 +658,8 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
658 658 buttonAlign: 'left',
659 659 bodyStyle: {background : '#dfe8f6'},
660 660 padding: '5 5 5 5',
661   - layout: {type: 'hbox', pack: 'start', align: 'stretch'},
662   - items: [
  661 + layout: {type: 'hbox', pack: 'start', align: 'stretch'},
  662 + items: [
663 663 {
664 664 xtype: 'container',
665 665 flex: 3.6,
... ... @@ -672,26 +672,26 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
672 672 flex: 2.5,
673 673 id: 'operation'
674 674 }
675   - ]
676   - },
677   - {
  675 + ]
  676 + },
  677 + {
678 678 xtype: 'container',
679 679 border: false,
680 680 padding: '0 0 5 15',
681   - flex: 4,
  681 + flex: 4,
682 682 layout: 'fit',
683   - items: [ this.TTGrid ]
  683 + items: [ this.TTGrid ]
684 684 }
685 685 ],
686 686 fbar:[
687   - {
  687 + {
688 688 xtype: 'button',
689 689 text: 'Save',
690 690 width: 65,
691 691 scope : this,
692 692 handler: function () {
693 693 if (this.updateObject()){
694   - var basicForm = this.formPanel.getForm();
  694 + var basicForm = this.formPanel.getForm();
695 695 // if there's at least one record in the store of TTGrid
696 696 if (this.TTGrid.getStore().getTotalCount()>0) {
697 697 // update TimeTable object which the content of form
... ... @@ -700,7 +700,7 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
700 700 var me = this;
701 701 this.checkIntervalsStatusForSave(function () {
702 702 //Name validation
703   - var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id);
  703 + var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id);
704 704 if (!ttModule)
705 705 return;
706 706 ttModule.linkedNode.isValidName(me.fieldName.getValue(), function (res) {
... ... @@ -711,16 +711,16 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
711 711 me.fieldName.validate();
712 712 return;
713 713 }
714   -
  714 +
715 715 if (!res.valid)
716 716 {
717 717 if (res.error)
718 718 {
719   - if (res.error.search('subtree') != -1) {
720   - Ext.MessageBox.show({title:'Warning',
  719 + if (res.error.search('subtree') != -1) {
  720 + Ext.MessageBox.show({title:'Warning',
721 721 msg: res.error+'<br/>Do you want to overwrite it?',
722 722 width: 300,
723   - buttons: Ext.MessageBox.OKCANCEL,
  723 + buttons: Ext.MessageBox.OKCANCEL,
724 724 fn : me.overwriteProcess,
725 725 icon: Ext.MessageBox.WARNING,
726 726 scope : me
... ... @@ -738,36 +738,36 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
738 738 me.fieldName.validate();
739 739 return;
740 740 }
741   -
  741 +
742 742 me.fieldName.validFlag = true;
743 743 me.fieldName.validate();
744 744 me.saveProcess(false);
745 745 });
746   - });
  746 + });
747 747 } else {
748 748 // warning:
749 749 Ext.Msg.alert('No intervals', 'Your time table is invalid, <br>you must have at least one interval');
750 750 }
751 751 }
752   - }
753   - },{
  752 + }
  753 + },{
754 754 xtype: 'button',
755 755 text: 'Reset',
756 756 width: 65,
757 757 scope: this,
758 758 handler: function() {
759   - var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id);
  759 + var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id);
760 760 ttModule.createLinkedNode();
761 761 ttModule.createObject();
762 762 this.setObject(ttModule.getLinkedNode().get('object'));
763 763 }
764   - }
  764 + }
765 765 ]
766   - },
  766 + },
767 767 {
768 768 xtype: 'panel', region: 'south',
769 769 title: 'Information',
770   - collapsible: true,
  770 + collapsible: true,
771 771 collapseMode: 'header',
772 772 height: 100,
773 773 autoHide: false,
... ... @@ -776,25 +776,25 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
776 776 loader: {
777 777 autoLoad: true,
778 778 url: helpDir+'timetableHOWTO'
779   - }
  779 + }
780 780 }
781 781 ],
782   - plugins: [ {ptype: 'statisticalPlugin'} ]
  782 + plugins: [ {ptype: 'statisticalPlugin'} ]
783 783 };
784   -
785   - Ext.apply (this , Ext.apply (arguments, myConf));
  784 +
  785 + Ext.apply (this , Ext.apply (arguments, myConf));
786 786 },
787   -
  787 +
788 788 checkIntervalsStatusForSave : function(onStatusOk) {
789 789 if (this.status == null)
790 790 return;
791   -
  791 +
792 792 if (this.status.nbValid <= 0)
793 793 {
794 794 myDesktopApp.errorMsg('Your time table is invalid, <br>you must have at least one valid interval');
795 795 return;
796 796 }
797   -
  797 +
798 798 var msg = '';
799 799 if (this.status.nbInvalid > 0)
800 800 msg += 'There are some invalid intervals. Only valid intervals will be saved!<br/>';
... ... @@ -819,19 +819,19 @@ Ext.define(&#39;amdaUI.TimeTableUI&#39;, {
819 819 });
820 820 return;
821 821 }
822   -
  822 +
823 823 onStatusOk();
824 824 },
825   -
  825 +
826 826 /**
827   - * Check if changes were made before closing window
  827 + * Check if changes were made before closing window
828 828 * @return true if changes
829   - */
  829 + */
830 830 fclose : function() {
831 831 if (this.status == null)
832 832 return false;
833   -
  833 +
834 834 var isDirty = this.formPanel.getForm().isDirty() || (this.status.isModified) || (this.status.nbModified > 0) || (this.status.nbNew > 0);
835 835 return isDirty;
836 836 }
837   -});
  837 +});
... ...
php/classes/AmdaAction.php
... ... @@ -61,7 +61,7 @@ class AmdaAction
61 61 $node = $obj->node;
62 62  
63 63 $nodeType = $obj->nodeType;
64   -
  64 +
65 65 $remoteBase = false;
66 66 $isRemoteDataSet = false;
67 67  
... ... @@ -211,12 +211,12 @@ class AmdaAction
211 211  
212 212 if ($child->hasAttribute("parentId"))
213 213 $component_info["parentId"] = $child->getAttribute("parentId");
214   -
  214 +
215 215 if ($child->hasAttribute("iconCls"))
216 216 $iconCls = $child->getAttribute("iconCls");
217   -
  217 +
218 218 if ($isLeaf) $isParameter = true;
219   -
  219 +
220 220 break;
221 221  
222 222 case 'timeTable':
... ... @@ -235,7 +235,7 @@ class AmdaAction
235 235 break;
236 236 case 'derivedParam':
237 237 $info = $child->getAttribute('buildchain');
238   -
  238 +
239 239 if ($child->hasAttribute('dim_1')) {
240 240 $dim_1 = $child->getAttribute('dim_1');
241 241 }
... ... @@ -265,7 +265,7 @@ class AmdaAction
265 265  
266 266 if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) {
267 267 $info .= "<br/>Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop');
268   -
  268 +
269 269 if ($child->hasAttribute('lastUpdate')) {
270 270 $info .= "<br/>Last Updated: : ".$child->getAttribute('lastUpdate');
271 271 }
... ... @@ -274,7 +274,7 @@ class AmdaAction
274 274 if ($child->getAttribute('dataStart') == 'depending on mission') {
275 275 $info .= "<br/>Time Range: ".$child->getAttribute('dataStart');
276 276 }
277   -
  277 +
278 278 // if ($child->getAttribute('restriction') > 1) {
279 279 // $restricted = $child->getAttribute('restriction');
280 280 // $info .= "<br/><b>Time Restriction</b>: -$restricted days";
... ... @@ -282,15 +282,15 @@ class AmdaAction
282 282 }
283 283  
284 284 if ($child->hasAttribute('units')) {
285   -
  285 +
286 286 $units = $child->getAttribute('units');
287   -
  287 +
288 288 if ($child->hasAttribute('description'))
289 289 $info = $child->getAttribute('description')."<br/>".$units;
290   - else
  290 + else
291 291 $info = $units;
292 292 }
293   -
  293 +
294 294 if ($child->tagName == 'parameter') {
295 295 $isParameter = true;
296 296  
... ... @@ -298,7 +298,7 @@ class AmdaAction
298 298 $globalStart = $child->parentNode->getAttribute('dataStart');
299 299 $globalStop = $child->parentNode->getAttribute('dataStop');
300 300 }
301   -
  301 +
302 302 if ($child->parentNode->hasAttribute('restriction')) {
303 303 if ($child->parentNode->getAttribute('restriction') == "plotOnly") {
304 304 $not_yet = true;
... ... @@ -318,7 +318,7 @@ class AmdaAction
318 318 $globalStart = $child->parentNode->parentNode->getAttribute('dataStart');
319 319 $globalStop = $child->parentNode->parentNode->getAttribute('dataStop');
320 320 }
321   -
  321 +
322 322 if ($child->parentNode->parentNode->hasAttribute('restriction')) {
323 323 if ($child->parentNode->parentNode->getAttribute('restriction') == "plotOnly") {
324 324 $not_yet = true;
... ... @@ -363,7 +363,7 @@ class AmdaAction
363 363 if ($child->tagName == 'mission' || $child->tagName == 'observatory') {
364 364 $rank = $child->getAttribute('rank');
365 365 }
366   -
  366 +
367 367 $disable = $child->hasAttribute('group');
368 368  
369 369 if ($disable) {
... ... @@ -373,7 +373,7 @@ class AmdaAction
373 373 else {
374 374 $info .= "<br/><b>Sorry! Not finished yet...</b>";
375 375 }
376   - }
  376 + }
377 377 else {
378 378 if ($child->hasAttribute('restriction') && $child->getAttribute('restriction') == 'plotOnly')
379 379 $info .= "<br/><b>Plot Only!!!</b>";
... ... @@ -474,7 +474,7 @@ class AmdaAction
474 474 {
475 475 if ($child->tagName == 'dataset') $isRemoteDataSet = true;
476 476 }
477   -
  477 +
478 478 if ($child->tagName == 'parameter'){
479 479 if ($child->parentNode->hasAttribute('dataStart')){
480 480 $globalStart = date('Y-m-d\TH:i:s\Z', strtotime($child->parentNode->getAttribute('dataStart')));
... ... @@ -488,7 +488,7 @@ class AmdaAction
488 488 $globalStop = date('Y-m-d\TH:i:s\Z', strtotime($child->parentNode->getAttribute('dataStop')));
489 489 }
490 490 }
491   -
  491 +
492 492 if ($isParameter)
493 493 {
494 494 $disable = $child->parentNode->getAttribute('disabled');
... ... @@ -514,7 +514,7 @@ class AmdaAction
514 514 else
515 515 {
516 516 $restricted = FALSE;
517   -
  517 +
518 518 if ($child->tagName == 'dataset')
519 519 {
520 520 $nonavailable = ($child->getAttribute('disabled'));
... ... @@ -558,7 +558,7 @@ class AmdaAction
558 558 $size = $child->getAttribute('size');
559 559 $mask = $child->getAttribute('mask');
560 560 $sampling = null;
561   - if ($child->hasAttribute('minsampling'))
  561 + if ($child->hasAttribute('minsampling'))
562 562 $sampling = $child->getAttribute('minsampling');
563 563 $isSpectra = false;
564 564  
... ... @@ -598,7 +598,7 @@ class AmdaAction
598 598  
599 599 $childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info,
600 600 'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter, 'dim_1' => $dim_1, 'dim_2' => $dim_2, 'tabs' => $plotTabs,
601   - 'component_info' => isset($component_info) ? $component_info : NULL,
  601 + 'component_info' => isset($component_info) ? $component_info : NULL,
602 602 'iconCls' => isset($iconCls) ? $iconCls : NULL );
603 603 }
604 604 }
... ... @@ -614,19 +614,19 @@ class AmdaAction
614 614 /*
615 615 * add Remote Parameter to user RemoteParams.xml
616 616 * send request to DDServer to AddVi if Vi doesn't exist
617   - * create Remote Parameter Description
  617 + * create Remote Parameter Description
618 618 */
619 619 public function saveTree($obj)
620 620 {
621 621 $paramMgr = new RemoteParamManager();
622 622 $res = $paramMgr->init();
623   -
  623 +
624 624 if ($res['success'])
625 625 return $paramMgr->saveTree($obj);
626   - else
  626 + else
627 627 return $res;
628 628 }
629   -
  629 +
630 630 /*
631 631 * delete Remote Parameter from user RemoteParams.xml
632 632 */
... ... @@ -634,13 +634,13 @@ class AmdaAction
634 634 {
635 635 $paramMgr = new RemoteParamManager();
636 636 $res = $paramMgr->init();
637   -
  637 +
638 638 if ($res['success'])
639 639 return $paramMgr->deleteFromTree($obj);
640   - else
  640 + else
641 641 return $res;
642 642 }
643   -
  643 +
644 644 public function doNothing($obj)
645 645 {
646 646 return array("res" => 'ok');
... ... @@ -726,7 +726,7 @@ class AmdaAction
726 726 case 'request' :
727 727 $objectMgr = new RequestMgr($nodeType);
728 728 break;
729   - case 'bkgWorks' :
  729 + case 'bkgWorks' :
730 730 return $this->executeRequest($id, FunctionTypeEnumClass::PROCESSGETINFO);
731 731 break;
732 732 case 'myData' :
... ... @@ -940,7 +940,7 @@ class AmdaAction
940 940 // return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support for IMPEx not implemented");
941 941 }
942 942 else {
943   - // check disk space
  943 + // check disk space
944 944 if ($dd->getWsSize() > DISK_QUOTA) {
945 945 //Try to delete log files - cf. #6245
946 946 if ($dd->getWsSize(TRUE) > DISK_QUOTA) {
... ... @@ -955,8 +955,8 @@ class AmdaAction
955 955 }
956 956  
957 957 private function executeRequest($obj, $function)
958   - {
959   -
  958 + {
  959 +
960 960 // Check user if access to DD Server and / or possible 'space consuming' action
961 961 if ( $function == FunctionTypeEnumClass::PARAMS ||
962 962 $function == FunctionTypeEnumClass::ACTION ||
... ... @@ -1070,24 +1070,24 @@ class AmdaAction
1070 1070 return $result;
1071 1071 }
1072 1072  
1073   - public function initTTCache($isCatalog = false, $nparams)
  1073 + public function initObjectCache($isCatalog = false, $nparams = 1)
1074 1074 {
1075 1075 if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
1076 1076 else $cacheMgr = new CatalogCacheMgr();
1077 1077  
1078   - return $cacheMgr->initTTCache($nparams);
  1078 + return $cacheMgr->initObjectCache(array('nparams' => $nparams));
1079 1079 }
1080 1080  
1081 1081  
1082   - public function initTTCacheFromTT($id, $type)
  1082 + public function initObjectCacheFromTT($id, $type)
1083 1083 {
1084 1084 if ($type == 'catalog' || $type == 'sharedcatalog') $cacheMgr = new CatalogCacheMgr();
1085 1085 else $cacheMgr = new TimeTableCacheMgr();
1086 1086  
1087   - return $cacheMgr->initFromTT($id, $type);
  1087 + return $cacheMgr->initFromObject($id, $type);
1088 1088 }
1089 1089  
1090   - public function initTTCacheFromCatalog($id, $type)
  1090 + public function initObjectCacheFromCatalog($id, $type)
1091 1091 {
1092 1092 $cacheMgr = new TimeTableCacheMgr();
1093 1093  
... ... @@ -1099,13 +1099,13 @@ class AmdaAction
1099 1099 {
1100 1100 if ($isTmpObject && $type == 'catalog' && $id == 'cacheCat')
1101 1101 return array('success' => true, 'cache' => $id);
1102   -
  1102 +
1103 1103 if ($type == 'catalog' || $type == 'sharedcatalog') $objMgr = new CatalogMgr();
1104 1104  
1105 1105 return $objMgr->initForChart($id, $name, $isTmpObject, $type);
1106 1106 }
1107 1107  
1108   - public function initTTCacheFromTmpObject($folderId, $name, $isCatalog = false)
  1108 + public function initObjectCacheFromTmpObject($folderId, $name, $isCatalog = false)
1109 1109 {
1110 1110 if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
1111 1111 else $cacheMgr = new CatalogCacheMgr();
... ... @@ -1113,7 +1113,7 @@ class AmdaAction
1113 1113 return $cacheMgr->initFromTmpObject($folderId, $name);
1114 1114 }
1115 1115  
1116   - public function initTTCacheFromUploadedFile($name, $format, $isCatalog = false)
  1116 + public function initObjectCacheFromUploadedFile($name, $format, $isCatalog = false)
1117 1117 {
1118 1118 if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr();
1119 1119 else $cacheMgr = new CatalogCacheMgr();
... ... @@ -1132,13 +1132,13 @@ class AmdaAction
1132 1132 public function readIntervalsForChart($o)
1133 1133 {
1134 1134 if (isset($o->typeTT) && ($o->typeTT == 'catalog' || $o->typeTT == 'sharedcatalog')) {
1135   -
  1135 +
1136 1136 if ($o->fromPlugin && $o->id == 'cacheCat') {
1137 1137 $objMgr = new CatalogCacheMgr();
1138   -
  1138 +
1139 1139 return $objMgr->getIntervals();
1140 1140 }
1141   -
  1141 +
1142 1142 $objMgr = new CatalogMgr();
1143 1143 }
1144 1144  
... ... @@ -1148,7 +1148,7 @@ class AmdaAction
1148 1148 public function saveTTCacheIntervalsInTT($o)
1149 1149 {
1150 1150 $cacheMgr = new TimeTableCacheMgr();
1151   - return $cacheMgr->saveInTT($o->ttId,$o->action,$o->cacheToken);
  1151 + return $cacheMgr->saveInObject($o->ttId,$o->action,$o->cacheToken);
1152 1152 }
1153 1153  
1154 1154 public function addTTCacheInterval($o)
... ... @@ -1193,8 +1193,8 @@ class AmdaAction
1193 1193  
1194 1194 public function getTTCacheStatistics($obj)
1195 1195 {
1196   - error_log("name",$obj->name );
1197   - if($obj->name == "timeTableUi"){
  1196 + error_log("name",$obj->name );
  1197 + if($obj->name == "timeTableUi"){
1198 1198 $cacheMgr = new TimeTableCacheMgr();
1199 1199 }elseif($obj->name == "catalogUI"){
1200 1200 $cacheMgr = new CatalogCacheMgr();
... ... @@ -1467,7 +1467,7 @@ class AmdaAction
1467 1467 return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO);
1468 1468 }
1469 1469 public function getDerivedParamInfo($obj)
1470   - {
  1470 + {
1471 1471 $dom = new DomDocument("1.0");
1472 1472 $xmlName=USERWSDIR.$this->xmlFiles['derivedParam'];
1473 1473 @$dom->load($xmlName);
... ... @@ -1480,18 +1480,18 @@ class AmdaAction
1480 1480 $dim_2=$param->getAttribute("dim_2");
1481 1481 return $this->createDerivedParamInfo($dim_1,$dim_2,$obj->paramId);
1482 1482 }
1483   -
  1483 +
1484 1484 }
1485   - return array('success'=>false, 'message'=>'unkown parameter (derived parameter arguments are not handled)');
  1485 + return array('success'=>false, 'message'=>'unkown parameter (derived parameter arguments are not handled)');
1486 1486 }
1487   -
  1487 +
1488 1488 public function createDerivedParamInfo($dim_1,$dim_2,$paramId)
1489 1489 {
1490 1490 /* case of constant */
1491 1491 if($dim_1*$dim_2==1)
1492 1492 {
1493 1493 return array('success'=>false,'msg'=>"dim1=1 dim2=1 no arguments for this parameter");
1494   - }elseif(($dim_1==1 && $dim_2>1 && $dim_2<=3)||($dim_2==1 && $dim_1>1 && $dim_1<=3) )
  1494 + }elseif(($dim_1==1 && $dim_2>1 && $dim_2<=3)||($dim_2==1 && $dim_1>1 && $dim_1<=3) )
1495 1495 /* case of vector */
1496 1496 {
1497 1497  
... ... @@ -1519,7 +1519,7 @@ class AmdaAction
1519 1519 'dimensions'=>$dims,
1520 1520 'components'=>$compts
1521 1521 );
1522   -
  1522 +
1523 1523  
1524 1524 return array('success'=>true,'data'=>$data);
1525 1525 }else
... ... @@ -1535,7 +1535,7 @@ class AmdaAction
1535 1535 for($j=0;$j<count($sizes);$j++)
1536 1536 {
1537 1537 $compts=array();
1538   -
  1538 +
1539 1539 for($i=0;$i<$sizes[$j];$i++)
1540 1540 {
1541 1541 $c=array('min'=>'L' . $i,'max'=>'L' . ($i+1));
... ... @@ -1543,7 +1543,7 @@ class AmdaAction
1543 1543 }
1544 1544  
1545 1545 $tab=array(
1546   - 'relatedDim'=>'dim' . ($j+1),
  1546 + 'relatedDim'=>'dim' . ($j+1),
1547 1547 'name'=>'component' . ($j+1),
1548 1548 'units'=>"",
1549 1549 'variable'=>"",
... ... @@ -1553,14 +1553,14 @@ class AmdaAction
1553 1553  
1554 1554 array_push($tables,$tab);
1555 1555 }
1556   -
  1556 +
1557 1557 $data=array(
1558 1558 'dimensions'=>$dims,
1559 1559 'tables'=>$tables
1560 1560 );
1561 1561 return array('success'=>true,'data'=>$data);
1562 1562 }
1563   -
  1563 +
1564 1564 }
1565 1565 public function getSharedObjectFolders($obj)
1566 1566 {
... ...
php/classes/CatalogCacheMgr.php
... ... @@ -6,25 +6,30 @@
6 6  
7 7 class CatalogCacheMgr extends TimeTableCacheMgr
8 8 {
9   -
10   - protected static $cache_file = "cacheCat";
11   -
12   - protected $ttMgr = null;
  9 + protected $objectMgr = null;
13 10 protected $cache = null;
14 11  
15 12 function __construct() {
16 13  
17   - $this->ttMgr = new CatalogMgr();
  14 + $this->objectMgr = new CatalogMgr();
18 15 }
19 16  
  17 + protected function getCacheFileName() {
  18 + return "cacheCat";
  19 + }
  20 +
  21 + protected function resetCache() {
  22 + $this->cache = new CatalogCacheObject();
  23 + }
  24 +
20 25  
21 26 public function initFromTmpObject($folderId, $name) {
22 27  
23 28 //Create new cache
24   - $this->cache = new CatalogCacheObject();
  29 + $this->resetCache();
25 30  
26 31 //Load intervals from TmpObject file (Statistics Module)
27   - $intervals_res = $this->ttMgr->getTmpObject($folderId, $name);
  32 + $intervals_res = $this->objectMgr->getTmpObject($folderId, $name);
28 33  
29 34 if (!isset($intervals_res))
30 35 return array('success' => false, 'message' => 'Cannot get Tmp Object');
... ... @@ -60,10 +65,10 @@ class CatalogCacheMgr extends TimeTableCacheMgr
60 65 public function initFromUploadedFile($name, $format)
61 66 {
62 67 //Create new cache
63   - $this->cache = new CatalogCacheObject();
  68 + $this->resetCache();
64 69  
65 70 //Load intervals from uploaded file
66   - $intervals_res = $this->ttMgr->getUploadedObject($name, $format);
  71 + $intervals_res = $this->objectMgr->getUploadedObject($name, $format);
67 72  
68 73 if (!isset($intervals_res))
69 74 return array('success' => false, 'message' => 'Cannot get Uploaded Object');
... ... @@ -94,13 +99,13 @@ class CatalogCacheMgr extends TimeTableCacheMgr
94 99 'status'=>$this->cache->getStatus(), 'parameters'=>$paramHeaders);
95 100 }
96 101  
97   - public function initFromTT($id, $typeTT)
  102 + public function initFromObject($id, $type)
98 103 {
99 104 //Create new cache
100   - $this->cache = new CatalogCacheObject();
  105 + $this->resetCache();
101 106  
102 107 //Load intervals from catalog file and add to cache
103   - $intervals_res = $this->ttMgr->loadIntervalsFromTT($id,$typeTT);
  108 + $intervals_res = $this->objectMgr->loadIntervalsFromObject($id,$type);
104 109  
105 110 if (!$intervals_res['success'])
106 111 return $intervals_res;
... ... @@ -132,7 +137,7 @@ class CatalogCacheMgr extends TimeTableCacheMgr
132 137 {
133 138 if (!file_exists($this->getCacheFilePath()))
134 139 return false;
135   - $this->cache = new CatalogCacheObject();
  140 + $this->resetCache();
136 141 $handle = fopen($this->getCacheFilePath(), 'rb');
137 142 $result = false;
138 143 if (flock($handle, LOCK_SH))
... ... @@ -145,12 +150,7 @@ class CatalogCacheMgr extends TimeTableCacheMgr
145 150 return $result;
146 151 }
147 152  
148   - protected function getCacheFilePath()
149   - {
150   - return USERTTDIR.(self::$cache_file);
151   - }
152   -
153   - public function saveInTT($id, $action, $token)
  153 + public function saveInObject($id, $action, $token)
154 154 {
155 155 if (!$this->loadFromFile())
156 156 return array('success' => false, 'message' => 'Cannot load cache file');
... ... @@ -165,10 +165,10 @@ class CatalogCacheMgr extends TimeTableCacheMgr
165 165  
166 166 $this->cache->reset();
167 167  
168   - return $this->ttMgr->saveIntervals($id, $intervals, $action);
  168 + return $this->objectMgr->saveIntervals($id, $intervals, $action);
169 169 }
170 170  
171   - public function addInterval($index, $start, $stop, $params) {
  171 + public function addInterval($index, $start, $stop, $params = array()) {
172 172 if (!$this->loadFromFile())
173 173 return array('success' => false, 'message' => 'Cannot load cache file');
174 174  
... ... @@ -204,9 +204,11 @@ class CatalogCacheMgr extends TimeTableCacheMgr
204 204 return array('success' => true, 'status' => $this->cache->getStatus());
205 205 }
206 206  
207   - public function initTTCache($nparams) {
  207 + public function initObjectCache($options = array()) {
208 208 //Create new cache
209   - $this->cache = new CatalogCacheObject();
  209 + $nparams = isset($options['nparams']) ? $options['nparams'] : 1;
  210 +
  211 + $this->resetCache();
210 212 $this->cache->setParamsNumber((int)$nparams);
211 213 $paramHeaders = array();
212 214  
... ...
php/classes/CatalogMgr.php
... ... @@ -4,67 +4,67 @@
4 4 * @class CatalogMgr
5 5 */
6 6  
7   -class CatalogMgr extends TimeTableMgr
8   -{
  7 +class CatalogMgr extends TimeTableMgr
  8 +{
9 9 function __construct($sharedObject = FALSE) {
10 10 parent::__construct('Tt.xml', $sharedObject);
11 11 $this->contentRootId = 'catalog-treeRootNode';
12 12 $this->contentRootTag = 'catalogList';
13   - $this->attributes = array('name' => '', 'intervals' => ''); // + 'parameters'
  13 + $this->attributes = array('name' => '', 'intervals' => ''); // + 'parameters'
14 14 $this->optionalAttributes = array();
15 15 $this->objTagName = 'catalog';
16 16 $this->id_prefix = 'cat_'; // 'tt_' ?
17 17  
18 18 if (!$sharedObject && !file_exists($this->xmlName)) {
19 19 $this->createDom();
20   - $this->xp = new domxpath($this->contentDom);
  20 + $this->xp = new domxpath($this->contentDom);
21 21 }
22   - }
23   -
24   - public function getUploadedObject($name, $format, $onlyDescription = false)
  22 + }
  23 +
  24 + public function getUploadedObject($name, $format, $onlyDescription = false)
25 25 {
26   - if ($format == 'VOT')
  26 + if ($format == 'VOT')
27 27 {
28   - $attributesToReturn = $this->vot2amda(USERTEMPDIR.$name, $onlyDescription);
  28 + $attributesToReturn = $this->vot2amda(USERTEMPDIR.$name, $onlyDescription);
29 29 }
30 30 $attributesToReturn['objName'] = $name;
31   - $attributesToReturn['objFormat'] = $format;
  31 + $attributesToReturn['objFormat'] = $format;
32 32  
33 33 return $attributesToReturn;
34 34 }
35   -
36   - public function getTmpObject($folderId, $name, $onlyDescription = false)
37   - {
  35 +
  36 + public function getTmpObject($folderId, $name, $onlyDescription = false)
  37 + {
38 38 $filePath = USERWORKINGDIR.$folderId.'/'.$name.'.xml';
39   -
40   - if (!file_exists($filePath))
  39 +
  40 + if (!file_exists($filePath))
41 41 return array('error' => 'Cannot find result file');
42   -
43   - $dom = new DomDocument('1.0');
  42 +
  43 + $dom = new DomDocument('1.0');
44 44 $dom->formatOutput = true;
45   -
  45 +
46 46 if (!$dom -> load($filePath))
47 47 return array('error' => 'Cannot load result file');
48 48 $nameNodes = $dom->getElementsByTagName('name');
49 49 if ($nameNodes->length > 0)
50 50 $attributesToReturn['name'] = $nameNodes->item(0)->nodeValue;
51   -
  51 +
52 52 $descNodes = $dom->getElementsByTagName('description');
53 53 if ($descNodes->length > 0)
54 54 $attributesToReturn['description'] = $descNodes->item(0)->nodeValue;
55   -
  55 +
56 56 $creatNodes = $dom->getElementsByTagName('created');
57 57 if ($creatNodes->length > 0)
58 58 $attributesToReturn['created'] = $creatNodes->item(0)->nodeValue;
59   -
  59 +
60 60 $histNodes = $dom->getElementsByTagName('history');
61 61 if ($histNodes->length > 0)
62 62 $attributesToReturn['history'] = $histNodes->item(0)->nodeValue;
63   -
  63 +
64 64 $attributesToReturn['objName'] = $name;
65 65 $attributesToReturn['folderId'] = $folderId;
66 66 $attributesToReturn['success'] = true;
67   -
  67 +
68 68 if (!$onlyDescription)
69 69 {
70 70 $intNodes = $dom->getElementsByTagName('intervals');
... ... @@ -73,91 +73,91 @@ class CatalogMgr extends TimeTableMgr
73 73 $startNodes = $intNode->getElementsByTagName('start');
74 74 if ($startNodes->length <= 0)
75 75 return array('error' => 'Error detected in result file');
76   -
  76 +
77 77 $stopNodes = $intNode->getElementsByTagName('stop');
78 78 if ($stopNodes->length <= 0)
79 79 return array('error' => 'Error detected in result file');
80   -
81   - // for catalog
  80 +
  81 + // for catalog
82 82 $paramNodes = $intNode->getElementsByTagName('param');
83 83 $params = array();
84   - if ($paramNodes->length > 0)
  84 + if ($paramNodes->length > 0)
85 85 foreach ( $paramNodes as $paramNode ) $params[] = $paramNode->nodeValue;
86   -
87   -
  86 +
  87 +
88 88 $attributesToReturn['intervals'][] = array('start' => $startNodes->item(0)->nodeValue,
89 89 'stop' => $stopNodes->item(0)->nodeValue,
90 90 'paramTable' => $params);
91 91 }
92 92 // for catalog
93 93 $paramsNodes = $dom->getElementsByTagName('parameter');
94   -
  94 +
95 95 if ($paramsNodes->length > 0){
96   -
97   - $paramsArray = array();
  96 +
  97 + $paramsArray = array();
98 98 foreach ($paramsNodes as $paramNode) {
99   -
  99 +
100 100 $oneParam = array();
101   - foreach ($paramNode->attributes as $attr)
  101 + foreach ($paramNode->attributes as $attr)
102 102 $oneParam[$attr->nodeName] = $attr->nodeValue;
103   -
104   - if (substr($paramNode->getAttribute('id'),0,8) == 'stat_cov') {
  103 +
  104 + if (substr($paramNode->getAttribute('id'),0,8) == 'stat_cov') {
105 105 $oneParam['size'] = '1';
106 106 $oneParam['name'] = 'Flag';
107 107 }
108   -
  108 +
109 109 $paramsArray[] = $oneParam;
110 110 }
111 111 $attributesToReturn['success'] = true;
112 112 $attributesToReturn['parameters'] = $paramsArray;
113 113 }
114   - else
115   - return array('error' => 'No information on parameters in result file');
  114 + else
  115 + return array('error' => 'No information on parameters in result file');
116 116 }
117   -
  117 +
118 118 return $attributesToReturn;
119 119 }
120 120  
121   -
122   - public function loadIntervalsFromTT($id, $typeTT, $start = NULL, $limit = NULL)
  121 +
  122 + public function loadIntervalsFromObject($id, $type, $start = NULL, $limit = NULL)
123 123 {
124   - if ($typeTT == 'sharedcatalog') {
  124 + if ($type == 'sharedcatalog') {
125 125 //Shared object
126 126 $sharedObjMgr = new SharedObjectsMgr();
127 127 $path = $sharedObjMgr->getDataFilePath('catalog', $id);
128 128 }
129 129 else {
130   - $path = USERTTDIR.$id.'.xml';
  130 + $path = USERTTDIR.$id.'.xml';
131 131 }
132   -
  132 +
133 133 //load intervals from TT id
134 134 if (!file_exists($path))
135   - return array('success' => false, 'message' => "Cannot find Catalog file ".$typeTT);
136   -
  135 + return array('success' => false, 'message' => "Cannot find Catalog file ".$type);
  136 +
137 137 $this->objectDom->load($path);
138   -
  138 +
139 139 if (!($objToGet = $this->objectDom->getElementById($id)))
140 140 return array('success' => false, 'message' => NO_SUCH_ID." ".$id);
141   -
  141 +
142 142 $xpath = new DOMXPath($this->objectDom);
143 143 $intervals = $xpath->query('//intervals');
144   -
  144 +
145 145 $result = array();
146   -
  146 +
147 147 if (!isset($start) || !isset($limit))
148 148 {
149 149 foreach ($intervals as $interval)
150 150 {
151 151 $startTime = $interval->getElementsByTagName('start')->item(0)->nodeValue;
152 152 $stopTime = $interval->getElementsByTagName('stop')->item(0)->nodeValue;
153   - // for catalog
  153 + // for catalog
154 154 $paramNodes = $interval->getElementsByTagName('param');
155 155 $params = array();
156   - if ($paramNodes->length > 0)
  156 + if ($paramNodes->length > 0)
157 157 foreach ( $paramNodes as $paramNode ) $params[] = $paramNode->nodeValue;
158   -
  158 +
159 159 array_push($result, array('start' => $startTime, 'stop' => $stopTime,'paramTable' => $params));
160   -
  160 +
161 161 }
162 162 }
163 163 else
... ... @@ -171,27 +171,27 @@ class CatalogMgr extends TimeTableMgr
171 171 // for catalog
172 172 $paramNodes = $intervals->item($start+$i)->getElementsByTagName('param');
173 173 $params = array();
174   - if ($paramNodes->length > 0)
  174 + if ($paramNodes->length > 0)
175 175 foreach ( $paramNodes as $paramNode ) $params[] = $paramNode->nodeValue;
176   -
  176 +
177 177 array_push($result, array('start' => $startTime, 'stop' => $stopTime,'paramTable' => $params));
178 178 }
179 179 }
180 180 // for catalog : params header
181 181 $paramsNodes = $xpath->query('//parameters/parameter');
182 182 $paramsArray = array();
183   -
  183 +
184 184 if ($paramsNodes->length > 0)
185   - {
186   - foreach ($paramsNodes as $paramNode)
187   - {
  185 + {
  186 + foreach ($paramsNodes as $paramNode)
  187 + {
188 188 $oneParam = array();
189   - foreach ($paramNode->attributes as $attr)
190   - $oneParam[$attr->nodeName] = $attr->nodeValue;
  189 + foreach ($paramNode->attributes as $attr)
  190 + $oneParam[$attr->nodeName] = $attr->nodeValue;
191 191 $paramsArray[] = $oneParam;
192 192 }
193   - }
194   -
  193 + }
  194 +
195 195 return array(
196 196 'totalCount' => $intervals->length,
197 197 'intervals' => $result,
... ... @@ -200,28 +200,28 @@ class CatalogMgr extends TimeTableMgr
200 200 'limit' => isset($limit) ? $limit : 0,
201 201 'success' => true
202 202 );
203   -
  203 +
204 204 }
205 205  
206 206 /*
207 207 * catalog header
208 208 */
209   - protected function setParamDescription($params)
210   - {
  209 + protected function setParamDescription($params)
  210 + {
211 211 $paramsElement = $this->objectDom->createElement('parameters');
212   - foreach ($params as $param)
  212 + foreach ($params as $param)
213 213 {
214 214 $paramElement = $this->objectDom->createElement('parameter');
215   - $attrArray = (array)$param;
  215 + $attrArray = (array)$param;
216 216 foreach ($attrArray as $key => $value)
217 217 $paramElement->setAttribute($key, $value);
218   - $paramsElement->appendChild($paramElement);
  218 + $paramsElement->appendChild($paramElement);
219 219 }
220   -
  220 +
221 221 return $paramsElement;
222 222 }
223   -
224   - protected function createIntervalElement($interval)
  223 +
  224 + protected function createIntervalElement($interval)
225 225 {
226 226 $newInterval = $this->objectDom->createElement('intervals');
227 227 $newInterval->appendChild($this->objectDom->createElement('start',$interval['start']));
... ... @@ -229,24 +229,24 @@ class CatalogMgr extends TimeTableMgr
229 229 foreach ($interval as $key =>$value) {
230 230 if (substr($key,0,5) == 'param')
231 231 $newInterval->appendChild($this->objectDom->createElement('param', $value));
232   -
  232 +
233 233 }
234 234 return $newInterval;
235 235 }
236   -
  236 +
237 237 public function createObject($p, $folder)
238   - {
  238 + {
239 239 if ($p -> leaf)
240 240 {
241 241 $result = $this->createParameter($p, $folder);
242 242 if ($result['error'])
243 243 return $result;
244   -
  244 +
245 245 $cacheMgr = new CatalogCacheMgr();
246   -
  246 +
247 247 if (isset($p->cacheToken) && ($p->cacheToken != ''))
248 248 {
249   - $resultSaveInt = $cacheMgr->saveInTT($result['id'], "update", $p->cacheToken);
  249 + $resultSaveInt = $cacheMgr->saveInObject($result['id'], "update", $p->cacheToken);
250 250 if (!$resultSaveInt['success'])
251 251 {
252 252 if ($resultSaveInt['message'])
... ... @@ -260,154 +260,154 @@ class CatalogMgr extends TimeTableMgr
260 260 // else return $this->createFolder($p);
261 261 //TODO check if this is possible?
262 262 else return array('error' => 'createFolder should be called from RENAME');
263   -
  263 +
264 264 }
265   -
266   - public function initForChart($id, $name, $isTmpObject, $typeTT)
  265 +
  266 + public function initForChart($id, $name, $isTmpObject, $type)
267 267 {
268   - $intervals_res = $this->getCatalogParamDescription($id, $name, $isTmpObject, $typeTT);
269   -
  268 + $intervals_res = $this->getCatalogParamDescription($id, $name, $isTmpObject, $type);
  269 +
270 270 if (!$intervals_res['success'])
271 271 return $intervals_res;
272 272  
273 273 $paramHeaders = array();
274   -
  274 +
275 275 foreach ( $intervals_res['parameters'] as $param ) {
276   -
  276 +
277 277 if ($param['size'] > 1) {
278   -
  278 +
279 279 for ($i = 0; $i < $param['size']; $i++) {
280 280 $paramComp = array();
281 281 $paramComp['id'] = $param['id'].'_'.$i;
282 282 $paramComp['name'] = $param['name'].'_'.$i;
283 283 // $paramComp['size'] = 1;
284   -
  284 +
285 285 $paramHeaders[] = $paramComp;
286 286 }
287 287 }
288 288 else {
289   - $paramHeaders[] = $param;
  289 + $paramHeaders[] = $param;
290 290 }
291 291 }
292   -
  292 +
293 293 // unset($intervals_res);
294   -
295   - return array('success' => true, 'parameters' => $paramHeaders,
  294 +
  295 + return array('success' => true, 'parameters' => $paramHeaders,
296 296 'totalCount' => $intervals_res['totalCount'], 'name' => $intervals_res['name']);
297 297 }
298   -
299   -
  298 +
  299 +
300 300 public function getIntervalsForChart($id, $name, $isTmpObject, $type) {
301   -
  301 +
302 302 if ($isTmpObject)
303   - $intervals_res = $this->getTmpObject($id, $name);
  303 + $intervals_res = $this->getTmpObject($id, $name);
304 304 else
305   - $intervals_res = $this->loadIntervalsFromTT($id,$type);
306   -
  305 + $intervals_res = $this->loadIntervalsFromObject($id,$type);
  306 +
307 307 if (!$intervals_res['success'])
308 308 return $intervals_res;
309   -
  309 +
310 310 $newIntervals = array();
311   -
  311 +
312 312 foreach ($intervals_res['intervals'] as $interval)
313 313 {
314 314 $newIntervalComp = array();
315 315 $k = 0;
316   -
  316 +
317 317 for ( $j = 0; $j < count($interval['paramTable']); $j++ ) {
318   -
  318 +
319 319 $param = $interval['paramTable'][$j];
320 320 $tempArr = explode(',',$param);
321 321  
322 322 if (count($tempArr) > 1) {
323 323 for ($i = 0; $i < count($tempArr); $i++) {
324 324 $newIntervalComp['param'.$k] = $tempArr[$i];
325   - $k++;
326   - }
327   - }
  325 + $k++;
  326 + }
  327 + }
328 328 else {
329 329 $newIntervalComp['param'.$k] = $param;
330   - $k++;
  330 + $k++;
331 331 }
332 332 }
333   - $newIntervals[] = $newIntervalComp;
  333 + $newIntervals[] = $newIntervalComp;
334 334 }
335   -
  335 +
336 336 return array('success' => true, 'intervals' => $newIntervals);
337   -
  337 +
338 338 }
339   -
340   - public function getCatalogParamDescription($id, $name, $isTmpObject, $typeTT)
  339 +
  340 + public function getCatalogParamDescription($id, $name, $isTmpObject, $type)
341 341 {
342   - if ($typeTT == 'sharedcatalog') {
  342 + if ($type == 'sharedcatalog') {
343 343 //Shared object
344 344 $sharedObjMgr = new SharedObjectsMgr();
345 345 $path = $sharedObjMgr->getDataFilePath('catalog', $id);
346 346 }
347 347 elseif (!$isTmpObject) {
348   - $path = USERTTDIR.$id.'.xml';
  348 + $path = USERTTDIR.$id.'.xml';
349 349 }
350 350 else {
351 351 $path = USERWORKINGDIR.$id.'/'.$name.'.xml';
352 352 }
353   -
  353 +
354 354 //load intervals from Catalog id
355 355 if (!file_exists($path))
356 356 return array('success' => false, 'message' => "Cannot find Catalog file ".$id);
357   -
358   - if (!$this->objectDom->load($path))
  357 +
  358 + if (!$this->objectDom->load($path))
359 359 return array('success' => false, 'message' => "Cannot load Catalog file ".$id);
360   -
  360 +
361 361 // if (!($objToGet = $this->objectDom->getElementById($id)))
362 362 // return array('success' => false, 'message' => NO_SUCH_ID." ".$id);
363 363  
364 364 $nameNodes = $this->objectDom->getElementsByTagName('name');
365   -
  365 +
366 366 if ($nameNodes->length > 0)
367 367 $nameReal = $nameNodes->item(0)->nodeValue;
368   - else
  368 + else
369 369 $nameReal = $name;
370   -
  370 +
371 371 $xpath = new DOMXPath($this->objectDom);
372 372 $intervals = $xpath->query('//intervals');
373 373  
374   -
  374 +
375 375 // params header
376 376 $paramsNodes = $xpath->query('//parameters/parameter');
377 377 $paramsArray = array();
378   -
  378 +
379 379 if ($paramsNodes->length > 0)
380   - {
381   - foreach ($paramsNodes as $paramNode)
382   - {
  380 + {
  381 + foreach ($paramsNodes as $paramNode)
  382 + {
383 383 $oneParam = array();
384   - foreach ($paramNode->attributes as $attr)
385   - $oneParam[$attr->nodeName] = $attr->nodeValue;
  384 + foreach ($paramNode->attributes as $attr)
  385 + $oneParam[$attr->nodeName] = $attr->nodeValue;
386 386 $paramsArray[] = $oneParam;
387 387 }
388   - }
389   -
  388 + }
  389 +
390 390 return array(
391 391 'name' => $nameReal,
392 392 'totalCount' => $intervals->length,
393 393 'parameters' => $paramsArray,
394 394 'success' => true
395 395 );
396   -
  396 +
397 397 }
398   -
  398 +
399 399 // public function modifyObject($p) {
400 400 // $folder = $this->getObjectFolder($p->id);
401   -//
  401 +//
402 402 // //Copy TT in a tempory file
403 403 // $ttFilePath = USERTTDIR.$p->id.'.xml';
404 404 // $tmpFileExist = FALSE;
405 405 // if (file_exists($ttFilePath))
406 406 // $tmpFileExist = copy($ttFilePath,$ttFilePath.".tmp");
407   -//
  407 +//
408 408 // //Delete TT
409 409 // $this->deleteObject($p);
410   -//
  410 +//
411 411 // //Save modifications
412 412 // try {
413 413 // $result = $this->createObject($p, $folder);
... ... @@ -431,47 +431,47 @@ class CatalogMgr extends TimeTableMgr
431 431 /*
432 432 * Uploaded vot catalog => convert to AMDA tmp
433 433 */
434   - protected function vot2amda($tmp_file, $onlyDescription = false)
435   - {
436   - // Load Catalog
  434 + protected function vot2amda($tmp_file, $onlyDescription = false)
  435 + {
  436 + // Load Catalog
437 437 $this->objectDom->load($tmp_file);
438 438 $objToGet = $this->objectDom->getElementsByTagName('TABLEDATA')->item(0);
439   -
  439 +
440 440 $attributes = $objToGet->childNodes;
441 441 $paramsNodes = $this->objectDom->getElementsByTagName('FIELD');
442 442 $paramsNumber = $paramsNodes->length;
443   -
  443 +
444 444 foreach($attributes as $attribute)
445 445 {
446   - if ($attribute->tagName == 'TR')
  446 + if ($attribute->tagName == 'TR')
447 447 {
448 448 $start = $attribute->getElementsByTagName('TD')->item(0)->nodeValue;
449 449 $stop = $attribute->getElementsByTagName('TD')->item(1)->nodeValue;
450 450 $params = array();
451   -
  451 +
452 452 for ($i = 2; $i < $paramsNumber; $i++)
453 453 {
454 454 $param = $attribute->getElementsByTagName('TD')->item($i)->nodeValue;
455   -
  455 +
456 456 if ($paramsNodes->item($i)->hasAttribute('arraysize'))
457 457 {
458 458 $param = join(",",explode(" ",trim($param)));
459   - }
  459 + }
460 460 $params[] = $param;
461   - }
462   - if (!$onlyDescription)
  461 + }
  462 + if (!$onlyDescription)
463 463 $attributesToReturn['intervals'][] = array('start' => $start, 'stop' => $stop, 'paramTable' => $params);
464 464 }
465 465 }
466 466  
467 467 if ($paramsNumber > 2)
468   - {
469   - $paramsArray = array();
  468 + {
  469 + $paramsArray = array();
470 470 for ($i = 2; $i < $paramsNumber; $i++)
471   - {
  471 + {
472 472 $oneParam = array();
473 473 $paramNode = $paramsNodes->item($i);
474   -
  474 +
475 475 if ($paramNode->hasAttribute('arraysize'))
476 476 {
477 477 $oneParam['size'] = $paramNode->getAttribute('arraysize');
... ... @@ -480,13 +480,13 @@ class CatalogMgr extends TimeTableMgr
480 480 {
481 481 $oneParam['size'] = 1;
482 482 }
483   -
  483 +
484 484 foreach ($paramNode->attributes as $attr)
485 485 {
486 486 if ($attr->nodeName == 'datatype')
487 487 {
488 488 $datatype = $attr->nodeValue;
489   -
  489 +
490 490 if ($paramNode->hasAttribute('xtype') && (($paramNode->getAttribute('xtype') == 'dateTime') || ($paramNode->getAttribute('xtype') == 'iso8601')))
491 491 {
492 492 $oneParam['type'] = 1;
... ... @@ -498,7 +498,7 @@ class CatalogMgr extends TimeTableMgr
498 498 $oneParam['type'] = 2;// string
499 499 $paramNode->setAttribute('size', 1);
500 500 }
501   - else
  501 + else
502 502 {
503 503 $oneParam['type'] = 0;//'Double';
504 504 }
... ... @@ -507,15 +507,15 @@ class CatalogMgr extends TimeTableMgr
507 507 {
508 508 $oneParam[$attr->nodeName] = $attr->nodeValue;
509 509 }
510   - }
  510 + }
511 511 $paramsArray[] = $oneParam;
512   - }
  512 + }
513 513 $attributesToReturn['success'] = true;
514 514 $attributesToReturn['parameters'] = $paramsArray;
515 515 }
516   -
517   - $suffix = explode('.', basename($tmp_file));
518   - $attributesToReturn['name'] = basename($tmp_file, '.'.$suffix[1]);
  516 +
  517 + $suffix = explode('.', basename($tmp_file));
  518 + $attributesToReturn['name'] = basename($tmp_file, '.'.$suffix[1]);
519 519 $attributesToReturn['created'] = date('Y-m-d')."T".date('H:i:s');
520 520 $attributesToReturn['description'] = htmlspecialchars($this->objectDom->getElementsByTagName('DESCRIPTION')->item(0)->nodeValue);
521 521  
... ...
php/classes/TimeTableCacheMgr.php
... ... @@ -2,30 +2,39 @@
2 2  
3 3 class TimeTableCacheMgr
4 4 {
5   - protected static $cache_file = "cacheTT";
6   -
7   - protected $ttMgr = null;
  5 + protected $objectMgr = null;
8 6 protected $cache = null;
9 7  
10   - function __construct() {
11   - $this->ttMgr = new TimeTableMgr();
12   - $this->catMgr = new CatalogMgr();
  8 + function __construct() {
  9 + $this->objectMgr = new TimeTableMgr();
13 10 }
14 11  
15   - public function initTTCache() {
  12 + protected function getCacheFileName() {
  13 + return "cacheTT";
  14 + }
  15 +
  16 + protected function getCacheDirectory() {
  17 + return USERTTDIR;
  18 + }
  19 +
  20 + protected function resetCache() {
  21 + $this->cache = new TimeTableCacheObject();
  22 + }
  23 +
  24 + public function initObjectCache($options = array()) {
16 25 //Create new cache
17   - $this->cache = new TimeTableCacheObject();
  26 + $this->resetCache();
18 27  
19 28 //Save cache file
20 29 return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus());
21 30 }
22 31  
23   - public function initFromTT($id, $typeTT) {
  32 + public function initFromObject($id, $type) {
24 33 //Create new cache
25   - $this->cache = new TimeTableCacheObject();
  34 + $this->resetCache();
26 35  
27   - //Load intervals from TT file and add to cache
28   - $intervals_res = $this->ttMgr->loadIntervalsFromTT($id,$typeTT);
  36 + //Load intervals from object file and add to cache
  37 + $intervals_res = $this->objectMgr->loadIntervalsFromObject($id,$type);
29 38  
30 39 if (!$intervals_res['success'])
31 40 return $intervals_res;
... ... @@ -45,12 +54,13 @@
45 54 return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus());
46 55 }
47 56  
48   - public function initFromCatalog($id, $typeTT) {
  57 + public function initFromCatalog($id, $type) {
49 58 //Create new cache
50   - $this->cache = new TimeTableCacheObject();
  59 + $this->resetCache();
51 60  
52   - //Load intervals from TT file and add to cache
53   - $intervals_res = $this->catMgr->loadIntervalsFromTT($id,$typeTT);
  61 + //Load intervals from object file and add to cache
  62 + $catMgr = new CatalogMgr();
  63 + $intervals_res = $catMgr->loadIntervalsFromObject($id,$type);
54 64  
55 65 if (!$intervals_res['success'])
56 66 return $intervals_res;
... ... @@ -73,10 +83,10 @@
73 83  
74 84 public function initFromTmpObject($folderId, $name) {
75 85 //Create new cache
76   - $this->cache = new TimeTableCacheObject();
  86 + $this->resetCache();
77 87  
78 88 //Load intervals from TmpObject file (DD_Search output)
79   - $intervals_res = $this->ttMgr->getTmpObject($folderId, $name);
  89 + $intervals_res = $this->objectMgr->getTmpObject($folderId, $name);
80 90  
81 91 if (!isset($intervals_res))
82 92 return array('success' => false, 'message' => 'Cannot get Tmp Object');
... ... @@ -103,10 +113,10 @@
103 113  
104 114 public function initFromUploadedFile($name, $format) {
105 115 //Create new cache
106   - $this->cache = new TimeTableCacheObject();
  116 + $this->resetCache();
107 117  
108 118 //Load intervals from uploaded file
109   - $intervals_res = $this->ttMgr->getUploadedObject($name, $format);
  119 + $intervals_res = $this->objectMgr->getUploadedObject($name, $format);
110 120  
111 121 if (!isset($intervals_res))
112 122 return array('success' => false, 'message' => 'Cannot get Tmp Object');
... ... @@ -131,7 +141,7 @@
131 141 return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus());
132 142 }
133 143  
134   - public function saveInTT($id, $action, $token) {
  144 + public function saveInObject($id, $action, $token) {
135 145 if (!$this->loadFromFile())
136 146 return array('success' => false, 'message' => 'Cannot load cache file');
137 147  
... ... @@ -159,7 +169,7 @@
159 169  
160 170 unset($intervals);
161 171  
162   - return $this->ttMgr->saveIntervals($id, $res_intervals, $action);
  172 + return $this->objectMgr->saveIntervals($id, $res_intervals, $action);
163 173 }
164 174  
165 175 public function getIntervals($start,$limit,$sort_obj,$filter_json) {
... ... @@ -302,8 +312,8 @@
302 312 $this->cache->dump();
303 313 }
304 314  
305   - protected function getCacheFilePath() {
306   - return USERTTDIR.(self::$cache_file);
  315 + protected function getCacheFilePath() {
  316 + return $this->getCacheDirectory().'/'.$this->getCacheFileName();
307 317 }
308 318  
309 319 protected function saveToFile() {
... ... @@ -324,7 +334,7 @@
324 334 protected function loadFromFile() {
325 335 if (!file_exists($this->getCacheFilePath()))
326 336 return false;
327   - $this->cache = new TimeTableCacheObject();
  337 + $this->resetCache();
328 338 $handle = fopen($this->getCacheFilePath(), 'rb');
329 339 $result = false;
330 340 if (flock($handle, LOCK_SH))
... ...
php/classes/TimeTableMgr.php
... ... @@ -83,7 +83,7 @@ class TimeTableMgr extends AmdaObjectMgr
83 83 }
84 84 else
85 85 $attributesToReturn[$attribute->tagName] = $attribute->nodeValue;*/
86   - //BRE - load all except intervals - Intervals will be loaded later with 'loadIntervalsFromTT' function
  86 + //BRE - load all except intervals - Intervals will be loaded later with 'loadIntervalsFromObject' function
87 87 if ($attribute->tagName != 'intervals') {
88 88 $attributesToReturn[$attribute->tagName] = $attribute->nodeValue;
89 89 } else {
... ... @@ -150,7 +150,7 @@ class TimeTableMgr extends AmdaObjectMgr
150 150 }
151 151 $cacheMgr = new TimeTableCacheMgr();
152 152 if (isset($p->cacheToken) && ($p->cacheToken != '')) {
153   - $resultSaveInt = $cacheMgr->saveInTT($result['id'], "update", $p->cacheToken);
  153 + $resultSaveInt = $cacheMgr->saveInObject($result['id'], "update", $p->cacheToken);
154 154 if (!$resultSaveInt['success']) {
155 155 if ($resultSaveInt['message']) {
156 156 return ['error' => $resultSaveInt['message']];
... ... @@ -490,7 +490,7 @@ class TimeTableMgr extends AmdaObjectMgr
490 490  
491 491 $intervals = 0;
492 492 for ($iId = 0; $iId < count($obj->ids); $iId++) {
493   - $table[$iId] = $this->loadIntervalsFromTT($obj->ids[$iId]);
  493 + $table[$iId] = $this->loadIntervalsFromObject($obj->ids[$iId]);
494 494 for ($jId = 0; $jId < count($table[$iId]['intervals']); $jId++) {
495 495 $interval[$iId][$jId][0] = $table[$iId]['intervals'][$jId]['start'];
496 496 $interval[$iId][$jId][1] = $table[$iId]['intervals'][$jId]['stop'];
... ... @@ -562,7 +562,7 @@ class TimeTableMgr extends AmdaObjectMgr
562 562 * @param null $limit
563 563 * @return array
564 564 */
565   - public function loadIntervalsFromTT($id, $typeTT = '', $start = null, $limit = null)
  565 + public function loadIntervalsFromObject($id, $typeTT = '', $start = null, $limit = null)
566 566 {
567 567 if ($typeTT == 'sharedtimeTable') {
568 568 //Shared object
... ... @@ -690,7 +690,7 @@ class TimeTableMgr extends AmdaObjectMgr
690 690 {
691 691 $intervals = 0;
692 692 for ($iId = 0; $iId < count($obj->ids); $iId++) {
693   - $table[$iId] = $this->loadIntervalsFromTT($obj->ids[$iId]);
  693 + $table[$iId] = $this->loadIntervalsFromObject($obj->ids[$iId]);
694 694 for ($jId = 0; $jId < count($table[$iId]['intervals']); $jId++) {
695 695 $interval[$iId][$jId][0] = $table[$iId]['intervals'][$jId]['start'];
696 696 $interval[$iId][$jId][1] = $table[$iId]['intervals'][$jId]['stop'];
... ...
php/config.php
... ... @@ -29,7 +29,7 @@ define(&#39;log&#39;, IHM_SRC_DIR.&#39;/LOG&#39;);
29 29 if (is_file('amda_version.php')) require_once 'amda_version.php';
30 30 if (is_file('errors.php')) require_once 'errors.php';
31 31  
32   -// SYSTEM config section
  32 +// SYSTEM config section
33 33 if (!defined('PHP_VERSION_ID')) {
34 34 $version = explode('.', PHP_VERSION);
35 35 define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
... ... @@ -52,7 +52,7 @@ define(&#39;MAX_FILE_INDEX_TO_SHOW&#39;, 100);
52 52 define('DDSERVICE_PRIVATEKEY', '!%p856Dc');
53 53  
54 54  
55   -// BATCH JOBS section
  55 +// BATCH JOBS section
56 56 //define('JOBTIMEOUT', '1'); // one cycle secs to sleep to allow job be executed
57 57 //define('PLOT_CYCLES_NUMBER', 500); // cycles number for PNG
58 58 //define('JOB_CYCLES_NUMBER', 5); // cycles number for all the jobs
... ... @@ -62,7 +62,7 @@ define(&#39;DDSERVICE_PRIVATEKEY&#39;, &#39;!%p856Dc&#39;);
62 62 define('EPNTAP_APIS', 'http://voparis-tap.obspm.fr/__system__/tap/run/tap/sync');
63 63 define('EPNTAP_AMDA', 'http://cdpp-epntap.irap.omp.eu/__system__/tap/run/tap/sync');
64 64  
65   -// PHP run-time settings
  65 +// PHP run-time settings
66 66 ini_set('memory_limit',256000000);
67 67 ini_set('max_execution_time',600); // max PHP execution
68 68  
... ... @@ -155,12 +155,12 @@ $API = array(
155 155 'intersect'=>array('len'=>1),
156 156 'loadTTIntervals'=>array('len'=>1),
157 157 'saveTTCacheIntervalsInTT'=>array('len'=>1),
158   - 'initTTCache'=>array ('len'=>2),
159   - 'initTTCacheFromTT'=>array('len'=>2),
  158 + 'initObjectCache'=>array ('len'=>2),
  159 + 'initObjectCacheFromTT'=>array('len'=>2),
160 160 'initForChart'=>array('len'=>4),
161   - 'initTTCacheFromTmpObject'=>array('len'=>3),
162   - 'initTTCacheFromUploadedFile'=>array('len'=>3),
163   - 'initTTCacheFromCatalog'=>array('len'=>2),
  161 + 'initObjectCacheFromTmpObject'=>array('len'=>3),
  162 + 'initObjectCacheFromUploadedFile'=>array('len'=>3),
  163 + 'initObjectCacheFromCatalog'=>array('len'=>2),
164 164 'readTTCacheIntervals'=>array('len'=>1),
165 165 'readIntervalsForChart'=>array('len'=>1),
166 166 'addTTCacheInterval'=>array('len'=>1),
... ...