Commit e6e5b2592cd178bbe5ba1587ff73211bd76e30f5

Authored by Benjamin Renard
1 parent 18d4a11e

Add kill plot request

js/app/models/ExecutableNode.js
... ... @@ -74,6 +74,9 @@ Ext.define('amdaModel.ExecutableNode', {
74 74 return;
75 75 }
76 76  
  77 + if (res.killed)
  78 + return;
  79 +
77 80 if (isInteractivePlot)
78 81 {
79 82 myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.plot.id, true, function (module) {
... ...
php/classes/AmdaAction.php
... ... @@ -899,20 +899,13 @@ class AmdaAction {
899 899 }
900 900  
901 901 /*
902   - * kill plot process by tabID
  902 + * kill plot process
903 903 */
904 904  
905   - public function killPlotRequest($obj)
906   - {
907   - $objectMgr = new RequestMgr('request');
908   - if (count($obj->tabId) > 1)
909   - {
910   - return $objectMgr->killMultiPlot($obj->tabId);
911   - }
912   - else
913   - {
914   - return $objectMgr->killPlot($obj->tabId);
915   - }
  905 + public function killPlotRequest()
  906 + {
  907 + require_once(INTEGRATION_SRC_DIR."RequestManager.php");
  908 + return $this->executeRequest((object) array('nodeType' => 'killplot'), FunctionTypeEnumClass::PARAMS);
916 909 }
917 910  
918 911 /*
... ...
php/classes/RequestMgr.php
... ... @@ -168,7 +168,78 @@ class RequestMgr extends AmdaObjectMgr {
168 168 }
169 169  
170 170  
171   -
  171 + /*
  172 + * Change NAME in JSON resource
  173 + */
  174 + protected function renameInResource($name, $id) {
  175 +
  176 + $obj = json_decode(file_get_contents(USERREQDIR.$id));
  177 + $obj->name = $name;
  178 +
  179 + $file = fopen(USERREQDIR.$id, 'w');
  180 + fwrite($file, json_encode($obj));
  181 + fclose($file);
  182 + }
  183 +
  184 +
  185 + /*
  186 + * Make new request/condition resource file (JSON!!) and add it to content file
  187 + * ATTENTION : it is not DD parameter!!!
  188 + */
  189 + protected function createParameter($p)
  190 + {
  191 + if ($this -> objectExistsByName($p->name)) {
  192 + $p->id = $this->getObjectIdByName($p->name);
  193 + $this -> deleteObject($p);
  194 + }
  195 + $this->id = $this->setId();
  196 + if (!$this->id) return array('error' => ID_CREATION_ERROR);
  197 +
  198 + //if alias exists, replace alias name by parameter name
  199 + if (file_exists(USERWSDIR.'Alias.xml')) {
  200 + if ($this->type == 'condition') {
  201 + $p->expression = $this->resetAlias($p->expression);
  202 + $info = $p->expression;
  203 + }
  204 + else if ($this->type == 'request') {
  205 + $info = '';
  206 + for ($i=0; $i < count($p->children); $i++) {
  207 + for ($j=0; $j < count($p->children[$i]->children); $j++) {
  208 + $p->children[$i]->children[$j]->name = $this->resetAlias($p->children[$i]->children[$j]->name);
  209 + $info = $info.' '.$p->children[$i]->children[$j]->name;
  210 + }
  211 + }
  212 + }
  213 + }
  214 +
  215 + $this->descFileName = USERREQDIR.$this->id;
  216 + $p->id = $this->id;
  217 + // save request as json
  218 + $file = fopen($this->descFileName, 'w');
  219 + fwrite($file, json_encode($p));
  220 + fclose($file);
  221 +
  222 + $this -> addToContent($p, $folder);
  223 +
  224 + return array('id' => $this->id, 'info' => $info);
  225 + }
  226 +
  227 + /*
  228 + * Delete request/condition JSON file
  229 + */
  230 + protected function deleteParameter($id){
  231 +
  232 + if (file_exists(USERREQDIR.$id))
  233 + unlink(USERREQDIR.$id);
  234 + }
  235 +
  236 + /*
  237 + * TODO Check file JSON objects differ in names only
  238 + */
  239 + protected function renameOnly($p) {
  240 +
  241 + return false;
  242 + }
172 243  
173 244  
174 245 }
... ...
php/config.php
... ... @@ -258,7 +258,7 @@ $API = array(
258 258 'len'=>1
259 259 ),
260 260 'killPlotRequest' =>array(
261   - 'len'=>1
  261 + 'len'=>0
262 262 ),
263 263 'merge'=>array(
264 264 'len'=>1
... ...