diff --git a/js/app/views/CatalogUI.js b/js/app/views/CatalogUI.js index d85e12d..53aaec8 100644 --- a/js/app/views/CatalogUI.js +++ b/js/app/views/CatalogUI.js @@ -10,77 +10,77 @@ Ext.define('amdaUI.CatalogUI', { extend: 'Ext.container.Container', alias: 'widget.panelCatalog', - + requires: [ 'Ext.grid.plugin.BufferedRenderer', 'amdaUI.StatisticalPlug' ], - + isCatalog : true, statics: { COL_TO_HIDE_DURATION : 'colToHideDuration' }, - + constructor: function(config) { this.init(config); this.callParent(arguments); this.toReconfigure = true; - + if (this.object) { this.loadObject(); } }, - - setObject : function (object, toReconfigure) { - if (toReconfigure) + + setObject : function (object, toReconfigure) { + if (toReconfigure) this.toReconfigure = true; - // set object - this.object = object; + // set object + this.object = object; // load object into view this.loadObject(); // show the default duration column this.TTGrid.headerCt.getGridColumns(); - + Ext.Array.each(this.TTGrid.headerCt.getGridColumns(), function(item,index,all){ // if item is the default duration column if ( item.id == amdaUI.CatalogUI.COL_TO_HIDE_DURATION+'2' ) { // show this column item.show(); } - }); + }); // fire the refresh event (to statistical plugin) this.fireEvent("refresh"); // global event myDesktopApp.EventManager.fireEvent("refresh"); }, - + /** * set params description into this.object */ setParamInfo : function(parameters) { var params = []; Ext.Array.each(parameters, function(item, index) { - params[index] = item; + params[index] = item; }, this); - + this.object.set('parameters', params); - this.object.set('nbParameters', params.length); + this.object.set('nbParameters', params.length); }, - + /** * update this.object from form - */ - updateObject : function(){ - // get the basic form - var basicForm = this.formPanel.getForm(); + */ + updateObject : function(){ + // get the basic form + var basicForm = this.formPanel.getForm(); var updateStatus = true; var fieldsWithoutName = basicForm.getFields().items; Ext.Array.each(fieldsWithoutName, function(item, index,allItems){ - if(item !== this.fieldName) { + if(item !== this.fieldName) { if (!item.isValid()) { // set update isn't allowed - updateStatus = false; + updateStatus = false; } } }, this); @@ -88,10 +88,10 @@ Ext.define('amdaUI.CatalogUI', { if (updateStatus) { /// real object update // update TimeTable object with the content of form - basicForm.updateRecord(this.object); + basicForm.updateRecord(this.object); } - // return the update status - return updateStatus; + // return the update status + return updateStatus; }, addInterval : function(start, stop) { @@ -111,12 +111,12 @@ Ext.define('amdaUI.CatalogUI', { } }, this); }, - + updateCount : function() { - this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount()); + this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount()); this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals')); - }, - generateTT : function(catId){ + }, + generateTT : function(catId){ var catObj = Ext.create('amdaModel.TimeTable'); var timeTabNode = Ext.create('amdaModel.TimeTableNode',{leaf : true}); catObj.set('relatedCatalogId', catId) @@ -133,17 +133,17 @@ Ext.define('amdaUI.CatalogUI', { // edit newNode into Parameter Module with node as contextNode timeTabNode.editInModule(); }); - - - + + + }, - onAfterInit: function(result, e) + onAfterInit: function(result, e) { var me = this; - if (!result) { + if (!result) { myDesktopApp.errorMsg(e.message); Ext.defer(function(){Ext.Msg.toFront()},10); - + return; } else if (!result.success) @@ -156,9 +156,9 @@ Ext.define('amdaUI.CatalogUI', { Ext.defer(function(){Ext.Msg.toFront()},10); return; } - - if (me.toReconfigure) - { + + if (me.toReconfigure) + { var fieldsConfig = [ { name : 'start', @@ -250,7 +250,7 @@ Ext.define('amdaUI.CatalogUI', { text: 'Start Time', format: 'Y-m-d\\TH:i:s', sortable : true, - dataIndex: 'start', + dataIndex: 'start', width : 120, menuDisabled: false, editor : { @@ -264,7 +264,7 @@ Ext.define('amdaUI.CatalogUI', { xtype: 'datecolumn', text: 'Stop Time', format: 'Y-m-d\\TH:i:s', - sortable : true, + sortable : true, dataIndex: 'stop', width : 120, menuDisabled: false, @@ -279,9 +279,9 @@ Ext.define('amdaUI.CatalogUI', { xtype: 'gridcolumn', text: 'Duration (hour)', sortable : true, - dataIndex: 'durationHour', + dataIndex: 'durationHour', width : 120, - menuDisabled: false, + menuDisabled: false, hidden:true, id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION+'1', renderer: function(value) { @@ -297,9 +297,9 @@ Ext.define('amdaUI.CatalogUI', { xtype: 'gridcolumn', text: 'Duration (Min)', sortable : true, - dataIndex: 'durationMin', + dataIndex: 'durationMin', width : 120, - menuDisabled: false, + menuDisabled: false, hidden:false, id: amdaUI.CatalogUI.COL_TO_HIDE_DURATION+'2', renderer: function(value) { @@ -315,7 +315,7 @@ Ext.define('amdaUI.CatalogUI', { xtype: 'gridcolumn', text: 'Duration (Sec)', sortable : true, - dataIndex: 'durationSec', + dataIndex: 'durationSec', width : 120, menuDisabled: false, hidden:true, @@ -327,7 +327,7 @@ Ext.define('amdaUI.CatalogUI', { beforeshow : function(){ updateDurationColumnsVisibility(this.ownerCt.getGridColumns(), amdaUI.CatalogUI.COL_TO_HIDE_DURATION+'3'); } - } + } } ]; @@ -339,7 +339,13 @@ Ext.define('amdaUI.CatalogUI', { text: obj.name, sortable : true, dataIndex: 'param'+(index+2), - menuDisabled: false + menuDisabled: false, + listeners: { + 'sortchange' : function(ct, column, direction, eOpts) { + //console.log(column); + }, + scope: this + } }; switch (obj.type) { case 1: //dateTime @@ -353,7 +359,7 @@ Ext.define('amdaUI.CatalogUI', { } return value; } - + }); column = Ext.apply({}, column, { xtype: 'datecolumn', @@ -371,6 +377,7 @@ Ext.define('amdaUI.CatalogUI', { type: 'string' }); column = Ext.apply({}, column, { + xtype: 'gridcolumn', width : 50. * parseInt(obj.size), editor: 'textfield' }); @@ -383,7 +390,7 @@ Ext.define('amdaUI.CatalogUI', { fields: fieldsConfig, autoDestroy: false, pageSize : 200, - buffered : true, + buffered : true, purgePageCount: 0, remoteSort: true, proxy: { @@ -400,77 +407,77 @@ Ext.define('amdaUI.CatalogUI', { }, listeners: { scope : me, - load: function(store,records) { + load: function(store,records) { // myDesktopApp.EventManager.fireEvent('refresh'); me.TTGrid.getView().refresh(); me.TTGrid.getSelectionModel().refresh(); me.updateCount(); //Statistical plugin this.fireEvent("refresh"); - } + } } }); - + me.TTGrid.reconfigure(store, columnsConfig); } me.TTGrid.getSelectionModel().deselectAll(); - // + // // // clear filters // me.TTGrid.getStore().clearFilter(true); - // + // // clear sort me.TTGrid.getStore().sorters.clear(); - // me.TTGrid.getStore().sorters = new Ext.util.MixedCollection(); - + me.TTGrid.getStore().sorters = new Ext.util.MixedCollection(); + //set cache token to the Catalog object me.object.set('cacheToken', result.token); - me.setParamInfo(result.parameters); + me.setParamInfo(result.parameters); me.TTGrid.getStore().load(); - + me.status = result.status; //Statistical plugin me.fireEvent("refresh"); }, - + /** * load object catalog into this view */ - loadObject : function(){ + loadObject : function(){ // load object into form this.formPanel.getForm().loadRecord(this.object); - + this.status = null; - - if (this.object.get('fromPlugin') && (this.object.get('objName') != '')){ + + if (this.object.get('fromPlugin') && (this.object.get('objName') != '')){ if (this.object.get('objFormat') && this.object.get('objFormat') != ''){ //From uploaded file - AmdaAction.initTTCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), this.isCatalog, this.onAfterInit, this); + AmdaAction.initObjectCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), this.isCatalog, this.onAfterInit, this); } else { - //From tmp object (ie Statistics result) - AmdaAction.initTTCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), this.isCatalog, this.onAfterInit, this); + //From tmp object (ie Statistics result) + AmdaAction.initObjectCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), this.isCatalog, this.onAfterInit, this); } } else { var typeTT = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id).linkedNode.data.nodeType; - + if (this.object.get('id') == '') { - AmdaAction.initTTCache(this.isCatalog, this.object.get('nbParameters'), this.onAfterInit,this); - } + AmdaAction.initObjectCache(this.isCatalog, this.object.get('nbParameters'), this.onAfterInit,this); + } else { //From existing TT file - AmdaAction.initTTCacheFromTT(this.object.get('id'), typeTT, this.onAfterInit, this); + AmdaAction.initObjectCacheFromTT(this.object.get('id'), typeTT, this.onAfterInit, this); } } //Statistical plugin this.fireEvent("refresh"); }, - + checkIntervalsStatusForSave : function(onStatusOk) { onStatusOk(); }, - - /* + + /* * save method called by Save button */ saveProcess : function(toRename) @@ -478,22 +485,22 @@ Ext.define('amdaUI.CatalogUI', { var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); // store / columns are the same - not needed to reconfigure grid this.toReconfigure = false; - + // if save shared catalog if (module.contextNode && (module.contextNode.get('id') == 'sharedcatalog-treeRootNode')) - { - module.linkedNode = null; + { + module.linkedNode = null; module.createLinkedNode(); - module.createObject(this.object.getJsonValues()); - var obj = module.linkedNode.get('object'); + module.createObject(this.object.getJsonValues()); + var obj = module.linkedNode.get('object'); // synchronisation of objects this.object = obj; module.linkedNode.create(); } // if the name has been modified this is a creation - else if (this.fclose()) { - if (this.object.isModified('name') || this.object.get('fromPlugin')) { - // if object already has an id : it's a 'rename' of an existing + else if (this.fclose()) { + if (this.object.isModified('name') || this.object.get('fromPlugin')) { + // if object already has an id : it's a 'rename' of an existing if (this.object.get('id')){ // the context Node is the parent node of current edited one var contextNode = module.linkedNode.parentNode; @@ -503,46 +510,46 @@ Ext.define('amdaUI.CatalogUI', { module.linkedNode.set('contextNode',contextNode); // create a new object linked module.createObject(this.object.getJsonValues()); - - var obj = module.linkedNode.get('object'); + + var obj = module.linkedNode.get('object'); // synchronisation of objects this.object = obj; if (toRename) module.linkedNode.toRename = true; - } + } module.linkedNode.create({callback : function() {module.linkedNode.update();}, scope : this}); } else { - //update + //update module.linkedNode.update(); - } + } } }, - + /** * overwrite metod called by Save button */ - overwriteProcess : function(btn) { + overwriteProcess : function(btn) { if (btn == 'cancel') return; - + this.fieldName.clearInvalid(); this.saveProcess(true); }, - + /** - * Check if changes were made before closing window + * Check if changes were made before closing window * @return true if changes - */ + */ fclose : function() { if (this.status == null) return false; - + var isDirty = this.formPanel.getForm().isDirty() || (this.status.isModified) || (this.status.nbModified > 0) || (this.status.nbNew > 0); return isDirty; }, - - init : function (config) - { + + init : function (config) + { this.object = config.object; - + this.fieldName = new Ext.form.field.Text({ fieldLabel: 'Name', allowBlank : false, @@ -556,7 +563,7 @@ Ext.define('amdaUI.CatalogUI', { return this.validFlag; } }); - + var cellEditing = Ext.create('Ext.grid.plugin.CellEditing',{ // clicksToEdit: 2, onEditComplete : function(ed, value, startValue) { @@ -571,7 +578,7 @@ Ext.define('amdaUI.CatalogUI', { me.setActiveEditor(null); me.setActiveColumn(null); me.setActiveRecord(null); - + context.value = value; if (!me.validateEdit()) { me.editing = false; @@ -581,16 +588,16 @@ Ext.define('amdaUI.CatalogUI', { // Only update the record if the new value is different than the // startValue. When the view refreshes its el will gain focus if (!record.isEqual(value, startValue)) { - var obj = {}; - + var obj = {}; + obj['cacheId'] = record.get('cacheId'); obj['isCatalog'] = true; - obj[activeColumn.dataIndex] = value; - + obj[activeColumn.dataIndex] = value; + //Interval is modified on the server side me.editing = true; - - AmdaAction.modifyTTCacheInterval(obj, function (result, e) { + + AmdaAction.modifyTTCacheInterval(obj, function (result, e) { var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); if (module) module.getUiContent().status = result.status; @@ -613,32 +620,32 @@ Ext.define('amdaUI.CatalogUI', { else me.editing = false; } - } + } }); - this.TTGrid = Ext.create('Ext.grid.Panel', { + this.TTGrid = Ext.create('Ext.grid.Panel', { height: 530, columns: [ ], frame: true, - columnLines: true, + columnLines: true, selModel: {pruneRemoved: false}, // selType: 'cellmodel', plugins: [ cellEditing, { ptype : 'bufferedrenderer'} ], dockedItems: [{ - xtype: 'toolbar', + xtype: 'toolbar', items: [{ iconCls: 'icon-add', scope: this, - handler: function(){ + handler: function(){ cellEditing.cancelEdit(); var store = this.TTGrid.getStore(); - + var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; var row = 0; if (selection) row = store.indexOf(selection) + 1; this.TTGrid.getSelectionModel().deselectAll(); - + var me = this; AmdaAction.addTTCacheInterval({'index' : row, 'isCatalog' : true}, function (result, e) { this.status = result.status; @@ -647,7 +654,7 @@ Ext.define('amdaUI.CatalogUI', { callback : function(records, options, success) { me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function() { me.TTGrid.getView().select(row); - cellEditing.startEditByPosition({row: row, column: 1}); + cellEditing.startEditByPosition({row: row, column: 1}); }, me); } }); @@ -661,9 +668,9 @@ Ext.define('amdaUI.CatalogUI', { scope: this, handler: function(){ var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; - if (selection) + if (selection) { - var rowId = selection.get('cacheId'); + var rowId = selection.get('cacheId'); this.TTGrid.getSelectionModel().deselectAll(); AmdaAction.removeTTCacheIntervalFromId(rowId, this.isCatalog, function (result, e) { this.status = result.status; @@ -676,34 +683,39 @@ Ext.define('amdaUI.CatalogUI', { }] }] }); - - this.formPanel = Ext.create('Ext.form.Panel', { + + this.TTGrid.down('.headercontainer').on('sortchange', function(ct, column, direction, eOpts) { + console.log(column); +console.log(direction); +}); + + this.formPanel = Ext.create('Ext.form.Panel', { region : 'center', layout: 'hbox', model : 'amdaModel.Catalog', - trackResetOnLoad : true, // reset to the last loaded record + trackResetOnLoad : true, // reset to the last loaded record bodyStyle: {background : '#dfe8f6'}, defaults: { border : false, align: 'stretch', bodyStyle: {background : '#dfe8f6'}, padding: '3'}, fieldDefaults: { labelWidth: 80, labelAlign : 'top' }, - items: [{ - xtype: 'form', + items: [{ + xtype: 'form', flex: 1, buttonAlign: 'left', - // title : 'Information', + // title : 'Information', layout: {type: 'vbox', pack: 'start', align: 'stretch'}, items : [ this.fieldName, { xtype: 'fieldcontainer', - layout: 'hbox', + layout: 'hbox', items: [{ xtype:'datefield', fieldLabel:'Creation date', - name: 'created', disabled: true, + name: 'created', disabled: true, hideTrigger: true, format: 'Y/m/d H:i:s' - }, - { xtype: 'splitter' }, + }, + { xtype: 'splitter' }, { xtype:'textfield', fieldLabel: 'Intervals', name: 'nbIntervals', disabled: true } - ] + ] }, { xtype: 'textarea', @@ -714,28 +726,28 @@ Ext.define('amdaUI.CatalogUI', { { xtype: 'component', height: 90 - }], + }], dockedItems:[{ xtype: 'toolbar', - dock: 'bottom', + dock: 'bottom', ui: 'footer', items: [{ type: 'button', text: 'Create New Catalog', scope : this, - handler: function () - { - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); - + handler: function () + { + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); + if (!module) return; - + module.createLinkedNode(); module.createObject(); - + var obj = module.linkedNode.get('object'); - + var me = this; - + Ext.Msg.prompt('Define Parameters', 'Please enter parameters number:', function(btn, text){ if (btn == 'ok'){ module.createLinkedNode(); @@ -751,27 +763,27 @@ Ext.define('amdaUI.CatalogUI', { me.setObject(obj,true); } }, this); - + } }] }, - - { + + { xtype: 'toolbar', - dock: 'bottom', + dock: 'bottom', ui: 'footer', items: [ { type: 'button', text: 'Save', scope : this, - handler: function () + handler: function () { if (this.updateObject()) { - var basicForm = this.formPanel.getForm(); + var basicForm = this.formPanel.getForm(); // if there's at least one record in the store of TTGrid - if (this.TTGrid.getStore().getTotalCount() > 0) + if (this.TTGrid.getStore().getTotalCount() > 0) { // update TimeTable object which the content of form basicForm.updateRecord(this.object); @@ -779,10 +791,10 @@ Ext.define('amdaUI.CatalogUI', { var me = this; this.checkIntervalsStatusForSave(function () { //Name validation - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); - + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); + if (!module) return; - module.linkedNode.isValidName(me.fieldName.getValue(), function (res) + module.linkedNode.isValidName(me.fieldName.getValue(), function (res) { if (!res) { me.fieldName.validFlag = 'Error during object validation'; @@ -790,14 +802,14 @@ Ext.define('amdaUI.CatalogUI', { me.fieldName.validate(); return; } - + if (!res.valid) { if (res.error) { - if (res.error.search('subtree') != -1) { - Ext.MessageBox.show({title:'Warning', + if (res.error.search('subtree') != -1) { + Ext.MessageBox.show({title:'Warning', msg: res.error+'<br/>Do you want to overwrite it?', width: 300, - buttons: Ext.MessageBox.OKCANCEL, + buttons: Ext.MessageBox.OKCANCEL, fn : me.overwriteProcess, icon: Ext.MessageBox.WARNING, scope : me @@ -814,35 +826,35 @@ Ext.define('amdaUI.CatalogUI', { me.fieldName.validate(); return; } - + me.fieldName.validFlag = true; me.fieldName.validate(); me.saveProcess(false); }); - }); - } + }); + } else { Ext.Msg.alert('No intervals', 'Your catalog is invalid, <br>you must have at least one interval'); } } - } + } },{ type: 'button', text: 'Reset', scope : this, handler: function() { - var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); + var module = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id); // module.createLinkedNode(); // module.createObject(); - this.setObject(module.getLinkedNode().get('object'), true); - } - }, -// { + this.setObject(module.getLinkedNode().get('object'), true); + } + }, +// { // type: 'button', // text: 'Share', // scope : this, -// handler: function() { -// var me = this; +// handler: function() { +// var me = this; // myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.catalog.id, true, function (module) { // var catalog = module.getLinkedNode().get('object'); // module.shareCatalog({'name' : catalog.get('text'), 'id' : catalog.get('id')}); @@ -852,48 +864,48 @@ Ext.define('amdaUI.CatalogUI', { ] }, - //statistical info + //statistical info { xtype: 'toolbar', - dock: 'bottom', + dock: 'bottom', ui: 'footer', - items:[{ + items:[{ xtype: 'button', text: 'Statistical info', scope: this, - //dock: 'bottom', + //dock: 'bottom', //ui: 'footer', handler: function() { this.fireEvent('info','catalogUI'); } }, - { + { type: 'button', text: 'Visualize', scope: this, handler: function() { var me = this; - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) { + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.visu.id, true, function (module) { //temporary linked node - as Visu module is 'pseudo' interactive - no 'save', no 'execute' var temporaryNode = Ext.create('amdaModel.CatalogNode', { leaf : true }); - if (temporaryNode) temporaryNode.set('object',me.object); + if (temporaryNode) temporaryNode.set('object',me.object); module.setLinkedNode(temporaryNode); - - module.createWindow(); - }); + + module.createWindow(); + }); } } ] }, { xtype: 'toolbar', - dock: 'bottom', + dock: 'bottom', ui: 'footer', - items:[{ + items:[{ xtype: 'button', text: 'Generate Time Table', scope: this, - //dock: 'bottom', + //dock: 'bottom', //ui: 'footer', handler: function() { this.generateTT(this.object.get('id')); @@ -902,24 +914,24 @@ Ext.define('amdaUI.CatalogUI', { ] }, { - xtype: 'form', + xtype: 'form', bodyStyle: {background : '#dfe8f6'}, //padding: '3', flex: 2, - items : [ this.TTGrid ] - }] - }); - + items : [ this.TTGrid ] + }] + }); + this.TTGrid.getSelectionModel().on('selectionchange', function(selModel,selections) { - this.TTGrid.down('#delete').setDisabled(selections.length === 0); - }, this); - + this.TTGrid.down('#delete').setDisabled(selections.length === 0); + }, this); + var myConf = { layout: 'border', - items: [ - this.formPanel, + items: [ + this.formPanel, { - xtype: 'panel', + xtype: 'panel', region: 'south', title: 'Information', collapsible: true, @@ -928,16 +940,16 @@ Ext.define('amdaUI.CatalogUI', { autoHide: false, bodyStyle: 'padding:5px', iconCls: 'icon-information', - loader: + loader: { autoLoad: true, url: helpDir+'catalogHOWTO' - } + } } ] , - plugins: [ {ptype: 'statisticalPlugin'} ] - }; - Ext.apply (this, Ext.apply(arguments, myConf)); + plugins: [ {ptype: 'statisticalPlugin'} ] + }; + Ext.apply (this, Ext.apply(arguments, myConf)); } - -}); + +}); diff --git a/js/app/views/TimeTableUI.js b/js/app/views/TimeTableUI.js index ec8f791..0394676 100755 --- a/js/app/views/TimeTableUI.js +++ b/js/app/views/TimeTableUI.js @@ -11,7 +11,7 @@ Ext.define('amdaUI.TimeTableUI', { extend: 'Ext.container.Container', alias: 'widget.panelTimeTable', - + requires: [ 'Ext.ux.grid.FiltersFeature', 'Ext.ux.grid.filter.DateFilter', @@ -20,14 +20,14 @@ Ext.define('amdaUI.TimeTableUI', { 'amdaUI.StatisticalPlug', 'Ext.grid.plugin.BufferedRenderer' ], - + statics: { COL_TO_HIDE : 'colToHide' }, - + status: null, - - constructor: function(config) { + + constructor: function(config) { this.init(config); this.callParent(arguments); // load object into view @@ -38,42 +38,42 @@ Ext.define('amdaUI.TimeTableUI', { * set the current editing object * this method will be used on timetable edition when this win is already opened */ - setObject : function (object) + setObject : function (object) { // set object this.object = object; - + // load object into view this.loadObject(); - + // show the default duration column this.TTGrid.headerCt.getGridColumns(); - + Ext.Array.each(this.TTGrid.headerCt.getGridColumns(), function(item,index,all){ // if item is the default duration column if ( item.id == amdaUI.TimeTableUI.COL_TO_HIDE+'2' ) { // show this column item.show(); } - }); + }); // fire the refresh event (to statistical plugin) this.fireEvent("refresh"); // global event myDesktopApp.EventManager.fireEvent("refresh"); }, - + /** * load object timetable into this view */ - loadObject : function(){ + loadObject : function(){ // load object into form this.formPanel.getForm().loadRecord(this.object); - + this.status = null; - + // var me = this; - + var onAfterInit = function(result, e) { if (!result || !result.success) { @@ -83,63 +83,63 @@ Ext.define('amdaUI.TimeTableUI', { myDesktopApp.errorMsg('Unknown error during cache initialisation'); return; } - + me.TTGrid.getSelectionModel().deselectAll(); - + // clear filters me.TTGrid.getStore().clearFilter(true); me.TTGrid.filters.clearFilters(); - + //clear sort me.TTGrid.getStore().sorters.clear(); //me.TTGrid.getStore().sorters = new Ext.util.MixedCollection(); - + //set cache token to the Time Table object me.object.set('cacheToken', result.token); - + me.TTGrid.getStore().load(); - + me.status = result.status; - + //Statistical plugin me.fireEvent("refresh"); }; - + if (this.object.get('fromPlugin')) { if (this.object.get('objFormat') && this.object.get('objFormat') != '') { //From uploaded file - AmdaAction.initTTCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), false, onAfterInit); + AmdaAction.initObjectCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), false, onAfterInit); } else { //From tmp object (ie Search result) - AmdaAction.initTTCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), false, onAfterInit); + AmdaAction.initObjectCacheFromTmpObject(this.object.get('folderId'), this.object.get('objName'), false, onAfterInit); } } else if(this.object.get('relatedCatalogId') != '') - { + { var pathern=this.object.get('relatedCatalogId').split('_')[0] ; catType=''; if(pathern=='cat') catType=' catalog' ; if(pathern=='sharedcatalog') catType='sharedcatalog' ; - AmdaAction.initTTCacheFromCatalog(this.object.get('relatedCatalogId'), catType, onAfterInit); + AmdaAction.initObjectCacheFromCatalog(this.object.get('relatedCatalogId'), catType, onAfterInit); } - else + else { var typeTT = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id).linkedNode.data.nodeType; if (this.object.get('id') == '') { //Init empty cache - AmdaAction.initTTCache(false,0,onAfterInit); - } + AmdaAction.initObjectCache(false,0,onAfterInit); + } else { //From existing TT file - AmdaAction.initTTCacheFromTT(this.object.get('id'), typeTT, onAfterInit); + AmdaAction.initObjectCacheFromTT(this.object.get('id'), typeTT, onAfterInit); } } }, @@ -150,17 +150,17 @@ Ext.define('amdaUI.TimeTableUI', { updateObject : function() { this.updateCount(); - + // get the basic form - var basicForm = this.formPanel.getForm(); + var basicForm = this.formPanel.getForm(); var updateStatus = true; var fieldsWithoutName = basicForm.getFields().items; Ext.Array.each(fieldsWithoutName, function(item, index,allItems){ - if(item !== this.fieldName) { + if(item !== this.fieldName) { if (!item.isValid()) { // set update isn't allowed - updateStatus = false; + updateStatus = false; } } }, this); @@ -168,40 +168,40 @@ Ext.define('amdaUI.TimeTableUI', { if (updateStatus) { /// real object update // update TimeTable object with the content of form - basicForm.updateRecord(this.object); + basicForm.updateRecord(this.object); } // return the update status - return updateStatus; - }, + return updateStatus; + }, - updateCount : function() + updateCount : function() { this.object.set('nbIntervals',this.TTGrid.getStore().getTotalCount()); this.formPanel.getForm().findField('nbIntervals').setValue(this.object.get('nbIntervals')); }, - - /* + + /* * save method called by Save button */ saveProcess : function(toRename) { - var timeTableModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); - + var timeTableModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); + // if the name has been modified this is a creation if (timeTableModule.contextNode && (timeTableModule.contextNode.data.id == 'sharedtimeTable-treeRootNode')) - { - timeTableModule.linkedNode = null; + { + timeTableModule.linkedNode = null; timeTableModule.createLinkedNode(); - timeTableModule.createObject(this.object.getJsonValues()); - var ttobj = timeTableModule.linkedNode.get('object'); + timeTableModule.createObject(this.object.getJsonValues()); + var ttobj = timeTableModule.linkedNode.get('object'); // synchronisation of objects this.object = ttobj; timeTableModule.linkedNode.create(); } else if (this.fclose()) /*TimeTable object has been modified*/ { - if (this.object.isModified('name') || this.object.get('fromPlugin')) - { + if (this.object.isModified('name') || this.object.get('fromPlugin')) + { // if object already has an id : it's a 'rename' of an existing TimeTable if (this.object.get('id')) { @@ -213,17 +213,17 @@ Ext.define('amdaUI.TimeTableUI', { timeTableModule.linkedNode.set('contextNode',contextNode); // create a new object linked timeTableModule.createObject(this.object.getJsonValues()); - - var ttobj = timeTableModule.linkedNode.get('object'); + + var ttobj = timeTableModule.linkedNode.get('object'); // synchronisation of objects this.object = ttobj; - + if (toRename) timeTableModule.linkedNode.toRename = true; - } + } timeTableModule.linkedNode.create({callback : function ($action) { if (timeTableModule.linkedNode.get('object').get('fromPlugin')) timeTableModule.linkedNode.get('object').set('fromPlugin',false); - timeTableModule.linkedNode.update();}, + timeTableModule.linkedNode.update();}, scope : this}); } else { //update @@ -231,20 +231,20 @@ Ext.define('amdaUI.TimeTableUI', { } } }, - + /** * overwrite metod called by Save button */ overwriteProcess : function(btn) - { + { if (btn == 'cancel') return; - + this.fieldName.clearInvalid(); - this.saveProcess(true); - + this.saveProcess(true); + }, - - addInterval : function(start, stop) + + addInterval : function(start, stop) { var row = this.TTGrid.getStore().getTotalCount(); var me = this; @@ -262,11 +262,11 @@ Ext.define('amdaUI.TimeTableUI', { } }, this); }, - - init : function(config) - { + + init : function(config) + { this.object = config.object; - + this.fieldName = new Ext.form.field.Text({ fieldLabel: 'Name*', allowBlank : false, @@ -281,7 +281,7 @@ Ext.define('amdaUI.TimeTableUI', { return this.validFlag; } }); - + this.formPanel = new Ext.form.Panel({ bodyStyle: {background : '#dfe8f6'}, id: 'formTimeTable', @@ -291,22 +291,22 @@ Ext.define('amdaUI.TimeTableUI', { border : false, fieldDefaults: { labelWidth: 80 }, items: [ - this.fieldName, + this.fieldName, { xtype: 'fieldcontainer', layout: 'hbox', fieldLabel:'Creation date', items: [ { - xtype:'datefield', width: 180, - name: 'created', disabled: true, + xtype:'datefield', width: 180, + name: 'created', disabled: true, hideTrigger: true, format: 'Y/m/d H:i:s' }, { xtype:'component', width: 20 }, { xtype:'displayfield', value: 'Intervals:', width: 50 }, { xtype:'component', width: 8 }, { xtype:'textfield', name: 'nbIntervals', disabled: true, width: 70 } - ] + ] }, { xtype: 'textarea', @@ -323,7 +323,7 @@ Ext.define('amdaUI.TimeTableUI', { ] }); - + var store = Ext.create('Ext.data.Store', { model: 'amdaModel.Interval', autoDestroy: false, @@ -332,10 +332,10 @@ Ext.define('amdaUI.TimeTableUI', { autoLoad: true, purgePageCount: 0, remoteSort: true, - listeners: { + listeners: { load: function(store,records) { - - // alert('nb of records in store:'+records.length ); + + // alert('nb of records in store:'+records.length ); myDesktopApp.EventManager.fireEvent('refresh'); this.TTGrid.getView().refresh(); this.TTGrid.getSelectionModel().refresh(); @@ -366,21 +366,21 @@ Ext.define('amdaUI.TimeTableUI', { this.fireEvent("refresh"); }, scope : this - } - }); - + } + }); + var filters = { ftype: 'filters', encode: true, // json encode the filter query local: false, // defaults to false (remote filte filters: [ { type: 'numeric', dataIndex: 'durationHour'}, - { type: 'numeric', dataIndex: 'durationMin'}, - { type: 'numeric', dataIndex: 'durationSec'}, + { type: 'numeric', dataIndex: 'durationMin'}, + { type: 'numeric', dataIndex: 'durationSec'}, { type: 'date', dataIndex: 'start', dateFormat: 'Y-m-d'}, { type: 'date', dataIndex: 'stop', dateFormat: 'Y-m-d' } ] - }; + }; var cellEditing = Ext.create('Ext.grid.plugin.CellEditing',{ onEditComplete : function(ed, value, startValue) { @@ -395,7 +395,7 @@ Ext.define('amdaUI.TimeTableUI', { me.setActiveEditor(null); me.setActiveColumn(null); me.setActiveRecord(null); - + context.value = value; if (!me.validateEdit()) { me.editing = false; @@ -421,13 +421,13 @@ Ext.define('amdaUI.TimeTableUI', { me.editing = false; return; } - + //context.grid.getSelectionModel().deselectAll(); //Interval is modified on the server side me.editing = true; - + AmdaAction.modifyTTCacheInterval(obj, function (result, e) { - + var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); if (ttModule) ttModule.getUiContent().status = result.status; @@ -438,7 +438,7 @@ Ext.define('amdaUI.TimeTableUI', { context.view.bufferedRenderer.scrollTo(context.rowIdx, true, function() { me.fireEvent('edit', me, context); me.editing = false; - }, me); + }, me); } }); } @@ -451,7 +451,7 @@ Ext.define('amdaUI.TimeTableUI', { me.editing = false; } } - + }); this.TTGrid = Ext.create('Ext.grid.Panel', { @@ -459,7 +459,7 @@ Ext.define('amdaUI.TimeTableUI', { features: [filters], columnLines: true, selModel: {pruneRemoved: false}, - columns: [ + columns: [ { xtype: 'rownumberer', width: 50, @@ -473,10 +473,10 @@ Ext.define('amdaUI.TimeTableUI', { return msg; } }, - { + { header: 'Start Time', dataIndex: 'start', width: 120, - editor: { xtype:'datefield', allowBlank:false, hideTrigger: true, format : 'Y-m-d\\TH:i:s'}, - renderer: function(value){ + editor: { xtype:'datefield', allowBlank:false, hideTrigger: true, format : 'Y-m-d\\TH:i:s'}, + renderer: function(value){ if (value != null) { if(Ext.isDate(value)){ return Ext.Date.format(value, 'Y-m-d\\TH:i:s'); @@ -488,8 +488,8 @@ Ext.define('amdaUI.TimeTableUI', { } } }, - { - header: 'Stop Time', dataIndex: 'stop', width: 120, + { + header: 'Stop Time', dataIndex: 'stop', width: 120, editor: { xtype: 'datefield', allowBlank: false, hideTrigger: true, format : 'Y-m-d\\TH:i:s'}, renderer: function(value) { if (value != null) { @@ -502,7 +502,7 @@ Ext.define('amdaUI.TimeTableUI', { return value; } } - }, + }, { header: 'Duration (hour)', width: 120, dataIndex: 'durationHour', id: amdaUI.TimeTableUI.COL_TO_HIDE+'1', @@ -524,7 +524,7 @@ Ext.define('amdaUI.TimeTableUI', { }); } } - }, + }, { header: 'Duration (min)', width: 120, dataIndex: 'durationMin', id: amdaUI.TimeTableUI.COL_TO_HIDE+'2', @@ -545,7 +545,7 @@ Ext.define('amdaUI.TimeTableUI', { }); } } - }, + }, { header: 'Duration (sec)', width: 120, dataIndex: 'durationSec', id: amdaUI.TimeTableUI.COL_TO_HIDE+'3', @@ -568,22 +568,22 @@ Ext.define('amdaUI.TimeTableUI', { } } } - ], + ], frame: true, dockedItems: [{ - xtype: 'toolbar', + xtype: 'toolbar', items: [{ iconCls: 'icon-add', scope: this, handler: function(){ cellEditing.cancelEdit(); - + var selection = this.TTGrid.getView().getSelectionModel().getSelection()[0]; var row = 0; if (selection) row = store.indexOf(selection) + 1; this.TTGrid.getSelectionModel().deselectAll(); - + var me = this; AmdaAction.addTTCacheInterval({'index' : row}, function (result, e) { this.status = result.status; @@ -592,8 +592,8 @@ Ext.define('amdaUI.TimeTableUI', { callback : function(records, options, success) { me.TTGrid.getView().bufferedRenderer.scrollTo(row, false, function() { me.TTGrid.getView().select(row); - cellEditing.startEditByPosition({row: row, column: 1}); - }, me); + cellEditing.startEditByPosition({row: row, column: 1}); + }, me); } }); } @@ -625,14 +625,14 @@ Ext.define('amdaUI.TimeTableUI', { handler: function () { this.TTGrid.getStore().clearFilter(true); this.TTGrid.filters.clearFilters(); - } + } } - ] + ] }], plugins: [ cellEditing, {ptype : 'bufferedrenderer'} ], listeners : { scope : this, - edit : function(editor,e) { + edit : function(editor,e) { if (e.record.get('stop') != null && e.record.get('start') != null) { e.record.set('durationHour', (e.record.get('stop') - e.record.get('start'))/3600000.0); e.record.set('durationMin', (e.record.get('stop') - e.record.get('start'))/60000.0); @@ -645,9 +645,9 @@ Ext.define('amdaUI.TimeTableUI', { }); this.TTGrid.getSelectionModel().on('selectionchange', function(selModel,selections){ - this.TTGrid.down('#delete').setDisabled(selections.length === 0); + this.TTGrid.down('#delete').setDisabled(selections.length === 0); }, this); - + var myConf = { layout: 'border', defaults: { layout: 'fit', border: false }, @@ -658,8 +658,8 @@ Ext.define('amdaUI.TimeTableUI', { buttonAlign: 'left', bodyStyle: {background : '#dfe8f6'}, padding: '5 5 5 5', - layout: {type: 'hbox', pack: 'start', align: 'stretch'}, - items: [ + layout: {type: 'hbox', pack: 'start', align: 'stretch'}, + items: [ { xtype: 'container', flex: 3.6, @@ -672,26 +672,26 @@ Ext.define('amdaUI.TimeTableUI', { flex: 2.5, id: 'operation' } - ] - }, - { + ] + }, + { xtype: 'container', border: false, padding: '0 0 5 15', - flex: 4, + flex: 4, layout: 'fit', - items: [ this.TTGrid ] + items: [ this.TTGrid ] } ], fbar:[ - { + { xtype: 'button', text: 'Save', width: 65, scope : this, handler: function () { if (this.updateObject()){ - var basicForm = this.formPanel.getForm(); + var basicForm = this.formPanel.getForm(); // if there's at least one record in the store of TTGrid if (this.TTGrid.getStore().getTotalCount()>0) { // update TimeTable object which the content of form @@ -700,7 +700,7 @@ Ext.define('amdaUI.TimeTableUI', { var me = this; this.checkIntervalsStatusForSave(function () { //Name validation - var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); + var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); if (!ttModule) return; ttModule.linkedNode.isValidName(me.fieldName.getValue(), function (res) { @@ -711,16 +711,16 @@ Ext.define('amdaUI.TimeTableUI', { me.fieldName.validate(); return; } - + if (!res.valid) { if (res.error) { - if (res.error.search('subtree') != -1) { - Ext.MessageBox.show({title:'Warning', + if (res.error.search('subtree') != -1) { + Ext.MessageBox.show({title:'Warning', msg: res.error+'<br/>Do you want to overwrite it?', width: 300, - buttons: Ext.MessageBox.OKCANCEL, + buttons: Ext.MessageBox.OKCANCEL, fn : me.overwriteProcess, icon: Ext.MessageBox.WARNING, scope : me @@ -738,36 +738,36 @@ Ext.define('amdaUI.TimeTableUI', { me.fieldName.validate(); return; } - + me.fieldName.validFlag = true; me.fieldName.validate(); me.saveProcess(false); }); - }); + }); } else { // warning: Ext.Msg.alert('No intervals', 'Your time table is invalid, <br>you must have at least one interval'); } } - } - },{ + } + },{ xtype: 'button', text: 'Reset', width: 65, scope: this, handler: function() { - var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); + var ttModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.tt.id); ttModule.createLinkedNode(); ttModule.createObject(); this.setObject(ttModule.getLinkedNode().get('object')); } - } + } ] - }, + }, { xtype: 'panel', region: 'south', title: 'Information', - collapsible: true, + collapsible: true, collapseMode: 'header', height: 100, autoHide: false, @@ -776,25 +776,25 @@ Ext.define('amdaUI.TimeTableUI', { loader: { autoLoad: true, url: helpDir+'timetableHOWTO' - } + } } ], - plugins: [ {ptype: 'statisticalPlugin'} ] + plugins: [ {ptype: 'statisticalPlugin'} ] }; - - Ext.apply (this , Ext.apply (arguments, myConf)); + + Ext.apply (this , Ext.apply (arguments, myConf)); }, - + checkIntervalsStatusForSave : function(onStatusOk) { if (this.status == null) return; - + if (this.status.nbValid <= 0) { myDesktopApp.errorMsg('Your time table is invalid, <br>you must have at least one valid interval'); return; } - + var msg = ''; if (this.status.nbInvalid > 0) msg += 'There are some invalid intervals. Only valid intervals will be saved!<br/>'; @@ -819,19 +819,19 @@ Ext.define('amdaUI.TimeTableUI', { }); return; } - + onStatusOk(); }, - + /** - * Check if changes were made before closing window + * Check if changes were made before closing window * @return true if changes - */ + */ fclose : function() { if (this.status == null) return false; - + var isDirty = this.formPanel.getForm().isDirty() || (this.status.isModified) || (this.status.nbModified > 0) || (this.status.nbNew > 0); return isDirty; } -}); +}); diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index 8501ee6..4aae42f 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -61,7 +61,7 @@ class AmdaAction $node = $obj->node; $nodeType = $obj->nodeType; - + $remoteBase = false; $isRemoteDataSet = false; @@ -211,12 +211,12 @@ class AmdaAction if ($child->hasAttribute("parentId")) $component_info["parentId"] = $child->getAttribute("parentId"); - + if ($child->hasAttribute("iconCls")) $iconCls = $child->getAttribute("iconCls"); - + if ($isLeaf) $isParameter = true; - + break; case 'timeTable': @@ -235,7 +235,7 @@ class AmdaAction break; case 'derivedParam': $info = $child->getAttribute('buildchain'); - + if ($child->hasAttribute('dim_1')) { $dim_1 = $child->getAttribute('dim_1'); } @@ -265,7 +265,7 @@ class AmdaAction if ($child->hasAttribute('dataStart') && $child->hasAttribute('dataStop')) { $info .= "<br/>Time Range: ".$child->getAttribute('dataStart')."-".$child->getAttribute('dataStop'); - + if ($child->hasAttribute('lastUpdate')) { $info .= "<br/>Last Updated: : ".$child->getAttribute('lastUpdate'); } @@ -274,7 +274,7 @@ class AmdaAction if ($child->getAttribute('dataStart') == 'depending on mission') { $info .= "<br/>Time Range: ".$child->getAttribute('dataStart'); } - + // if ($child->getAttribute('restriction') > 1) { // $restricted = $child->getAttribute('restriction'); // $info .= "<br/><b>Time Restriction</b>: -$restricted days"; @@ -282,15 +282,15 @@ class AmdaAction } if ($child->hasAttribute('units')) { - + $units = $child->getAttribute('units'); - + if ($child->hasAttribute('description')) $info = $child->getAttribute('description')."<br/>".$units; - else + else $info = $units; } - + if ($child->tagName == 'parameter') { $isParameter = true; @@ -298,7 +298,7 @@ class AmdaAction $globalStart = $child->parentNode->getAttribute('dataStart'); $globalStop = $child->parentNode->getAttribute('dataStop'); } - + if ($child->parentNode->hasAttribute('restriction')) { if ($child->parentNode->getAttribute('restriction') == "plotOnly") { $not_yet = true; @@ -318,7 +318,7 @@ class AmdaAction $globalStart = $child->parentNode->parentNode->getAttribute('dataStart'); $globalStop = $child->parentNode->parentNode->getAttribute('dataStop'); } - + if ($child->parentNode->parentNode->hasAttribute('restriction')) { if ($child->parentNode->parentNode->getAttribute('restriction') == "plotOnly") { $not_yet = true; @@ -363,7 +363,7 @@ class AmdaAction if ($child->tagName == 'mission' || $child->tagName == 'observatory') { $rank = $child->getAttribute('rank'); } - + $disable = $child->hasAttribute('group'); if ($disable) { @@ -373,7 +373,7 @@ class AmdaAction else { $info .= "<br/><b>Sorry! Not finished yet...</b>"; } - } + } else { if ($child->hasAttribute('restriction') && $child->getAttribute('restriction') == 'plotOnly') $info .= "<br/><b>Plot Only!!!</b>"; @@ -474,7 +474,7 @@ class AmdaAction { if ($child->tagName == 'dataset') $isRemoteDataSet = true; } - + if ($child->tagName == 'parameter'){ if ($child->parentNode->hasAttribute('dataStart')){ $globalStart = date('Y-m-d\TH:i:s\Z', strtotime($child->parentNode->getAttribute('dataStart'))); @@ -488,7 +488,7 @@ class AmdaAction $globalStop = date('Y-m-d\TH:i:s\Z', strtotime($child->parentNode->getAttribute('dataStop'))); } } - + if ($isParameter) { $disable = $child->parentNode->getAttribute('disabled'); @@ -514,7 +514,7 @@ class AmdaAction else { $restricted = FALSE; - + if ($child->tagName == 'dataset') { $nonavailable = ($child->getAttribute('disabled')); @@ -558,7 +558,7 @@ class AmdaAction $size = $child->getAttribute('size'); $mask = $child->getAttribute('mask'); $sampling = null; - if ($child->hasAttribute('minsampling')) + if ($child->hasAttribute('minsampling')) $sampling = $child->getAttribute('minsampling'); $isSpectra = false; @@ -598,7 +598,7 @@ class AmdaAction $childrenToReturn[] = array('text' => $name, 'id' => $id, 'nodeType' => $nodeType, 'info' => $info, 'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter, 'dim_1' => $dim_1, 'dim_2' => $dim_2, 'tabs' => $plotTabs, - 'component_info' => isset($component_info) ? $component_info : NULL, + 'component_info' => isset($component_info) ? $component_info : NULL, 'iconCls' => isset($iconCls) ? $iconCls : NULL ); } } @@ -614,19 +614,19 @@ class AmdaAction /* * add Remote Parameter to user RemoteParams.xml * send request to DDServer to AddVi if Vi doesn't exist - * create Remote Parameter Description + * create Remote Parameter Description */ public function saveTree($obj) { $paramMgr = new RemoteParamManager(); $res = $paramMgr->init(); - + if ($res['success']) return $paramMgr->saveTree($obj); - else + else return $res; } - + /* * delete Remote Parameter from user RemoteParams.xml */ @@ -634,13 +634,13 @@ class AmdaAction { $paramMgr = new RemoteParamManager(); $res = $paramMgr->init(); - + if ($res['success']) return $paramMgr->deleteFromTree($obj); - else + else return $res; } - + public function doNothing($obj) { return array("res" => 'ok'); @@ -726,7 +726,7 @@ class AmdaAction case 'request' : $objectMgr = new RequestMgr($nodeType); break; - case 'bkgWorks' : + case 'bkgWorks' : return $this->executeRequest($id, FunctionTypeEnumClass::PROCESSGETINFO); break; case 'myData' : @@ -940,7 +940,7 @@ class AmdaAction // return array('success' => false, "message" => "AKKA-KERNEL-INT - WS support for IMPEx not implemented"); } else { - // check disk space + // check disk space if ($dd->getWsSize() > DISK_QUOTA) { //Try to delete log files - cf. #6245 if ($dd->getWsSize(TRUE) > DISK_QUOTA) { @@ -955,8 +955,8 @@ class AmdaAction } private function executeRequest($obj, $function) - { - + { + // Check user if access to DD Server and / or possible 'space consuming' action if ( $function == FunctionTypeEnumClass::PARAMS || $function == FunctionTypeEnumClass::ACTION || @@ -1070,24 +1070,24 @@ class AmdaAction return $result; } - public function initTTCache($isCatalog = false, $nparams) + public function initObjectCache($isCatalog = false, $nparams = 1) { if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr(); else $cacheMgr = new CatalogCacheMgr(); - return $cacheMgr->initTTCache($nparams); + return $cacheMgr->initObjectCache(array('nparams' => $nparams)); } - public function initTTCacheFromTT($id, $type) + public function initObjectCacheFromTT($id, $type) { if ($type == 'catalog' || $type == 'sharedcatalog') $cacheMgr = new CatalogCacheMgr(); else $cacheMgr = new TimeTableCacheMgr(); - return $cacheMgr->initFromTT($id, $type); + return $cacheMgr->initFromObject($id, $type); } - public function initTTCacheFromCatalog($id, $type) + public function initObjectCacheFromCatalog($id, $type) { $cacheMgr = new TimeTableCacheMgr(); @@ -1099,13 +1099,13 @@ class AmdaAction { if ($isTmpObject && $type == 'catalog' && $id == 'cacheCat') return array('success' => true, 'cache' => $id); - + if ($type == 'catalog' || $type == 'sharedcatalog') $objMgr = new CatalogMgr(); return $objMgr->initForChart($id, $name, $isTmpObject, $type); } - public function initTTCacheFromTmpObject($folderId, $name, $isCatalog = false) + public function initObjectCacheFromTmpObject($folderId, $name, $isCatalog = false) { if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr(); else $cacheMgr = new CatalogCacheMgr(); @@ -1113,7 +1113,7 @@ class AmdaAction return $cacheMgr->initFromTmpObject($folderId, $name); } - public function initTTCacheFromUploadedFile($name, $format, $isCatalog = false) + public function initObjectCacheFromUploadedFile($name, $format, $isCatalog = false) { if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr(); else $cacheMgr = new CatalogCacheMgr(); @@ -1132,13 +1132,13 @@ class AmdaAction public function readIntervalsForChart($o) { if (isset($o->typeTT) && ($o->typeTT == 'catalog' || $o->typeTT == 'sharedcatalog')) { - + if ($o->fromPlugin && $o->id == 'cacheCat') { $objMgr = new CatalogCacheMgr(); - + return $objMgr->getIntervals(); } - + $objMgr = new CatalogMgr(); } @@ -1148,7 +1148,7 @@ class AmdaAction public function saveTTCacheIntervalsInTT($o) { $cacheMgr = new TimeTableCacheMgr(); - return $cacheMgr->saveInTT($o->ttId,$o->action,$o->cacheToken); + return $cacheMgr->saveInObject($o->ttId,$o->action,$o->cacheToken); } public function addTTCacheInterval($o) @@ -1193,8 +1193,8 @@ class AmdaAction public function getTTCacheStatistics($obj) { - error_log("name",$obj->name ); - if($obj->name == "timeTableUi"){ + error_log("name",$obj->name ); + if($obj->name == "timeTableUi"){ $cacheMgr = new TimeTableCacheMgr(); }elseif($obj->name == "catalogUI"){ $cacheMgr = new CatalogCacheMgr(); @@ -1467,7 +1467,7 @@ class AmdaAction return $this->executeRequest($inputobj, FunctionTypeEnumClass::PARAMINFO); } public function getDerivedParamInfo($obj) - { + { $dom = new DomDocument("1.0"); $xmlName=USERWSDIR.$this->xmlFiles['derivedParam']; @$dom->load($xmlName); @@ -1480,18 +1480,18 @@ class AmdaAction $dim_2=$param->getAttribute("dim_2"); return $this->createDerivedParamInfo($dim_1,$dim_2,$obj->paramId); } - + } - return array('success'=>false, 'message'=>'unkown parameter (derived parameter arguments are not handled)'); + return array('success'=>false, 'message'=>'unkown parameter (derived parameter arguments are not handled)'); } - + public function createDerivedParamInfo($dim_1,$dim_2,$paramId) { /* case of constant */ if($dim_1*$dim_2==1) { return array('success'=>false,'msg'=>"dim1=1 dim2=1 no arguments for this parameter"); - }elseif(($dim_1==1 && $dim_2>1 && $dim_2<=3)||($dim_2==1 && $dim_1>1 && $dim_1<=3) ) + }elseif(($dim_1==1 && $dim_2>1 && $dim_2<=3)||($dim_2==1 && $dim_1>1 && $dim_1<=3) ) /* case of vector */ { @@ -1519,7 +1519,7 @@ class AmdaAction 'dimensions'=>$dims, 'components'=>$compts ); - + return array('success'=>true,'data'=>$data); }else @@ -1535,7 +1535,7 @@ class AmdaAction for($j=0;$j<count($sizes);$j++) { $compts=array(); - + for($i=0;$i<$sizes[$j];$i++) { $c=array('min'=>'L' . $i,'max'=>'L' . ($i+1)); @@ -1543,7 +1543,7 @@ class AmdaAction } $tab=array( - 'relatedDim'=>'dim' . ($j+1), + 'relatedDim'=>'dim' . ($j+1), 'name'=>'component' . ($j+1), 'units'=>"", 'variable'=>"", @@ -1553,14 +1553,14 @@ class AmdaAction array_push($tables,$tab); } - + $data=array( 'dimensions'=>$dims, 'tables'=>$tables ); return array('success'=>true,'data'=>$data); } - + } public function getSharedObjectFolders($obj) { diff --git a/php/classes/CatalogCacheMgr.php b/php/classes/CatalogCacheMgr.php index 225e4af..a9b9b3a 100644 --- a/php/classes/CatalogCacheMgr.php +++ b/php/classes/CatalogCacheMgr.php @@ -6,25 +6,30 @@ class CatalogCacheMgr extends TimeTableCacheMgr { - - protected static $cache_file = "cacheCat"; - - protected $ttMgr = null; + protected $objectMgr = null; protected $cache = null; function __construct() { - $this->ttMgr = new CatalogMgr(); + $this->objectMgr = new CatalogMgr(); } + protected function getCacheFileName() { + return "cacheCat"; + } + + protected function resetCache() { + $this->cache = new CatalogCacheObject(); + } + public function initFromTmpObject($folderId, $name) { //Create new cache - $this->cache = new CatalogCacheObject(); + $this->resetCache(); //Load intervals from TmpObject file (Statistics Module) - $intervals_res = $this->ttMgr->getTmpObject($folderId, $name); + $intervals_res = $this->objectMgr->getTmpObject($folderId, $name); if (!isset($intervals_res)) return array('success' => false, 'message' => 'Cannot get Tmp Object'); @@ -60,10 +65,10 @@ class CatalogCacheMgr extends TimeTableCacheMgr public function initFromUploadedFile($name, $format) { //Create new cache - $this->cache = new CatalogCacheObject(); + $this->resetCache(); //Load intervals from uploaded file - $intervals_res = $this->ttMgr->getUploadedObject($name, $format); + $intervals_res = $this->objectMgr->getUploadedObject($name, $format); if (!isset($intervals_res)) return array('success' => false, 'message' => 'Cannot get Uploaded Object'); @@ -94,13 +99,13 @@ class CatalogCacheMgr extends TimeTableCacheMgr 'status'=>$this->cache->getStatus(), 'parameters'=>$paramHeaders); } - public function initFromTT($id, $typeTT) + public function initFromObject($id, $type) { //Create new cache - $this->cache = new CatalogCacheObject(); + $this->resetCache(); //Load intervals from catalog file and add to cache - $intervals_res = $this->ttMgr->loadIntervalsFromTT($id,$typeTT); + $intervals_res = $this->objectMgr->loadIntervalsFromObject($id,$type); if (!$intervals_res['success']) return $intervals_res; @@ -132,7 +137,7 @@ class CatalogCacheMgr extends TimeTableCacheMgr { if (!file_exists($this->getCacheFilePath())) return false; - $this->cache = new CatalogCacheObject(); + $this->resetCache(); $handle = fopen($this->getCacheFilePath(), 'rb'); $result = false; if (flock($handle, LOCK_SH)) @@ -145,12 +150,7 @@ class CatalogCacheMgr extends TimeTableCacheMgr return $result; } - protected function getCacheFilePath() - { - return USERTTDIR.(self::$cache_file); - } - - public function saveInTT($id, $action, $token) + public function saveInObject($id, $action, $token) { if (!$this->loadFromFile()) return array('success' => false, 'message' => 'Cannot load cache file'); @@ -165,10 +165,10 @@ class CatalogCacheMgr extends TimeTableCacheMgr $this->cache->reset(); - return $this->ttMgr->saveIntervals($id, $intervals, $action); + return $this->objectMgr->saveIntervals($id, $intervals, $action); } - public function addInterval($index, $start, $stop, $params) { + public function addInterval($index, $start, $stop, $params = array()) { if (!$this->loadFromFile()) return array('success' => false, 'message' => 'Cannot load cache file'); @@ -204,9 +204,11 @@ class CatalogCacheMgr extends TimeTableCacheMgr return array('success' => true, 'status' => $this->cache->getStatus()); } - public function initTTCache($nparams) { + public function initObjectCache($options = array()) { //Create new cache - $this->cache = new CatalogCacheObject(); + $nparams = isset($options['nparams']) ? $options['nparams'] : 1; + + $this->resetCache(); $this->cache->setParamsNumber((int)$nparams); $paramHeaders = array(); diff --git a/php/classes/CatalogMgr.php b/php/classes/CatalogMgr.php index 01e7b41..1a6aa0c 100644 --- a/php/classes/CatalogMgr.php +++ b/php/classes/CatalogMgr.php @@ -4,67 +4,67 @@ * @class CatalogMgr */ -class CatalogMgr extends TimeTableMgr -{ +class CatalogMgr extends TimeTableMgr +{ function __construct($sharedObject = FALSE) { parent::__construct('Tt.xml', $sharedObject); $this->contentRootId = 'catalog-treeRootNode'; $this->contentRootTag = 'catalogList'; - $this->attributes = array('name' => '', 'intervals' => ''); // + 'parameters' + $this->attributes = array('name' => '', 'intervals' => ''); // + 'parameters' $this->optionalAttributes = array(); $this->objTagName = 'catalog'; $this->id_prefix = 'cat_'; // 'tt_' ? if (!$sharedObject && !file_exists($this->xmlName)) { $this->createDom(); - $this->xp = new domxpath($this->contentDom); + $this->xp = new domxpath($this->contentDom); } - } - - public function getUploadedObject($name, $format, $onlyDescription = false) + } + + public function getUploadedObject($name, $format, $onlyDescription = false) { - if ($format == 'VOT') + if ($format == 'VOT') { - $attributesToReturn = $this->vot2amda(USERTEMPDIR.$name, $onlyDescription); + $attributesToReturn = $this->vot2amda(USERTEMPDIR.$name, $onlyDescription); } $attributesToReturn['objName'] = $name; - $attributesToReturn['objFormat'] = $format; + $attributesToReturn['objFormat'] = $format; return $attributesToReturn; } - - public function getTmpObject($folderId, $name, $onlyDescription = false) - { + + public function getTmpObject($folderId, $name, $onlyDescription = false) + { $filePath = USERWORKINGDIR.$folderId.'/'.$name.'.xml'; - - if (!file_exists($filePath)) + + if (!file_exists($filePath)) return array('error' => 'Cannot find result file'); - - $dom = new DomDocument('1.0'); + + $dom = new DomDocument('1.0'); $dom->formatOutput = true; - + if (!$dom -> load($filePath)) return array('error' => 'Cannot load result file'); $nameNodes = $dom->getElementsByTagName('name'); if ($nameNodes->length > 0) $attributesToReturn['name'] = $nameNodes->item(0)->nodeValue; - + $descNodes = $dom->getElementsByTagName('description'); if ($descNodes->length > 0) $attributesToReturn['description'] = $descNodes->item(0)->nodeValue; - + $creatNodes = $dom->getElementsByTagName('created'); if ($creatNodes->length > 0) $attributesToReturn['created'] = $creatNodes->item(0)->nodeValue; - + $histNodes = $dom->getElementsByTagName('history'); if ($histNodes->length > 0) $attributesToReturn['history'] = $histNodes->item(0)->nodeValue; - + $attributesToReturn['objName'] = $name; $attributesToReturn['folderId'] = $folderId; $attributesToReturn['success'] = true; - + if (!$onlyDescription) { $intNodes = $dom->getElementsByTagName('intervals'); @@ -73,91 +73,91 @@ class CatalogMgr extends TimeTableMgr $startNodes = $intNode->getElementsByTagName('start'); if ($startNodes->length <= 0) return array('error' => 'Error detected in result file'); - + $stopNodes = $intNode->getElementsByTagName('stop'); if ($stopNodes->length <= 0) return array('error' => 'Error detected in result file'); - - // for catalog + + // for catalog $paramNodes = $intNode->getElementsByTagName('param'); $params = array(); - if ($paramNodes->length > 0) + if ($paramNodes->length > 0) foreach ( $paramNodes as $paramNode ) $params[] = $paramNode->nodeValue; - - + + $attributesToReturn['intervals'][] = array('start' => $startNodes->item(0)->nodeValue, 'stop' => $stopNodes->item(0)->nodeValue, 'paramTable' => $params); } // for catalog $paramsNodes = $dom->getElementsByTagName('parameter'); - + if ($paramsNodes->length > 0){ - - $paramsArray = array(); + + $paramsArray = array(); foreach ($paramsNodes as $paramNode) { - + $oneParam = array(); - foreach ($paramNode->attributes as $attr) + foreach ($paramNode->attributes as $attr) $oneParam[$attr->nodeName] = $attr->nodeValue; - - if (substr($paramNode->getAttribute('id'),0,8) == 'stat_cov') { + + if (substr($paramNode->getAttribute('id'),0,8) == 'stat_cov') { $oneParam['size'] = '1'; $oneParam['name'] = 'Flag'; } - + $paramsArray[] = $oneParam; } $attributesToReturn['success'] = true; $attributesToReturn['parameters'] = $paramsArray; } - else - return array('error' => 'No information on parameters in result file'); + else + return array('error' => 'No information on parameters in result file'); } - + return $attributesToReturn; } - - public function loadIntervalsFromTT($id, $typeTT, $start = NULL, $limit = NULL) + + public function loadIntervalsFromObject($id, $type, $start = NULL, $limit = NULL) { - if ($typeTT == 'sharedcatalog') { + if ($type == 'sharedcatalog') { //Shared object $sharedObjMgr = new SharedObjectsMgr(); $path = $sharedObjMgr->getDataFilePath('catalog', $id); } else { - $path = USERTTDIR.$id.'.xml'; + $path = USERTTDIR.$id.'.xml'; } - + //load intervals from TT id if (!file_exists($path)) - return array('success' => false, 'message' => "Cannot find Catalog file ".$typeTT); - + return array('success' => false, 'message' => "Cannot find Catalog file ".$type); + $this->objectDom->load($path); - + if (!($objToGet = $this->objectDom->getElementById($id))) return array('success' => false, 'message' => NO_SUCH_ID." ".$id); - + $xpath = new DOMXPath($this->objectDom); $intervals = $xpath->query('//intervals'); - + $result = array(); - + if (!isset($start) || !isset($limit)) { foreach ($intervals as $interval) { $startTime = $interval->getElementsByTagName('start')->item(0)->nodeValue; $stopTime = $interval->getElementsByTagName('stop')->item(0)->nodeValue; - // for catalog + // for catalog $paramNodes = $interval->getElementsByTagName('param'); $params = array(); - if ($paramNodes->length > 0) + if ($paramNodes->length > 0) foreach ( $paramNodes as $paramNode ) $params[] = $paramNode->nodeValue; - + array_push($result, array('start' => $startTime, 'stop' => $stopTime,'paramTable' => $params)); - + } } else @@ -171,27 +171,27 @@ class CatalogMgr extends TimeTableMgr // for catalog $paramNodes = $intervals->item($start+$i)->getElementsByTagName('param'); $params = array(); - if ($paramNodes->length > 0) + if ($paramNodes->length > 0) foreach ( $paramNodes as $paramNode ) $params[] = $paramNode->nodeValue; - + array_push($result, array('start' => $startTime, 'stop' => $stopTime,'paramTable' => $params)); } } // for catalog : params header $paramsNodes = $xpath->query('//parameters/parameter'); $paramsArray = array(); - + if ($paramsNodes->length > 0) - { - foreach ($paramsNodes as $paramNode) - { + { + foreach ($paramsNodes as $paramNode) + { $oneParam = array(); - foreach ($paramNode->attributes as $attr) - $oneParam[$attr->nodeName] = $attr->nodeValue; + foreach ($paramNode->attributes as $attr) + $oneParam[$attr->nodeName] = $attr->nodeValue; $paramsArray[] = $oneParam; } - } - + } + return array( 'totalCount' => $intervals->length, 'intervals' => $result, @@ -200,28 +200,28 @@ class CatalogMgr extends TimeTableMgr 'limit' => isset($limit) ? $limit : 0, 'success' => true ); - + } /* * catalog header */ - protected function setParamDescription($params) - { + protected function setParamDescription($params) + { $paramsElement = $this->objectDom->createElement('parameters'); - foreach ($params as $param) + foreach ($params as $param) { $paramElement = $this->objectDom->createElement('parameter'); - $attrArray = (array)$param; + $attrArray = (array)$param; foreach ($attrArray as $key => $value) $paramElement->setAttribute($key, $value); - $paramsElement->appendChild($paramElement); + $paramsElement->appendChild($paramElement); } - + return $paramsElement; } - - protected function createIntervalElement($interval) + + protected function createIntervalElement($interval) { $newInterval = $this->objectDom->createElement('intervals'); $newInterval->appendChild($this->objectDom->createElement('start',$interval['start'])); @@ -229,24 +229,24 @@ class CatalogMgr extends TimeTableMgr foreach ($interval as $key =>$value) { if (substr($key,0,5) == 'param') $newInterval->appendChild($this->objectDom->createElement('param', $value)); - + } return $newInterval; } - + public function createObject($p, $folder) - { + { if ($p -> leaf) { $result = $this->createParameter($p, $folder); if ($result['error']) return $result; - + $cacheMgr = new CatalogCacheMgr(); - + if (isset($p->cacheToken) && ($p->cacheToken != '')) { - $resultSaveInt = $cacheMgr->saveInTT($result['id'], "update", $p->cacheToken); + $resultSaveInt = $cacheMgr->saveInObject($result['id'], "update", $p->cacheToken); if (!$resultSaveInt['success']) { if ($resultSaveInt['message']) @@ -260,154 +260,154 @@ class CatalogMgr extends TimeTableMgr // else return $this->createFolder($p); //TODO check if this is possible? else return array('error' => 'createFolder should be called from RENAME'); - + } - - public function initForChart($id, $name, $isTmpObject, $typeTT) + + public function initForChart($id, $name, $isTmpObject, $type) { - $intervals_res = $this->getCatalogParamDescription($id, $name, $isTmpObject, $typeTT); - + $intervals_res = $this->getCatalogParamDescription($id, $name, $isTmpObject, $type); + if (!$intervals_res['success']) return $intervals_res; $paramHeaders = array(); - + foreach ( $intervals_res['parameters'] as $param ) { - + if ($param['size'] > 1) { - + for ($i = 0; $i < $param['size']; $i++) { $paramComp = array(); $paramComp['id'] = $param['id'].'_'.$i; $paramComp['name'] = $param['name'].'_'.$i; // $paramComp['size'] = 1; - + $paramHeaders[] = $paramComp; } } else { - $paramHeaders[] = $param; + $paramHeaders[] = $param; } } - + // unset($intervals_res); - - return array('success' => true, 'parameters' => $paramHeaders, + + return array('success' => true, 'parameters' => $paramHeaders, 'totalCount' => $intervals_res['totalCount'], 'name' => $intervals_res['name']); } - - + + public function getIntervalsForChart($id, $name, $isTmpObject, $type) { - + if ($isTmpObject) - $intervals_res = $this->getTmpObject($id, $name); + $intervals_res = $this->getTmpObject($id, $name); else - $intervals_res = $this->loadIntervalsFromTT($id,$type); - + $intervals_res = $this->loadIntervalsFromObject($id,$type); + if (!$intervals_res['success']) return $intervals_res; - + $newIntervals = array(); - + foreach ($intervals_res['intervals'] as $interval) { $newIntervalComp = array(); $k = 0; - + for ( $j = 0; $j < count($interval['paramTable']); $j++ ) { - + $param = $interval['paramTable'][$j]; $tempArr = explode(',',$param); if (count($tempArr) > 1) { for ($i = 0; $i < count($tempArr); $i++) { $newIntervalComp['param'.$k] = $tempArr[$i]; - $k++; - } - } + $k++; + } + } else { $newIntervalComp['param'.$k] = $param; - $k++; + $k++; } } - $newIntervals[] = $newIntervalComp; + $newIntervals[] = $newIntervalComp; } - + return array('success' => true, 'intervals' => $newIntervals); - + } - - public function getCatalogParamDescription($id, $name, $isTmpObject, $typeTT) + + public function getCatalogParamDescription($id, $name, $isTmpObject, $type) { - if ($typeTT == 'sharedcatalog') { + if ($type == 'sharedcatalog') { //Shared object $sharedObjMgr = new SharedObjectsMgr(); $path = $sharedObjMgr->getDataFilePath('catalog', $id); } elseif (!$isTmpObject) { - $path = USERTTDIR.$id.'.xml'; + $path = USERTTDIR.$id.'.xml'; } else { $path = USERWORKINGDIR.$id.'/'.$name.'.xml'; } - + //load intervals from Catalog id if (!file_exists($path)) return array('success' => false, 'message' => "Cannot find Catalog file ".$id); - - if (!$this->objectDom->load($path)) + + if (!$this->objectDom->load($path)) return array('success' => false, 'message' => "Cannot load Catalog file ".$id); - + // if (!($objToGet = $this->objectDom->getElementById($id))) // return array('success' => false, 'message' => NO_SUCH_ID." ".$id); $nameNodes = $this->objectDom->getElementsByTagName('name'); - + if ($nameNodes->length > 0) $nameReal = $nameNodes->item(0)->nodeValue; - else + else $nameReal = $name; - + $xpath = new DOMXPath($this->objectDom); $intervals = $xpath->query('//intervals'); - + // params header $paramsNodes = $xpath->query('//parameters/parameter'); $paramsArray = array(); - + if ($paramsNodes->length > 0) - { - foreach ($paramsNodes as $paramNode) - { + { + foreach ($paramsNodes as $paramNode) + { $oneParam = array(); - foreach ($paramNode->attributes as $attr) - $oneParam[$attr->nodeName] = $attr->nodeValue; + foreach ($paramNode->attributes as $attr) + $oneParam[$attr->nodeName] = $attr->nodeValue; $paramsArray[] = $oneParam; } - } - + } + return array( 'name' => $nameReal, 'totalCount' => $intervals->length, 'parameters' => $paramsArray, 'success' => true ); - + } - + // public function modifyObject($p) { // $folder = $this->getObjectFolder($p->id); -// +// // //Copy TT in a tempory file // $ttFilePath = USERTTDIR.$p->id.'.xml'; // $tmpFileExist = FALSE; // if (file_exists($ttFilePath)) // $tmpFileExist = copy($ttFilePath,$ttFilePath.".tmp"); -// +// // //Delete TT // $this->deleteObject($p); -// +// // //Save modifications // try { // $result = $this->createObject($p, $folder); @@ -431,47 +431,47 @@ class CatalogMgr extends TimeTableMgr /* * Uploaded vot catalog => convert to AMDA tmp */ - protected function vot2amda($tmp_file, $onlyDescription = false) - { - // Load Catalog + protected function vot2amda($tmp_file, $onlyDescription = false) + { + // Load Catalog $this->objectDom->load($tmp_file); $objToGet = $this->objectDom->getElementsByTagName('TABLEDATA')->item(0); - + $attributes = $objToGet->childNodes; $paramsNodes = $this->objectDom->getElementsByTagName('FIELD'); $paramsNumber = $paramsNodes->length; - + foreach($attributes as $attribute) { - if ($attribute->tagName == 'TR') + if ($attribute->tagName == 'TR') { $start = $attribute->getElementsByTagName('TD')->item(0)->nodeValue; $stop = $attribute->getElementsByTagName('TD')->item(1)->nodeValue; $params = array(); - + for ($i = 2; $i < $paramsNumber; $i++) { $param = $attribute->getElementsByTagName('TD')->item($i)->nodeValue; - + if ($paramsNodes->item($i)->hasAttribute('arraysize')) { $param = join(",",explode(" ",trim($param))); - } + } $params[] = $param; - } - if (!$onlyDescription) + } + if (!$onlyDescription) $attributesToReturn['intervals'][] = array('start' => $start, 'stop' => $stop, 'paramTable' => $params); } } if ($paramsNumber > 2) - { - $paramsArray = array(); + { + $paramsArray = array(); for ($i = 2; $i < $paramsNumber; $i++) - { + { $oneParam = array(); $paramNode = $paramsNodes->item($i); - + if ($paramNode->hasAttribute('arraysize')) { $oneParam['size'] = $paramNode->getAttribute('arraysize'); @@ -480,13 +480,13 @@ class CatalogMgr extends TimeTableMgr { $oneParam['size'] = 1; } - + foreach ($paramNode->attributes as $attr) { if ($attr->nodeName == 'datatype') { $datatype = $attr->nodeValue; - + if ($paramNode->hasAttribute('xtype') && (($paramNode->getAttribute('xtype') == 'dateTime') || ($paramNode->getAttribute('xtype') == 'iso8601'))) { $oneParam['type'] = 1; @@ -498,7 +498,7 @@ class CatalogMgr extends TimeTableMgr $oneParam['type'] = 2;// string $paramNode->setAttribute('size', 1); } - else + else { $oneParam['type'] = 0;//'Double'; } @@ -507,15 +507,15 @@ class CatalogMgr extends TimeTableMgr { $oneParam[$attr->nodeName] = $attr->nodeValue; } - } + } $paramsArray[] = $oneParam; - } + } $attributesToReturn['success'] = true; $attributesToReturn['parameters'] = $paramsArray; } - - $suffix = explode('.', basename($tmp_file)); - $attributesToReturn['name'] = basename($tmp_file, '.'.$suffix[1]); + + $suffix = explode('.', basename($tmp_file)); + $attributesToReturn['name'] = basename($tmp_file, '.'.$suffix[1]); $attributesToReturn['created'] = date('Y-m-d')."T".date('H:i:s'); $attributesToReturn['description'] = htmlspecialchars($this->objectDom->getElementsByTagName('DESCRIPTION')->item(0)->nodeValue); diff --git a/php/classes/TimeTableCacheMgr.php b/php/classes/TimeTableCacheMgr.php index 0ab5ed9..7a67a57 100644 --- a/php/classes/TimeTableCacheMgr.php +++ b/php/classes/TimeTableCacheMgr.php @@ -2,30 +2,39 @@ class TimeTableCacheMgr { - protected static $cache_file = "cacheTT"; - - protected $ttMgr = null; + protected $objectMgr = null; protected $cache = null; - function __construct() { - $this->ttMgr = new TimeTableMgr(); - $this->catMgr = new CatalogMgr(); + function __construct() { + $this->objectMgr = new TimeTableMgr(); } - public function initTTCache() { + protected function getCacheFileName() { + return "cacheTT"; + } + + protected function getCacheDirectory() { + return USERTTDIR; + } + + protected function resetCache() { + $this->cache = new TimeTableCacheObject(); + } + + public function initObjectCache($options = array()) { //Create new cache - $this->cache = new TimeTableCacheObject(); + $this->resetCache(); //Save cache file return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus()); } - public function initFromTT($id, $typeTT) { + public function initFromObject($id, $type) { //Create new cache - $this->cache = new TimeTableCacheObject(); + $this->resetCache(); - //Load intervals from TT file and add to cache - $intervals_res = $this->ttMgr->loadIntervalsFromTT($id,$typeTT); + //Load intervals from object file and add to cache + $intervals_res = $this->objectMgr->loadIntervalsFromObject($id,$type); if (!$intervals_res['success']) return $intervals_res; @@ -45,12 +54,13 @@ return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus()); } - public function initFromCatalog($id, $typeTT) { + public function initFromCatalog($id, $type) { //Create new cache - $this->cache = new TimeTableCacheObject(); + $this->resetCache(); - //Load intervals from TT file and add to cache - $intervals_res = $this->catMgr->loadIntervalsFromTT($id,$typeTT); + //Load intervals from object file and add to cache + $catMgr = new CatalogMgr(); + $intervals_res = $catMgr->loadIntervalsFromObject($id,$type); if (!$intervals_res['success']) return $intervals_res; @@ -73,10 +83,10 @@ public function initFromTmpObject($folderId, $name) { //Create new cache - $this->cache = new TimeTableCacheObject(); + $this->resetCache(); //Load intervals from TmpObject file (DD_Search output) - $intervals_res = $this->ttMgr->getTmpObject($folderId, $name); + $intervals_res = $this->objectMgr->getTmpObject($folderId, $name); if (!isset($intervals_res)) return array('success' => false, 'message' => 'Cannot get Tmp Object'); @@ -103,10 +113,10 @@ public function initFromUploadedFile($name, $format) { //Create new cache - $this->cache = new TimeTableCacheObject(); + $this->resetCache(); //Load intervals from uploaded file - $intervals_res = $this->ttMgr->getUploadedObject($name, $format); + $intervals_res = $this->objectMgr->getUploadedObject($name, $format); if (!isset($intervals_res)) return array('success' => false, 'message' => 'Cannot get Tmp Object'); @@ -131,7 +141,7 @@ return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus()); } - public function saveInTT($id, $action, $token) { + public function saveInObject($id, $action, $token) { if (!$this->loadFromFile()) return array('success' => false, 'message' => 'Cannot load cache file'); @@ -159,7 +169,7 @@ unset($intervals); - return $this->ttMgr->saveIntervals($id, $res_intervals, $action); + return $this->objectMgr->saveIntervals($id, $res_intervals, $action); } public function getIntervals($start,$limit,$sort_obj,$filter_json) { @@ -302,8 +312,8 @@ $this->cache->dump(); } - protected function getCacheFilePath() { - return USERTTDIR.(self::$cache_file); + protected function getCacheFilePath() { + return $this->getCacheDirectory().'/'.$this->getCacheFileName(); } protected function saveToFile() { @@ -324,7 +334,7 @@ protected function loadFromFile() { if (!file_exists($this->getCacheFilePath())) return false; - $this->cache = new TimeTableCacheObject(); + $this->resetCache(); $handle = fopen($this->getCacheFilePath(), 'rb'); $result = false; if (flock($handle, LOCK_SH)) diff --git a/php/classes/TimeTableMgr.php b/php/classes/TimeTableMgr.php index 7c17b92..cc3be69 100644 --- a/php/classes/TimeTableMgr.php +++ b/php/classes/TimeTableMgr.php @@ -83,7 +83,7 @@ class TimeTableMgr extends AmdaObjectMgr } else $attributesToReturn[$attribute->tagName] = $attribute->nodeValue;*/ - //BRE - load all except intervals - Intervals will be loaded later with 'loadIntervalsFromTT' function + //BRE - load all except intervals - Intervals will be loaded later with 'loadIntervalsFromObject' function if ($attribute->tagName != 'intervals') { $attributesToReturn[$attribute->tagName] = $attribute->nodeValue; } else { @@ -150,7 +150,7 @@ class TimeTableMgr extends AmdaObjectMgr } $cacheMgr = new TimeTableCacheMgr(); if (isset($p->cacheToken) && ($p->cacheToken != '')) { - $resultSaveInt = $cacheMgr->saveInTT($result['id'], "update", $p->cacheToken); + $resultSaveInt = $cacheMgr->saveInObject($result['id'], "update", $p->cacheToken); if (!$resultSaveInt['success']) { if ($resultSaveInt['message']) { return ['error' => $resultSaveInt['message']]; @@ -490,7 +490,7 @@ class TimeTableMgr extends AmdaObjectMgr $intervals = 0; for ($iId = 0; $iId < count($obj->ids); $iId++) { - $table[$iId] = $this->loadIntervalsFromTT($obj->ids[$iId]); + $table[$iId] = $this->loadIntervalsFromObject($obj->ids[$iId]); for ($jId = 0; $jId < count($table[$iId]['intervals']); $jId++) { $interval[$iId][$jId][0] = $table[$iId]['intervals'][$jId]['start']; $interval[$iId][$jId][1] = $table[$iId]['intervals'][$jId]['stop']; @@ -562,7 +562,7 @@ class TimeTableMgr extends AmdaObjectMgr * @param null $limit * @return array */ - public function loadIntervalsFromTT($id, $typeTT = '', $start = null, $limit = null) + public function loadIntervalsFromObject($id, $typeTT = '', $start = null, $limit = null) { if ($typeTT == 'sharedtimeTable') { //Shared object @@ -690,7 +690,7 @@ class TimeTableMgr extends AmdaObjectMgr { $intervals = 0; for ($iId = 0; $iId < count($obj->ids); $iId++) { - $table[$iId] = $this->loadIntervalsFromTT($obj->ids[$iId]); + $table[$iId] = $this->loadIntervalsFromObject($obj->ids[$iId]); for ($jId = 0; $jId < count($table[$iId]['intervals']); $jId++) { $interval[$iId][$jId][0] = $table[$iId]['intervals'][$jId]['start']; $interval[$iId][$jId][1] = $table[$iId]['intervals'][$jId]['stop']; diff --git a/php/config.php b/php/config.php index e5025ec..75b9ece 100644 --- a/php/config.php +++ b/php/config.php @@ -29,7 +29,7 @@ define('log', IHM_SRC_DIR.'/LOG'); if (is_file('amda_version.php')) require_once 'amda_version.php'; if (is_file('errors.php')) require_once 'errors.php'; -// SYSTEM config section +// SYSTEM config section if (!defined('PHP_VERSION_ID')) { $version = explode('.', PHP_VERSION); define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2])); @@ -52,7 +52,7 @@ define('MAX_FILE_INDEX_TO_SHOW', 100); define('DDSERVICE_PRIVATEKEY', '!%p856Dc'); -// BATCH JOBS section +// BATCH JOBS section //define('JOBTIMEOUT', '1'); // one cycle secs to sleep to allow job be executed //define('PLOT_CYCLES_NUMBER', 500); // cycles number for PNG //define('JOB_CYCLES_NUMBER', 5); // cycles number for all the jobs @@ -62,7 +62,7 @@ define('DDSERVICE_PRIVATEKEY', '!%p856Dc'); define('EPNTAP_APIS', 'http://voparis-tap.obspm.fr/__system__/tap/run/tap/sync'); define('EPNTAP_AMDA', 'http://cdpp-epntap.irap.omp.eu/__system__/tap/run/tap/sync'); -// PHP run-time settings +// PHP run-time settings ini_set('memory_limit',256000000); ini_set('max_execution_time',600); // max PHP execution @@ -155,12 +155,12 @@ $API = array( 'intersect'=>array('len'=>1), 'loadTTIntervals'=>array('len'=>1), 'saveTTCacheIntervalsInTT'=>array('len'=>1), - 'initTTCache'=>array ('len'=>2), - 'initTTCacheFromTT'=>array('len'=>2), + 'initObjectCache'=>array ('len'=>2), + 'initObjectCacheFromTT'=>array('len'=>2), 'initForChart'=>array('len'=>4), - 'initTTCacheFromTmpObject'=>array('len'=>3), - 'initTTCacheFromUploadedFile'=>array('len'=>3), - 'initTTCacheFromCatalog'=>array('len'=>2), + 'initObjectCacheFromTmpObject'=>array('len'=>3), + 'initObjectCacheFromUploadedFile'=>array('len'=>3), + 'initObjectCacheFromCatalog'=>array('len'=>2), 'readTTCacheIntervals'=>array('len'=>1), 'readIntervalsForChart'=>array('len'=>1), 'addTTCacheInterval'=>array('len'=>1), -- libgit2 0.21.2