From e6e5b2592cd178bbe5ba1587ff73211bd76e30f5 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Fri, 28 Aug 2015 15:28:23 +0200 Subject: [PATCH] Add kill plot request --- js/app/models/ExecutableNode.js | 3 +++ php/classes/AmdaAction.php | 17 +++++------------ php/classes/RequestMgr.php | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- php/config.php | 2 +- 4 files changed, 81 insertions(+), 14 deletions(-) diff --git a/js/app/models/ExecutableNode.js b/js/app/models/ExecutableNode.js index ac2a708..9cac40f 100644 --- a/js/app/models/ExecutableNode.js +++ b/js/app/models/ExecutableNode.js @@ -74,6 +74,9 @@ Ext.define('amdaModel.ExecutableNode', { return; } + if (res.killed) + return; + if (isInteractivePlot) { myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) { diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index a1e3588..2403fa5 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -899,20 +899,13 @@ class AmdaAction { } /* - * kill plot process by tabID + * kill plot process */ - public function killPlotRequest($obj) - { - $objectMgr = new RequestMgr('request'); - if (count($obj->tabId) > 1) - { - return $objectMgr->killMultiPlot($obj->tabId); - } - else - { - return $objectMgr->killPlot($obj->tabId); - } + public function killPlotRequest() + { + require_once(INTEGRATION_SRC_DIR."RequestManager.php"); + return $this->executeRequest((object) array('nodeType' => 'killplot'), FunctionTypeEnumClass::PARAMS); } /* diff --git a/php/classes/RequestMgr.php b/php/classes/RequestMgr.php index 67dc6d6..f4d33ff 100644 --- a/php/classes/RequestMgr.php +++ b/php/classes/RequestMgr.php @@ -168,7 +168,78 @@ class RequestMgr extends AmdaObjectMgr { } - + /* + * Change NAME in JSON resource + */ + protected function renameInResource($name, $id) { + + $obj = json_decode(file_get_contents(USERREQDIR.$id)); + $obj->name = $name; + + $file = fopen(USERREQDIR.$id, 'w'); + fwrite($file, json_encode($obj)); + fclose($file); + } + + + /* + * Make new request/condition resource file (JSON!!) and add it to content file + * ATTENTION : it is not DD parameter!!! + */ + protected function createParameter($p) + { + if ($this -> objectExistsByName($p->name)) { + $p->id = $this->getObjectIdByName($p->name); + $this -> deleteObject($p); + } + $this->id = $this->setId(); + if (!$this->id) return array('error' => ID_CREATION_ERROR); + + //if alias exists, replace alias name by parameter name + if (file_exists(USERWSDIR.'Alias.xml')) { + if ($this->type == 'condition') { + $p->expression = $this->resetAlias($p->expression); + $info = $p->expression; + } + else if ($this->type == 'request') { + $info = ''; + for ($i=0; $i < count($p->children); $i++) { + for ($j=0; $j < count($p->children[$i]->children); $j++) { + $p->children[$i]->children[$j]->name = $this->resetAlias($p->children[$i]->children[$j]->name); + $info = $info.' '.$p->children[$i]->children[$j]->name; + } + } + } + } + + $this->descFileName = USERREQDIR.$this->id; + $p->id = $this->id; + // save request as json + $file = fopen($this->descFileName, 'w'); + fwrite($file, json_encode($p)); + fclose($file); + + $this -> addToContent($p, $folder); + + return array('id' => $this->id, 'info' => $info); + } + + /* + * Delete request/condition JSON file + */ + protected function deleteParameter($id){ + + if (file_exists(USERREQDIR.$id)) + unlink(USERREQDIR.$id); + } + + /* + * TODO Check file JSON objects differ in names only + */ + protected function renameOnly($p) { + + return false; + } } diff --git a/php/config.php b/php/config.php index a860243..5518f78 100644 --- a/php/config.php +++ b/php/config.php @@ -258,7 +258,7 @@ $API = array( 'len'=>1 ), 'killPlotRequest' =>array( - 'len'=>1 + 'len'=>0 ), 'merge'=>array( 'len'=>1 -- libgit2 0.21.2