From 42e2e019dbb600d7f98c916536b439b6340b4b60 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 5 Aug 2019 14:56:51 +0200 Subject: [PATCH] Next step for cache rework --- js/app/models/InteractiveNode.js | 394 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- js/app/views/CatalogUI.js | 2 +- php/TTCacheDump.php | 12 +----------- php/classes/AmdaAction.php | 33 +++++++++++++++++++++++++++++++-- php/classes/CatalogCacheIntervalObject.php | 11 +++++++++++ php/classes/CatalogCacheMgr.php | 21 ++------------------- php/classes/CatalogCacheObject.php | 13 ++++--------- php/classes/CatalogMgr.php | 30 ++++++++++++++---------------- php/classes/TimeTableCacheIntervalObject.php | 13 ++++++++++++- php/classes/TimeTableCacheMgr.php | 18 +++++++++++------- php/classes/TimeTableCacheObject.php | 15 +-------------- php/classes/TimeTableMgr.php | 10 +++++----- 12 files changed, 290 insertions(+), 282 deletions(-) diff --git a/js/app/models/InteractiveNode.js b/js/app/models/InteractiveNode.js index b08aaa2..79f9db4 100644 --- a/js/app/models/InteractiveNode.js +++ b/js/app/models/InteractiveNode.js @@ -1,4 +1,4 @@ -/** +/** * Project : AMDA-NG4 * Name : InteractiveNode.js * @class amdaModel.InteractiveNode @@ -14,10 +14,10 @@ Ext.define('amdaModel.InteractiveNode', { requires: [ 'amdaPlotObj.PlotRequestObject' ], - - fields: [ + + fields: [ {name: 'contextNode', type: 'amdaModel.AmdaNode', persist: false}, - {name: 'objectDataModel', type: 'string', persist: false}, + {name: 'objectDataModel', type: 'string', persist: false}, {name: 'object', type: 'object', persist: false}, {name: 'moduleId', type: 'string', persist: false}, {name: 'filtered', type: 'boolean', defaultValue: false, persist: false}, @@ -28,7 +28,7 @@ Ext.define('amdaModel.InteractiveNode', { statics: { preloadNodes : function(node,onready) { - var me = this; + var me = this; var nodesToLoad = new Array(); nodesToLoad.push(node); this.preloadTreeNode(node, nodesToLoad, function (node) @@ -38,7 +38,7 @@ Ext.define('amdaModel.InteractiveNode', { { if (!element.isLoaded()) isFinish = false; - }); + }); if (isFinish && onready) onready.call(); }); @@ -47,29 +47,29 @@ Ext.define('amdaModel.InteractiveNode', { preloadTreeNode : function(node, nodesToLoad, onloaded) { var me = this; - + if (node.isLoaded()) { node.eachChild(function(n) - { + { if (!n.isLoaded() && !n.isRealLeaf()) { nodesToLoad.push(n); me.preloadTreeNode(n,nodesToLoad,onloaded); } }); - + if (onloaded) onloaded.call(me,node); return; - } - + } + node.store.load({ - node : node, + node : node, callback : function(records, operation, successful) { records.forEach(function (record) - { + { if (!record.isLoaded() && !record.isRealLeaf()) { nodesToLoad.push(record); @@ -82,21 +82,21 @@ Ext.define('amdaModel.InteractiveNode', { }); } }, - + onReady : null, - + constructor : function(config) { - this.callParent(arguments); - this.set('nodeType',this.self.nodeType); + this.callParent(arguments); + this.set('nodeType',this.self.nodeType); this.set('ownerTreeId',amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); if (this.get('id')) { // TODO why sometimes (delete in remote interoper tree) this.get('id') = undefined ? - // if id of this node have root category suffix + // if id of this node have root category suffix if (Ext.util.Format.substr(this.get('id'), -(amdaUI.ExplorerUI.CAT_SUFFIX.length), this.get('id').length) === amdaUI.ExplorerUI.CAT_SUFFIX) { // set the expanded property to true this.set('expanded',true); - } + } } }, @@ -104,7 +104,7 @@ Ext.define('amdaModel.InteractiveNode', { { return this.isLeaf(); }, - + /** * this method is overriden into ExecutableNode to return true */ @@ -116,7 +116,7 @@ Ext.define('amdaModel.InteractiveNode', { /** * open Module with THIS NODE */ - editInModule : function (contextNode, onReady) + editInModule : function (contextNode, onReady) { // set the contextNode of this node this.set('contextNode',contextNode); @@ -124,50 +124,50 @@ Ext.define('amdaModel.InteractiveNode', { var me = this; myDesktopApp.getLoadedModule(this.get('moduleId'),true, function (module) { // If the node to edit is not already linked to this module - if (module.getLinkedNode() != me) + if (module.getLinkedNode() != me) { // set relative node into parameter Module - module.setLinkedNode(me); - if (contextNode==null) + module.setLinkedNode(me); + if (contextNode==null) { // set the root node as contextNode contextNode = me.getRootNode(); - } - module.setContextNode(contextNode); - + } + module.setContextNode(contextNode); + } else if (module.getLinkedNode() != null){ //TODO the node to edit is already edited // myDesktopApp.warningMsg('This object is being edited'); //Sol1: msg alert: "warning this node is already edited! If you want to get the original, please press the 'reset' button"->'OK' //Sol2: msg with user choice: "warning this node is already edited! Would you confirm this action and lost your modification?"->'Confirm','Cancel' } - // Opening parameter window - module.createWindow(onReady); - }); + // Opening parameter window + module.createWindow(onReady); + }); }, /** * Method to rename the workspace node */ - rename: function(value,callBackFn) - { + rename: function(value,callBackFn) + { var dataToSend = {id : this.get('id'), old_name: this.modified.text, name: value, parent : this.data.parentId, leaf: this.isRealLeaf(), nodeType: this.get('nodeType')}; - AmdaAction.renameObject(dataToSend, callBackFn); + AmdaAction.renameObject(dataToSend, callBackFn); }, - + /** * Method to rename the workspace node when D&D */ - renameDD: function(parentId, callBackFn) - { + renameDD: function(parentId, callBackFn) + { var dataToSend = {id : this.get('id'), old_name: this.get('name'), name: this.get('name'), parent : parentId, leaf: this.isRealLeaf(), nodeType: this.get('nodeType')}; AmdaAction.renameObject(dataToSend, callBackFn); }, - + /** * validation method on name (used in module forms) * @param name the name to validate -* @returns +* @returns */ isValidName : function(name, callBackFn) { @@ -180,42 +180,42 @@ Ext.define('amdaModel.InteractiveNode', { * node linked to a Module */ update : function(opt) - { + { AmdaAction.modifyObject(this.get('object').getJsonValues(true), function(res,e){ - + if(e.status) { - if (res.id) { + if (res.id) { if (!this.get('contextNode')) { // set the root node of 'Derived Parameters' tree as contextNode this.set('contextNode',this.getRootNode()); } this.get('contextNode').expand(false,false); this.myGetOwnerTree().getSelectionModel().select(this); - + if (opt) { var scope = opt.scope ? opt.scope : this; if (opt.callback) opt.callback.call(scope,'update'); - - } - if(opt.notDisplayMsg){ - //do nothing - }else{ - Ext.Msg.alert('Complete', 'Object '+this.get('object').get('name')+' has been modified'); - } + if(opt.notDisplayMsg){ + //do nothing + }else{ + Ext.Msg.alert('Complete', 'Object '+this.get('object').get('name')+' has been modified'); + } + + } // fix the modifications for object this.get('object').commit(); - + if (res.info) { this.set('info',res.info); } - + // myDataParam and Parameter special update this.specialUpdate(res, false); - + // reload object into the view of corresponding Module var me = this; myDesktopApp.getLoadedModule(this.get('moduleId'), true, function (module) { @@ -224,7 +224,7 @@ Ext.define('amdaModel.InteractiveNode', { } else { //TODO proper error message handling - // error code from server; but e.status==true + // error code from server; but e.status==true // revert all modifications since last load or commit this.get('object').reject(); myDesktopApp.errorMsg(res.error); @@ -233,7 +233,7 @@ Ext.define('amdaModel.InteractiveNode', { else { // revert all modifications since last load or commit this.get('object').reject(); - myDesktopApp.errorMsg(e.message); + myDesktopApp.errorMsg(e.message); } },this); }, @@ -242,30 +242,30 @@ Ext.define('amdaModel.InteractiveNode', { * Method to create a new AmdaObject by server side and create the workspace node linked to a Module * under its contextNode or the root node corresponding to this nodeType category */ - create : function(opt) + create : function(opt) { if (!this.get('contextNode') || (this.get('contextNode').data.id == 'sharedtimeTable-treeRootNode') || (this.get('contextNode').data.id == 'sharedcatalog-treeRootNode')) { // set the root node of 'Derived Parameters' tree as contextNode this.set('contextNode',this.getRootNode()); - } - // call the Ext.Direct method to create parameter - AmdaAction.createObject(this.get('object').getJsonValues(false), this.get('contextNode').get('id'), function(res,e){ + } + // call the Ext.Direct method to create parameter + AmdaAction.createObject(this.get('object').getJsonValues(false), this.get('contextNode').get('id'), function(res,e){ //success - if(e.status) - { + if(e.status) + { // if correct response received if (res.id) { //if (res.id || res.error == 'NAME_EXISTS') { // 'save as' case ; delete old node if it exists - if (this.toRename) + if (this.toRename) { - this.toRename = false; + this.toRename = false; var myRoot = this.getRootNode(); // search the same named node to override var updateNode = myRoot.findChild('text',this.get('object').get('name'),true); // destroy the overrided node updateNode.parentNode.removeChild(updateNode);//TODO ??if destroy==true => too many recursions.... - updateNode.destroy(); - } + updateNode.destroy(); + } // set text of this node this.set('text',this.get('object').get('name')); @@ -274,52 +274,52 @@ Ext.define('amdaModel.InteractiveNode', { this.internalId = res.id; // set id of node's object - this.get('object').set('id',res.id); + this.get('object').set('id',res.id); if (res.created){ // set the created date this.get('object').set('created',res.created); } - + if (res.info){ // set the tooltip this.set('info',res.info); } //set globalStart & global Stop to be used for time selection this.specialUpdate(res, true); - + //TODO do we need this commission ??? // fix the modifications for object - this.get('object').commit(); + this.get('object').commit(); // if ownerTree panel is not active if (this.myGetOwnerTree().ownerCt.getActiveTab()!==this.myGetOwnerTree()) { // set ownerTree panel as the active tab - to enable selection of this node his ownerTree must have a view - this.myGetOwnerTree().ownerCt.setActiveTab(this.myGetOwnerTree()); + this.myGetOwnerTree().ownerCt.setActiveTab(this.myGetOwnerTree()); } if(opt.notDisplayMsg){ //do nothing - }else{ - Ext.Msg.alert('Complete', 'New object '+this.get('object').get('name')+' has been created'); + }else{ + Ext.Msg.alert('Complete', 'New object '+this.get('object').get('name')+' has been created'); } - + // expand the contextNode this.get('contextNode').expand(false, function() { if (!this.get('contextNode').findChild('text',this.get('text'))) { - // create node in tree as child of contextNode - this.get('contextNode').appendChild(this); + // create node in tree as child of contextNode + this.get('contextNode').appendChild(this); } - // select the new node + // select the new node this.myGetOwnerTree().getSelectionModel().select(this); if (opt) { var scope = opt.scope ? opt.scope : this; if (opt.callback) opt.callback.call(scope,'create'); - } + } }, this); - } + } // error code from server; but e.status==true else { - myDesktopApp.errorMsg(res.error); + myDesktopApp.errorMsg(res.error); // revert all modifications since last load or commit this.get('object').reject(); } @@ -331,14 +331,14 @@ Ext.define('amdaModel.InteractiveNode', { //TODO: this.destroy(); myDesktopApp.errorMsg(e.message); } - },this); + },this); }, specialUpdate : function() {}, /** * Generic part of Context Menu -* -*/ +* +*/ allMenuItems : function() { var src = this.self.objectName; var menuItems = @@ -383,14 +383,14 @@ Ext.define('amdaModel.InteractiveNode', { return menuMulti; }, - getAllContextMenuItems: function(){ - return this.allMenuItems(); + getAllContextMenuItems: function(){ + return this.allMenuItems(); }, getMultiContextMenuItems: function(){ return this.allMenuMultiItems(); }, - + /** * default implementation * no menu display if there's no override of this function @@ -398,99 +398,99 @@ Ext.define('amdaModel.InteractiveNode', { getMultiContextMenuItems: function(){ return null; }, - + /** * Context Menu Actions -* -*/ +* +*/ onMenuItemClick : function(menu,item,event) { // fnId parsing : var fnId = Ext.util.Format.substr(item.fnId, 5, item.fnId.length); switch (fnId) { case 'deleteNode': - this.deleteNode(); + this.deleteNode(); break; case 'createDir': - this.createDir(); + this.createDir(); break; case 'createLeaf': this.createLeaf(this); - break; + break; case 'renameNode': this.renameNode(false); break; - case 'editLeaf': - this.editLeaf(); - break; + case 'editLeaf': + this.editLeaf(); + break; case 'deleteMulti': this.deleteMulti(); - break; - case 'plotParam': - this.createPlot(this); break; - case 'downParam': - this.createDownload(this); - break; + case 'plotParam': + this.createPlot(this); + break; + case 'downParam': + this.createDownload(this); + break; default: break; } // switch end }, - + getTimeFromNode: function(node) { var startString = new String(node.get('globalStart')); var stopString = new String(node.get('globalStop')); - var startDate = new Date(startString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); + var startDate = new Date(startString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); var stopDate = new Date(stopString.replace(/\-/g,'\/').replace(/[T|Z]/g,' ')); if (stopDate - startDate > 86400000 ) { - var startTime = Ext.Date.add(stopDate, Ext.Date.DAY, -1); + var startTime = Ext.Date.add(stopDate, Ext.Date.DAY, -1); // var timeObj = {start: Ext.Date.format(startTime, 'Y/m/d H:i:s'), stop: Ext.Date.format(stopDate, 'Y/m/d H:i:s')}; var timeObj = {start: Ext.Date.format(startTime, 'Y/m/d'), stop: Ext.Date.format(stopDate, 'Y/m/d')}; - } + } else { var timeObj = {start: node.get('globalStart'), stop: node.get('globalStop')}; } - return timeObj; + return timeObj; }, - createPlot: function(node) - { - if (node.get('disable')) return; + createPlot: function(node) + { + if (node.get('disable')) return; myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) { - if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.plot.id)) { + if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.plot.id)) { var request = Ext.create(amdaPlotObj.PlotRequestObject.$className); - var newNode = Ext.create(amdaModel.PlotNode.$className, { object : request }); + var newNode = Ext.create(amdaModel.PlotNode.$className, { object : request }); // edit newNode into Plot Module with node as contextNode newNode.editInModule(); - if((node.get('globalStart') != null) && (node.get('globalStop') != null) && node.get('globalStart') != 'depending on mission' && node.get('isParameter')) { - module.getUiContent().setTimeFromData(node.getTimeFromNode(node)); + if((node.get('globalStart') != null) && (node.get('globalStop') != null) && node.get('globalStart') != 'depending on mission' && node.get('isParameter')) { + module.getUiContent().setTimeFromData(node.getTimeFromNode(node)); } - } - module.getUiContent().addParameter(node); + } + module.getUiContent().addParameter(node); }); }, - - createDownload: function(node) - { + + createDownload: function(node) + { myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id, true, function (module) { - if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.download.id)) { + if (!myDesktopApp.desktop.getWindow(myDesktopApp.dynamicModules.download.id)) { var request = Ext.create(amdaModel.Download.$className); - amdaModel.DownloadNode.set('object',request); + amdaModel.DownloadNode.set('object',request); // singleton! amdaModel.DownloadNode.editInModule(); if ((node.get('globalStart') != null) && (node.get('globalStop') != null) && node.get('globalStart') != 'depending on mission' && node.get('isParameter')) { - module.getUiContent().setTimeFromData(node.getTimeFromNode(node)); + module.getUiContent().setTimeFromData(node.getTimeFromNode(node)); } - } - var paramName; + } + var paramName; var components = null; switch (node.$className) { - case 'amdaModel.AliasNode' : + case 'amdaModel.AliasNode' : paramName = "#"+node.get('text'); break; - case 'amdaModel.DerivedParamComponentNode' : + case 'amdaModel.DerivedParamComponentNode' : paramId = node.get('text'); var parentId = paramId.substr(0, paramId.length - 3); paramName= "ws_" + parentId; @@ -502,18 +502,18 @@ Ext.define('amdaModel.InteractiveNode', { components['index1'] = component_index[1]; } break; - case 'amdaModel.DerivedParamNode' : + case 'amdaModel.DerivedParamNode' : paramName = "ws_"+node.get('text'); break; case 'amdaModel.MyDataParamNode' : - paramName = 'wsd_'+node.get('text'); - break; - default : + paramName = 'wsd_'+node.get('text'); + break; + default : if (node.get('alias')!= "" ) paramName = "#"+node.get('alias'); - else + else paramName = node.get('id'); - } + } var component_info = node.get('component_info'); if (component_info && component_info.parentId) { //It's a component @@ -523,23 +523,23 @@ Ext.define('amdaModel.InteractiveNode', { components['index1'] = component_info.index1; if (component_info.index2) components['index2'] = component_info.index2; - } - module.addParam(paramName,true,node.get('needsArgs'),components); - }); + } + module.addParam(paramName,true,node.get('needsArgs'),components); + }); }, - - deleteNode: function() { + + deleteNode: function() { // if the target is a directory if (!this.isRealLeaf()) { // determine if this directory is empty before launching the delete confirmation method - this.isNotEmptyDir(this.confirmDirectoryDeletion); + this.isNotEmptyDir(this.confirmDirectoryDeletion); // else (the target is a leaf) } else { // no confirmation prompt for leaves this.confirmDirectoryDeletion(false); } }, - + /** * this method return if node has Childs even if it was not already loaded */ @@ -547,21 +547,21 @@ Ext.define('amdaModel.InteractiveNode', { var hasChilds; // if node not already loaded if (!this.isLoaded()){ - // call directFunction to load this node + // call directFunction to load this node AmdaAction.getTree({node:this.get('id'),nodeType:this.get('nodeType')},function(res,e){ callbackFn.call(this,res.length>0?true:false); },this); - } + } else { callbackFn.call(this,this.hasChildNodes()); } }, - + /** * this method is used to display a confirmation message */ confirmDirectoryDeletion : function(isNotEmptyDir) - { + { // if this is a non-empty directory if (isNotEmptyDir) { // Prompt to the user if he also wants to delete its content @@ -571,28 +571,28 @@ Ext.define('amdaModel.InteractiveNode', { this.realDelete(); } },this); - } + } else { this.realDelete(); - } + } }, - + /* * Call the extDirect method to delete parameter -* Callback method needed to execute node deletion in tree if id in result or to show error msg +* Callback method needed to execute node deletion in tree if id in result or to show error msg */ realDelete : function() - { - AmdaAction.deleteObject({id: this.get('id'), leaf: this.isRealLeaf(), nodeType: this.get('nodeType')}, function(res,e){ - //TODO proper errors handling - // node deletion in tree + { + AmdaAction.deleteObject({id: this.get('id'), leaf: this.isRealLeaf(), nodeType: this.get('nodeType')}, function(res,e){ + //TODO proper errors handling + // node deletion in tree if (res) { // if success if (res.id) { //Ext.Msg.show({title:'Warning', msg: 'Requests with parameter '+node.data.text+' are deleted', icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); if (this.parentNode) { if (this.isRealLeaf()){ var moduleId = this.get('moduleId'); - // if really interactive node + // if really interactive node if (moduleId) { var win = myDesktopApp.getDesktop().getWindow(moduleId); // if window is really open @@ -600,72 +600,72 @@ Ext.define('amdaModel.InteractiveNode', { var me = this; myDesktopApp.getLoadedModule(moduleId, true, function (module) { var editedNode = module.getLinkedNode(); - - // file node is not linked directly to the module + + // file node is not linked directly to the module var isThisFile = false; - if (editedNode && editedNode.$className == 'amdaModel.MyDataParamNode') + if (editedNode && editedNode.$className == 'amdaModel.MyDataParamNode') if (editedNode.get('fileObject').get('fileName') == me.get('text')) - isThisFile = true; - - // node was created BEFORE tree loading; node.id are different ; but it is the same node + isThisFile = true; + + // node was created BEFORE tree loading; node.id are different ; but it is the same node if ( editedNode && editedNode.get('id') == me.get('id') && editedNode !== me ) { module.setLinkedNode(me); isThisFile = true; } - + if (me.$className == 'amdaModel.DerivedParamNode') { var obj = { paramId : 'ws_'+me.get('text') }; AmdaAction.compilParamDelete(obj); } - - if (editedNode === me || isThisFile ){ + + if (editedNode === me || isThisFile ){ var newNode = Ext.ModelManager.create({leaf : true}, me.$className); // several tabs could be connected to one node if (moduleId === myDesktopApp.dynamicModules.plot.id) { var linkedNodes = module.linkedNodes; - + if (linkedNodes) { - linkedNodes.each(function(key, value){ - if (value === me) { + linkedNodes.each(function(key, value){ + if (value === me) { linkedNodes.replace(key,newNode); var tabPanel = module.getUiContent().tabPanel.items.getByKey(key); - tabPanel.setObject(Ext.create(amdaModel.Plot.$className, {})); - } + tabPanel.setObject(Ext.create(amdaModel.Plot.$className, {})); + } }, me); - } - } + } + } newNode.editInModule(); } - }); + }); } } - } - //update mask info in myData + } + //update mask info in myData if (res.maskDesc && !res.maskDeleted) { this.parentNode.set('info', res.maskDesc); this.updateMyDataParam(res.mask, res.maskDesc); - } - this.remove(); + } + this.remove(); } - //TODO Several special node-dependent actions - to move to node functions.. - // nodes of another nodeType to be deleted as they depend on deleted node + //TODO Several special node-dependent actions - to move to node functions.. + // nodes of another nodeType to be deleted as they depend on deleted node if (res.params) { this.deleteDependence(res.params); //TODO reset - } - // mask was deleted or updated - to update mydata tree + } + // mask was deleted or updated - to update mydata tree if (res.maskDeleted) { - this.updateMyData(); - } + this.updateMyData(); + } } else { - myDesktopApp.warningMsg(res.error); + myDesktopApp.warningMsg(res.error); } } else { - myDesktopApp.errorMsg(e.message); + myDesktopApp.errorMsg(e.message); } }, this); }, @@ -681,7 +681,7 @@ Ext.define('amdaModel.InteractiveNode', { item.deleteNode(); }) }, - + /* * Create Folder */ @@ -710,9 +710,9 @@ Ext.define('amdaModel.InteractiveNode', { newNode.renameNode(true); }); }, - + /* -* +* */ createLeaf: function(contextNode) { // create new node with the same type than the contextNode @@ -730,7 +730,7 @@ Ext.define('amdaModel.InteractiveNode', { renameNode: function(deleteOnFailure) { if (this.myGetOwnerTree()) - { + { // load the rootNode and recursively all its child nodes if not already loaded var me = this; amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), @@ -752,48 +752,48 @@ Ext.define('amdaModel.InteractiveNode', { * load the rootNode and recursively all its child nodes * to know all names of DerivedParameters */ - editLeaf: function(onReady) - { + editLeaf: function(onReady) + { var me = this; amdaModel.InteractiveNode.preloadNodes(this.getRootNode(), function() { - if (me.get('object')) + if (me.get('object')) { // launch edition of parameter into parameter module me.editInModule(null, onReady); } else - { + { // call the ext method to get the details of parameter - // the edition of real parameter is done into callback method getObjectCallback - if (onReady) + // the edition of real parameter is done into callback method getObjectCallback + if (onReady) me.onReady = onReady; - + AmdaAction.getObject(me.get('id'), me.get('nodeType'), me.getObjectCallback, me); } - }); + }); }, /* -* +* */ getObjectCallback : function(result,remoteEvent) { var t = remoteEvent.getTransaction(); - - if (result) { + + if (result) { var paramObj = Ext.create(this.get('objectDataModel'), result); // set parameter into node this.set('object',paramObj); - // Edition of parameter into parameter Module + // Edition of parameter into parameter Module this.editInModule(null, this.onReady); this.onReady = null; - } + } else { // EXCEPTION : parameter not found !? myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '" - + this.get('name') + "' found!"); + + this.get('name') + "' found!"); } - } + } }); diff --git a/js/app/views/CatalogUI.js b/js/app/views/CatalogUI.js index f3f0bef..d485947 100644 --- a/js/app/views/CatalogUI.js +++ b/js/app/views/CatalogUI.js @@ -672,7 +672,7 @@ Ext.define('amdaUI.CatalogUI', { 'isCatalog' : true, 'data' : {} }; - obj['data']['activeColumn.dataIndex'] = value; + obj['data'][activeColumn.dataIndex] = value; //Interval is modified on the server side me.editing = true; diff --git a/php/TTCacheDump.php b/php/TTCacheDump.php index 5780cd4..0d7bf00 100644 --- a/php/TTCacheDump.php +++ b/php/TTCacheDump.php @@ -1,15 +1,4 @@ dump(); diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index 8adc914..95a22fd 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -654,20 +654,51 @@ class AmdaAction $fileContent = preg_replace(['~\R~u', "/\t/"], ["\n", ' '], trim(file_get_contents(USERTEMPDIR . $name))); file_put_contents(USERTEMPDIR . $name, $fileContent); + $isTTCat = FALSE; switch ($nodeType) { case 'timeTable' : $objectMgr = new TimeTableMgr(); + $isTTCat = TRUE; break; case 'myDataParam' : $objectMgr = new FilesMgr(); break; case 'catalog' : $objectMgr = new CatalogMgr(); + $isTTCat = TRUE; break; default: return array("error" => $nodeType." NOT_IMPLEMENTED_YET"); } + if ($isTTCat) { + //Pre-process: convert to INTERNAL format if needed + if (($format == 'ASCII') || ($format == 'VOT')) { + $result = $this->executeRequest((Object) array( + 'compression' => 'none', + 'fileformat' => 'internal', + 'sendToSamp' => FALSE, + 'list' => array( + (Object) array( + 'path' => USERTEMPDIR . $name, + 'format' => $format, + 'name' => pathinfo($name, PATHINFO_FILENAME), + ) + ), + ), FunctionTypeEnumClass::TTCONVERT); + if (!$result['success']) { + return array("error" => "Error during file conversion"); + } + $name = basename($result['download']); + $convertedFile = USERDIR.'/DOWNLOAD.TEMP/'.$name; + if (!file_exists($convertedFile)) { + return array("error" => "Error during file conversion"); + } + + $format = 'internal'; + rename($convertedFile, USERTEMPDIR . '/' . $name); + } + } return $objectMgr->getUploadedObject($name, $format, true); } @@ -1117,7 +1148,6 @@ class AmdaAction { if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr(); else $cacheMgr = new CatalogCacheMgr(); - return $cacheMgr->initFromUploadedFile($name, $format); } @@ -1192,7 +1222,6 @@ class AmdaAction public function getTTCacheStatistics($obj) { - error_log("name",$obj->name ); if($obj->name == "timeTableUi"){ $cacheMgr = new TimeTableCacheMgr(); }elseif($obj->name == "catalogUI"){ diff --git a/php/classes/CatalogCacheIntervalObject.php b/php/classes/CatalogCacheIntervalObject.php index faeddd3..c9e2f27 100644 --- a/php/classes/CatalogCacheIntervalObject.php +++ b/php/classes/CatalogCacheIntervalObject.php @@ -27,6 +27,17 @@ class CatalogCacheIntervalObject extends TimeTableCacheIntervalObject return $this->params; } + public function modifyInterval($data) { + parent::modifyInterval($data); + foreach ($this->cacheObject->getParametersInfo() as $parameter) { + if (array_key_exists($parameter['id'], $data)) { + $this->setParamValue($parameter['id'], $data->{$parameter['id']}); + $this->setIsModified(true); + } + } + return $this->isModified(); + } + public function writeBin($handle) { parent::writeBin($handle); diff --git a/php/classes/CatalogCacheMgr.php b/php/classes/CatalogCacheMgr.php index ff2cacd..c93b5d3 100644 --- a/php/classes/CatalogCacheMgr.php +++ b/php/classes/CatalogCacheMgr.php @@ -42,31 +42,14 @@ class CatalogCacheMgr extends TimeTableCacheMgr return array('parameters' => $this->cache->getParametersInfo()); } - protected function loadAdditionalDescription($id, $type) { - $params_desc = $this->objectMgr->getCatalogParamDescription($id, "", FALSE, $type); + protected function loadAdditionalDescription($options) { + $params_desc = $this->objectMgr->getCatalogParamDescription($options); if (!$params_desc['success']) { return array(); } return array('parameters' => $params_desc['parameters']); } - public function initFromTmpObject($folderId, $name) { - $result = parent::initFromTmpObject($folderId, $name); - if (!$result['success']) { - return $result; - } - - $params_desc = $this->objectMgr->getCatalogParamDescription($id, $name, FALSE, $type); - if (!$params_desc['success']) { - return $params_desc; - } - - foreach ($params_desc['parameters'] as $parameter) { - $this->cache->addParameter($parameter['id'], $parameter['name'], intval($parameter['size']), intval($parameter['type'])); - } - - return $result+ array('parameters' => $this->cache->getParametersInfo()); - } public function initFromUploadedFile($name, $format) { diff --git a/php/classes/CatalogCacheObject.php b/php/classes/CatalogCacheObject.php index d5f0268..725e3a4 100644 --- a/php/classes/CatalogCacheObject.php +++ b/php/classes/CatalogCacheObject.php @@ -121,16 +121,11 @@ class CatalogCacheObject extends TimeTableCacheObject if ($interval->getId() == $cacheId) { foreach($data as $key => $value) { - if (strpos($key, 'param') !== FALSE) { - $params = $interval->getParams(); - $paramIndex = (int)substr($key,5); - $params[$paramIndex-2] = $value; - $interval->setParams($params); - $interval->setIsModified(true); - $this->isModified = true; - } + $interval->setParamValue($key, $value); + $interval->setIsModified(true); + $this->isModified = true; } - return true; + return $this->isModified; } } diff --git a/php/classes/CatalogMgr.php b/php/classes/CatalogMgr.php index e35bac9..6db6587 100644 --- a/php/classes/CatalogMgr.php +++ b/php/classes/CatalogMgr.php @@ -209,15 +209,15 @@ class CatalogMgr extends TimeTableMgr return $paramsElement; } - protected function createIntervalElement($interval) + protected function createIntervalElement($interval, $options = array()) { $newInterval = $this->objectDom->createElement('intervals'); $newInterval->appendChild($this->objectDom->createElement('start',$interval['start'])); $newInterval->appendChild($this->objectDom->createElement('stop',$interval['stop'])); - foreach ($interval as $key =>$value) { - if (substr($key,0,5) == 'param') - $newInterval->appendChild($this->objectDom->createElement('param', $value)); - + if (!empty($options['parameters'])) { + foreach ($options['parameters'] as $parameter) { + $newInterval->appendChild($this->objectDom->createElement('param', $interval[$parameter['id']])); + } } return $newInterval; } @@ -325,36 +325,34 @@ class CatalogMgr extends TimeTableMgr } - public function getCatalogParamDescription($id, $name, $isTmpObject, $type) + public function getCatalogParamDescription($options) { - if ($type == 'sharedcatalog') { + if (isset($options['type']) && ($options['type'] == 'sharedcatalog')) { //Shared object $sharedObjMgr = new SharedObjectsMgr(); - $path = $sharedObjMgr->getDataFilePath('catalog', $id); + $path = $sharedObjMgr->getDataFilePath('catalog', $options['id']); } - elseif (!$isTmpObject) { - $path = USERTTDIR.$id.'.xml'; + elseif (!isset($options['isTmpObject']) || !$options['isTmpObject']) { + $path = USERTTDIR.$options['id'].'.xml'; } else { - $path = USERWORKINGDIR.$id.'/'.$name.'.xml'; + $path = $options['folder'].'/'.$options['name'].'.xml'; } //load intervals from Catalog id if (!file_exists($path)) - return array('success' => false, 'message' => "Cannot find Catalog file ".$id); + return array('success' => false, 'message' => "Cannot find Catalog file ".$path); if (!$this->objectDom->load($path)) - return array('success' => false, 'message' => "Cannot load Catalog file ".$id); + return array('success' => false, 'message' => "Cannot load Catalog file"); -// 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 - $nameReal = $name; + $nameReal = $options['name']; $xpath = new DOMXPath($this->objectDom); $intervals = $xpath->query('//intervals'); diff --git a/php/classes/TimeTableCacheIntervalObject.php b/php/classes/TimeTableCacheIntervalObject.php index 8865e23..14186c1 100644 --- a/php/classes/TimeTableCacheIntervalObject.php +++ b/php/classes/TimeTableCacheIntervalObject.php @@ -93,7 +93,18 @@ class TimeTableCacheIntervalObject return $result; } + public function modifyInterval($data) { + if (array_key_exists('start', $data)) { + $this->setStartFromISO($data->{'start'}); + $this->setIsModified(true); + } + if (array_key_exists('stop', $data)) { + $this->setStopFromISO($data->{'stop'}); + $this->setIsModified(true); + } + return $this->isModified(); + } public function writeBin($handle) { fwrite($handle,pack('L6',$this->id,$this->index,$this->start,$this->stop,$this->isNew,$this->isModified)); @@ -110,7 +121,7 @@ class TimeTableCacheIntervalObject } public function dump() { - echo " => Interval : id = ".$this->id.", index = ".$this->index.", start = ".$this->start.", stop = ".$this->stop.", isNew = ".$this->isNew.", isModified = ".$this->isModified.PHP_EOL; + echo " => Interval : id = ".$this->id.", index = ".$this->index.", start = ".TimeUtils::stamp2iso($this->start).", stop = ".TimeUtils::stamp2iso($this->stop).", isNew = ".$this->isNew.", isModified = ".$this->isModified.PHP_EOL; } } ?> diff --git a/php/classes/TimeTableCacheMgr.php b/php/classes/TimeTableCacheMgr.php index 4c78c5c..9adbd6a 100644 --- a/php/classes/TimeTableCacheMgr.php +++ b/php/classes/TimeTableCacheMgr.php @@ -26,7 +26,7 @@ return array(); } - protected function loadAdditionalDescription($id, $type) { + protected function loadAdditionalDescription($options) { return array(); } @@ -39,7 +39,7 @@ } public function initFromObject($id, $type) { - $options = $this->loadAdditionalDescription($id, $type); + $options = $this->loadAdditionalDescription(array('id' => $id, 'type' => $type, 'isTmpObject' => FALSE)); //Create new cache $info = $this->resetCache($options); @@ -92,8 +92,9 @@ public function initFromTmpObject($folderId, $name) { + $options = $this->loadAdditionalDescription(array('folder' => USERWORKINGDIR.$folderId, 'name' => $name, 'isTmpObject' => TRUE)); //Create new cache - $this->resetCache(); + $info = $this->resetCache($options); //Load intervals from TmpObject file (DD_Search output) $intervals_res = $this->objectMgr->getTmpObject($folderId, $name); @@ -118,12 +119,13 @@ $this->cache->updateIndexes(); //Save cache file - return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus()); + return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus()) + $info; } public function initFromUploadedFile($name, $format) { + $options = $this->loadAdditionalDescription(array('folder' => USERTEMPDIR, 'name' => $name, 'isTmpObject' => TRUE)); //Create new cache - $this->resetCache(); + $info = $this->resetCache($options); //Load intervals from uploaded file $intervals_res = $this->objectMgr->getUploadedObject($name, $format); @@ -148,7 +150,7 @@ $this->cache->updateIndexes(); //Save cache file - return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus()); + return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), 'status' => $this->cache->getStatus()) + $info; } public function saveInObject($id, $action, $token) { @@ -165,7 +167,9 @@ $this->cache->reset(); - return $this->objectMgr->saveIntervals($id, $intervals, $action); + $options = $this->loadAdditionalDescription(array('id' => $id)); + + return $this->objectMgr->saveIntervals($id, $intervals, $action, $options); } public function getIntervals($start,$limit,$sort_obj,$filter_json) { diff --git a/php/classes/TimeTableCacheObject.php b/php/classes/TimeTableCacheObject.php index 7bd81f2..3cbe5ae 100644 --- a/php/classes/TimeTableCacheObject.php +++ b/php/classes/TimeTableCacheObject.php @@ -93,20 +93,7 @@ class TimeTableCacheObject { if ($interval->getId() == $cacheId) { - foreach ($data as $key => $value) { - switch ($key) { - case 'start' : - $interval->setStartFromISO($value); - $interval->setIsModified(true); - $this->isModified = true; - break; - case 'stop': - $interval->setStopFromISO($value); - $interval->setIsModified(true); - $this->isModified = true; - break; - } - } + $this->isModified = $interval->modifyInterval($data); return $this->isModified; } } diff --git a/php/classes/TimeTableMgr.php b/php/classes/TimeTableMgr.php index be88dee..d4a7c56 100644 --- a/php/classes/TimeTableMgr.php +++ b/php/classes/TimeTableMgr.php @@ -511,7 +511,7 @@ class TimeTableMgr extends AmdaObjectMgr * @param $action * @return array */ - public function saveIntervals($id, $intervals, $action) + public function saveIntervals($id, $intervals, $action, $options = array()) { if (substr($id, 0, 6) == 'shared') { return ['success' => false, 'message' => "Cannot save shared TimeTable"]; @@ -543,7 +543,7 @@ class TimeTableMgr extends AmdaObjectMgr //add new intervals foreach ($intervals as $interval) { - $newInterval = $this->createIntervalElement($interval); + $newInterval = $this->createIntervalElement($interval, $options); $this->objectDom->documentElement->appendChild($newInterval); } @@ -562,11 +562,11 @@ class TimeTableMgr extends AmdaObjectMgr * @param $interval * @return DOMElement */ - protected function createIntervalElement($interval) + protected function createIntervalElement($interval, $options = array()) { $newInterval = $this->objectDom->createElement('intervals'); - $newInterval->appendChild($this->objectDom->createElement('start', $interval->start)); - $newInterval->appendChild($this->objectDom->createElement('stop', $interval->stop)); + $newInterval->appendChild($this->objectDom->createElement('start', $interval['start'])); + $newInterval->appendChild($this->objectDom->createElement('stop', $interval['stop'])); return $newInterval; } -- libgit2 0.21.2