diff --git a/js/app/models/AliasNode.js b/js/app/models/AliasNode.js index 82a2f8b..fe3f88b 100644 --- a/js/app/models/AliasNode.js +++ b/js/app/models/AliasNode.js @@ -18,120 +18,121 @@ Ext.define('amdaModel.AliasNode', { deletedAliases : null }, - constructor : function(config) - { - this.callParent(arguments); - if (this.get('leaf')) this.set('iconCls', 'icon-scalar'); - }, + constructor : function(config) { + this.callParent(arguments); + if (this.get('leaf')) this.set('iconCls', 'icon-scalar'); + }, - allMenuItems : function() { - var menuItems = - [{ - fnId : 'leaf-deleteNode', - text : 'Delete Alias' - },{ - fnId : 'leaf-plotParam', - text : 'Plot Parameter', - hidden : true - }, { - fnId : 'leaf-downParam', - text : 'Download Parameter', - hidden : true - }]; + allMenuItems : function() { + var menuItems = + [{ + fnId : 'leaf-deleteNode', + text : 'Delete Alias' + },{ + fnId : 'leaf-plotParam', + text : 'Plot Parameter', + hidden : true + }, { + fnId : 'leaf-downParam', + text : 'Download Parameter', + hidden : true + }]; - return menuItems; - }, + return menuItems; + }, - - create: function(alias, param) { - AmdaAction.createObject({name: alias, param: param, - nodeType:amdaModel.AliasNode.nodeType, leaf:true}, null, - function(result, e){ - var t = e.getTransaction(); - if (e.status) { - // SUCCESS - if (result && !result.error) { - if ( result == "OK" ) { - Ext.Msg.alert('Complete', 'New alias '+ alias +' has been created'); - // set text of this node - this.set('text', alias); - //TODO id from server - this.set('id', 'alias_' + param); - // create node in tree as child of contextNode - this.get('rootNode').appendChild(this); - // set the tooltip - this.set('info',param); - } - } else { - // EXCEPTION : - alert(t.action + "." + t.method + " : " + e.message); - } - } - else - { - // FAILURE - Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); - } - },this); + create: function(alias, param, component_info) { + //if (!Ext.Object.isEmpty(component_info))) + AmdaAction.createObject({ name: alias, param: param, component_info : component_info, + nodeType:amdaModel.AliasNode.nodeType, leaf:true }, null, + function(result, e){ + var t = e.getTransaction(); + if (e.status) { + // SUCCESS + if (result && !result.error) { + if ( result == "OK" ) { + Ext.Msg.alert('Complete', 'New alias '+ alias +' has been created'); + // set text of this node + this.set('text', alias); + //TODO id from server + this.set('id', 'alias_' + param); + // create node in tree as child of contextNode + this.get('rootNode').appendChild(this); + // set the tooltip + this.set('info', param); + this.set('component_info',component_info); + } + } else { + // EXCEPTION : + alert(t.action + "." + t.method + " : " + e.message); + } + } + else + { + // FAILURE + Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); + } + },this); }, - - renameNode: function(old_alias,alias, param) { - AmdaAction.renameObject({id : param, old_name: old_alias, name: alias, - parent : this.parentNode.get('id'), leaf: this.isLeaf(), nodeType: this.get('nodeType')}, - function(result, e){ - var t = e.getTransaction(); - if (e.status) { - // SUCCESS - if (result && !result.error) { - if ( result.id ) { - Ext.Msg.alert('Complete', 'Alias '+ alias +' has been renamed'); - // set text of this node - this.set('text', alias); - //TODO id from server - this.set('id', 'alias_' + param); - // create node in tree as child of contextNode - this.get('rootNode').appendChild(this); - - } - } else { - // EXCEPTION : - alert(t.action + "." + t.method + " : " + e.message); - } - } - else - { - // FAILURE - Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); - } - },this); - }, - - deleteNode: function() { - this.callParent(); -//temporary array to keep deleted aliases during this session - if (!amdaModel.AliasNode.deletedAliases) { - amdaModel.AliasNode.deletedAliases = new Array(); - } - amdaModel.AliasNode.deletedAliases.push(this.get('id').substr(6)); - // Replace alias by parameter name in active window - Ext.Array.each(myDesktopApp.paramModulesID, function(id){ - var module = myDesktopApp.getLoadedModule(id); - if (module) { - module.getUiContent().updateConstruct("#"+this.get('text'),this.get('id').substr(6)); - } - }, this); - - // Reset alias of parameter in local data tree or in remote data tree - var tree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); - var rootNode = tree.getRootNode().findChild('id','myLocalData-treeRootNode',true); - - var paramNode = rootNode.findChild('id', this.get('id').substr(6),true); - - if (paramNode == null) { - var rootNode = tree.getRootNode().findChild('id','myRemoteData-treeRootNode',true); + renameNode: function(old_alias,alias, param) { + AmdaAction.renameObject({id : param, old_name: old_alias, name: alias, + parent : this.parentNode.get('id'), leaf: this.isLeaf(), nodeType: this.get('nodeType')}, + function(result, e){ + var t = e.getTransaction(); + if (e.status) { + // SUCCESS + if (result && !result.error) { + if ( result.id ) { + Ext.Msg.alert('Complete', 'Alias '+ alias +' has been renamed'); + // set text of this node + this.set('text', alias); + //TODO id from server + this.set('id', 'alias_' + param); + // create node in tree as child of contextNode + this.get('rootNode').appendChild(this); + + } + } else { + // EXCEPTION : + alert(t.action + "." + t.method + " : " + e.message); + } + } + else + { + // FAILURE + Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); + } + },this); + }, + + deleteNode: function() { + this.callParent(); + //temporary array to keep deleted aliases during this session + if (!amdaModel.AliasNode.deletedAliases) { + amdaModel.AliasNode.deletedAliases = new Array(); + } + amdaModel.AliasNode.deletedAliases.push(this.get('id').substr(6)); + + // Replace alias by parameter name in active window + Ext.Array.each(myDesktopApp.paramModulesID, function(id){ + var module = myDesktopApp.getLoadedModule(id); + if (module) { + module.getUiContent().updateConstruct("#"+this.get('text'),this.get('id').substr(6)); + } + }, this); + + // Reset alias of parameter in local data tree or in remote data tree + var tree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); + var rootNode = tree.getRootNode().findChild('id','myLocalData-treeRootNode',true); + var paramNode = rootNode.findChild('id', this.get('id').substr(6),true); - } - if (paramNode) paramNode.set('alias',null); - } + + if (paramNode == null) { + var rootNode = tree.getRootNode().findChild('id','myRemoteData-treeRootNode',true); + var paramNode = rootNode.findChild('id', this.get('id').substr(6),true); + } + + if (paramNode) paramNode.set('alias',null); + } }); diff --git a/js/app/models/InteractiveNode.js b/js/app/models/InteractiveNode.js index 4409e81..7fc5913 100644 --- a/js/app/models/InteractiveNode.js +++ b/js/app/models/InteractiveNode.js @@ -22,7 +22,8 @@ Ext.define('amdaModel.InteractiveNode', { {name: 'moduleId', type: 'string', persist: false}, {name: 'filtered', type: 'boolean', defaultValue: false, persist: false}, {name: 'needsArgs', type:'boolean', defaultValue: false}, - {name: 'disable', type: 'boolean', defaultValue: false, persist: false} + {name: 'disable', type: 'boolean', defaultValue: false, persist: false}, + {name: 'component_info', type: 'object', persist: false} ], statics: { @@ -475,18 +476,18 @@ Ext.define('amdaModel.InteractiveNode', { case 'amdaModel.AliasNode' : paramName = "#"+node.get('text'); break; - case 'amdaModel.DerivedParamComponentNode' : - paramId = node.get('text'); - var parentId = paramId.substr(0, paramId.length - 3); - paramName= "ws_" + parentId; - var regExp = /\(([\d]+)\)/; - var component_index = regExp.exec(paramId); - if (component_index) - { - components = []; - components['index1'] = component_index[1]; - } - break; + case 'amdaModel.DerivedParamComponentNode' : + paramId = node.get('text'); + var parentId = paramId.substr(0, paramId.length - 3); + paramName= "ws_" + parentId; + var regExp = /\(([\d]+)\)/; + var component_index = regExp.exec(paramId); + if (component_index) + { + components = []; + components['index1'] = component_index[1]; + } + break; case 'amdaModel.DerivedParamNode' : paramName = "ws_"+node.get('text'); break; diff --git a/js/app/models/LocalParamNode.js b/js/app/models/LocalParamNode.js index acb0035..7519250 100644 --- a/js/app/models/LocalParamNode.js +++ b/js/app/models/LocalParamNode.js @@ -98,13 +98,9 @@ Ext.define('amdaModel.LocalParamNode', fnId : 'para-createDerivedParam', text : 'Create Derived Parameter', hidden : true - }, { - fnId : 'leaf-createAlias', - text : 'Create/Edit Alias', - hidden : true },{ - fnId : 'leaf-createDerivedParam', - text : 'Create Derived Parameter', + fnId : 'para-createAlias', + text : 'Create/Edit Alias', hidden : true },{ fnId : 'leaf-plotParam', @@ -114,7 +110,15 @@ Ext.define('amdaModel.LocalParamNode', fnId : 'leaf-downParam', text : 'Download Parameter', hidden : true - }, { + },{ + fnId : 'leaf-createDerivedParam', + text : 'Create Derived Parameter', + hidden : true + }, { + fnId : 'leaf-createAlias', + text : 'Create/Edit Alias', + hidden : true + },{ fnId : 'miss-epnTap', text : 'Display EPN-TAP services', hidden : true @@ -160,6 +164,7 @@ Ext.define('amdaModel.LocalParamNode', } } break; + case 'para-createAlias': case 'leaf-createAlias': if (!this.get('disable')) { if (this.get('notyet')) { @@ -201,7 +206,7 @@ Ext.define('amdaModel.LocalParamNode', createAlias: function(node) { var win = myDesktopApp.desktop.getWindow('alias-win'); - if (!node.get('needsArgs') && node.get('leaf')) + if (!node.get('needsArgs')) { if(!win) { diff --git a/js/app/models/PlotObjects/PlotPanelObject.js b/js/app/models/PlotObjects/PlotPanelObject.js index 9f72b42..37dda9f 100644 --- a/js/app/models/PlotObjects/PlotPanelObject.js +++ b/js/app/models/PlotObjects/PlotPanelObject.js @@ -317,6 +317,11 @@ Ext.define('amdaPlotObj.PlotPanelObject', { if (components['index2']) { recs[0].set('dim2-index', components['index2']); } + // it is alias + if (components['paramId']) { + recs[0].set('real-paramid', components['paramId']); + recs[0].set('real-type', 1); + } } recs[0].set('param-type', isTTCat ? 'ttcat' : 'param'); diff --git a/js/app/models/RequestParamObject.js b/js/app/models/RequestParamObject.js index f581499..1c51ebb 100644 --- a/js/app/models/RequestParamObject.js +++ b/js/app/models/RequestParamObject.js @@ -21,8 +21,10 @@ Ext.define('amdaModel.RequestParamObject', { getEmptyObj: function() { return { 'paramid': '', + 'real-paramid': '', 'is-init': false, - 'type': 0, + 'type': 0, + 'real-type': 0, 'dim1-index': '*', 'dim1-sum-type': 0, 'dim1-min-value': 0., @@ -44,8 +46,10 @@ Ext.define('amdaModel.RequestParamObject', { fields : [ {name: 'type', type: 'int'}, /* Parameter type. 0: Scalar, 1: Tab1D, 2: Tab2D */ + {name: 'real-type', type: 'int'}, /* for aliases */ {name: 'is-init', type: 'bool', default:false}, {name: 'paramid', type: 'string'}, + {name: 'real-paramid', type: 'string'}, /* for aliases */ /* Fields for dim1 */ {name: 'dim1-index', type: 'string', defaultValue: '*'}, {name: 'dim1-sum-type', type: 'int', defaultValue: 0}, /* Sum type. 0: None, 1: sum into values range, 2: sum between indexes */ @@ -134,9 +138,12 @@ Ext.define('amdaModel.RequestParamObject', { getJsonValues : function() { var paramValues = new Object(); - paramValues['id'] = this.get('id'); - paramValues['paramid'] = this.get('paramid'); + if (this.get('real-paramid') == '') + paramValues['paramid'] = this.get('paramid'); + else + paramValues['paramid'] = this.get('real-paramid'); + paramValues['name'] = this.get('name'); paramValues['dim1-index'] = this.get('dim1-index'); @@ -153,7 +160,11 @@ Ext.define('amdaModel.RequestParamObject', { paramValues['dim2-min-index'] = this.get('dim2-min-index'); paramValues['dim2-max-index'] = this.get('dim2-max-index'); - paramValues['type'] = this.get('type'); + if (this.get('real-type') > 0) + paramValues['type'] = this.get('real-type'); + else + paramValues['type'] = this.get('type'); + paramValues['is-init'] = this.get('is-init'); if (this.get('template_args') != null) { diff --git a/js/app/views/AliasUI.js b/js/app/views/AliasUI.js index 4418cc7..7c23af7 100644 --- a/js/app/views/AliasUI.js +++ b/js/app/views/AliasUI.js @@ -2,15 +2,12 @@ * Project  : AMDA-NG * Name : AliasUI.js * @class amdaUI.AliasUI - * @extends Ext.form.FieldSet + * @extends Ext.form.Panel * @brief Alias UI definition (View) * @author Myriam * @version $Id: AliasUI.js 966 2012-07-03 14:50:05Z elena $ - ******************************************************************************** - * FT Id : Date : Name - Description - ******************************************************************************* - * 08/06/2011: Myriam - Migration extjs4 */ + Ext.define('amdaUI.AliasUI',{ extend: 'Ext.form.Panel', alias: 'widget.alias', @@ -63,27 +60,27 @@ Ext.define('amdaUI.AliasUI',{ } }, - createLinkedNode : function (){ - + createLinkedNode : function () + { var newNode = Ext.create(this.nodeDataModel, { leaf : true, contextNode : this.contextNode }); - this.setLinkedNode(newNode); + this.setLinkedNode(newNode); }, - validate : function(alias,param) { - + validate : function(alias,param) + { var aliasNodeByName = this.linkedNode.get('rootNode').findChild('text', alias); if (aliasNodeByName) { - //TODO process - var paramId = aliasNodeByName.get('id').substr(6); - Ext.Msg.alert('Alias','Alias '+ alias +' already exists for parameter\n' + paramId); - return false; - } + //TODO process + var paramId = aliasNodeByName.get('id').substr(6); + Ext.Msg.alert('Alias','Alias '+ alias +' already exists for parameter\n' + paramId); + return false; + } - return true; + return true; }, updateConstruct : function(oldval,newval) { @@ -94,12 +91,12 @@ Ext.define('amdaUI.AliasUI',{ }); }, - saveAlias: function() { - - if (this.parameterField.value.match(/[a-z,0-9]/gi) == null) { - Ext.Msg.show({title:'No Parameter', msg: 'Please select parameter to create alias for', - icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK}); - return; + saveAlias: function() + { + if (this.parameterField.value.match(/[a-z,0-9]/gi) == null) { + Ext.Msg.show({title:'No Parameter', msg: 'Please select parameter to create alias for', + icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK}); + return; } var tree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); @@ -108,92 +105,92 @@ Ext.define('amdaUI.AliasUI',{ if (!rootNode.isExpanded()) rootNode.expand(false); if (!this.paramNode.get('alias')) { - this.createLinkedNode(); - var isNew = true; - } + this.createLinkedNode(); + var isNew = true; + } else { - var aliasNode = rootNode.findChild('text', this.paramNode.get('alias')); - if (!aliasNode) {//TODO error - alert('NOT FOUND'); - } - this.setLinkedNode(aliasNode); - var isNew = false; + var aliasNode = rootNode.findChild('text', this.paramNode.get('alias')); + if (!aliasNode) { + //TODO error + alert('NOT FOUND'); + } + this.setLinkedNode(aliasNode); + var isNew = false; } this.linkedNode.set('rootNode', rootNode); var alias = this.aliasField.value; var param = this.parameterField.value; + var component_info = this.paramNode.get('component_info'); // now validation if (this.validate(alias,param)) { - if (isNew) { - if (alias.match(/[a-z,0-9]/gi) == null) { - Ext.Msg.show({title:'No Alias', msg: 'No alias was created for parameter '+ param, - icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK}); - - } + if (isNew) { + if (alias.match(/[a-z,0-9]/gi) == null) { + Ext.Msg.show({title:'No Alias', msg: 'No alias was created for parameter '+ param, + icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK}); + } + else { + // create alias + this.linkedNode.create(alias, param, component_info); + this.updateConstruct(param,"#"+alias); + } + } + else if (alias.match(/[a-z,0-9]/gi) == null) { + var alias = this.paramNode.get('alias'); + Ext.Msg.confirm('Delete', 'Are you sure you want to delete this alias ?', function(btn, text){ + if (btn == 'yes'){ + // remove alias + this.updateConstruct("#"+alias,param); + this.linkedNode.deleteNode(); + } + },this); + } else { - // create alias - this.linkedNode.create(alias, param); - this.updateConstruct(param,"#"+alias); + // rename alias + this.linkedNode.renameNode(this.paramNode.get('alias'),alias, param); + this.updateConstruct("#"+this.paramNode.get('alias'),"#"+alias); } - } - else if (alias.match(/[a-z,0-9]/gi) == null) { - var alias = this.paramNode.get('alias'); - Ext.Msg.confirm('Delete', 'Are you sure you want to delete this alias ?', function(btn, text){ - if (btn == 'yes'){ - // remove alias - this.updateConstruct("#"+alias,param); - this.linkedNode.deleteNode(); - } - },this); - } - else { - // rename alias - this.linkedNode.renameNode(this.paramNode.get('alias'),alias, param); - this.updateConstruct("#"+this.paramNode.get('alias'),"#"+alias); - } - // Delete alias from array of deleted aliases - this.checkDeleted(this.paramNode.get('id')); - this.paramNode.set('alias',alias); + // Delete alias from array of deleted aliases + this.checkDeleted(this.paramNode.get('id')); + this.paramNode.set('alias',alias); } var win = myDesktopApp.getDesktop().getWindow('alias-win'); if (win) win.close(); }, - initComponent : function (){ + initComponent : function (){ - if (this.initialConfig.paramNode) - this.setParamNode(this.initialConfig.paramNode); + if (this.initialConfig.paramNode) + this.setParamNode(this.initialConfig.paramNode); - this.parameterField = new Ext.form.field.Text({ - fieldLabel: 'AMDA Parameter', name:'param', labelAlign: 'top', - disabled: true, width : '90%', padding : '10px 0 0 10px', allowBlank: false - }); + this.parameterField = new Ext.form.field.Text({ + fieldLabel: 'AMDA Parameter', name:'param', labelAlign: 'top', + disabled: true, width : '90%', padding : '10px 0 0 10px', allowBlank: false + }); - this.aliasField = new Ext.form.field.Text({ - fieldLabel: 'Your Alias', padding : '10px 0 0 10px', width : '90%', - labelWidth: 70, allowBlank: false - }); + this.aliasField = new Ext.form.field.Text({ + fieldLabel: 'Your Alias', padding : '10px 0 0 10px', width : '90%', + labelWidth: 70, allowBlank: false + }); - this.setAlias(this.paramNode); + this.setAlias(this.paramNode); - var config = { - defaultType: 'textfield', - bodyStyle: 'background:#ddecfe;', - items: [ - this.parameterField, - this.aliasField - ], - fbar: [ - { - text: 'Save Alias', - scope: this, - handler: this.saveAlias - } - ] - }; - Ext.apply (this , Ext.apply(this.initialConfig, config)); - this.callParent(arguments); - - } + var config = { + defaultType: 'textfield', + bodyStyle: 'background:#ddecfe;', + items: [ + this.parameterField, + this.aliasField + ], + fbar: [ + { + text: 'Save Alias', + scope: this, + handler: this.saveAlias + } + ] + }; + Ext.apply (this , Ext.apply(this.initialConfig, config)); + this.callParent(arguments); + } }); \ No newline at end of file diff --git a/js/app/views/ExplorerUI.js b/js/app/views/ExplorerUI.js index bb633d7..b270b40 100644 --- a/js/app/views/ExplorerUI.js +++ b/js/app/views/ExplorerUI.js @@ -592,7 +592,7 @@ Ext.define('amdaUI.ExplorerUI', { case 'localParam' : case 'remoteParam': case 'remoteSimuParam': - record.createAlias(record); + record.createPlot(record); break; case 'bkgWorks' : if (!record.get('object')) { diff --git a/js/app/views/PlotComponents/PlotTree.js b/js/app/views/PlotComponents/PlotTree.js index b9e3e6c..725c3b5 100644 --- a/js/app/views/PlotComponents/PlotTree.js +++ b/js/app/views/PlotComponents/PlotTree.js @@ -678,30 +678,48 @@ Ext.define('amdaPlotComp.PlotTree', { if (!record.get('isParameter') || record.get('disable')) return false; - if (record.get('alias') != "") - this.dropParamToCreate(targetNode, position, "#" + record.get('alias')); + var isVector = record.get('iconCls') == 'icon-vector'; + var component_info = record.get('component_info'); + var param_id = record.get('id'); + var plot_only = record.get('notyet'); + var components = null; + if (component_info && component_info.parentId) { + //It's a component + param_id = component_info.parentId; + components = []; + if (component_info.index1) + components['index1'] = component_info.index1; + if (component_info.index2) + components['index2'] = component_info.index2; + } + if (record.get('alias') != "") { + if (components) + components['paramId'] = component_info.parentId; + + this.dropParamToCreate(targetNode, position, "#" + record.get('alias'), {'components': components }); + } else { - var isVector = record.get('iconCls') == 'icon-vector'; - var component_info = record.get('component_info'); - var param_id = record.get('id'); - var plot_only = record.get('notyet'); - var components = null; - if (component_info && component_info.parentId) { - //It's a component - param_id = component_info.parentId; - components = []; - if (component_info.index1) - components['index1'] = component_info.index1; - if (component_info.index2) - components['index2'] = component_info.index2; - } this.dropParamToCreate(targetNode, position, param_id, {'components': components, 'isVector': isVector, 'plotOnly': plot_only}); } return true; case 'amdaModel.AliasNode' : if (!record.isLeaf()) return false; - this.dropParamToCreate(targetNode, position, "#" + record.get('text')); + var component_info = record.get('component_info'); + var components = null; + if (component_info && component_info.parentId) { + //It's a component + components = []; + components['paramId'] = component_info.parentId; + + if (component_info.index1) + components['index1'] = component_info.index1; + + if (component_info.index2) + components['index2'] = component_info.index2; + } + + this.dropParamToCreate(targetNode, position, "#" + record.get('text'), { 'components': components }); return true; case 'amdaModel.DerivedParamNode' : if (!record.get('isParameter')) diff --git a/js/app/views/PlotUI.js b/js/app/views/PlotUI.js index e604eae..4d0e100 100644 --- a/js/app/views/PlotUI.js +++ b/js/app/views/PlotUI.js @@ -55,6 +55,11 @@ Ext.define('amdaUI.PlotUI', { requestOptionCB.setValue(allInOne); }, + updateConstruct : function(oldval,newval) + { + return; + }, + /** * overwrite metod called by Save button */ diff --git a/php/classes/AliasMgr.php b/php/classes/AliasMgr.php index 9da579b..663f468 100644 --- a/php/classes/AliasMgr.php +++ b/php/classes/AliasMgr.php @@ -2,95 +2,98 @@ /** * @class AliasMgr * @version $Id: AliasMgr.php 899 2012-05-02 14:08:28Z benjamin $ - * - * */ - class AliasMgr extends AmdaObjectMgr { - - function __construct() { +class AliasMgr extends AmdaObjectMgr { - parent::__construct('Alias.xml'); - $this->contentRootId = 'alias-treeRootNode'; - $this->contentRootTag = 'aliasList'; - $this->attributes = array('name' => '', 'param' => ''); - $this->objTagName = 'alias'; - if (!file_exists($this->xmlName)) { - $this->createDom(); - $this->xp = new domxpath($this->contentDom); + function __construct() { + parent::__construct('Alias.xml'); + $this->contentRootId = 'alias-treeRootNode'; + $this->contentRootTag = 'aliasList'; + $this->attributes = array('name' => '', 'param' => ''); + $this->objTagName = 'alias'; + if (!file_exists($this->xmlName)) { + $this->createDom(); + $this->xp = new domxpath($this->contentDom); } } protected function createDom() { - $rootElement = $this->contentDom->createElement($this->contentRootTag); + $rootElement = $this->contentDom->createElement($this->contentRootTag); $rootElement->setAttribute('xml:id', $this->contentRootId); - $this->contentDom->appendChild($rootElement); + $this->contentDom->appendChild($rootElement); $this->contentDom->save($this->xmlName); - } + } -/* -* Add Alias in Alias.xml -*/ - protected function addAlias($obj) { - - $objList = $this->contentDom->getElementById($this->contentRootId); - $newObj = $this->contentDom->createElement($this->objTagName); - $newObj->setAttribute('xml:id',$this->id); - $obj_arr = (array)$obj; - foreach ($this->attributes as $key => $value) { - if ($key == 'name') $newObj->setAttribute($key, $obj_arr[$key]); - } - $objList -> appendChild($newObj); + /* + * Add Alias in Alias.xml + */ + protected function addAlias($obj) { + $objList = $this->contentDom->getElementById($this->contentRootId); + $newObj = $this->contentDom->createElement($this->objTagName); + $newObj->setAttribute('xml:id',$this->id); + $obj_arr = (array)$obj; + foreach ($this->attributes as $key => $value) { + if ($key == 'name') $newObj->setAttribute($key, $obj_arr[$key]); + } + + if (count($obj_arr['component_info']) > 0) { + foreach ($obj_arr['component_info'] as $key => $value) { + $newObj->setAttribute($key, $value); + } + } + + $objList -> appendChild($newObj); - $this->saveContent() ; - } + $this->saveContent() ; + } /* * Create Alias - */ + */ protected function createParameter($obj) { $this->id = $obj->param; - $this -> addAlias($obj); + $this->addAlias($obj); return "OK"; } + /***************************************************************** * PUBLIC FUNCTIONS *****************************************************************/ - public function getList() { - - $AliasList = $this->contentDom->getElementsByTagName('alias'); + public function getList() { + $AliasList = $this->contentDom->getElementsByTagName('alias'); - return $AliasList; - } + return $AliasList; + } - public function substrParamAlias($chain, $paramName, $aliasName) { + public function substrParamAlias($chain, $paramName, $aliasName) { - $aliasName="#".$aliasName; - $pos = strpos($chain, $paramName); - while ( $pos !== FALSE ) { - $pos = $pos+strlen($paramName); - if (preg_match('/[-+*,^<>&|=\/\[\]\(\)\ ]/', $chain[$pos]) || $chain[$pos] === '') { - $chain = substr_replace($chain, $aliasName,$pos-strlen($paramName),strlen($paramName)); - } - $pos = strpos($chain, $paramName, $pos); - } - return $chain; - } + $aliasName="#".$aliasName; + $pos = strpos($chain, $paramName); + while ( $pos !== FALSE ) { + $pos = $pos+strlen($paramName); + if (preg_match('/[-+*,^<>&|=\/\[\]\(\)\ ]/', $chain[$pos]) || $chain[$pos] === '') { + $chain = substr_replace($chain, $aliasName,$pos-strlen($paramName),strlen($paramName)); + } + $pos = strpos($chain, $paramName, $pos); + } + return $chain; + } - public function substrAliasParam($chain, $paramName, $aliasName) { + public function substrAliasParam($chain, $paramName, $aliasName) { - $aliasName="#".$aliasName; - $pos = strpos($chain, $aliasName); - while ( $pos !== FALSE ) { - $pos = $pos+strlen($aliasName); - if (preg_match('/[-+*,^<>&|=\/\[\]\(\)\ ]/', $chain[$pos]) || $chain[$pos] === '') { - $chain = substr_replace($chain, $paramName,$pos-strlen($aliasName),strlen($aliasName)); - } - $pos = strpos($chain, $aliasName, $pos); - } - return $chain; - } + $aliasName="#".$aliasName; + $pos = strpos($chain, $aliasName); + while ( $pos !== FALSE ) { + $pos = $pos+strlen($aliasName); + if (preg_match('/[-+*,^<>&|=\/\[\]\(\)\ ]/', $chain[$pos]) || $chain[$pos] === '') { + $chain = substr_replace($chain, $paramName,$pos-strlen($aliasName),strlen($aliasName)); + } + $pos = strpos($chain, $aliasName, $pos); + } + return $chain; + } protected function deleteParameter($id){ @@ -98,7 +101,7 @@ /* * Get Object into Edit - */ + */ public function getObject($id) { if (!($obj = $this->objectExistsById($id))) return "NO_SUCH_ID"; $attributesToReturn['id'] = $obj->getAttribute('xml:id'); @@ -107,8 +110,8 @@ } /* - * Get alias of parameter - */ + * Get alias of parameter + */ public function getAlias($id) { $alias = ""; if (($obj = $this->objectExistsById($id))) @@ -117,4 +120,4 @@ return $alias; } - } \ No newline at end of file +} diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index 0bbb43d..7b20f55 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -189,7 +189,17 @@ class AmdaAction case 'alias': $info = $id; $id = 'alias_'.$id; + $component_info = array(); + if ($child->hasAttribute("index1")) + $component_info["index1"] = $child->getAttribute('index1'); + if ($child->hasAttribute("index2")) + $component_info["index2"] = $child->getAttribute('index2'); + + if ($child->hasAttribute("parentId")) + $component_info["parentId"] = $child->getAttribute("parentId"); + if ($isLeaf) $isParameter = true; + break; case 'timeTable': @@ -561,7 +571,8 @@ 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); + 'help' => $help, 'leaf' => $isLeaf, 'isParameter' => $isParameter, 'dim_1' => $dim_1, 'dim_2' => $dim_2, + "component_info" => isset($component_info) ? $component_info : NULL); } } // if $childrenToReturn we have to return [] @@ -915,7 +926,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 || -- libgit2 0.21.2