diff --git a/generic_data/operations.json b/generic_data/operations.json index 0169284..0730ae0 100644 --- a/generic_data/operations.json +++ b/generic_data/operations.json @@ -1,5 +1,6 @@ {"nodes": [ {"nodeType" : "request", "text" : "Plot", "id" : "request-treeRootNode"} , {"nodeType" : "download", "text" : "Download", "id" : "download-treeRootNode"} , - {"nodeType" : "condition","text" : "Data Mining","id" : "condition-treeRootNode" } + {"nodeType" : "condition","text" : "Data Mining","id" : "condition-treeRootNode" }, + {"nodeType" : "statistic","text" : "Statistic","id" : "statistic-treeRootNode" } ]} diff --git a/js/app/controllers/ExplorerModule.js b/js/app/controllers/ExplorerModule.js index 09ff729..6ad9b30 100644 --- a/js/app/controllers/ExplorerModule.js +++ b/js/app/controllers/ExplorerModule.js @@ -48,7 +48,7 @@ Ext.define('amdaDesktop.ExplorerModule', 'amdaModel.Download', 'amdaModel.TimeTable', 'amdaModel.Catalog', - 'amdaModel.Stats', + 'amdaModel.Statistic', 'amdaModel.FileObject', 'amdaModel.FileParamObject', 'amdaModel.FilterInfo' diff --git a/js/app/controllers/JobsMgr.js b/js/app/controllers/JobsMgr.js index b2193c3..8e018c8 100644 --- a/js/app/controllers/JobsMgr.js +++ b/js/app/controllers/JobsMgr.js @@ -94,7 +94,7 @@ Ext.define('amdaDesktop.JobsMgr', { case 'download': type = 'Download ' break - case 'statistics': + case 'statistic': type = 'Statistics ' break default: @@ -161,7 +161,7 @@ Ext.define('amdaDesktop.JobsMgr', { resRootNode = root.findChild('id', bkgJob.RES_ROOT_NODE.DOWNLOAD, true) jobRootNode = root.findChild('id', bkgJob.JOB_ROOT_NODE.DOWNLOAD, true) break - case 'statistics': + case 'statistic': resRootNode = root.findChild('id', bkgJob.RES_ROOT_NODE.STATISTICS, true) jobRootNode = root.findChild('id', bkgJob.JOB_ROOT_NODE.STATISTICS, true) break diff --git a/js/app/controllers/StatisticsModule.js b/js/app/controllers/StatisticsModule.js index 39415fb..1008018 100644 --- a/js/app/controllers/StatisticsModule.js +++ b/js/app/controllers/StatisticsModule.js @@ -21,7 +21,7 @@ Ext.define('amdaDesktop.StatisticsModule', { * @required */ nodeDataModel : 'amdaModel.StatisticsNode', - objectDataModel : 'amdaModel.Stats', + objectDataModel : 'amdaModel.Statistic', /** * @cfg {String} window definitions * @required @@ -31,15 +31,6 @@ Ext.define('amdaDesktop.StatisticsModule', { uiType : 'panelStatistics', helpTitle : 'Help on Statistics Module', helpFile : 'statisticsHelp', - /** - * @override - */ - createWindow : function() { - if (!this.linkedNode){ - this.setLinkedNode(amdaModel.StatisticsNode); - } - this.callParent(arguments); - }, saveState: function() { var uiContent = this.getUiContent(); diff --git a/js/app/models/BkgJobNode.js b/js/app/models/BkgJobNode.js index 8e3e2c7..60d4470 100644 --- a/js/app/models/BkgJobNode.js +++ b/js/app/models/BkgJobNode.js @@ -18,7 +18,7 @@ Ext.define('amdaModel.BkgJobNode', { PLOT: 'request',//'plot', CONDITION: 'condition', DOWNLOAD: 'download', - STATISTICS: 'statistics' + STATISTICS: 'statistic' }, JOB_ROOT_NODE: { PLOT: 'bkgPlot-treeRootNode', @@ -179,7 +179,7 @@ Ext.define('amdaModel.BkgJobNode', { case 'condition' : var type = 'Data Mining '; break; case 'request' : var type = 'Plot '; break; case 'download' : var type = 'Download '; break; - case 'statistics' : var type = 'Statistics '; break; + case 'statistic' : var type = 'Statistics '; break; default: var type = 'unknown'; } @@ -228,8 +228,8 @@ Ext.define('amdaModel.BkgJobNode', { resultId : result.result, folderId : result.folder}); break; - case 'statistics' : - obj = Ext.create('amdaModel.Stats', + case 'statistic' : + obj = Ext.create('amdaModel.Statistic', {name: result.name, resultId : result.result, folderId : result.folder}); @@ -325,7 +325,7 @@ Ext.define('amdaModel.BkgJobNode', { case 'condition' : var type = 'Data Mining '; break; case 'request' : var type = 'Plot '; break; case 'download' : var type = 'Download '; break; - case 'statistics' : var type = 'Statistics '; break; + case 'statistic' : var type = 'Statistics '; break; default: var type = 'unknown'; } myDesktopApp.infoMsg('Your request is still running and has been assigned the name '+this.get('text')+' -- Check Jobs in Progress'); diff --git a/js/app/models/Statistic.js b/js/app/models/Statistic.js new file mode 100644 index 0000000..bd2a8ff --- /dev/null +++ b/js/app/models/Statistic.js @@ -0,0 +1,117 @@ +/** + * Project : AMDA-NG + * Name : Statistic.js + * Description : Statistics Object Definition + * @class amdaModel.Statistic + * @extends amdaModel.AmdaTimeObject + * @author elena + */ + +Ext.define('amdaModel.Statistic', { + extend: 'amdaModel.AmdaTimeObject', + + requires: [ + "amdaModel.StatisticParam" + ], + + fields : [ + {name: 'type', type: 'string', defaultValue: 'Statistic'}, + {name: 'description', type: 'string'} + ], + + associations : [ + { + type : 'hasMany', + model : 'amdaModel.StatisticParam', + name : 'params' + } + ], + + constructor: function(){ + var me = this; + me.callParent(arguments); + if ((arguments.length > 0) && arguments[0]) + { + if (arguments[0].parameter) + me.loadParams(arguments[0].parameter); + } + this.dirty = false; + }, + + loadParams: function(params) + { + /* Compatability mode */ + Ext.each(params, function(param, index) { + if (param.hasOwnProperty('is-init')) { + return; + } + params[index]['dim1-sum-type'] = param['dim1-is-range'] ? 1 : 0; + params[index]['dim1-min-value'] = param['dim1-min-range']; + params[index]['dim1-max-value'] = param['dim1-max-range']; + params[index]['dim2-sum-type'] = param['dim2-is-range'] ? 1 : 0; + params[index]['dim2-min-value'] = param['dim2-min-range']; + params[index]['dim2-max-value'] = param['dim2-max-range']; + params[index]['is-init'] = true; + }); + this.params().loadData(params); + }, + + isDirty : function() { + if (this.dirty) + return true; + + var d = false; + + this.params().each(function (param, index) { + if (param.dirty) + d = true; + }); + return d; + }, + + getJsonValues : function () + { + var values = new Object(); + values.nodeType = 'statistic'; + values.type = this.get('type'); + values.name = this.get('name'); + values.timesrc = this.get('timesrc'); + + // if there's at least one parameter + values.parameter = []; + this.params().each(function (param, index) { + values.parameter[index] = param.getJsonValues(); + }); + + if (values.timesrc == amdaModel.AmdaTimeObject.inputTimeSrc[0]) + { + // get complete timeTables collection + var timeTables = this.get('timeTables'); + // init an empty array for timeTables + values.timeTables=[]; + // for each interval record + Ext.Array.each(timeTables, function(item, index, all) + { + if (!item.$className) { + values.timeTables[index] = {timeTableName : item.timeTableName, id : item.id}; + } + // get Json simplified value + else { + values.timeTables[index] = item.getJsonValues(); + } + }); + } else + { + values.startDate = this.get('startDate'); + values.stopDate = this.get('stopDate'); + values.durationDay = this.get('durationDay'); + values.durationHour = this.get('durationHour'); + values.durationMin = this.get('durationMin'); + values.durationSec = this.get('durationSec'); + } + + values.leaf = true; + + return values; + } +}); diff --git a/js/app/models/StatisticParam.js b/js/app/models/StatisticParam.js new file mode 100644 index 0000000..c96d6b6 --- /dev/null +++ b/js/app/models/StatisticParam.js @@ -0,0 +1,30 @@ +/** + * Project : AMDA-NG + * Name : StatisticParam.js + * Description : Statistic Param Business Object Definition + * @class amdaModel.StatisticParam + * @extends amdaModel.RequestParamObject + * + * @author benjamin + * @version $Id: StatisticParam.js 2068 2021-05-20 11:27:38Z benjamin $ + ****************************************************************************** + * FT Id : Date : Name - Description + ****************************************************************************** + * : :20/05/2021: benjamin – creation + */ + + +Ext.define('amdaModel.StatisticParam', { + extend: 'amdaModel.RequestParamObject', + + fields : [ + {name: 'function', type: 'string', defaultValue: ''} + ], + + getJsonValues : function () + { + var values = this.callParent(arguments); + values['function'] = this.get('function'); + return values; + } +}); diff --git a/js/app/models/StatisticsNode.js b/js/app/models/StatisticsNode.js index 41d7e0b..29bf1d5 100644 --- a/js/app/models/StatisticsNode.js +++ b/js/app/models/StatisticsNode.js @@ -10,22 +10,15 @@ Ext.define('amdaModel.StatisticsNode', { extend: 'amdaModel.ExecutableNode', - - singleton: true, + + statics: { + nodeType: 'statistic', + objectName: 'Statistic' + }, - fields: [ - {name: 'object', type: 'object'}, - {name: 'moduleId', type: 'string', defaultValue:'statistics-win'}, - {name: 'nodeType', type: 'string', defaultValue: 'statistics'}, - {name: 'objectDataModel', type: 'string', defaultValue:'amdaModel.Stats'}, - {name: 'jobNode', type: 'string', defaultValue: 'amdaModel.BkgJobNode'} - ], - - constructor: function(config) { - this.callParent(arguments); - this.set('nodeType','statistics'); - }, - isExecutable: function(){ - return true; + constructor: function(config) { + this.callParent(arguments); + this.set('moduleId',myDesktopApp.dynamicModules.statistics.id); + this.set('objectDataModel',amdaModel.Statistic.$className); } }); diff --git a/js/app/models/Stats.js b/js/app/models/Stats.js deleted file mode 100644 index c324f12..0000000 --- a/js/app/models/Stats.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Project : AMDA-NG - * Name : Stats.js - * Description : Statistics Object Definition - * @class amdaModel.Stats - * @extends amdaModel.TimeTable - * @author elena - */ - -Ext.define('amdaModel.Stats', { - extend: 'amdaModel.AmdaTimeObject', - - fields : [ - { name: 'parameter' } , - { name: 'description' } - ], - - getJsonValues : function (hasId) - { - var values = new Object(); - if (hasId) { - values.id = this.get('id'); - } - - values.timesrc = this.get('timesrc'); - values.name = this.get('name'); - -// if (this.get('description').match(/[a-z,0-9]/gi) != null) { -// values.description = this.get('description'); -// } -// if (this.get('history').match(/[a-z,0-9]/gi) != null) { -// values.history = this.get('history'); -// } - values.objName = this.get('objName'); - values.objFormat = this.get('objFormat'); - -// values.cacheToken = this.get('cacheToken'); - values.parameter = this.get('parameter'); - - // if there's at least one parameter -// if (this.get('parameter') && this.get('parameter').length) -// { -// var list = this.get('parameter'); -// values.parameter=[]; -// Ext.each(list, function(item, index){ -// values.parameter[index] = item.getJsonValues(); -// }); -// } - - if (values.timesrc == amdaModel.AmdaTimeObject.inputTimeSrc[0]) - { - // get complete timeTables collection - var timeTables = this.get('timeTables'); - // init an empty array for timeTables - values.timeTables=[]; - // for each interval record - Ext.Array.each(timeTables, function(item, index, all) - { - if (!item.$className) { - values.timeTables[index] = {timeTableName : item.timeTableName, id : item.id}; - } - // get Json simplified value - else { - values.timeTables[index] = item.getJsonValues(); - } - }); - } else - { - values.startDate = this.get('startDate'); - values.stopDate = this.get('stopDate'); - values.durationDay = this.get('durationDay'); - values.durationHour = this.get('durationHour'); - values.durationMin = this.get('durationMin'); - values.durationSec = this.get('durationSec'); - } - - values.leaf = true; - values.nodeType = 'statistics'; - - return values; - } -}); diff --git a/js/app/stores/ExplorerReader.js b/js/app/stores/ExplorerReader.js index 7c8c86e..ae911be 100644 --- a/js/app/stores/ExplorerReader.js +++ b/js/app/stores/ExplorerReader.js @@ -48,7 +48,9 @@ Ext.define('amdaReader.ExplorerReader', { case 'request' : return amdaModel.PlotNode; case 'download' : - return amdaModel.DownloadNode; + return amdaModel.DownloadNode; + case 'statistic' : + return amdaModel.StatisticsNode; case 'bkgWorks' : return amdaModel.BkgJobNode; default: diff --git a/js/app/views/ExplorerUI.js b/js/app/views/ExplorerUI.js index 215b3ff..5f9564d 100644 --- a/js/app/views/ExplorerUI.js +++ b/js/app/views/ExplorerUI.js @@ -589,6 +589,7 @@ Ext.define('amdaUI.ExplorerUI', { case 'request' : case 'condition' : case 'download': + case 'statistic': record.editLeaf(); break; case 'localParam' : diff --git a/js/app/views/StatisticsUI.js b/js/app/views/StatisticsUI.js index 582cef7..03ad904 100644 --- a/js/app/views/StatisticsUI.js +++ b/js/app/views/StatisticsUI.js @@ -13,18 +13,11 @@ Ext.define('amdaUI.StatisticsUI', alias: 'widget.panelStatistics', requires: [ - //'amdaModel.Function' 'amdaUI.TimeSelectorUI', 'amdaUI.ParamArgumentsPlug', - 'amdaModel.DownloadParam', - 'amdaModel.RequestParamObject' + 'amdaModel.StatisticParam' ], - statics: - { - // functionStore : null - }, - constructor: function (config) { this.init(config); @@ -41,7 +34,13 @@ Ext.define('amdaUI.StatisticsUI', // load object into form var basicForm = this.formPanel.items.items[1].getForm(); basicForm.loadRecord(this.object); + // set parameters + this.paramGrid.reconfigure(this.object.params()); + }, + setObject: function (obj) { + this.object = obj; + this.loadObject(); }, onApplyParameterArgs: function (parentUI, paramObject) @@ -67,7 +66,7 @@ Ext.define('amdaUI.StatisticsUI', } } - var r = Ext.create('amdaModel.DownloadParam', paramObj); + var r = Ext.create('amdaModel.StatisticParam', paramObj); this.paramGrid.getStore().add(r); this.paramGrid.getSelectionModel().select(this.paramGrid.getStore().getCount() - 1); // var pos = this.paramGrid.store.getCount(); @@ -86,6 +85,88 @@ Ext.define('amdaUI.StatisticsUI', paramArgsPlug.show('statistics-param-arguments-plugin', record); }, + saveRequest : function() + { + var me = this; + + if (!this.updateObject()) { + return; + } + + var statisticModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.statistics.id); + + if ((this.object.get('id') != '') && (statisticModule.linkedNode.get('text') == this.object.get('name'))) { + this.saveProcess(false); + return; + } + + statisticModule.linkedNode.isValidName(this.fieldName.getValue(), function (res) { + if (!res) + { + me.fieldName.validFlag = 'Error during object validation'; + myDesktopApp.errorMsg(me.fieldName.validFlag); + me.fieldName.validate(); + return; + } + + if (!res.valid) + { + if (res.error) + { + 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, + fn : function(btn) { + if (btn == 'cancel') return; + this.fieldName.clearInvalid(); + this.saveProcess(true); + }, + icon: Ext.MessageBox.WARNING, + scope : me + }); + me.fieldName.validFlag = true; + } + else + me.fieldName.validFlag = res.error; + } + else + { + me.fieldName.validFlag = 'Invalid object name'; + myDesktopApp.errorMsg(me.fieldName.validFlag); + } + me.fieldName.validate(); + return; + } + + me.fieldName.validFlag = true; + me.fieldName.validate(); + me.saveProcess(false); + }); + }, + + saveProcess: function(toRename) { + var statisticModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.statistics.id); + if (this.object.isModified('name')) { + if (this.object.get('id')) + { + var contextNode = statisticModule.linkedNode.parentNode; + statisticModule.createLinkedNode(); + statisticModule.linkedNode.set('contextNode',contextNode); + statisticModule.createObject(this.object.getJsonValues()); + var statisticObj = statisticModule.linkedNode.get('object'); + this.object = statisticObj; + if (toRename) statisticModule.linkedNode.toRename = true; + } + statisticModule.linkedNode.create(); + } + else { + statisticModule.linkedNode.set('contextNode',statisticModule.contextNode); + statisticModule.linkedNode.update(); + } + }, + addTT: function (TTname, TTid) { this.timeSelector.addTT(TTname, TTid); @@ -181,7 +262,7 @@ Ext.define('amdaUI.StatisticsUI', init: function (config) { this.fieldName = new Ext.form.field.Text({ - fieldLabel: 'Catalog Name', + fieldLabel: 'Request Name', allowBlank: false, stripCharsRe: /(^\s+|\s+$)/g, emptyText: 'Please no spaces!', @@ -195,25 +276,15 @@ Ext.define('amdaUI.StatisticsUI', } }); - var ttStore = Ext.create('Ext.data.Store', - { - fields: ['name', 'hidden_id'] - }); - this.timeSelector = new amdaUI.TimeSelectorUI({id: 'statisticsTimeSelector', flex: 1}); - var store = Ext.create('Ext.data.Store', - { - fields: ['name', 'function'] - }); - this.paramGrid = Ext.create('Ext.grid.Panel', { title: 'Select Parameter & Apply Function', selType: 'rowmodel', flex: 2, // height :250, - store: store, + store: Ext.create('Ext.data.Store', {model: 'amdaModel.StatisticParam'}), columns: [ {xtype: 'rownumberer'}, { @@ -408,7 +479,7 @@ Ext.define('amdaUI.StatisticsUI', items: [this.paramGrid], fbar: [{ type: 'button', - text: 'Generate Catalog', + text: 'Generate', scope: this, handler: function () { @@ -428,7 +499,16 @@ Ext.define('amdaUI.StatisticsUI', this.paramGrid.store.removeAll(); this.timeSelector.TTGrid.store.removeAll(); } - }] + }, + { + text: 'Save', + id: 'save-statistic', + scope: this, + handler: function () { + this.saveRequest(); + } + } + ] }, { xtype: 'form', diff --git a/js/app/views/TabResultUI.js b/js/app/views/TabResultUI.js index ff4fe6e..5e1f4d9 100644 --- a/js/app/views/TabResultUI.js +++ b/js/app/views/TabResultUI.js @@ -31,7 +31,7 @@ Ext.define('amdaUI.TabResultUI', { break; case 'download': var title = 'Download Results'; break; - case 'statistics': var title = 'Statistics Results'; + case 'statistic': var title = 'Statistics Results'; break; default: } @@ -319,7 +319,7 @@ Ext.define('amdaUI.ResultItem', { case 'condition' : Ext.apply(this, configTT); break; - case 'statistics' : + case 'statistic' : Ext.apply(this, configCat); break; case 'request' : diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index 5c4aeda..21ca373 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -10,7 +10,7 @@ class AmdaAction 'remoteSimuParam' => 'RemoteParams.xml', 'derivedParam' => 'WsParams.xml', 'myDataParam' => 'WsParams.xml', 'timeTable' => 'Tt.xml', 'catalog' => 'Tt.xml', 'alias' => 'Alias.xml', 'myData' => 'Files.xml', - 'request' => 'Request.xml', 'condition' => 'Request.xml', 'download' => 'Request.xml', + 'request' => 'Request.xml', 'condition' => 'Request.xml', 'download' => 'Request.xml', 'statistic' => 'Request.xml', 'bkgWorks' => 'jobs.xml'); private $user, $amdaStat; @@ -172,6 +172,7 @@ class AmdaAction case 'download': case 'condition': case 'request': + case 'statistic': $objectMgr = new RequestMgr($nodeType); $info = $objectMgr->getObjectInfo($id); break; @@ -735,6 +736,7 @@ class AmdaAction case 'condition' : case 'request' : case 'download' : + case 'statistic': $objectMgr = new RequestMgr($nodeType); break; case 'bkgWorks' : @@ -769,6 +771,7 @@ class AmdaAction case 'condition' : case 'request' : case 'download' : + case 'statistic' : $objectMgr = new RequestMgr($obj->nodeType); break; case 'alias' : @@ -808,6 +811,7 @@ class AmdaAction case 'condition' : case 'request' : case 'download' : + case 'statistic' : $objectMgr = new RequestMgr($obj->nodeType); break; case 'alias' : @@ -842,6 +846,7 @@ class AmdaAction case 'condition' : case 'request' : case 'download' : + case 'statistic' : $objectMgr = new RequestMgr($obj->nodeType); break; case 'alias' : @@ -873,6 +878,7 @@ class AmdaAction case 'condition' : case 'request' : case 'download' : + case 'statistic' : $objectMgr = new RequestMgr($obj->nodeType); break; default: @@ -900,6 +906,7 @@ class AmdaAction case 'condition' : case 'request' : case 'download' : + case 'statistic' : $objectMgr = new RequestMgr($obj->nodeType); break; default: diff --git a/php/classes/AmdaStats.php b/php/classes/AmdaStats.php index 430dfeb..08a0a79 100644 --- a/php/classes/AmdaStats.php +++ b/php/classes/AmdaStats.php @@ -7,13 +7,13 @@ class AmdaStats { public $statXml; - public $tasks = array('plot', 'mining', 'print', 'statistics'); + public $tasks = array('plot', 'mining', 'print', 'statistic'); public $tasksWs = array('ws_print', 'ws_plot'); public $tasksAdd = array('ttoper', 'samp', 'upload', 'create', 'images'); public $usersToExclude = array('bouchemit'); public $success = true; private $user = null; - private $task = array('request'=>'plot','condition'=>'mining', 'download'=>'print','statistics'=>'statistics', + private $task = array('request'=>'plot','condition'=>'mining', 'download'=>'print','statistic'=>'statistics', 'getparameter'=>'ws_print', 'getdataset' => 'ws_print', 'getorbites' => 'ws_print', 'getplot' => 'ws_plot'); public function __construct($user) { diff --git a/php/classes/RequestMgr.php b/php/classes/RequestMgr.php index 41e7cc8..70cb336 100644 --- a/php/classes/RequestMgr.php +++ b/php/classes/RequestMgr.php @@ -9,7 +9,7 @@ class RequestMgr extends AmdaObjectMgr public $obj; protected $type; protected $jobXml, $jobXmlName; - protected $types = array('request', 'download', 'condition'); + protected $types = array('request', 'download', 'condition', 'statistic'); function __construct($type) { @@ -38,6 +38,10 @@ class RequestMgr extends AmdaObjectMgr { $this->id_prefix = 'down_'; } + else if ($type == 'statistic') + { + $this->id_prefix = 'stat_'; + } else { $this->id_prefix = 'cond_'; @@ -298,7 +302,7 @@ class RequestMgr extends AmdaObjectMgr if (count($argsTab) > 0) $args[] = $argsTab; break; - case 'statistics' : + case 'statistic' : return array('success' => true); break; default : @@ -421,6 +425,9 @@ class RequestMgr extends AmdaObjectMgr $info .= "Empty"; } break; + case 'statistic': + $info .= "Statistic: TODO"; + break; default: $info .= "<b>ERROR:</b> Unknown request type"; } -- libgit2 0.21.2